/
home
/
sjslayjy
/
public_html
/
ccbfsoution
/
Upload File
HOME
@extends('layouts.app') @section('title', 'Fertilizer Management') @section('content') <style> .btn-add { background-color: #6b8e23; color: white; padding: 8px 12px; border-radius: 6px; font-size: 14px; border: none; } .modal-content { border-radius: 12px; padding: 20px; } table th { background-color: #6b8e23; color: white; } table tbody tr:nth-child(even) { background-color: #f0f4e6; } </style> @if(session('success')) <div class="alert alert-success alert-dismissible fade show mt-3" role="alert"> {{ session('success') }} <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> </div> @endif <div class="d-flex justify-content-between align-items-center mt-4"> <button class="btn-add" data-bs-toggle="modal" data-bs-target="#addFertilizerModal">Add Fertilizer</button> <form method="GET" action="{{ route('fertilizer.index') }}" class="input-group shadow-sm rounded-pill w-25"> <input type="text" name="search" class="form-control border-0" placeholder="Search..." value="{{ request('search') }}"> <button class="btn btn-light border-0" type="submit"> <i class="fas fa-search text-secondary"></i> </button> </form> </div> <div class="table-responsive mt-3"> <table class="table table-bordered text-center"> <thead> <tr> <th>Sr.No.</th> <th>Fertilizer Name</th> <th>Fertilizer Type</th> <th>Brand Name</th> <th>Current Stock (kg)</th> <th>Purchase Date</th> <th>Storage</th> <th>Expiry Details</th> <th>Supplier Name</th> <th>Rate (₹)</th> <th>UOM</th> <th>Action</th> </tr> </thead> <tbody> @forelse ($fertilizers as $index => $fertilizer) <tr> <td>{{ $index + 1 }}</td> <td>{{ $fertilizer->fertilizer_name }}</td> <td>{{ $fertilizer->fertilizer_type }}</td> <td>{{ $fertilizer->brand_name }}</td> <td>{{ $fertilizer->stock_kg }}</td> <td>{{ \Carbon\Carbon::parse($fertilizer->purchase_date)->format('d-m-Y') }}</td> <td>{{ $fertilizer->storage_location }}</td> <td>{{ \Carbon\Carbon::parse($fertilizer->expiry_date)->format('d-m-Y') }}</td> <td>{{ $fertilizer->supplier_name }}</td> <td>₹{{ $fertilizer->rate }}</td> <td>{{ $fertilizer->uom }}</td> <td class="d-flex align-items-center gap-2"> <!-- Edit Icon Button --> <button class="btn p-0 border-0 bg-transparent text-warning" data-bs-toggle="modal" data-bs-target="#editFertilizerModal{{ $fertilizer->id }}"> <i class="fas fa-edit"></i> </button> <!-- Delete Icon Form --> <form action="{{ route('fertilizer.de', $fertilizer->id) }}" method="POST"> @csrf @method('DELETE') <button onclick="return confirm('Are you sure?')" class="btn p-0 border-0 bg-transparent text-danger"> <i class="fas fa-trash-alt"></i> </button> </form> </td> </tr> <!-- EDIT MODAL FOR EACH FERTILIZER --> <div class="modal fade" id="editFertilizerModal{{ $fertilizer->id }}" tabindex="-1" aria-labelledby="editFertilizerModalLabel{{ $fertilizer->id }}" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <form action="{{ route('fertilizer.update', $fertilizer->id) }}" method="POST"> @csrf @method('PUT') <div class="modal-header"> <h5 class="modal-title">Edit Fertilizer</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> <div class="row"> @php $fields = [ 'fertilizer_name' => 'Fertilizer Name', 'fertilizer_type' => 'Fertilizer Type', 'brand_name' => 'Brand Name', 'storage_location' => 'Storage Location', 'supplier_name' => 'Supplier Name', 'uom' => 'UOM', ]; @endphp @foreach ($fields as $field => $label) <div class="col-md-4"> <label>{{ $label }}</label> <input type="text" name="{{ $field }}" class="form-control" value="{{ $fertilizer->$field }}" required> </div> @endforeach <div class="col-md-6 mb-3"> <label>Purchase Date</label> <input type="date" name="purchase_date" class="form-control" value="{{ $fertilizer->purchase_date }}" required> </div> <div class="col-md-6 mb-3"> <label>Expiry Date</label> <input type="date" name="expiry_date" class="form-control" value="{{ $fertilizer->expiry_date }}" required> </div> <div class="col-md-6 mb-3"> <label>Rate (₹)</label> <input type="number" name="cost_per_bag" class="form-control" value="{{ $fertilizer->rate }}" required> </div> <div class="col-md-6 mb-3"> <label>Current Stock (kg)</label> <input type="number" step="0.01" name="stock_kg" class="form-control" value="{{ $fertilizer->stock_kg }}" readonly> <small class="text-muted">Stock is managed separately</small> </div> </div> <button type="submit" class="btn btn-primary w-100">Update</button> </div> </form> </div> </div> </div> @empty <tr> <td colspan="12">No fertilizers found.</td> </tr> @endforelse </tbody> </table> </div> <!-- ADD FERTILIZER MODAL --> <div class="modal fade" id="addFertilizerModal" tabindex="-1" aria-labelledby="addFertilizerModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <form action="{{ route('fertilizer.store') }}" method="POST"> @csrf <div class="modal-header"> <h5 class="modal-title">Add Fertilizer</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> <div class="row"> @php $inputs = [ 'fertilizer_name' => 'Fertilizer Name', 'fertilizer_type' => 'Fertilizer Type', 'brand_name' => 'Brand Name', 'supplier_name' => 'Supplier Name', 'uom' => 'UOM', ]; @endphp @foreach ($inputs as $field => $label) <div class="col-md-6 mb-3"> <label>{{ $label }}</label> <input type="text" name="{{ $field }}" class="form-control" placeholder="{{ $label }}" required> </div> @endforeach <div class="col-md-6 mb-3"> <label>Purchase Date</label> <input type="date" name="purchase_date" class="form-control" required> </div> <div class="col-md-6 mb-3"> <label>Expiry Date</label> <input type="date" name="expiry_date" class="form-control" required> </div> <div class="col-md-6 mb-3"> <label>Rate (₹)</label> <input type="number" name="cost_per_bag" class="form-control" placeholder="Rate per unit" required> </div> <div class="col-md-6 mb-3"> <label>Initial Stock (kg)</label> <input type="number" step="0.01" name="stock_kg" class="form-control" placeholder="0.00" required> </div> </div> <button type="submit" class="btn btn-success w-100">Submit</button> </div> </form> </div> </div> </div> @endsection