restaurant changes
This commit is contained in:
0
Modules/PurchaseEntry/app/Http/Controllers/.gitkeep
Normal file
0
Modules/PurchaseEntry/app/Http/Controllers/.gitkeep
Normal file
@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PurchaseEntry\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Admin\Repositories\FieldInterface;
|
||||
use Modules\Supplier\Repositories\SupplierInterface;
|
||||
use Modules\Ingredient\Repositories\IngredientCategoryInterface;
|
||||
use Modules\Ingredient\Repositories\IngredientInterface;
|
||||
use Modules\Ingredient\Repositories\UnitInterface;
|
||||
use Modules\PurchaseEntry\Models\PurchaseEntry;
|
||||
use Modules\PurchaseEntry\Repositories\PurchaseEntryInterface;
|
||||
use Modules\Stock\Repositories\StockInterface;
|
||||
|
||||
class PurchaseEntryController extends Controller
|
||||
{
|
||||
|
||||
private $ingredientRepository;
|
||||
private $supplierRepository;
|
||||
private $purchaseEntryRepository;
|
||||
private $ingredientCategoryRepository;
|
||||
private $stockRepository;
|
||||
private $unitRepository;
|
||||
private $fieldRepository;
|
||||
|
||||
public function __construct( IngredientInterface $ingredientRepository,
|
||||
SupplierInterface $supplierRepository,
|
||||
PurchaseEntryInterface $purchaseEntryRepository,
|
||||
IngredientCategoryInterface $ingredientCategoryRepository,
|
||||
StockInterface $stockRepository,
|
||||
FieldInterface $fieldRepository,
|
||||
UnitInterface $unitRepository)
|
||||
{
|
||||
$this->ingredientRepository = $ingredientRepository;
|
||||
$this->unitRepository = $unitRepository;
|
||||
$this->supplierRepository = $supplierRepository;
|
||||
$this->purchaseEntryRepository = $purchaseEntryRepository;
|
||||
$this->ingredientCategoryRepository = $ingredientCategoryRepository;
|
||||
$this->stockRepository = $stockRepository;
|
||||
$this->fieldRepository = $fieldRepository;
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$filters = $request->all();
|
||||
$data['title'] = 'Purchase Entries';
|
||||
$data['stockList'] = $this->stockRepository->pluck();
|
||||
$data['ingredientList'] = $this->ingredientRepository->pluck();
|
||||
$data['ingredientCategoryList'] = $this->ingredientCategoryRepository->pluck();
|
||||
$data['purchaseEntries'] = $this->purchaseEntryRepository->findAll($filters);
|
||||
return view('purchaseEntry::purchaseEntry.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'New Purchase Entry';
|
||||
$data['stockList'] = $this->stockRepository->pluck();
|
||||
$data['unitList'] = $this->unitRepository->pluck();
|
||||
$data['ingredientList'] = $this->ingredientRepository->pluck();
|
||||
$data['ingredientCategoryList'] = $this->ingredientCategoryRepository->pluck();
|
||||
$data['supplierList'] = $this->supplierRepository->pluck();
|
||||
$data['sizes'] = $this->fieldRepository->getDropdownByAlias('size');
|
||||
$data['paymentModes'] = $this->fieldRepository->getDropdownByAlias('payment-mode');
|
||||
$data['editable'] = false;
|
||||
|
||||
return view('purchaseEntry::purchaseEntry.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->purchaseEntryRepository->create($request);
|
||||
|
||||
return redirect()->route('purchaseEntry.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('purchaseEntry::purchaseEntry.show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['supplierList'] = $this->supplierRepository->pluck();
|
||||
$data['ingredientCategoryList'] = $this->ingredientCategoryRepository->pluck();
|
||||
$data['stockList'] = $this->stockRepository->pluck();
|
||||
$data['unitList'] = $this->unitRepository->pluck();
|
||||
$data['ingredientList'] = $this->ingredientRepository->pluck();
|
||||
$data['sizes'] = $this->fieldRepository->getDropdownByAlias('size');
|
||||
$data['paymentModes'] = $this->fieldRepository->getDropdownByAlias('payment-mode');
|
||||
$data['order'] = PurchaseEntry::with('orderDetails')->find($id);
|
||||
$data['id'] = $id;
|
||||
$data['editable'] = true;
|
||||
$data['title'] = "Edit Purchase Entry";
|
||||
return view('purchaseEntry::purchaseEntry.edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$this->purchaseEntryRepository->update($id,$request);
|
||||
return redirect()->route('purchaseEntry.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
return $this->purchaseEntryRepository->delete($id);
|
||||
}
|
||||
|
||||
public function clonePurchaseIngredient(Request $request)
|
||||
{
|
||||
$data = [];
|
||||
$numInc = $request->numberInc;
|
||||
$script = true;
|
||||
$ingredientList= $this->ingredientRepository->pluck('id');
|
||||
$stockList= $this->stockRepository->pluck('id');
|
||||
$ingredientCategoryList= $this->ingredientCategoryRepository->pluck('id');
|
||||
$sizes = $this->fieldRepository->getDropdownByAlias('size');
|
||||
$paymentModes = $this->fieldRepository->getDropdownByAlias('payment-mode');
|
||||
|
||||
return response()->json([
|
||||
'view' => view('purchaseEntry::purchaseEntry.clone-product', compact('data', 'numInc', 'script', 'ingredientList', 'ingredientCategoryList', 'stockList', 'sizes', 'paymentModes'))->render(),
|
||||
]);
|
||||
}
|
||||
public function clonePurchaseProduct(Request $request)
|
||||
{
|
||||
$data = [];
|
||||
$numInc = $request->numberInc;
|
||||
$script = true;
|
||||
$ingredientList= $this->ingredientRepository->pluck('id');
|
||||
$stockList= $this->stockRepository->pluck('id');
|
||||
$unitList = $this->unitRepository->pluck('id');
|
||||
$ingredientCategoryList= $this->ingredientCategoryRepository->pluck('id');
|
||||
$sizes = $this->fieldRepository->getDropdownByAlias('size');
|
||||
$paymentModes = $this->fieldRepository->getDropdownByAlias('payment-mode');
|
||||
|
||||
return response()->json([
|
||||
'view' => view('purchaseEntry::purchaseEntry.clone-ingredient', compact('data', 'numInc', 'script', 'ingredientList', 'ingredientCategoryList', 'stockList', 'unitList', 'sizes', 'paymentModes'))->render(),
|
||||
]);
|
||||
}
|
||||
}
|
0
Modules/PurchaseEntry/app/Http/Requests/.gitkeep
Normal file
0
Modules/PurchaseEntry/app/Http/Requests/.gitkeep
Normal file
0
Modules/PurchaseEntry/app/Models/.gitkeep
Normal file
0
Modules/PurchaseEntry/app/Models/.gitkeep
Normal file
42
Modules/PurchaseEntry/app/Models/PurchaseEntry.php
Normal file
42
Modules/PurchaseEntry/app/Models/PurchaseEntry.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PurchaseEntry\Models;
|
||||
|
||||
use App\Traits\StatusTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Modules\Customer\Models\Customer;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Modules\PurchaseEntry\Models\PurchaseEntryDetail;
|
||||
use Modules\Supplier\Models\Supplier;
|
||||
|
||||
class PurchaseEntry extends Model
|
||||
{
|
||||
USE StatusTrait;
|
||||
|
||||
protected $table = 'tbl_purchaseentries';
|
||||
protected $fillable = [
|
||||
'supplier_id',
|
||||
'purchase_date',
|
||||
'payment',
|
||||
'paymentmode_id',
|
||||
'paymentref',
|
||||
'total_amt',
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
|
||||
public function purchaseEntryDetails():HasMany{
|
||||
return $this->hasMany(PurchaseEntryDetail::class,'purchaseentry_id');
|
||||
}
|
||||
|
||||
public function supplier():BelongsTo{
|
||||
return $this->belongsTo(Supplier::class);
|
||||
}
|
||||
|
||||
public static function getFillableField(){
|
||||
return (new self())->fillable;
|
||||
}
|
||||
}
|
39
Modules/PurchaseEntry/app/Models/PurchaseEntryDetail.php
Normal file
39
Modules/PurchaseEntry/app/Models/PurchaseEntryDetail.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PurchaseEntry\Models;
|
||||
|
||||
use App\Traits\StatusTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Modules\PurchaseEntry\Models\PurchaseEntry;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Modules\Supplier\Models\Supplier;
|
||||
|
||||
|
||||
class PurchaseEntryDetail extends Model
|
||||
{
|
||||
USE StatusTrait;
|
||||
|
||||
protected $table = 'tbl_purchaseentrydetails';
|
||||
protected $fillable = [
|
||||
'purchaseentry_id',
|
||||
'product_id',
|
||||
'category_id',
|
||||
'stock_id',
|
||||
'size_id',
|
||||
'unit',
|
||||
'price',
|
||||
'rate',
|
||||
'quantity',
|
||||
'amount',
|
||||
'desc',
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
|
||||
public function order(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PurchaseEntry::class);
|
||||
}
|
||||
}
|
0
Modules/PurchaseEntry/app/Observers/.gitkeep
Normal file
0
Modules/PurchaseEntry/app/Observers/.gitkeep
Normal file
0
Modules/PurchaseEntry/app/Providers/.gitkeep
Normal file
0
Modules/PurchaseEntry/app/Providers/.gitkeep
Normal file
32
Modules/PurchaseEntry/app/Providers/EventServiceProvider.php
Normal file
32
Modules/PurchaseEntry/app/Providers/EventServiceProvider.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PurchaseEntry\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event handler mappings for the application.
|
||||
*
|
||||
* @var array<string, array<int, string>>
|
||||
*/
|
||||
protected $listen = [];
|
||||
|
||||
/**
|
||||
* Indicates if events should be discovered.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected static $shouldDiscoverEvents = true;
|
||||
|
||||
/**
|
||||
* Configure the proper event listeners for email verification.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function configureEmailVerification(): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PurchaseEntry\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Ingredient\Repositories\IngredientCategoryInterface;
|
||||
use Modules\Ingredient\Repositories\IngredientCategoryRepository;
|
||||
use Modules\Ingredient\Repositories\IngredientInterface;
|
||||
use Modules\Ingredient\Repositories\IngredientRepository;
|
||||
use Modules\Ingredient\Repositories\UnitInterface;
|
||||
use Modules\Ingredient\Repositories\UnitRepository;
|
||||
use Modules\PurchaseEntry\Repositories\PurchaseEntryInterface;
|
||||
use Modules\PurchaseEntry\Repositories\PurchaseEntryRepository;
|
||||
|
||||
class PurchaseEntryServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected string $moduleName = 'PurchaseEntry';
|
||||
|
||||
protected string $moduleNameLower = 'purchaseEntry';
|
||||
|
||||
/**
|
||||
* 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(EventServiceProvider::class);
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
$this->app->bind(PurchaseEntryInterface::class, PurchaseEntryRepository::class);
|
||||
$this->app->bind(IngredientInterface::class, IngredientRepository::class);
|
||||
$this->app->bind(UnitInterface::class, UnitRepository::class);
|
||||
$this->app->bind(IngredientCategoryInterface::class, IngredientCategoryRepository::class);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register commands in the format of Command::class
|
||||
*/
|
||||
protected function registerCommands(): void
|
||||
{
|
||||
// $this->commands([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register command Schedules.
|
||||
*/
|
||||
protected function registerCommandSchedules(): void
|
||||
{
|
||||
// $this->app->booted(function () {
|
||||
// $schedule = $this->app->make(Schedule::class);
|
||||
// $schedule->command('inspire')->hourly();
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', '')));
|
||||
Blade::componentNamespace($componentNamespace, $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
49
Modules/PurchaseEntry/app/Providers/RouteServiceProvider.php
Normal file
49
Modules/PurchaseEntry/app/Providers/RouteServiceProvider.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PurchaseEntry\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* 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')->group(module_path('PurchaseEntry', '/routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*/
|
||||
protected function mapApiRoutes(): void
|
||||
{
|
||||
Route::middleware('api')->prefix('api')->name('api.')->group(module_path('PurchaseEntry', '/routes/api.php'));
|
||||
}
|
||||
}
|
0
Modules/PurchaseEntry/app/Repositories/.gitkeep
Normal file
0
Modules/PurchaseEntry/app/Repositories/.gitkeep
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PurchaseEntry\Repositories;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface PurchaseEntryInterface
|
||||
{
|
||||
public function findAll($filters);
|
||||
public function getPurchaseEntryById($PurchaseEntryId);
|
||||
public function getPurchaseEntryByEmail($email);
|
||||
public function delete($PurchaseEntryId);
|
||||
public function create(Request $request);
|
||||
public function update($PurchaseEntryId, Request $request);
|
||||
public function pluck();
|
||||
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PurchaseEntry\Repositories;
|
||||
|
||||
use Flasher\Laravel\Http\Request;
|
||||
use Modules\PurchaseEntry\Models\PurchaseEntry;
|
||||
use Modules\PurchaseEntry\Models\PurchaseEntryDetail;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class PurchaseEntryRepository implements PurchaseEntryInterface
|
||||
{
|
||||
// public function findAll()
|
||||
// {
|
||||
// return PurchaseEntry::when(true, function ($query) {
|
||||
// })->paginate(20);
|
||||
// }
|
||||
public function findAll($filters = [], $limit = null, $offset = null)
|
||||
{
|
||||
return PurchaseEntry::when($filters, function ($query) use ($filters) {
|
||||
|
||||
if (isset($filters["ingredient_category_id"])) {
|
||||
$query->whereHas('purchaseEntryDetails', function ( $query) use ($filters) {
|
||||
$query->where('ingredient_category_id', '=', $filters["ingredient_category_id"]);
|
||||
});
|
||||
}
|
||||
if (isset($filters["ingredient_id"])) {
|
||||
$query->whereHas('purchaseEntryDetails', function ( $query) use ($filters) {
|
||||
$query->where('ingredient_id', '=', $filters["ingredient_id"]);
|
||||
});
|
||||
}
|
||||
// if (isset($filters["stock_id"])) {
|
||||
// $query->whereHas('purchaseEntryDetails', function ( $query) use ($filters) {
|
||||
// $query->where('stock_id', '=', $filters["stock_id"]);
|
||||
// });
|
||||
// }
|
||||
|
||||
if (isset($filters["date"])) {
|
||||
$explodeDate = explode("to", $filters['date']);
|
||||
$query->whereBetween("purchase_date", [$explodeDate[0], preg_replace('/\s+/', '', $explodeDate[1])]);
|
||||
}
|
||||
|
||||
})->get();
|
||||
}
|
||||
|
||||
public function getPurchaseEntryById($PurchaseEntryId)
|
||||
{
|
||||
return PurchaseEntry::findOrFail($PurchaseEntryId);
|
||||
}
|
||||
|
||||
public function getPurchaseEntryByEmail($email)
|
||||
{
|
||||
return PurchaseEntry::where('email', $email)->first();
|
||||
}
|
||||
|
||||
public function delete($PurchaseEntryId)
|
||||
{
|
||||
DB::transaction(function() use ($PurchaseEntryId) {
|
||||
PurchaseEntryDetail::where('purchaseentry_id', $PurchaseEntryId)->delete();
|
||||
|
||||
PurchaseEntry::destroy($PurchaseEntryId);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function create($request)
|
||||
{
|
||||
$purchaseEntryDetails = $request->except(PurchaseEntry::getFillableField());
|
||||
|
||||
$purchaseEntry = $request->only(PurchaseEntry::getFillableField());
|
||||
$purchaseEntryData = PurchaseEntry::create($purchaseEntry);
|
||||
|
||||
$request->merge(['purchaseentry_id' => $purchaseEntryData->id]);
|
||||
|
||||
foreach ($purchaseEntryDetails['ingredient_id'] as $key => $ingredientId) {
|
||||
// dd($request->input('purchaseentry_id'));
|
||||
$data = [
|
||||
'purchaseentry_id' => $request->input('purchaseentry_id'),
|
||||
'ingredient_id' => $purchaseEntryDetails['ingredient_id'][$key],
|
||||
'ingredient_category_id' => $purchaseEntryDetails['ingredient_category_id'][$key],
|
||||
// 'stock_id' => $purchaseEntryDetails['stock_id'][$key],
|
||||
// 'size_id' => $purchaseEntryDetails['size_id'][$key],
|
||||
'rate' => $purchaseEntryDetails['price'][$key],
|
||||
'unit_id' => $purchaseEntryDetails['unit_id'][$key],
|
||||
'quantity' => $purchaseEntryDetails['qty'][$key],
|
||||
'amount' => $purchaseEntryDetails['amt'][$key],
|
||||
'desc' => $purchaseEntryDetails['desc'][$key],
|
||||
];
|
||||
PurchaseEntryDetail::create($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function update($PurchaseEntryId, $request)
|
||||
{
|
||||
$fillableFields = PurchaseEntry::getFillableField();
|
||||
$purchaseEntryData = $request->only($fillableFields);
|
||||
|
||||
$purchaseEntry = PurchaseEntry::find($PurchaseEntryId);
|
||||
$purchaseEntry->update($purchaseEntryData);
|
||||
|
||||
|
||||
$additionalExcludes = ['_method', '_token'];
|
||||
$excludeFields = array_merge($fillableFields, $additionalExcludes);
|
||||
|
||||
$data = $request->except($excludeFields);
|
||||
|
||||
$updatedCombinations = [];
|
||||
|
||||
if (isset($data['product_id'])) {
|
||||
foreach ($data['product_id'] as $key => $productId) {
|
||||
$obj = [
|
||||
'purchaseentry_id' => $PurchaseEntryId,
|
||||
'product_id' => $productId,
|
||||
'unit' => $data['unit'][$key],
|
||||
'rate' => $data['rate'][$key],
|
||||
'quantity' => $data['qty'][$key],
|
||||
'amount' => $data['amt'][$key],
|
||||
'desc' => $data['desc'][$key],
|
||||
];
|
||||
|
||||
$combinationKey = "{$PurchaseEntryId}_{$productId}_{$data['unit'][$key]}";
|
||||
|
||||
$purchaseEntryDetail = $purchaseEntry->purchaseEntryDetails()->where('product_id', $productId)->where('unit', $data['unit'][$key])->first();
|
||||
if ($purchaseEntryDetail) {
|
||||
$purchaseEntryDetail->update($obj);
|
||||
} else {
|
||||
PurchaseEntryDetail::create($obj);
|
||||
}
|
||||
|
||||
$updatedCombinations[] = $combinationKey;
|
||||
}
|
||||
}
|
||||
|
||||
$purchaseEntry->purchaseEntryDetails()->each(function ($purchaseEntryDetail) use ($updatedCombinations) {
|
||||
$combinationKey = "{$purchaseEntryDetail->purchaseEntry_id}_{$purchaseEntryDetail->product_id}_{$purchaseEntryDetail->unit}";
|
||||
if (!in_array($combinationKey, $updatedCombinations)) {
|
||||
$purchaseEntryDetail->delete();
|
||||
}
|
||||
});
|
||||
|
||||
return $purchaseEntry;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function pluck()
|
||||
{
|
||||
return PurchaseEntry::pluck('name', 'id');
|
||||
}
|
||||
}
|
30
Modules/PurchaseEntry/composer.json
Normal file
30
Modules/PurchaseEntry/composer.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "nwidart/purchaseentry",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Widart",
|
||||
"email": "n.widart@gmail.com"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\PurchaseEntry\\": "app/",
|
||||
"Modules\\PurchaseEntry\\Database\\Factories\\": "database/factories/",
|
||||
"Modules\\PurchaseEntry\\Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Modules\\PurchaseEntry\\Tests\\": "tests/"
|
||||
}
|
||||
}
|
||||
}
|
0
Modules/PurchaseEntry/config/.gitkeep
Normal file
0
Modules/PurchaseEntry/config/.gitkeep
Normal file
5
Modules/PurchaseEntry/config/config.php
Normal file
5
Modules/PurchaseEntry/config/config.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'PurchaseEntry',
|
||||
];
|
0
Modules/PurchaseEntry/database/factories/.gitkeep
Normal file
0
Modules/PurchaseEntry/database/factories/.gitkeep
Normal file
0
Modules/PurchaseEntry/database/migrations/.gitkeep
Normal file
0
Modules/PurchaseEntry/database/migrations/.gitkeep
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('tbl_purchaseentries', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->date('purchase_date')->nullable();
|
||||
$table->unsignedBigInteger('supplier_id')->nullable();
|
||||
$table->string('payment')->nullable();
|
||||
$table->unsignedBigInteger('paymentmode_id')->nullable();
|
||||
$table->string('paymentref')->nullable();
|
||||
$table->decimal('total_amt', 10, 2)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('tbl_purchaseentries');
|
||||
}
|
||||
};
|
||||
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('tbl_purchaseentrydetails', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('purchaseentry_id')->nullable();
|
||||
$table->unsignedBigInteger('ingredient_id')->nullable();
|
||||
$table->unsignedBigInteger('ingredient_category_id')->nullable();
|
||||
$table->unsignedBigInteger('unit_id')->nullable();
|
||||
$table->unsignedBigInteger('stock_id')->nullable();
|
||||
$table->integer('rate')->nullable();
|
||||
$table->integer('quantity')->nullable();
|
||||
$table->decimal('amount', 6);
|
||||
$table->text('desc')->nullable();
|
||||
$table->integer('status')->nullable();
|
||||
$table->text('remarks')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('tbl_purchaseentrydetails');
|
||||
}
|
||||
};
|
||||
|
0
Modules/PurchaseEntry/database/seeders/.gitkeep
Normal file
0
Modules/PurchaseEntry/database/seeders/.gitkeep
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PurchaseEntry\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class PurchaseEntryDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// $this->call([]);
|
||||
}
|
||||
}
|
11
Modules/PurchaseEntry/module.json
Normal file
11
Modules/PurchaseEntry/module.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "PurchaseEntry",
|
||||
"alias": "purchaseentry",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\PurchaseEntry\\Providers\\PurchaseEntryServiceProvider"
|
||||
],
|
||||
"files": []
|
||||
}
|
15
Modules/PurchaseEntry/package.json
Normal file
15
Modules/PurchaseEntry/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/PurchaseEntry/resources/assets/.gitkeep
Normal file
0
Modules/PurchaseEntry/resources/assets/.gitkeep
Normal file
0
Modules/PurchaseEntry/resources/assets/js/app.js
Normal file
0
Modules/PurchaseEntry/resources/assets/js/app.js
Normal file
0
Modules/PurchaseEntry/resources/views/.gitkeep
Normal file
0
Modules/PurchaseEntry/resources/views/.gitkeep
Normal file
7
Modules/PurchaseEntry/resources/views/index.blade.php
Normal file
7
Modules/PurchaseEntry/resources/views/index.blade.php
Normal file
@ -0,0 +1,7 @@
|
||||
@extends('purchaseentry::layouts.master')
|
||||
|
||||
@section('content')
|
||||
<h1>Hello World</h1>
|
||||
|
||||
<p>Module: {!! config('purchaseentry.name') !!}</p>
|
||||
@endsection
|
@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
|
||||
<title>PurchaseEntry Module - {{ config('app.name', 'Laravel') }}</title>
|
||||
|
||||
<meta name="description" content="{{ $description ?? '' }}">
|
||||
<meta name="keywords" content="{{ $keywords ?? '' }}">
|
||||
<meta name="author" content="{{ $author ?? '' }}">
|
||||
|
||||
<!-- Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.bunny.net">
|
||||
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
|
||||
|
||||
{{-- Vite CSS --}}
|
||||
{{-- {{ module_vite('build-purchaseentry', 'resources/assets/sass/app.scss') }} --}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@yield('content')
|
||||
|
||||
{{-- Vite JS --}}
|
||||
{{-- {{ module_vite('build-purchaseentry', 'resources/assets/js/app.js') }} --}}
|
||||
</body>
|
@ -0,0 +1,76 @@
|
||||
<div class="card card-body ingredient-card card-border-secondary mb-2 border">
|
||||
<div class="row gy-2 mb-2">
|
||||
<div class="col-md-2">
|
||||
{{ html()->label('Category')->class('form-label') }}
|
||||
@if (isset($editable) && $editable)
|
||||
{{ html()->select('ingredient_category_id[]', $ingredientCategoryList, $item->ingredient_category_id)->class('form-select ingredient_category_id')->attributes(['id' => 'ingredient_category_id'])->placeholder('Enter Category')->required() }}
|
||||
@else
|
||||
{{ html()->select('ingredient_category_id[]', $ingredientCategoryList)->class('form-select ingredient_category_id')->attributes(['id' => 'ingredient_category_id'])->placeholder('Enter Category')->required() }}
|
||||
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
{{ html()->label('Ingredient')->class('form-label') }}
|
||||
@if (isset($editable) && $editable)
|
||||
{{ html()->select('ingredient_id[]', $ingredientList, $item->ingredient_id)->class('form-select ingredient_id')->attributes(['id' => 'ingredient_id'])->placeholder('')->required() }}
|
||||
@else
|
||||
{{ html()->select('ingredient_id[]', [], null)->class('form-select ingredient_id')->attributes(['id' => 'ingredient_id'])->placeholder('')->required()->disabled() }}
|
||||
|
||||
@endif
|
||||
</div>
|
||||
{{-- <div class="col-md-2">
|
||||
{{ html()->label('Stock')->class('form-label') }}
|
||||
@if (isset($editable) && $editable)
|
||||
{{ html()->select('stock_id[]', $stockList, $item->stock_id)->class('form-select stock_id')->attributes(['id' => 'stock_id'])->placeholder('')->required() }}
|
||||
@else
|
||||
{{ html()->select('stock_id[]', $stockList)->class('form-select stock_id')->attributes(['id' => 'stock_id'])->placeholder('')->required()->disabled() }}
|
||||
|
||||
@endif
|
||||
</div> --}}
|
||||
{{-- <div class="col-md-1">
|
||||
{{ html()->label('Size')->class('form-label') }}
|
||||
{{ html()->select('size_id[]', $sizes)->class('form-select ')->placeholder('size') }}
|
||||
</div> --}}
|
||||
|
||||
<div class="col-md-2">
|
||||
{{ html()->label('Price')->class('form-label') }}
|
||||
{{ html()->text('price[]', isset($editable) && $editable ? $item->price : null)->class('form-control ingredient-price cleave-numeral rate~~')->placeholder('Price')->attributes(['id' => 'rate', 'onkeyup' => 'validatePriceInput(this)']) }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
{{ html()->label('Unit')->class('form-label') }}
|
||||
@if (isset($editable) && $editable)
|
||||
{{ html()->select('unit_id[]', $unitList, $item->unit_id)->class('form-select unit_id')->attributes(['id' => 'unit_id'])->placeholder('')->required() }}
|
||||
@else
|
||||
{{ html()->select('unit_id[]', $unitList)->class('form-select unit_id')->attributes(['id' => 'unit_id'])->placeholder('')->required() }}
|
||||
|
||||
@endif
|
||||
</div>
|
||||
|
||||
{{-- <div class="col-md-2">
|
||||
{{ html()->label('Unit')->class('form-label') }}
|
||||
{{ html()->text('unit[]', isset($editable) && $editable ? $item->unit : null)->class('form-control ingredient-unit cleave-numeral rate~~')->placeholder('Enter Unit')->required()}}
|
||||
</div> --}}
|
||||
|
||||
<div class="col-md-1">
|
||||
{{ html()->label('Quantity')->class('form-label') }}
|
||||
{{ html()->text('qty[]', isset($editable) && $editable ? $item->quantity : null)->class('form-control ingredient-quantity cleave-numeral qty')->placeholder('QTY')->attributes(['id' => 'qty', 'onkeyup' => 'validateNumericInput(this)']) }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
{{ html()->label('Amount')->class('form-label') }}
|
||||
{{ html()->text('amt[]', isset($editable) && $editable ? $item->amount : null)->class('form-control ingredient-line-price bg-light')->placeholder('Enter Amount')->isReadOnly() }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{{ html()->label('Description')->class('form-label') }}
|
||||
{{ html()->text('desc[]', isset($editable) && $editable ? $item->desc : null)->class('form-control')->placeholder('Enter Description') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-6 d-flex justify-content-end align-items-end">
|
||||
<button type="button" class="btn btn-danger btn-icon waves-effect btn-remove waves-light"><i
|
||||
class="ri-delete-bin-5-line"></i></button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,27 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
<!-- start page title -->
|
||||
@include('layouts.partials.breadcrumb', ['title' => $title])
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form action="{{ route('purchaseEntry.store') }}" class="needs-validation" novalidate method="post">
|
||||
@csrf
|
||||
@include('purchaseEntry::purchaseEntry.partials.action')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('js')
|
||||
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
|
||||
@endpush
|
@ -0,0 +1,47 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box d-sm-flex align-items-center justify-content-between">
|
||||
<h4 class="mb-sm-0">{{ $title }}</h4>
|
||||
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="javascript: void(0);">Dashboards</a></li>
|
||||
<li class="breadcrumb-item active">{{ $title }}</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
{{ html()->modelForm($order, 'PUT')->route('order.update', $id)->class(['needs-validation'])->attributes(['novalidate'])->open() }}
|
||||
|
||||
@include('order::order.partials.action')
|
||||
|
||||
{{ html()->closeModelForm() }}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--end row-->
|
||||
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('js')
|
||||
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
|
||||
@endpush
|
@ -0,0 +1,71 @@
|
||||
@extends('layouts.app')
|
||||
@section('content')
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
@include('purchaseEntry::purchaseEntry.partials.menu')
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-header align-items-center d-flex">
|
||||
<h5 class="card-title flex-grow-1 mb-0">{{ $title }}</h5>
|
||||
<div class="flex-shrink-0">
|
||||
<a href="{{ route('purchaseEntry.create') }}" class="btn btn-success waves-effect waves-light"><i
|
||||
class="ri-add-fill me-1 align-bottom"></i> Add</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table id="buttons-datatables" class="display table-sm table-bordered table"
|
||||
style="width:100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>S.N</th>
|
||||
<th>Supplier</th>
|
||||
<th>Purchase Date</th>
|
||||
<th>Total Amount</th>
|
||||
{{-- <th>Action</th> --}}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($purchaseEntries as $key => $item)
|
||||
{{-- @dd($item) --}}
|
||||
<tr>
|
||||
<td>{{ $key + 1 }}</td>
|
||||
<td>{{ $item->supplier->supplier_name }}</td>
|
||||
<td>{{ $item->purchase_date }}</td>
|
||||
<td>{{ $item->total_amt }}</td>
|
||||
{{-- <td>
|
||||
<div class="hstack flex-wrap gap-3">
|
||||
<a href="javascript:void(0);" class="link-info fs-15 view-item-btn"
|
||||
data-bs-toggle="modal" data-bs-target="#viewModal" data-link="{{ route('purchaseEntry.show', $item->id) }}">
|
||||
|
||||
<i class="ri-eye-line"></i>
|
||||
</a>
|
||||
<a href="{{ route('purchaseEntry.edit', $item->id) }}"
|
||||
class="link-success fs-15 edit-item-btn"><i
|
||||
class="ri-edit-2-line"></i></a>
|
||||
|
||||
<a href="javascript:void(0);"
|
||||
data-link="{{ route('purchaseEntry.destroy', $item->id) }}"
|
||||
data-id="{{ $item->id }}"
|
||||
class="link-danger fs-15 remove-item-btn"><i
|
||||
class="ri-delete-bin-line"></i></a>
|
||||
|
||||
</div>
|
||||
</td> --}}
|
||||
</tr>
|
||||
@empty
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--end row-->
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
@ -0,0 +1,271 @@
|
||||
<div class="row gy-1">
|
||||
<h5 class="text-primary text-center">Order Details</h5>
|
||||
<div class="border border-dashed"></div>
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Purchase Date')->class('form-label') }}
|
||||
{{ html()->date('purchase_date')->class('form-control')->placeholder('Choose Purchase Date')->required() }}
|
||||
{{ html()->div('Please choose Purchase date')->class('invalid-feedback') }}
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
{{ html()->label('Supplier')->class('form-label') }}
|
||||
{{ html()->select('supplier_id', $supplierList)->class('form-control')->placeholder('Select Supplier')->required() }}
|
||||
{{ html()->div('Please select supplier')->class('invalid-feedback') }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{{-- <div class="row mt-2">
|
||||
<p class="text-primary">Shipping Details</p>
|
||||
<div class="border border-dashed"></div>
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Address')->class('form-label') }}
|
||||
{{ html()->text('address')->class('form-control')->placeholder('Enter Address') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Shipping Date')->class('form-label') }}
|
||||
{{ html()->date('shiiping_date')->class('form-control')->placeholder('Enter Temporary Address') }}
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
<div class="row gy-1 gx-2 mt-1">
|
||||
<div class="d-flex justify-content-end">
|
||||
<button type="button" class="btn btn-info btn-icon add-btn text-end"><i class="ri-add-line"></i></button>
|
||||
</div>
|
||||
@if ($editable && $purchaseEntry->purchaseEntryDetail->isNotEmpty())
|
||||
@foreach ($purchaseEntry->purchaseEntryDetail as $item)
|
||||
@include('purchaseEntry::purchaseEntry.clone-ingredient')
|
||||
@endforeach
|
||||
@else
|
||||
@include('purchaseEntry::purchaseEntry.clone-ingredient')
|
||||
@endif
|
||||
<div class="appendProductCard"></div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end w-30 mb-2">
|
||||
<table class="table-borderless align-middle">
|
||||
<tbody>
|
||||
{{-- <tr>
|
||||
<th scope="row">Sub Total</th>
|
||||
<td style="width:150px;">
|
||||
<input type="text" name="sub_total" class="form-control bg-light border-0" id="subtotal"
|
||||
placeholder="$0.00" readonly="">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Estimated Tax (11%)</th>
|
||||
<td>
|
||||
<input type="text" name="tax" class="form-control bg-light border-0" id="tax"
|
||||
placeholder="$0.00" readonly="">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Discount</th>
|
||||
<td>
|
||||
<input type="text" name="discount_amt" class="form-control bg-light border-0" id="discount"
|
||||
placeholder="$0.00" readonly="">
|
||||
</td>
|
||||
</tr> --}}
|
||||
<tr class="border-top border-top-dashed">
|
||||
<th scope="row">Total Amount</th>
|
||||
<td>
|
||||
<input type="text" name="total_amt" class="form-control bg-light border-0" id="total"
|
||||
placeholder="$0.00" readonly="">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row gy-1 my-2 mb-4">
|
||||
<h5 class="text-primary text-center">Payment Details</h5>
|
||||
<div class="border border-dashed"></div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Payment')->class('form-label') }}
|
||||
{{ html()->text('payment')->class('form-control')->placeholder('Enter Payment') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Mode of Payment')->class('form-label') }}
|
||||
{{ html()->select('paymentmode_id', $paymentModes)->class('form-select select2')->placeholder('Select Payment Mode') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Payment Reference')->class('form-label') }}
|
||||
{{ html()->text('paymentref')->class('form-control')->placeholder('Enter Payment Reference') }}
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mb-4 mt-4 text-end">
|
||||
<button type="submit" class="btn btn-success w-sm">Save</button>
|
||||
</div>
|
||||
|
||||
|
||||
@push('js')
|
||||
<script src="{{ asset('assets/libs/cleave.js/cleave.min.js') }}"></script>
|
||||
<script src="{{ asset('assets/js/pages/form-masks.init.js') }}"></script>
|
||||
|
||||
<script>
|
||||
$("body").on('click', '.add-btn', function(e) {
|
||||
e.preventDefault();
|
||||
numberInc = $('.ingredient-card').length
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '{{ route('purchaseEntry.clonePurchaseProduct') }}',
|
||||
data: {
|
||||
numberInc: numberInc
|
||||
},
|
||||
success: function(response) {
|
||||
$('.appendProductCard').append(response.view)
|
||||
// $('#purchaseEntry-container').html(response.view).fadeIn()
|
||||
},
|
||||
error: function(xhr) {
|
||||
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
$("body").on('click', '.btn-remove', function() {0
|
||||
if ($('.ingredient-card').length > 1) {
|
||||
$(this).parents(".ingredient-card").remove();
|
||||
}
|
||||
recalculate();
|
||||
});
|
||||
|
||||
$(window).on('load', function() {
|
||||
recalculate();
|
||||
})
|
||||
|
||||
function validateNumericInput(input) {
|
||||
// Allow only numbers and remove any non-numeric input
|
||||
input.value = input.value.replace(/[^0-9]/g, '');
|
||||
}
|
||||
|
||||
|
||||
function amountKeyup() {
|
||||
$("body").on('keyup', '.ingredient-price', function() {
|
||||
var priceInput = $(this);
|
||||
var qtyInput = priceInput.closest(".row").find(".ingredient-quantity");
|
||||
var linePrice = priceInput.closest(".row").find(".ingredient-line-price");
|
||||
updateQuantity(priceInput.val(), qtyInput.val(), linePrice);
|
||||
});
|
||||
|
||||
$("body").on('keyup', '.ingredient-quantity', function() {
|
||||
var priceInput = $(this);
|
||||
var qtyInput = priceInput.closest(".row").find(".ingredient-price");
|
||||
var linePrice = priceInput.closest(".row").find(".ingredient-line-price");
|
||||
updateQuantity(priceInput.val(), qtyInput.val(), linePrice);
|
||||
});
|
||||
}
|
||||
|
||||
amountKeyup()
|
||||
|
||||
function updateQuantity(rate, qty, linePriceInput) {
|
||||
var amount = (rate * qty).toFixed(2);
|
||||
linePriceInput.val(amount);
|
||||
recalculate();
|
||||
}
|
||||
|
||||
function recalculate() {
|
||||
var subtotal = 0;
|
||||
$(".ingredient-line-price").each(function() {
|
||||
if ($(this).val()) {
|
||||
subtotal += parseFloat($(this).val());
|
||||
}
|
||||
});
|
||||
|
||||
// var tax = subtotal * 0.125;
|
||||
// var discount = subtotal * 0.15;
|
||||
// var shipping = subtotal > 0 ? 65 : 0;
|
||||
// var total = subtotal + tax + shipping - discount;
|
||||
|
||||
// $("#subtotal").val(subtotal.toFixed(2));
|
||||
// $("#tax").val(tax.toFixed(2));
|
||||
// $("#discount").val(discount.toFixed(2));
|
||||
// $("#shipping").val(shipping.toFixed(2));
|
||||
$("#total").val(subtotal.toFixed(2));
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.ingredient_id').prop('disabled', true);
|
||||
// $('.stock_id').prop('disabled', true);
|
||||
$('body').on('change', '.ingredient_id', function() {
|
||||
var selectedId = $(this).find(':selected').val();
|
||||
var formRow = $(this).closest('.row');
|
||||
|
||||
if (selectedId) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '{{ route('get-ingredient-detail') }}',
|
||||
data: {
|
||||
id: selectedId
|
||||
},
|
||||
success: function(response) {
|
||||
var qtyInput = formRow.find('#qty').val(response.data.qty);
|
||||
formRow.find('#unit').val(response.data.unit);
|
||||
var priceInput = formRow.find('#rate').val(response.data.price);
|
||||
var linePrice = priceInput.closest(".row").find(".ingredient-line-price");
|
||||
|
||||
|
||||
updateQuantity(priceInput.val(), qtyInput.val(), linePrice);
|
||||
},
|
||||
error: function(xhr) {
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// When category is selected, load ingredients dynamically
|
||||
$('body').on('change', '.ingredient_category_id', function () {
|
||||
var ingredientCategoryId = $(this).val();
|
||||
var formRow = $(this).closest('.row');
|
||||
var ingredientSelect = formRow.find('.ingredient_id');
|
||||
// var stockSelect = formRow.find('.stock_id');
|
||||
|
||||
// Reset stock field
|
||||
|
||||
if (ingredientCategoryId) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '{{ route('ingredients-by-category') }}', // Route to get ingredients by category
|
||||
data: {ingredient_category_id:ingredientCategoryId},
|
||||
success: function (response) {
|
||||
ingredientSelect.empty().append('<option value="">Select Product</option>');
|
||||
ingredientSelect.prop('disabled', false);
|
||||
|
||||
$.each(response.ingredients, function (id, name) {
|
||||
ingredientSelect.append('<option value="' + id + '">' + name + '</option>');
|
||||
});
|
||||
},
|
||||
error: function (xhr) {
|
||||
// Handle error
|
||||
}
|
||||
});
|
||||
// stockSelect.empty().prop('disabled', true);
|
||||
|
||||
} else {
|
||||
ingredientSelect.prop('disabled', true);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function validateNumericInput(input) {
|
||||
// Allow only numbers and remove any non-numeric input
|
||||
input.value = input.value.replace(/[^0-9.]/g, '');
|
||||
input.value = input.value.replace(/(\..*)\./g, '$1');
|
||||
input.value = input.value.replace(/^(\d+)(\.\d{0,2})?.*/, '$1$2');
|
||||
}
|
||||
</script>
|
||||
|
||||
@endpush
|
@ -0,0 +1,74 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row g-2">
|
||||
<div class="col-sm-12">
|
||||
{{ html()->form('GET')->route('purchaseEntry.index')->open() }}
|
||||
<div class="row g-8">
|
||||
{{-- <div class="col-xl-3">
|
||||
<div class="search-box">
|
||||
{{ html()->text('search')->class('form-control search')->value(request('search'))->placeholder('Search...') }}
|
||||
<i class="ri-search-line search-icon"></i>
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
<div class="col-sm-3">
|
||||
<div class="">
|
||||
{{ html()->text('date')->class('form-control')->value(request('date'))->placeholder('Date Range')->attributes([
|
||||
'id' => 'datepicker-range',
|
||||
'data-provider' => 'flatpickr',
|
||||
'data-date-format' => 'Y-m-d',
|
||||
'data-range-date' => 'true',
|
||||
]) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2">
|
||||
<div class="search-box">
|
||||
{{ html()->select('ingredient_category_id', $ingredientCategoryList)->class('form-control select2')->value(request('ingredient_category_id'))->placeholder('By Category') }}
|
||||
</div>
|
||||
</div>
|
||||
{{-- <div class="col-sm-2">
|
||||
<div class="search-box">
|
||||
{{ html()->select('stock_id', $stockList)->class('form-control select2')->value(request('stock_id'))->placeholder('By Stock') }}
|
||||
</div>
|
||||
</div> --}}
|
||||
<div class="col-sm-2">
|
||||
<div class="search-box">
|
||||
{{ html()->select('ingredient_id', $ingredientList)->class('form-control select2')->value(request('ingredient_id'))->placeholder('By Product') }}
|
||||
</div>
|
||||
</div>
|
||||
<!--end col-->
|
||||
{{-- <div class="align-item-right"> --}}
|
||||
<div class="col-sm-1 offset-lg-1">
|
||||
<div>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="ri-equalizer-fill me-2"></i>Filters</button>
|
||||
{{-- <a href="{{ route('task.index') }}" class="btn btn-danger">
|
||||
<i class="ri-bin-fill me-2"></i>Reset</a> --}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-1">
|
||||
<div>
|
||||
<a href="{{ route('purchaseEntry.index') }}" class="btn btn-primary">
|
||||
<i class="ri-loop-right-line me-2"></i>Reset</a>
|
||||
{{-- <a href="{{ route('task.index') }}" class="btn btn-danger">
|
||||
<i class="ri-bin-fill me-2"></i>Reset</a> --}}
|
||||
</div>
|
||||
</div>
|
||||
{{-- </div> --}}
|
||||
<!--end col-->
|
||||
</div>
|
||||
<!--end row-->
|
||||
{{ html()->form()->close() }}
|
||||
|
||||
</div>
|
||||
<!--end col-->
|
||||
|
||||
</div>
|
||||
<!--end row-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
</script>
|
0
Modules/PurchaseEntry/routes/.gitkeep
Normal file
0
Modules/PurchaseEntry/routes/.gitkeep
Normal file
19
Modules/PurchaseEntry/routes/api.php
Normal file
19
Modules/PurchaseEntry/routes/api.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\PurchaseEntry\Http\Controllers\PurchaseEntryController;
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------------------
|
||||
* 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')->group(function () {
|
||||
Route::apiResource('purchaseentry', PurchaseEntryController::class)->names('purchaseentry');
|
||||
});
|
20
Modules/PurchaseEntry/routes/web.php
Normal file
20
Modules/PurchaseEntry/routes/web.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\PurchaseEntry\Http\Controllers\PurchaseEntryController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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([], function () {
|
||||
Route::resource('purchaseEntry', PurchaseEntryController::class)->names('purchaseEntry');
|
||||
Route::get('clone-purchase-product', [PurchaseEntryController::class, 'clonePurchaseProduct'])->name('purchaseEntry.clonePurchaseProduct');
|
||||
});
|
26
Modules/PurchaseEntry/vite.config.js
Normal file
26
Modules/PurchaseEntry/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-purchaseentry',
|
||||
emptyOutDir: true,
|
||||
manifest: true,
|
||||
},
|
||||
plugins: [
|
||||
laravel({
|
||||
publicDirectory: '../../public',
|
||||
buildDirectory: 'build-purchaseentry',
|
||||
input: [
|
||||
__dirname + '/resources/assets/sass/app.scss',
|
||||
__dirname + '/resources/assets/js/app.js'
|
||||
],
|
||||
refresh: true,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
//export const paths = [
|
||||
// 'Modules/PurchaseEntry/resources/assets/sass/app.scss',
|
||||
// 'Modules/PurchaseEntry/resources/assets/js/app.js',
|
||||
//];
|
Reference in New Issue
Block a user