chore: update document approval workflow and bug fixes
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\MaterialLogistics\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Modules\MaterialLogistics\Models\InventoryMovement;
|
||||
use Modules\MaterialLogistics\Models\Warehouse;
|
||||
use Modules\ProjectManagement\Models\Project;
|
||||
|
||||
class InventoryMovementController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = InventoryMovement::with([
|
||||
'material:id,ulid,name,sku,unit',
|
||||
'warehouse:id,ulid,name,code',
|
||||
'project:id,ulid,name,code',
|
||||
'task:id,ulid,name',
|
||||
'performer:id,ulid,name',
|
||||
]);
|
||||
|
||||
if ($materialId = $request->material_id) {
|
||||
$query->where('material_id', $materialId);
|
||||
}
|
||||
|
||||
if ($warehouseId = $request->warehouse_id) {
|
||||
$query->where('warehouse_id', $warehouseId);
|
||||
}
|
||||
|
||||
if ($projectId = $request->project_id) {
|
||||
$query->where('project_id', $projectId);
|
||||
}
|
||||
|
||||
if ($type = $request->movement_type) {
|
||||
$query->where('movement_type', $type);
|
||||
}
|
||||
|
||||
if ($from = $request->date_from) {
|
||||
$query->where('created_at', '>=', $from);
|
||||
}
|
||||
|
||||
if ($to = $request->date_to) {
|
||||
$query->where('created_at', '<=', $to . ' 23:59:59');
|
||||
}
|
||||
|
||||
$movements = $query->latest()->paginate(20)->withQueryString();
|
||||
|
||||
$warehouses = Warehouse::select('id', 'ulid', 'name', 'code')->active()->get();
|
||||
$projects = Project::select('id', 'ulid', 'name', 'code')->latest()->get();
|
||||
|
||||
return Inertia::render('MaterialLogistics::Inventory/Movements', [
|
||||
'movements' => $movements,
|
||||
'warehouses' => $warehouses,
|
||||
'projects' => $projects,
|
||||
'filters' => $request->only(['material_id', 'warehouse_id', 'project_id', 'movement_type', 'date_from', 'date_to']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user