diff --git a/Modules/Adjustment/Config/.gitkeep b/Modules/Adjustment/Config/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Modules/Adjustment/Config/config.php b/Modules/Adjustment/Config/config.php new file mode 100644 index 00000000..62829799 --- /dev/null +++ b/Modules/Adjustment/Config/config.php @@ -0,0 +1,5 @@ + 'Adjustment' +]; diff --git a/Modules/Adjustment/Console/.gitkeep b/Modules/Adjustment/Console/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Modules/Adjustment/Database/Migrations/.gitkeep b/Modules/Adjustment/Database/Migrations/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Modules/Adjustment/Database/Migrations/2021_07_22_003941_create_adjustments_table.php b/Modules/Adjustment/Database/Migrations/2021_07_22_003941_create_adjustments_table.php new file mode 100644 index 00000000..740c0974 --- /dev/null +++ b/Modules/Adjustment/Database/Migrations/2021_07_22_003941_create_adjustments_table.php @@ -0,0 +1,34 @@ +id(); + $table->date('date'); + $table->string('reference'); + $table->text('note')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('adjustments'); + } +} diff --git a/Modules/Adjustment/Database/Migrations/2021_07_22_004043_create_adjusted_products_table.php b/Modules/Adjustment/Database/Migrations/2021_07_22_004043_create_adjusted_products_table.php new file mode 100644 index 00000000..68d92dca --- /dev/null +++ b/Modules/Adjustment/Database/Migrations/2021_07_22_004043_create_adjusted_products_table.php @@ -0,0 +1,36 @@ +id(); + $table->unsignedBigInteger('adjustment_id'); + $table->unsignedBigInteger('product_id'); + $table->integer('quantity'); + $table->string('type'); + $table->foreign('adjustment_id')->references('id')->on('adjustments')->onDelete('cascade'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('adjusted_products'); + } +} diff --git a/Modules/Adjustment/Database/Seeders/.gitkeep b/Modules/Adjustment/Database/Seeders/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Modules/Adjustment/Database/Seeders/AdjustmentDatabaseSeeder.php b/Modules/Adjustment/Database/Seeders/AdjustmentDatabaseSeeder.php new file mode 100644 index 00000000..b34127ee --- /dev/null +++ b/Modules/Adjustment/Database/Seeders/AdjustmentDatabaseSeeder.php @@ -0,0 +1,21 @@ +call("OthersTableSeeder"); + } +} diff --git a/Modules/Adjustment/Database/factories/.gitkeep b/Modules/Adjustment/Database/factories/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Modules/Adjustment/Entities/.gitkeep b/Modules/Adjustment/Entities/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Modules/Adjustment/Entities/AdjustedProduct.php b/Modules/Adjustment/Entities/AdjustedProduct.php new file mode 100644 index 00000000..a1ee47aa --- /dev/null +++ b/Modules/Adjustment/Entities/AdjustedProduct.php @@ -0,0 +1,24 @@ +belongsTo(Adjustment::class, 'adjustment_id', 'id'); + } + + public function product() { + return $this->belongsTo(Product::class, 'product_id', 'id'); + } +} diff --git a/Modules/Adjustment/Entities/Adjustment.php b/Modules/Adjustment/Entities/Adjustment.php new file mode 100644 index 00000000..96b37ecf --- /dev/null +++ b/Modules/Adjustment/Entities/Adjustment.php @@ -0,0 +1,23 @@ +format('M d, Y'); + } + + public function adjustedProducts() { + return $this->hasMany(AdjustedProduct::class, 'adjustment_id', 'id'); + } + +} diff --git a/Modules/Adjustment/Http/Controllers/.gitkeep b/Modules/Adjustment/Http/Controllers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Modules/Adjustment/Http/Controllers/AdjustmentController.php b/Modules/Adjustment/Http/Controllers/AdjustmentController.php new file mode 100644 index 00000000..91cc75c8 --- /dev/null +++ b/Modules/Adjustment/Http/Controllers/AdjustmentController.php @@ -0,0 +1,166 @@ +render('adjustment::index'); + } + + + public function create() { + abort_if(Gate::denies('create_adjustments'), 403); + + return view('adjustment::create'); + } + + + public function store(Request $request) { + abort_if(Gate::denies('create_adjustments'), 403); + + $request->validate([ + 'reference' => 'required|string|max:255', + 'date' => 'required|date', + 'note' => 'nullable|string|max:1000', + 'product_ids' => 'required', + 'quantities' => 'required', + 'types' => 'required' + ]); + + DB::transaction(function () use ($request) { + $adjustment = Adjustment::create([ + 'reference' => $request->reference, + 'date' => $request->date, + 'note' => $request->note + ]); + + foreach ($request->product_ids as $key => $id) { + AdjustedProduct::create([ + 'adjustment_id' => $adjustment->id, + 'product_id' => $id, + 'quantity' => $request->quantities[$key], + 'type' => $request->types[$key] + ]); + + $product = Product::findOrFail($id); + + if ($request->types[$key] == 'add') { + $product->update([ + 'product_quantity' => $product->product_quantity + $request->quantities[$key] + ]); + } elseif ($request->types[$key] == 'sub') { + $product->update([ + 'product_quantity' => $product->product_quantity - $request->quantities[$key] + ]); + } + } + }); + + toast('Adjustment Created!', 'success'); + + return redirect()->route('adjustments.index'); + } + + + public function show(Adjustment $adjustment) { + abort_if(Gate::denies('show_adjustments'), 403); + + return view('adjustment::show', compact('adjustment')); + } + + + public function edit(Adjustment $adjustment) { + abort_if(Gate::denies('edit_adjustments'), 403); + + return view('adjustment::edit', compact('adjustment')); + } + + + public function update(Request $request, Adjustment $adjustment) { + abort_if(Gate::denies('edit_adjustments'), 403); + + $request->validate([ + 'reference' => 'required|string|max:255', + 'date' => 'required|date', + 'note' => 'nullable|string|max:1000', + 'product_ids' => 'required', + 'quantities' => 'required', + 'types' => 'required' + ]); + + DB::transaction(function () use ($request, $adjustment) { + $adjustment->update([ + 'reference' => $request->reference, + 'date' => $request->date, + 'note' => $request->note + ]); + + foreach ($adjustment->adjustedProducts as $adjustedProduct) { + $product = Product::findOrFail($adjustedProduct->product->id); + + if ($adjustedProduct->type == 'add') { + $product->update([ + 'product_quantity' => $product->product_quantity - $adjustedProduct->quantity + ]); + } elseif ($adjustedProduct->type == 'sub') { + $product->update([ + 'product_quantity' => $product->product_quantity + $adjustedProduct->quantity + ]); + } + + $adjustedProduct->delete(); + } + + foreach ($request->product_ids as $key => $id) { + AdjustedProduct::create([ + 'adjustment_id' => $adjustment->id, + 'product_id' => $id, + 'quantity' => $request->quantities[$key], + 'type' => $request->types[$key] + ]); + + $product = Product::findOrFail($id); + + if ($request->types[$key] == 'add') + { + $product->update([ + 'product_quantity' => $product->product_quantity + $request->quantities[$key] + ]); + } elseif ($request->types[$key] == 'sub') { + $product->update([ + 'product_quantity' => $product->product_quantity - $request->quantities[$key] + ]); + } + } + }); + + toast('Adjustment Updated!', 'info'); + + return redirect()->route('adjustments.index'); + } + + + public function destroy(Adjustment $adjustment) { + abort_if(Gate::denies('delete_adjustments'), 403); + + $adjustment->delete(); + + toast('Adjustment Deleted!', 'warning'); + + return redirect()->route('adjustments.index'); + } +} diff --git a/Modules/Adjustment/Http/Middleware/.gitkeep b/Modules/Adjustment/Http/Middleware/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Modules/Adjustment/Http/Requests/.gitkeep b/Modules/Adjustment/Http/Requests/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Modules/Adjustment/Providers/.gitkeep b/Modules/Adjustment/Providers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Modules/Adjustment/Providers/AdjustmentServiceProvider.php b/Modules/Adjustment/Providers/AdjustmentServiceProvider.php new file mode 100644 index 00000000..91caf927 --- /dev/null +++ b/Modules/Adjustment/Providers/AdjustmentServiceProvider.php @@ -0,0 +1,112 @@ +registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations')); + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register config. + * + * @return void + */ + protected function registerConfig() + { + $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. + * + * @return void + */ + public function registerViews() + { + $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); + } + + /** + * Register translations. + * + * @return void + */ + public function registerTranslations() + { + $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); + } + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return []; + } + + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (\Config::get('view.paths') as $path) { + if (is_dir($path . '/modules/' . $this->moduleNameLower)) { + $paths[] = $path . '/modules/' . $this->moduleNameLower; + } + } + return $paths; + } +} diff --git a/Modules/Adjustment/Providers/RouteServiceProvider.php b/Modules/Adjustment/Providers/RouteServiceProvider.php new file mode 100644 index 00000000..831020db --- /dev/null +++ b/Modules/Adjustment/Providers/RouteServiceProvider.php @@ -0,0 +1,69 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + * + * @return void + */ + protected function mapWebRoutes() + { + Route::middleware('web') + ->namespace($this->moduleNamespace) + ->group(module_path('Adjustment', '/Routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + * + * @return void + */ + protected function mapApiRoutes() + { + Route::prefix('api') + ->middleware('api') + ->namespace($this->moduleNamespace) + ->group(module_path('Adjustment', '/Routes/api.php')); + } +} diff --git a/Modules/Adjustment/Resources/assets/.gitkeep b/Modules/Adjustment/Resources/assets/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Modules/Adjustment/Resources/assets/js/app.js b/Modules/Adjustment/Resources/assets/js/app.js new file mode 100644 index 00000000..e69de29b diff --git a/Modules/Adjustment/Resources/assets/sass/app.scss b/Modules/Adjustment/Resources/assets/sass/app.scss new file mode 100644 index 00000000..e69de29b diff --git a/Modules/Adjustment/Resources/lang/.gitkeep b/Modules/Adjustment/Resources/lang/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Modules/Adjustment/Resources/views/.gitkeep b/Modules/Adjustment/Resources/views/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Modules/Adjustment/Resources/views/create.blade.php b/Modules/Adjustment/Resources/views/create.blade.php new file mode 100644 index 00000000..28b26421 --- /dev/null +++ b/Modules/Adjustment/Resources/views/create.blade.php @@ -0,0 +1,64 @@ +@extends('layouts.app') + +@section('title', 'Create Adjustment') + +@push('page_css') + @livewireStyles +@endpush + +@section('breadcrumb') + +@endsection + +@section('content') +
+
+
+ +
+
+ +
+
+
+
+ @include('utils.alerts') +
+ @csrf +
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+ + +
+
+ +
+ +
+
+
+
+
+@endsection diff --git a/Modules/Adjustment/Resources/views/edit.blade.php b/Modules/Adjustment/Resources/views/edit.blade.php new file mode 100644 index 00000000..13ed4fc1 --- /dev/null +++ b/Modules/Adjustment/Resources/views/edit.blade.php @@ -0,0 +1,67 @@ +@extends('layouts.app') + +@section('title', 'Edit Adjustment') + +@push('page_css') + @livewireStyles +@endpush + +@section('breadcrumb') + +@endsection + +@section('content') +
+
+
+ +
+
+ +
+
+
+
+ @include('utils.alerts') +
+ @csrf + @method('patch') +
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+ + +
+
+ +
+ +
+
+
+
+
+@endsection diff --git a/Modules/Adjustment/Resources/views/index.blade.php b/Modules/Adjustment/Resources/views/index.blade.php new file mode 100644 index 00000000..338ac136 --- /dev/null +++ b/Modules/Adjustment/Resources/views/index.blade.php @@ -0,0 +1,40 @@ +@extends('layouts.app') + +@section('title', 'Adjustments') + +@section('third_party_stylesheets') + +@endsection + +@section('breadcrumb') + +@endsection + +@section('content') +
+
+
+
+
+ + Add Adjustment + + +
+ +
+ {!! $dataTable->table() !!} +
+
+
+
+
+
+@endsection + +@push('page_scripts') + {!! $dataTable->scripts() !!} +@endpush diff --git a/Modules/Adjustment/Resources/views/partials/actions.blade.php b/Modules/Adjustment/Resources/views/partials/actions.blade.php new file mode 100644 index 00000000..b7b5ed7f --- /dev/null +++ b/Modules/Adjustment/Resources/views/partials/actions.blade.php @@ -0,0 +1,24 @@ +@can('edit_adjustments') + + + +@endcan +@can('show_adjustments') + + + +@endcan +@can('delete_adjustments') + +@endcan diff --git a/Modules/Adjustment/Resources/views/show.blade.php b/Modules/Adjustment/Resources/views/show.blade.php new file mode 100644 index 00000000..57c0ca25 --- /dev/null +++ b/Modules/Adjustment/Resources/views/show.blade.php @@ -0,0 +1,70 @@ +@extends('layouts.app') + +@section('title', 'Adjustment Details') + +@push('page_css') + @livewireStyles +@endpush + +@section('breadcrumb') + +@endsection + +@section('content') +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + @foreach($adjustment->adjustedProducts as $adjustedProduct) + + + + + + + @endforeach +
+ Date + + Reference +
+ {{ $adjustment->date }} + + {{ $adjustment->reference }} +
Product NameCodeQuantityType
{{ $adjustedProduct->product->product_name }}{{ $adjustedProduct->product->product_code }}{{ $adjustedProduct->quantity }} + @if($adjustedProduct->type == 'add') + (+) Addition + @else + (-) Subtraction + @endif +
+
+
+
+
+
+
+@endsection diff --git a/Modules/Adjustment/Routes/.gitkeep b/Modules/Adjustment/Routes/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Modules/Adjustment/Routes/api.php b/Modules/Adjustment/Routes/api.php new file mode 100644 index 00000000..3fce5cfa --- /dev/null +++ b/Modules/Adjustment/Routes/api.php @@ -0,0 +1,18 @@ +get('/adjustment', function (Request $request) { + return $request->user(); +}); \ No newline at end of file diff --git a/Modules/Adjustment/Routes/web.php b/Modules/Adjustment/Routes/web.php new file mode 100644 index 00000000..aeab37ec --- /dev/null +++ b/Modules/Adjustment/Routes/web.php @@ -0,0 +1,17 @@ + 'auth'], function () { + //Product Adjustment + Route::resource('adjustments', 'AdjustmentController'); +}); diff --git a/Modules/Adjustment/Tests/Feature/.gitkeep b/Modules/Adjustment/Tests/Feature/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Modules/Adjustment/Tests/Unit/.gitkeep b/Modules/Adjustment/Tests/Unit/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Modules/Adjustment/composer.json b/Modules/Adjustment/composer.json new file mode 100644 index 00000000..b369fb69 --- /dev/null +++ b/Modules/Adjustment/composer.json @@ -0,0 +1,23 @@ +{ + "name": "nwidart/adjustment", + "description": "", + "authors": [ + { + "name": "Nicolas Widart", + "email": "n.widart@gmail.com" + } + ], + "extra": { + "laravel": { + "providers": [], + "aliases": { + + } + } + }, + "autoload": { + "psr-4": { + "Modules\\Adjustment\\": "" + } + } +} diff --git a/Modules/Adjustment/module.json b/Modules/Adjustment/module.json new file mode 100644 index 00000000..e21723f2 --- /dev/null +++ b/Modules/Adjustment/module.json @@ -0,0 +1,13 @@ +{ + "name": "Adjustment", + "alias": "adjustment", + "description": "", + "keywords": [], + "priority": 0, + "providers": [ + "Modules\\Adjustment\\Providers\\AdjustmentServiceProvider" + ], + "aliases": {}, + "files": [], + "requires": [] +} diff --git a/Modules/Adjustment/package.json b/Modules/Adjustment/package.json new file mode 100644 index 00000000..4599509f --- /dev/null +++ b/Modules/Adjustment/package.json @@ -0,0 +1,17 @@ +{ + "private": true, + "scripts": { + "dev": "npm run development", + "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", + "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", + "watch-poll": "npm run watch -- --watch-poll", + "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", + "prod": "npm run production", + "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": { + "cross-env": "^7.0", + "laravel-mix": "^5.0.1", + "laravel-mix-merge-manifest": "^0.1.2" + } +} diff --git a/Modules/Adjustment/webpack.mix.js b/Modules/Adjustment/webpack.mix.js new file mode 100644 index 00000000..6f5064ae --- /dev/null +++ b/Modules/Adjustment/webpack.mix.js @@ -0,0 +1,14 @@ +const dotenvExpand = require('dotenv-expand'); +dotenvExpand(require('dotenv').config({ path: '../../.env'/*, debug: true*/})); + +const mix = require('laravel-mix'); +require('laravel-mix-merge-manifest'); + +mix.setPublicPath('../../public').mergeManifest(); + +mix.js(__dirname + '/Resources/assets/js/app.js', 'js/adjustment.js') + .sass( __dirname + '/Resources/assets/sass/app.scss', 'css/adjustment.css'); + +if (mix.inProduction()) { + mix.version(); +} diff --git a/Modules/Product/Resources/views/barcode/index.blade.php b/Modules/Product/Resources/views/barcode/index.blade.php index 00ffc164..610e0229 100644 --- a/Modules/Product/Resources/views/barcode/index.blade.php +++ b/Modules/Product/Resources/views/barcode/index.blade.php @@ -17,7 +17,7 @@
- +
diff --git a/Modules/Product/Resources/views/products/create.blade.php b/Modules/Product/Resources/views/products/create.blade.php index d6bd3b7f..cbf43367 100644 --- a/Modules/Product/Resources/views/products/create.blade.php +++ b/Modules/Product/Resources/views/products/create.blade.php @@ -88,7 +88,7 @@
- +
diff --git a/Modules/Product/Resources/views/products/edit.blade.php b/Modules/Product/Resources/views/products/edit.blade.php index 75a2c056..f2f9a251 100644 --- a/Modules/Product/Resources/views/products/edit.blade.php +++ b/Modules/Product/Resources/views/products/edit.blade.php @@ -88,7 +88,7 @@
- +
diff --git a/app/DataTables/AdjustmentsDataTable.php b/app/DataTables/AdjustmentsDataTable.php new file mode 100644 index 00000000..6679fdb1 --- /dev/null +++ b/app/DataTables/AdjustmentsDataTable.php @@ -0,0 +1,101 @@ +eloquent($query) + ->addColumn('action', function ($data) { + return view('adjustment::partials.actions', compact('data')); + }); + } + + /** + * Get query source of dataTable. + * + * @param \Modules\Adjustment\Entities\Adjustment $model + * @return \Illuminate\Database\Eloquent\Builder + */ + public function query(Adjustment $model) + { + return $model->newQuery()->withCount('adjustedProducts'); + } + + /** + * Optional method if you want to use html builder. + * + * @return \Yajra\DataTables\Html\Builder + */ + public function html() + { + return $this->builder() + ->setTableId('adjustments-table') + ->columns($this->getColumns()) + ->minifiedAjax() + ->dom("<'row'<'col-md-3'l><'col-md-5 mb-2'B><'col-md-4'f>> . + 'tr' . + <'row'<'col-md-5'i><'col-md-7 mt-2'p>>") + ->orderBy(0) + ->buttons( + Button::make('excel') + ->text(' Excel'), + Button::make('print') + ->text(' Print'), + Button::make('reset') + ->text(' Reset'), + Button::make('reload') + ->text(' Reload') + ); + } + + /** + * Get columns. + * + * @return array + */ + protected function getColumns() + { + return [ + Column::make('date') + ->className('text-center align-middle'), + + Column::make('reference') + ->className('text-center align-middle'), + + Column::make('adjusted_products_count') + ->title('Products') + ->className('text-center align-middle'), + + Column::computed('action') + ->exportable(false) + ->printable(false) + ->className('text-center align-middle') + ]; + } + + /** + * Get filename for export. + * + * @return string + */ + protected function filename() + { + return 'Adjustments_' . date('YmdHis'); + } +} diff --git a/app/DataTables/ProductDataTable.php b/app/DataTables/ProductDataTable.php index 897b01f9..de26652a 100644 --- a/app/DataTables/ProductDataTable.php +++ b/app/DataTables/ProductDataTable.php @@ -80,39 +80,32 @@ class ProductDataTable extends DataTable return [ Column::computed('product_image') ->title('Image') - ->addClass('text-center') - ->addClass('align-middle'), + ->className('text-center align-middle'), Column::make('product_name') ->title('Name') - ->addClass('text-center') - ->addClass('align-middle'), + ->className('text-center align-middle'), Column::make('product_code') ->title('Code') - ->addClass('text-center') - ->addClass('align-middle'), + ->className('text-center align-middle'), Column::make('product_price') ->title('Price') - ->addClass('text-center') - ->addClass('align-middle'), + ->className('text-center align-middle'), Column::make('product_quantity') ->title('Quantity') - ->addClass('text-center') - ->addClass('align-middle'), + ->className('text-center align-middle'), Column::make('category.category_name') ->title('Category') - ->addClass('text-center') - ->addClass('align-middle'), + ->className('text-center align-middle'), Column::computed('action') ->exportable(false) ->printable(false) - ->addClass('text-center') - ->addClass('align-middle'), + ->className('text-center align-middle') ]; } diff --git a/app/Http/Livewire/Adjustment/ProductTable.php b/app/Http/Livewire/Adjustment/ProductTable.php new file mode 100644 index 00000000..57161845 --- /dev/null +++ b/app/Http/Livewire/Adjustment/ProductTable.php @@ -0,0 +1,56 @@ +products = []; + + if ($adjustedProducts) { + $this->hasAdjustments = true; + $this->products = $adjustedProducts; + } else { + $this->hasAdjustments = false; + } + } + + public function render() { + return view('livewire.adjustment.product-table'); + } + + public function productSelected($product) { + switch ($this->hasAdjustments) { + case true: + if (in_array($product, array_map(function ($adjustment) { + return $adjustment['product']; + }, $this->products))) { + return session()->flash('message', 'Already exists in the product table!'); + } + break; + case false: + if (in_array($product, $this->products)) { + return session()->flash('message', 'Already exists in the product table!'); + } + break; + default: + return session()->flash('message', 'Something went wrong!');; + } + + array_push($this->products, $product); + } + + public function removeProduct($key) { + unset($this->products[$key]); + } +} diff --git a/app/Http/Livewire/Barcode/SearchProduct.php b/app/Http/Livewire/SearchProduct.php similarity index 89% rename from app/Http/Livewire/Barcode/SearchProduct.php rename to app/Http/Livewire/SearchProduct.php index dcb63265..f479f8e5 100644 --- a/app/Http/Livewire/Barcode/SearchProduct.php +++ b/app/Http/Livewire/SearchProduct.php @@ -1,6 +1,6 @@ \Gloudemans\Shoppingcart\Calculation\DefaultCalculator::class, + + /* + |-------------------------------------------------------------------------- + | Default tax rate + |-------------------------------------------------------------------------- + | + | This default tax rate will be used when you make a class implement the + | Taxable interface and use the HasTax trait. + | + */ + + 'tax' => 0, + + /* + |-------------------------------------------------------------------------- + | Shoppingcart database settings + |-------------------------------------------------------------------------- + | + | Here you can set the connection that the shoppingcart should use when + | storing and restoring a cart. + | + */ + + 'database' => [ + + 'connection' => null, + + 'table' => 'shoppingcart', + + ], + + /* + |-------------------------------------------------------------------------- + | Destroy the cart on user logout + |-------------------------------------------------------------------------- + | + | When this option is set to 'true' the cart will automatically + | destroy all cart instances when the user logs out. + | + */ + + 'destroy_on_logout' => true, + + /* + |-------------------------------------------------------------------------- + | Default number format + |-------------------------------------------------------------------------- + | + | This defaults will be used for the formatted numbers if you don't + | set them in the method call. + | + */ + + 'format' => [ + + 'decimals' => 2, + + 'decimal_point' => '.', + + 'thousand_separator' => ',', + + ], + +]; diff --git a/config/snappy.php b/config/snappy.php index 4b73ab4d..13bacf9e 100644 --- a/config/snappy.php +++ b/config/snappy.php @@ -35,10 +35,11 @@ return [ 'pdf' => [ 'enabled' => true, - 'binary' => env('WKHTML_PDF_BINARY', '"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe"'), + 'binary' => env('WKHTML_PDF_BINARY', base_path('vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'),), 'timeout' => false, 'options' => [ - 'enable-local-file-access' => true + 'enable-local-file-access' => true, + 'print-media-type' => true ], 'env' => [], ], diff --git a/modules_statuses.json b/modules_statuses.json index 2d7d1f00..bbbd1ddf 100644 --- a/modules_statuses.json +++ b/modules_statuses.json @@ -1,5 +1,6 @@ { "Product": true, "Upload": true, - "User": true -} + "User": true, + "Adjustment": true +} \ No newline at end of file diff --git a/public/css/app.css b/public/css/app.css index 5cbf4288..bced94d9 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -18781,5 +18781,12 @@ h3 { } table { - width: 100% !important; + width: 990px !important; +} + +/* Large devices (desktops, 992px and up) */ +@media (min-width: 992px) { + table { + width: 100% !important; + } } diff --git a/resources/sass/app.scss b/resources/sass/app.scss index 6d7d88e4..06b2686e 100644 --- a/resources/sass/app.scss +++ b/resources/sass/app.scss @@ -8,5 +8,12 @@ } table { - width: 100% !important; + width: 990px !important; +} + +/* Large devices (desktops, 992px and up) */ +@media (min-width: 992px) { + table { + width: 100% !important; + } } diff --git a/resources/views/layouts/menu.blade.php b/resources/views/layouts/menu.blade.php index 79d06e7e..50008d1b 100644 --- a/resources/views/layouts/menu.blade.php +++ b/resources/views/layouts/menu.blade.php @@ -40,6 +40,28 @@ @endcan +@can('access_adjustments') +
  • + + Adjustments + + +
  • +@endcan + @can('access_user_management')
  • diff --git a/resources/views/livewire/adjustment/product-table.blade.php b/resources/views/livewire/adjustment/product-table.blade.php new file mode 100644 index 00000000..6e1d6dc3 --- /dev/null +++ b/resources/views/livewire/adjustment/product-table.blade.php @@ -0,0 +1,78 @@ +
    + @if (session()->has('message')) + + @endif +
    + + + + + + + + + + + + + + @if(!empty($products)) + @foreach($products as $key => $product) + + + + + + + + + + + @endforeach + @else + + + + @endif + +
    #Product NameCodeStockQuantityTypeAction
    {{ $key + 1 }}{{ $product['product_name'] ?? $product['product']['product_name'] }}{{ $product['product_code'] ?? $product['product']['product_code'] }} + + {{ $product['product_quantity'] ?? $product['product']['product_quantity'] }} + + + + + @if(isset($product['type'])) + @if($product['type'] == 'add') + + @elseif($product['type'] == 'sub') + + @endif + @else + + @endif + + +
    + + Please search & select products! + +
    +
    +
    diff --git a/resources/views/livewire/barcode/product-table.blade.php b/resources/views/livewire/barcode/product-table.blade.php index 9cfb360d..a02d4dff 100644 --- a/resources/views/livewire/barcode/product-table.blade.php +++ b/resources/views/livewire/barcode/product-table.blade.php @@ -48,7 +48,7 @@