diff --git a/Modules/Product/Database/Migrations/2021_07_14_145047_create_products_table.php b/Modules/Product/Database/Migrations/2021_07_14_145047_create_products_table.php index d8beafb2..dd983204 100644 --- a/Modules/Product/Database/Migrations/2021_07_14_145047_create_products_table.php +++ b/Modules/Product/Database/Migrations/2021_07_14_145047_create_products_table.php @@ -22,6 +22,7 @@ class CreateProductsTable extends Migration $table->integer('product_quantity'); $table->integer('product_cost'); $table->integer('product_price'); + $table->string('product_unit')->nullable(); $table->integer('product_stock_alert'); $table->integer('product_order_tax')->nullable(); $table->tinyInteger('product_tax_type')->nullable(); diff --git a/Modules/Product/Entities/Product.php b/Modules/Product/Entities/Product.php index 4c76d996..4ba9ecbd 100644 --- a/Modules/Product/Entities/Product.php +++ b/Modules/Product/Entities/Product.php @@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; +use Spatie\MediaLibrary\MediaCollections\Models\Media; class Product extends Model implements HasMedia { @@ -25,6 +26,12 @@ class Product extends Model implements HasMedia ->useFallbackUrl('/images/fallback_product_image.png'); } + public function registerMediaConversions(Media $media = null): void { + $this->addMediaConversion('thumb') + ->width(50) + ->height(50); + } + public function setProductCostAttribute($value) { $this->attributes['product_cost'] = ($value * 100); } diff --git a/Modules/Product/Http/Controllers/ProductController.php b/Modules/Product/Http/Controllers/ProductController.php index 114f1b44..d70baf17 100644 --- a/Modules/Product/Http/Controllers/ProductController.php +++ b/Modules/Product/Http/Controllers/ProductController.php @@ -35,7 +35,7 @@ class ProductController extends Controller if ($request->has('document')) { foreach ($request->input('document', []) as $file) { - $product->addMedia(storage_path('temp/dropzone/' . $file))->toMediaCollection('images'); + $product->addMedia(Storage::path('temp/dropzone/' . $file))->toMediaCollection('images'); } } @@ -75,7 +75,7 @@ class ProductController extends Controller foreach ($request->input('document', []) as $file) { if (count($media) === 0 || !in_array($file, $media)) { - $product->addMedia(storage_path('temp/dropzone/' . $file))->toMediaCollection('images'); + $product->addMedia(Storage::path('temp/dropzone/' . $file))->toMediaCollection('images'); } } } diff --git a/Modules/Product/Http/Requests/StoreProductRequest.php b/Modules/Product/Http/Requests/StoreProductRequest.php index 170bf44e..7d030f6d 100644 --- a/Modules/Product/Http/Requests/StoreProductRequest.php +++ b/Modules/Product/Http/Requests/StoreProductRequest.php @@ -18,6 +18,7 @@ class StoreProductRequest extends FormRequest 'product_name' => ['required', 'string', 'max:255'], 'product_code' => ['required', 'string', 'max:255', 'unique:products,product_code'], 'product_barcode_symbology' => ['required', 'string', 'max:255'], + 'product_unit' => ['required', 'string', 'max:255'], 'product_quantity' => ['required', 'integer', 'min:1'], 'product_cost' => ['required', 'numeric', 'max:2147483647'], 'product_price' => ['required', 'numeric', 'max:2147483647'], diff --git a/Modules/Product/Http/Requests/UpdateProductRequest.php b/Modules/Product/Http/Requests/UpdateProductRequest.php index 8aa052b0..3fd0d4c8 100644 --- a/Modules/Product/Http/Requests/UpdateProductRequest.php +++ b/Modules/Product/Http/Requests/UpdateProductRequest.php @@ -19,6 +19,7 @@ class UpdateProductRequest extends FormRequest 'product_name' => ['required', 'string', 'max:255'], 'product_code' => ['required', 'string', 'max:255', 'unique:products,product_code,' . $this->product->id], 'product_barcode_symbology' => ['required', 'string', 'max:255'], + 'product_unit' => ['required', 'string', 'max:255'], 'product_quantity' => ['required', 'integer', 'min:1'], 'product_cost' => ['required', 'numeric', 'max:2147483647'], 'product_price' => ['required', 'numeric', 'max:2147483647'], diff --git a/Modules/Product/Resources/views/products/create.blade.php b/Modules/Product/Resources/views/products/create.blade.php index 38f608d8..322190e0 100644 --- a/Modules/Product/Resources/views/products/create.blade.php +++ b/Modules/Product/Resources/views/products/create.blade.php @@ -97,13 +97,13 @@
-
+
-
+
+
+
+ + +
+
+
+ +
+ +
@@ -122,7 +133,7 @@
- +
@@ -152,7 +163,7 @@ addRemoveLinks: true, dictRemoveFile: " remove", headers: { - 'X-CSRF-TOKEN': "{{ csrf_token() }}" + "X-CSRF-TOKEN": "{{ csrf_token() }}" }, success: function (file, response) { $('form').append(''); @@ -166,6 +177,14 @@ } else { name = uploadedDocumentMap[file.name]; } + $.ajax({ + type: "POST", + url: "{{ route('dropzone.delete') }}", + data: { + '_token': "{{ csrf_token() }}", + 'file_name': `${name}` + }, + }); $('form').find('input[name="document[]"][value="' + name + '"]').remove(); }, init: function () { diff --git a/Modules/Product/Resources/views/products/edit.blade.php b/Modules/Product/Resources/views/products/edit.blade.php index 9d8b4f0d..cbeee92f 100644 --- a/Modules/Product/Resources/views/products/edit.blade.php +++ b/Modules/Product/Resources/views/products/edit.blade.php @@ -97,13 +97,13 @@
-
+
-
+
+
+
+ + +
+
+
+
+ +
@@ -122,7 +132,7 @@
- +
diff --git a/Modules/Product/Resources/views/products/show.blade.php b/Modules/Product/Resources/views/products/show.blade.php index c041fa1d..f3e9b5f0 100644 --- a/Modules/Product/Resources/views/products/show.blade.php +++ b/Modules/Product/Resources/views/products/show.blade.php @@ -18,7 +18,7 @@
-
+
@@ -49,7 +49,14 @@ Quantity - {{ $product->product_quantity }} + {{ $product->product_quantity . ' ' . $product->product_unit }} + + + Stock Worth + + COST:: {{ format_currency($product->product_cost * $product->product_quantity) }} / + PRICE:: {{ format_currency($product->product_price * $product->product_quantity) }} + Alert Quantity @@ -71,13 +78,17 @@ @endif + + Note + {{ $product->product_note ?? 'N/A' }} +
-
+
@forelse($product->getMedia('images') as $media) diff --git a/Modules/Purchase/Http/Controllers/PurchaseController.php b/Modules/Purchase/Http/Controllers/PurchaseController.php index 6e9305d2..fdaaad35 100644 --- a/Modules/Purchase/Http/Controllers/PurchaseController.php +++ b/Modules/Purchase/Http/Controllers/PurchaseController.php @@ -91,13 +91,15 @@ class PurchaseController extends Controller Cart::instance('purchase')->destroy(); - PurchasePayment::create([ - 'date' => $request->date, - 'reference' => 'INV/'.$purchase->reference, - 'amount' => $purchase->paid_amount, - 'purchase_id' => $purchase->id, - 'payment_method' => $request->payment_method - ]); + if ($purchase->paid_amount > 0) { + PurchasePayment::create([ + 'date' => $request->date, + 'reference' => 'INV/'.$purchase->reference, + 'amount' => $purchase->paid_amount, + 'purchase_id' => $purchase->id, + 'payment_method' => $request->payment_method + ]); + } }); toast('Purchase Created!', 'success'); diff --git a/Modules/Purchase/Resources/views/print.blade.php b/Modules/Purchase/Resources/views/print.blade.php index 2b8db84c..fc47be82 100644 --- a/Modules/Purchase/Resources/views/print.blade.php +++ b/Modules/Purchase/Resources/views/print.blade.php @@ -57,7 +57,6 @@ Product Net Unit Price - Stock Quantity Discount Tax @@ -76,10 +75,6 @@ {{ format_currency($item->unit_price) }} - - {{ $item->product->product_quantity }} - - {{ $item->quantity }} @@ -126,7 +121,7 @@
-

Computer generated invoice. {{ settings()->company_name }} © {{ date('Y') }}.

+

{{ settings()->company_name }} © {{ date('Y') }}.

diff --git a/Modules/Purchase/Resources/views/show.blade.php b/Modules/Purchase/Resources/views/show.blade.php index 38a4bc2e..f6ea25f6 100644 --- a/Modules/Purchase/Resources/views/show.blade.php +++ b/Modules/Purchase/Resources/views/show.blade.php @@ -64,7 +64,6 @@ Product Net Unit Price - Stock Quantity Discount Tax @@ -83,10 +82,6 @@ {{ format_currency($item->unit_price) }} - - {{ $item->product->product_quantity }} - - {{ $item->quantity }} diff --git a/Modules/PurchasesReturn/Http/Controllers/PurchasesReturnController.php b/Modules/PurchasesReturn/Http/Controllers/PurchasesReturnController.php index bebc7ad6..3e58c3f6 100644 --- a/Modules/PurchasesReturn/Http/Controllers/PurchasesReturnController.php +++ b/Modules/PurchasesReturn/Http/Controllers/PurchasesReturnController.php @@ -92,13 +92,15 @@ class PurchasesReturnController extends Controller Cart::instance('purchase_return')->destroy(); - PurchaseReturnPayment::create([ - 'date' => $request->date, - 'reference' => 'INV/'.$purchase_return->reference, - 'amount' => $purchase_return->paid_amount, - 'purchase_return_id' => $purchase_return->id, - 'payment_method' => $request->payment_method - ]); + if ($purchase_return->paid_amount > 0) { + PurchaseReturnPayment::create([ + 'date' => $request->date, + 'reference' => 'INV/' . $purchase_return->reference, + 'amount' => $purchase_return->paid_amount, + 'purchase_return_id' => $purchase_return->id, + 'payment_method' => $request->payment_method + ]); + } }); toast('Purchase Return Created!', 'success'); diff --git a/Modules/PurchasesReturn/Resources/views/print.blade.php b/Modules/PurchasesReturn/Resources/views/print.blade.php index 76746898..d0b5b7d0 100644 --- a/Modules/PurchasesReturn/Resources/views/print.blade.php +++ b/Modules/PurchasesReturn/Resources/views/print.blade.php @@ -57,7 +57,6 @@ Product Net Unit Price - Stock Quantity Discount Tax @@ -76,10 +75,6 @@ {{ format_currency($item->unit_price) }} - - {{ $item->product->product_quantity }} - - {{ $item->quantity }} @@ -126,7 +121,7 @@
-

Computer generated invoice. {{ settings()->company_name }} © {{ date('Y') }}.

+

{{ settings()->company_name }} © {{ date('Y') }}.

diff --git a/Modules/PurchasesReturn/Resources/views/show.blade.php b/Modules/PurchasesReturn/Resources/views/show.blade.php index 18f3ef15..387cc6e5 100644 --- a/Modules/PurchasesReturn/Resources/views/show.blade.php +++ b/Modules/PurchasesReturn/Resources/views/show.blade.php @@ -64,7 +64,6 @@ Product Net Unit Price - Stock Quantity Discount Tax @@ -83,10 +82,6 @@ {{ format_currency($item->unit_price) }} - - {{ $item->product->product_quantity }} - - {{ $item->quantity }} diff --git a/Modules/Sale/Http/Controllers/PosController.php b/Modules/Sale/Http/Controllers/PosController.php index d5191fba..4b4ede75 100644 --- a/Modules/Sale/Http/Controllers/PosController.php +++ b/Modules/Sale/Http/Controllers/PosController.php @@ -82,13 +82,15 @@ class PosController extends Controller Cart::instance('sale')->destroy(); - SalePayment::create([ - 'date' => now()->format('Y-m-d'), - 'reference' => 'INV/'.$sale->reference, - 'amount' => $sale->paid_amount, - 'sale_id' => $sale->id, - 'payment_method' => $request->payment_method - ]); + if ($sale->paid_amount > 0) { + SalePayment::create([ + 'date' => now()->format('Y-m-d'), + 'reference' => 'INV/'.$sale->reference, + 'amount' => $sale->paid_amount, + 'sale_id' => $sale->id, + 'payment_method' => $request->payment_method + ]); + } }); toast('POS Sale Created!', 'success'); diff --git a/Modules/Sale/Http/Controllers/SaleController.php b/Modules/Sale/Http/Controllers/SaleController.php index 1a356b65..c22fdfa5 100644 --- a/Modules/Sale/Http/Controllers/SaleController.php +++ b/Modules/Sale/Http/Controllers/SaleController.php @@ -92,13 +92,15 @@ class SaleController extends Controller Cart::instance('sale')->destroy(); - SalePayment::create([ - 'date' => $request->date, - 'reference' => 'INV/'.$sale->reference, - 'amount' => $sale->paid_amount, - 'sale_id' => $sale->id, - 'payment_method' => $request->payment_method - ]); + if ($sale->paid_amount > 0) { + SalePayment::create([ + 'date' => $request->date, + 'reference' => 'INV/'.$sale->reference, + 'amount' => $sale->paid_amount, + 'sale_id' => $sale->id, + 'payment_method' => $request->payment_method + ]); + } }); toast('Sale Created!', 'success'); diff --git a/Modules/Sale/Resources/views/print.blade.php b/Modules/Sale/Resources/views/print.blade.php index 705ea86f..25862fb8 100644 --- a/Modules/Sale/Resources/views/print.blade.php +++ b/Modules/Sale/Resources/views/print.blade.php @@ -57,7 +57,6 @@ Product Net Unit Price - Stock Quantity Discount Tax @@ -76,10 +75,6 @@ {{ format_currency($item->unit_price) }} - - {{ $item->product->product_quantity }} - - {{ $item->quantity }} @@ -126,7 +121,7 @@
-

Computer generated invoice. {{ settings()->company_name }} © {{ date('Y') }}.

+

{{ settings()->company_name }} © {{ date('Y') }}.

diff --git a/Modules/Sale/Resources/views/show.blade.php b/Modules/Sale/Resources/views/show.blade.php index 7feb63f4..680f8730 100644 --- a/Modules/Sale/Resources/views/show.blade.php +++ b/Modules/Sale/Resources/views/show.blade.php @@ -64,7 +64,6 @@ Product Net Unit Price - Stock Quantity Discount Tax @@ -83,10 +82,6 @@ {{ format_currency($item->unit_price) }} - - {{ $item->product->product_quantity }} - - {{ $item->quantity }} diff --git a/Modules/SalesReturn/Http/Controllers/SalesReturnController.php b/Modules/SalesReturn/Http/Controllers/SalesReturnController.php index 97a340a8..de5b6dcf 100644 --- a/Modules/SalesReturn/Http/Controllers/SalesReturnController.php +++ b/Modules/SalesReturn/Http/Controllers/SalesReturnController.php @@ -92,13 +92,15 @@ class SalesReturnController extends Controller Cart::instance('sale_return')->destroy(); - SaleReturnPayment::create([ - 'date' => $request->date, - 'reference' => 'INV/'.$sale_return->reference, - 'amount' => $sale_return->paid_amount, - 'sale_return_id' => $sale_return->id, - 'payment_method' => $request->payment_method - ]); + if ($sale_return->paid_amount > 0) { + SaleReturnPayment::create([ + 'date' => $request->date, + 'reference' => 'INV/'.$sale_return->reference, + 'amount' => $sale_return->paid_amount, + 'sale_return_id' => $sale_return->id, + 'payment_method' => $request->payment_method + ]); + } }); toast('Sale Return Created!', 'success'); diff --git a/Modules/SalesReturn/Resources/views/print.blade.php b/Modules/SalesReturn/Resources/views/print.blade.php index 6c8061f8..ee5eb6e6 100644 --- a/Modules/SalesReturn/Resources/views/print.blade.php +++ b/Modules/SalesReturn/Resources/views/print.blade.php @@ -57,7 +57,6 @@ Product Net Unit Price - Stock Quantity Discount Tax @@ -76,10 +75,6 @@ {{ format_currency($item->unit_price) }} - - {{ $item->product->product_quantity }} - - {{ $item->quantity }} @@ -126,7 +121,7 @@
-

Computer generated invoice. {{ settings()->company_name }} © {{ date('Y') }}.

+

{{ settings()->company_name }} © {{ date('Y') }}.

diff --git a/Modules/SalesReturn/Resources/views/show.blade.php b/Modules/SalesReturn/Resources/views/show.blade.php index 4ae290a4..a918556e 100644 --- a/Modules/SalesReturn/Resources/views/show.blade.php +++ b/Modules/SalesReturn/Resources/views/show.blade.php @@ -64,7 +64,6 @@ Product Net Unit Price - Stock Quantity Discount Tax @@ -83,10 +82,6 @@ {{ format_currency($item->unit_price) }} - - {{ $item->product->product_quantity }} - - {{ $item->quantity }} diff --git a/Modules/Setting/Http/Controllers/SettingController.php b/Modules/Setting/Http/Controllers/SettingController.php index 34603f34..617c65f9 100644 --- a/Modules/Setting/Http/Controllers/SettingController.php +++ b/Modules/Setting/Http/Controllers/SettingController.php @@ -5,8 +5,11 @@ namespace Modules\Setting\Http\Controllers; use Illuminate\Contracts\Support\Renderable; use Illuminate\Http\Request; use Illuminate\Routing\Controller; +use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Gate; +use Illuminate\Support\Facades\Log; use Modules\Setting\Entities\Setting; +use Modules\Setting\Http\Requests\StoreSettingsRequest; class SettingController extends Controller { @@ -20,20 +23,7 @@ class SettingController extends Controller } - public function update(Request $request) { - abort_if(Gate::denies('access_settings'), 403); - - $request->validate([ - 'company_name' => 'required|string|max:255', - 'company_email' => 'required|email|max:255', - 'company_phone' => 'required|string|max:255', - 'notification_email' => 'required|email|max:255', - 'company_address' => 'required|string|max:500', - 'default_currency_id' => 'required|numeric', - 'default_currency_position' => 'required|string|max:255', - 'footer_text' => 'required|string|max:255' - ]); - + public function update(StoreSettingsRequest $request) { Setting::firstOrFail()->update([ 'company_name' => $request->company_name, 'company_email' => $request->company_email, @@ -51,4 +41,40 @@ class SettingController extends Controller return redirect()->route('settings.index'); } + + + public function updateSmtp(Request $request) { + $toReplace = array( + 'MAIL_MAILER='.env('MAIL_HOST'), + 'MAIL_HOST="'.env('MAIL_HOST').'"', + 'MAIL_PORT='.env('MAIL_PORT'), + 'MAIL_FROM_ADDRESS="'.env('MAIL_FROM_ADDRESS').'"', + 'MAIL_FROM_NAME="'.env('MAIL_FROM_NAME').'"', + 'MAIL_USERNAME="'.env('MAIL_USERNAME').'"', + 'MAIL_PASSWORD="'.env('MAIL_PASSWORD').'"', + 'MAIL_ENCRYPTION="'.env('MAIL_ENCRYPTION').'"' + ); + + $replaceWith = array( + 'MAIL_MAILER='.$request->mail_mailer, + 'MAIL_HOST="'.$request->mail_host.'"', + 'MAIL_PORT='.$request->mail_port, + 'MAIL_FROM_ADDRESS="'.$request->mail_from_address.'"', + 'MAIL_FROM_NAME="'.$request->mail_from_name.'"', + 'MAIL_USERNAME="'.$request->mail_username.'"', + 'MAIL_PASSWORD="'.$request->mail_password.'"', + 'MAIL_ENCRYPTION="'.$request->mail_encryption.'"'); + + try { + file_put_contents(base_path('.env'), str_replace($toReplace, $replaceWith, file_get_contents(base_path('.env')))); + Artisan::call('cache:clear'); + + toast('Mail Settings Updated!', 'info'); + } catch (\Exception $exception) { + Log::error($exception); + session()->flash('settings_smtp_message', 'Something Went Wrong!'); + } + + return redirect()->route('settings.index'); + } } diff --git a/Modules/Setting/Http/Requests/StoreSettingsRequest.php b/Modules/Setting/Http/Requests/StoreSettingsRequest.php new file mode 100644 index 00000000..b8ae1b8b --- /dev/null +++ b/Modules/Setting/Http/Requests/StoreSettingsRequest.php @@ -0,0 +1,38 @@ + 'required|string|max:255', + 'company_email' => 'required|email|max:255', + 'company_phone' => 'required|string|max:255', + 'notification_email' => 'required|email|max:255', + 'company_address' => 'required|string|max:500', + 'default_currency_id' => 'required|numeric', + 'default_currency_position' => 'required|string|max:255', + 'footer_text' => 'required|string|max:255' + ]; + } + + /** + * Determine if the user is authorized to make this request. + * + * @return bool + */ + public function authorize() + { + return Gate::allows('access_settings'); + } +} diff --git a/Modules/Setting/Resources/views/index.blade.php b/Modules/Setting/Resources/views/index.blade.php index 78691238..f80c7731 100644 --- a/Modules/Setting/Resources/views/index.blade.php +++ b/Modules/Setting/Resources/views/index.blade.php @@ -86,7 +86,97 @@
-
+
+ +
+ +
+
+
+ +
+ @if (session()->has('settings_smtp_message')) + + @endif +
+
+
Mail Settings
+
+
+
+ @csrf + @method('patch') +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
diff --git a/Modules/Setting/Routes/web.php b/Modules/Setting/Routes/web.php index 27368b3c..4a246957 100644 --- a/Modules/Setting/Routes/web.php +++ b/Modules/Setting/Routes/web.php @@ -13,6 +13,9 @@ Route::group(['middleware' => 'auth'], function () { + //Mail Settings + Route::patch('/settings/smtp', 'SettingController@updateSmtp')->name('settings.smtp.update'); + //General Settings Route::get('/settings', 'SettingController@index')->name('settings.index'); Route::patch('/settings', 'SettingController@update')->name('settings.update'); diff --git a/Modules/Upload/Http/Controllers/UploadController.php b/Modules/Upload/Http/Controllers/UploadController.php index 89407396..e27ac986 100644 --- a/Modules/Upload/Http/Controllers/UploadController.php +++ b/Modules/Upload/Http/Controllers/UploadController.php @@ -49,21 +49,21 @@ class UploadController extends Controller public function dropzoneUpload(Request $request) { - $path = storage_path('temp/dropzone'); - - if (!file_exists($path)) { - mkdir($path, 0777, true); - } - $file = $request->file('file'); - $name = now()->timestamp . '.' . trim($file->getClientOriginalExtension()); + $filename = now()->timestamp . '.' . trim($file->getClientOriginalExtension()); - $file->move($path, $name); + Storage::putFileAs('temp/dropzone/', $file, $filename); return response()->json([ - 'name' => $name, + 'name' => $filename, 'original_name' => $file->getClientOriginalName(), ]); } + + public function dropzoneDelete(Request $request) { + Storage::delete('temp/dropzone/' . $request->file_name); + + return response()->json($request->file_name, 200); + } } diff --git a/Modules/Upload/Routes/web.php b/Modules/Upload/Routes/web.php index 9ea1d9c0..1bb8618d 100644 --- a/Modules/Upload/Routes/web.php +++ b/Modules/Upload/Routes/web.php @@ -15,6 +15,7 @@ Route::group(['middleware' => 'auth'], function () { //Dropzone Route::post('/dropzone/upload', 'UploadController@dropzoneUpload')->name('dropzone.upload'); + Route::post('/dropzone/delete', 'UploadController@dropzoneDelete')->name('dropzone.delete'); //Filepond Route::post('/filepond/upload', 'UploadController@filepondUpload')->name('filepond.upload'); Route::delete('/filepond/delete', 'UploadController@filepondDelete')->name('filepond.delete'); diff --git a/app/DataTables/ProductDataTable.php b/app/DataTables/ProductDataTable.php index c0b871ea..3a417de9 100644 --- a/app/DataTables/ProductDataTable.php +++ b/app/DataTables/ProductDataTable.php @@ -20,12 +20,15 @@ class ProductDataTable extends DataTable return view('product::products.partials.actions', compact('data')); }) ->addColumn('product_image', function ($data) { - $url = $data->getFirstMediaUrl('images'); + $url = $data->getFirstMediaUrl('images', 'thumb'); return ''; }) ->addColumn('product_price', function ($data) { return format_currency($data->product_price); }) + ->addColumn('product_quantity', function ($data) { + return $data->product_quantity . ' ' . $data->product_unit; + }) ->rawColumns(['product_image']); } @@ -75,7 +78,7 @@ class ProductDataTable extends DataTable ->title('Price') ->className('text-center align-middle'), - Column::make('product_quantity') + Column::computed('product_quantity') ->title('Quantity') ->className('text-center align-middle'), diff --git a/app/Http/Livewire/Pos/Checkout.php b/app/Http/Livewire/Pos/Checkout.php index 418669a0..0f8b91af 100644 --- a/app/Http/Livewire/Pos/Checkout.php +++ b/app/Http/Livewire/Pos/Checkout.php @@ -90,6 +90,7 @@ class Checkout extends Component 'sub_total' => $this->calculate($product)['sub_total'], 'code' => $product['product_code'], 'stock' => $product['product_quantity'], + 'unit' => $product['product_unit'], 'product_tax' => $this->calculate($product)['product_tax'], 'unit_price' => $this->calculate($product)['unit_price'] ] @@ -130,6 +131,7 @@ class Checkout extends Component 'sub_total' => $cart_item->price * $cart_item->qty, 'code' => $cart_item->options->code, 'stock' => $cart_item->options->stock, + 'unit' => $cart_item->options->unit, 'product_tax' => $cart_item->options->product_tax, 'unit_price' => $cart_item->options->unit_price, 'product_discount' => $cart_item->options->product_discount, @@ -159,11 +161,11 @@ class Checkout extends Component $this->updateCartOptions($row_id, $product_id, $cart_item, $discount_amount); } elseif ($this->discount_type[$product_id] == 'percentage') { - $discount_amount = $cart_item->price * ($this->item_discount[$product_id] / 100); + $discount_amount = ($cart_item->price + $cart_item->options->product_discount) * ($this->item_discount[$product_id] / 100); Cart::instance($this->cart_instance) ->update($row_id, [ - 'price' => ($cart_item->price + $cart_item->options->product_discount) - (($cart_item->price * $this->item_discount[$product_id] / 100)) + 'price' => ($cart_item->price + $cart_item->options->product_discount) - $discount_amount ]); $this->updateCartOptions($row_id, $product_id, $cart_item, $discount_amount); @@ -203,6 +205,7 @@ class Checkout extends Component 'sub_total' => $cart_item->price * $cart_item->qty, 'code' => $cart_item->options->code, 'stock' => $cart_item->options->stock, + 'unit' => $cart_item->options->unit, 'product_tax' => $cart_item->options->product_tax, 'unit_price' => $cart_item->options->unit_price, 'product_discount' => $discount_amount, diff --git a/app/Http/Livewire/ProductCart.php b/app/Http/Livewire/ProductCart.php index 56c14054..f040a71e 100644 --- a/app/Http/Livewire/ProductCart.php +++ b/app/Http/Livewire/ProductCart.php @@ -42,7 +42,7 @@ class ProductCart extends Component $this->discount_type[$cart_item->id] = $cart_item->options->product_discount_type; if ($cart_item->options->product_discount_type == 'fixed') { $this->item_discount[$cart_item->id] = $cart_item->options->product_discount; - } elseif($cart_item->options->product_discount_type == 'percentage') { + } elseif ($cart_item->options->product_discount_type == 'percentage') { $this->item_discount[$cart_item->id] = 100 * ($cart_item->options->product_discount / $cart_item->price); } } @@ -74,6 +74,7 @@ class ProductCart extends Component if ($exists->isNotEmpty()) { session()->flash('message', 'Product exists in the cart!'); + return; } @@ -84,13 +85,14 @@ class ProductCart extends Component 'price' => $this->calculate($product)['price'], 'weight' => 1, 'options' => [ - 'product_discount' => 0.00, + 'product_discount' => 0.00, 'product_discount_type' => 'fixed', - 'sub_total' => $this->calculate($product)['sub_total'], - 'code' => $product['product_code'], - 'stock' => $product['product_quantity'], - 'product_tax' => $this->calculate($product)['product_tax'], - 'unit_price' => $this->calculate($product)['unit_price'] + 'sub_total' => $this->calculate($product)['sub_total'], + 'code' => $product['product_code'], + 'stock' => $product['product_quantity'], + 'unit' => $product['product_unit'], + 'product_tax' => $this->calculate($product)['product_tax'], + 'unit_price' => $this->calculate($product)['unit_price'] ] ]); @@ -105,11 +107,11 @@ class ProductCart extends Component } public function updatedGlobalTax() { - Cart::instance($this->cart_instance)->setGlobalTax((integer) $this->global_tax); + Cart::instance($this->cart_instance)->setGlobalTax((integer)$this->global_tax); } public function updatedGlobalDiscount() { - Cart::instance($this->cart_instance)->setGlobalDiscount((integer) $this->global_discount); + Cart::instance($this->cart_instance)->setGlobalDiscount((integer)$this->global_discount); } public function updateQuantity($row_id, $product_id) { @@ -124,13 +126,14 @@ class ProductCart extends Component Cart::instance($this->cart_instance)->update($row_id, [ 'options' => [ - 'sub_total' => $cart_item->price * $cart_item->qty, - 'code' => $cart_item->options->code, - 'stock' => $cart_item->options->stock, - 'product_tax' => $cart_item->options->product_tax, - 'unit_price' => $cart_item->options->unit_price, - 'product_discount' => $cart_item->options->product_discount, - 'product_discount_type' => $cart_item->options->product_discount_type, + 'sub_total' => $cart_item->price * $cart_item->qty, + 'code' => $cart_item->options->code, + 'stock' => $cart_item->options->stock, + 'unit' => $cart_item->options->unit, + 'product_tax' => $cart_item->options->product_tax, + 'unit_price' => $cart_item->options->unit_price, + 'product_discount' => $cart_item->options->product_discount, + 'product_discount_type' => $cart_item->options->product_discount_type, ] ]); } @@ -155,13 +158,12 @@ class ProductCart extends Component $discount_amount = $this->item_discount[$product_id]; $this->updateCartOptions($row_id, $product_id, $cart_item, $discount_amount); - } - elseif ($this->discount_type[$product_id] == 'percentage') { - $discount_amount = $cart_item->price * ($this->item_discount[$product_id] / 100); + } elseif ($this->discount_type[$product_id] == 'percentage') { + $discount_amount = ($cart_item->price + $cart_item->options->product_discount) * ($this->item_discount[$product_id] / 100); Cart::instance($this->cart_instance) ->update($row_id, [ - 'price' => ($cart_item->price + $cart_item->options->product_discount) - (($cart_item->price * $this->item_discount[$product_id] / 100)) + 'price' => ($cart_item->price + $cart_item->options->product_discount) - $discount_amount ]); $this->updateCartOptions($row_id, $product_id, $cart_item, $discount_amount); @@ -181,14 +183,12 @@ class ProductCart extends Component $unit_price = $product['product_price']; $product_tax = $product['product_price'] * ($product['product_order_tax'] / 100); $sub_total = $product['product_price'] + ($product['product_price'] * ($product['product_order_tax'] / 100)); - } - elseif ($product['product_tax_type'] == 2) { + } elseif ($product['product_tax_type'] == 2) { $price = $product['product_price']; $unit_price = $product['product_price'] - ($product['product_price'] * ($product['product_order_tax'] / 100)); $product_tax = $product['product_price'] * ($product['product_order_tax'] / 100); $sub_total = $product['product_price']; - } - else { + } else { $price = $product['product_price']; $unit_price = $product['product_price']; $product_tax = 0.00; @@ -200,13 +200,14 @@ class ProductCart extends Component public function updateCartOptions($row_id, $product_id, $cart_item, $discount_amount) { Cart::instance($this->cart_instance)->update($row_id, ['options' => [ - 'sub_total' => $cart_item->price * $cart_item->qty, - 'code' => $cart_item->options->code, - 'stock' => $cart_item->options->stock, - 'product_tax' => $cart_item->options->product_tax, - 'unit_price' => $cart_item->options->unit_price, - 'product_discount' => $discount_amount, - 'product_discount_type' => $this->discount_type[$product_id], + 'sub_total' => $cart_item->price * $cart_item->qty, + 'code' => $cart_item->options->code, + 'stock' => $cart_item->options->stock, + 'unit' => $cart_item->options->unit, + 'product_tax' => $cart_item->options->product_tax, + 'unit_price' => $cart_item->options->unit_price, + 'product_discount' => $discount_amount, + 'product_discount_type' => $this->discount_type[$product_id], ]]); } } diff --git a/app/Models/User.php b/app/Models/User.php index 4145c7ab..8d4668cd 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -52,7 +52,7 @@ class User extends Authenticatable implements HasMedia public function registerMediaCollections(): void { $this->addMediaCollection('avatars') - ->useFallbackUrl('/images/fallback_profile_image.png'); + ->useFallbackUrl('https://www.gravatar.com/avatar/' . md5($this->attributes['email'])); } public function scopeIsActive(Builder $builder) { diff --git a/database/seeders/SuperUserSeeder.php b/database/seeders/SuperUserSeeder.php index 402f4487..6c8bff5f 100644 --- a/database/seeders/SuperUserSeeder.php +++ b/database/seeders/SuperUserSeeder.php @@ -18,7 +18,7 @@ class SuperUserSeeder extends Seeder { $user = User::create([ 'name' => 'Administrator', - 'email' => 'admin@gmail.com', + 'email' => 'admin@test.com', 'password' => Hash::make(12345678), 'is_active' => 1 ]); diff --git a/resources/views/livewire/pos/product-list.blade.php b/resources/views/livewire/pos/product-list.blade.php index aba67eea..a090bf21 100644 --- a/resources/views/livewire/pos/product-list.blade.php +++ b/resources/views/livewire/pos/product-list.blade.php @@ -12,7 +12,7 @@
- Product Image + Product Image
Stock: {{ $product->product_quantity }}
diff --git a/resources/views/livewire/product-cart.blade.php b/resources/views/livewire/product-cart.blade.php index 3611e9ff..1d53308a 100644 --- a/resources/views/livewire/product-cart.blade.php +++ b/resources/views/livewire/product-cart.blade.php @@ -44,7 +44,7 @@ {{ format_currency($cart_item->options->unit_price) }} - {{ $cart_item->options->stock }} + {{ $cart_item->options->stock . ' ' . $cart_item->options->unit }} @@ -64,9 +64,9 @@ - + + + @endforeach diff --git a/storage/temp/dropzone/1628696232.jpeg b/storage/temp/dropzone/1628696232.jpeg deleted file mode 100644 index ef1f5a91..00000000 Binary files a/storage/temp/dropzone/1628696232.jpeg and /dev/null differ diff --git a/storage/temp/dropzone/1628696281.jpeg b/storage/temp/dropzone/1628696281.jpeg deleted file mode 100644 index ef1f5a91..00000000 Binary files a/storage/temp/dropzone/1628696281.jpeg and /dev/null differ diff --git a/storage/temp/dropzone/1628696379.jpeg b/storage/temp/dropzone/1628696379.jpeg deleted file mode 100644 index ef1f5a91..00000000 Binary files a/storage/temp/dropzone/1628696379.jpeg and /dev/null differ diff --git a/storage/temp/dropzone/1628696579.jpeg b/storage/temp/dropzone/1628696579.jpeg deleted file mode 100644 index ef1f5a91..00000000 Binary files a/storage/temp/dropzone/1628696579.jpeg and /dev/null differ diff --git a/storage/temp/dropzone/1628696610.jpeg b/storage/temp/dropzone/1628696610.jpeg deleted file mode 100644 index ef1f5a91..00000000 Binary files a/storage/temp/dropzone/1628696610.jpeg and /dev/null differ diff --git a/storage/temp/dropzone/1628696677.jpeg b/storage/temp/dropzone/1628696677.jpeg deleted file mode 100644 index ef1f5a91..00000000 Binary files a/storage/temp/dropzone/1628696677.jpeg and /dev/null differ diff --git a/storage/temp/dropzone/1628696692.jpeg b/storage/temp/dropzone/1628696692.jpeg deleted file mode 100644 index ef1f5a91..00000000 Binary files a/storage/temp/dropzone/1628696692.jpeg and /dev/null differ diff --git a/storage/temp/dropzone/1628696719.jpeg b/storage/temp/dropzone/1628696719.jpeg deleted file mode 100644 index ef1f5a91..00000000 Binary files a/storage/temp/dropzone/1628696719.jpeg and /dev/null differ diff --git a/storage/temp/dropzone/1628696738.jpeg b/storage/temp/dropzone/1628696738.jpeg deleted file mode 100644 index ef1f5a91..00000000 Binary files a/storage/temp/dropzone/1628696738.jpeg and /dev/null differ diff --git a/storage/temp/dropzone/1628696962.jpeg b/storage/temp/dropzone/1628696962.jpeg deleted file mode 100644 index ef1f5a91..00000000 Binary files a/storage/temp/dropzone/1628696962.jpeg and /dev/null differ diff --git a/storage/temp/dropzone/1628697259.jpg b/storage/temp/dropzone/1628697259.jpg deleted file mode 100644 index f037663c..00000000 Binary files a/storage/temp/dropzone/1628697259.jpg and /dev/null differ diff --git a/storage/temp/dropzone/1628697283.jpg b/storage/temp/dropzone/1628697283.jpg deleted file mode 100644 index f037663c..00000000 Binary files a/storage/temp/dropzone/1628697283.jpg and /dev/null differ diff --git a/storage/temp/dropzone/1628699921.jpeg b/storage/temp/dropzone/1628699921.jpeg deleted file mode 100644 index ef1f5a91..00000000 Binary files a/storage/temp/dropzone/1628699921.jpeg and /dev/null differ diff --git a/storage/temp/dropzone/1628700339.torrent b/storage/temp/dropzone/1628700339.torrent deleted file mode 100644 index 0e9e4fcf..00000000 Binary files a/storage/temp/dropzone/1628700339.torrent and /dev/null differ diff --git a/storage/temp/dropzone/1628700356.torrent b/storage/temp/dropzone/1628700356.torrent deleted file mode 100644 index 0e9e4fcf..00000000 Binary files a/storage/temp/dropzone/1628700356.torrent and /dev/null differ diff --git a/storage/temp/dropzone/1628700527.jpeg b/storage/temp/dropzone/1628700527.jpeg deleted file mode 100644 index ef1f5a91..00000000 Binary files a/storage/temp/dropzone/1628700527.jpeg and /dev/null differ diff --git a/storage/temp/dropzone/1628700551.jpg b/storage/temp/dropzone/1628700551.jpg deleted file mode 100644 index f037663c..00000000 Binary files a/storage/temp/dropzone/1628700551.jpg and /dev/null differ diff --git a/storage/temp/dropzone/1628702071.jpg b/storage/temp/dropzone/1628702071.jpg deleted file mode 100644 index f037663c..00000000 Binary files a/storage/temp/dropzone/1628702071.jpg and /dev/null differ diff --git a/storage/temp/dropzone/1628702080.jpeg b/storage/temp/dropzone/1628702080.jpeg deleted file mode 100644 index ef1f5a91..00000000 Binary files a/storage/temp/dropzone/1628702080.jpeg and /dev/null differ diff --git a/storage/temp/dropzone/1628702698.jpg b/storage/temp/dropzone/1628702698.jpg deleted file mode 100644 index 2762f174..00000000 Binary files a/storage/temp/dropzone/1628702698.jpg and /dev/null differ diff --git a/storage/temp/dropzone/1628702702.jpeg b/storage/temp/dropzone/1628702702.jpeg deleted file mode 100644 index ef1f5a91..00000000 Binary files a/storage/temp/dropzone/1628702702.jpeg and /dev/null differ diff --git a/storage/temp/dropzone/1628702702.jpg b/storage/temp/dropzone/1628702702.jpg deleted file mode 100644 index f037663c..00000000 Binary files a/storage/temp/dropzone/1628702702.jpg and /dev/null differ diff --git a/storage/temp/dropzone/1628702724.jpeg b/storage/temp/dropzone/1628702724.jpeg deleted file mode 100644 index ef1f5a91..00000000 Binary files a/storage/temp/dropzone/1628702724.jpeg and /dev/null differ diff --git a/storage/temp/dropzone/1628702735.jpeg b/storage/temp/dropzone/1628702735.jpeg deleted file mode 100644 index ef1f5a91..00000000 Binary files a/storage/temp/dropzone/1628702735.jpeg and /dev/null differ diff --git a/storage/temp/dropzone/1628702735.jpg b/storage/temp/dropzone/1628702735.jpg deleted file mode 100644 index f037663c..00000000 Binary files a/storage/temp/dropzone/1628702735.jpg and /dev/null differ diff --git a/storage/temp/dropzone/1628702743.jpg b/storage/temp/dropzone/1628702743.jpg deleted file mode 100644 index f037663c..00000000 Binary files a/storage/temp/dropzone/1628702743.jpg and /dev/null differ diff --git a/storage/temp/dropzone/1628702907.jpeg b/storage/temp/dropzone/1628702907.jpeg deleted file mode 100644 index ef1f5a91..00000000 Binary files a/storage/temp/dropzone/1628702907.jpeg and /dev/null differ diff --git a/storage/temp/dropzone/1628702908.jpg b/storage/temp/dropzone/1628702908.jpg deleted file mode 100644 index f037663c..00000000 Binary files a/storage/temp/dropzone/1628702908.jpg and /dev/null differ diff --git a/storage/temp/dropzone/1628702914.jpg b/storage/temp/dropzone/1628702914.jpg deleted file mode 100644 index f037663c..00000000 Binary files a/storage/temp/dropzone/1628702914.jpg and /dev/null differ diff --git a/storage/temp/dropzone/1628702980.jpg b/storage/temp/dropzone/1628702980.jpg deleted file mode 100644 index f037663c..00000000 Binary files a/storage/temp/dropzone/1628702980.jpg and /dev/null differ