@extends('index') @section("body") {{-- Redirect to login if no session --}} @if (!Session::get("username")) <script> window.location.href = "login"; </script> @else <body> <center> <h1>LIST OF ASSET</h1><br><br><br> {{-- Search form --}} <div style="display: flex; justify-content: center; margin-bottom: 20px;"> <form style="display: flex; align-items: center;"> <input type="text" name="searchTxtAst" placeholder="Search Asset..." style="width: 300px; padding: 5px; margin-right: 10px;"> <input type="submit" name="btnSearchAst" value="Search" style="padding: 5px 10px;" class="button small"> @csrf </form> </div> {{-- List of Computer Assets --}} <h3> List of Computer/Laptop</h3> <table style="text-align: center;"> <tr> <th style="display: none;" >Id</th> <th style="text-align: center;">BRAND</th> <th style="text-align: center;">MODEL</th> <th style="text-align: center;">ASSET TAG</th> <th style="text-align: center;">SERIAL NO</th> <th style="text-align: center;">Remarks</th> <th style="text-align: center;">STATUS</th> <th style="text-align: center;">LOCATION</th> <th colspan="3" style="text-align: center;">ACTION</th> </tr> @foreach($CompAsset as $Ad) <tr> <td style="display: none;">{{$Ad->id}}</td> <td>{{$Ad->brand}}</td> <td>{{$Ad->model}}</td> <td>{{$Ad->assetTag}}</td> <td>{{$Ad->Serial_No}}</td> <td>{{$Ad->Remarks}}</td> <td>{{$Ad->status}}</td> <td>{{$Ad->location}}</td> <td> {{-- Display the request form if the asset is available --}} @if($Ad->status == 'Available') <form action="request-asset" method="POST"> @csrf <input type="hidden" name="asset_id" value="{{ $Ad->id }}"> <input type="hidden" name="asset_type" value="CompAsset"> <input type="text" name="location" placeholder="Enter location" required><br> <input type="submit" value="Request Asset" class="button small"> </form> @elseif($Ad->status == 'In Use') <span>Asset is currently in use.</span> @endif </td> <td> @if($Ad->status == 'In Use') {{-- Check if the logged-in user is the one who requested the asset --}} @php $assetHistory = DB::table('AssetHistory')->where('asset_id', $Ad->id) ->where('user_id', Session::get('user_id')) // Match with current user from session ->where('status', 'In Use') ->first(); @endphp @if($assetHistory) <form action="return-asset" method="POST"> @csrf <input type="hidden" name="asset_id" value="{{ $Ad->id }}"> <input type="hidden" name="asset_type" value="CompAsset"> <input type="submit" value="Return Asset" class="button small"> </form> @endif @endif </td> <td> @if (Session::get('userlevel') === 'admin') @if ($Ad->status === 'Pending') <form action="manage-request" method="POST"> @csrf <input type="hidden" name="asset_id" value="{{ $Ad->id }}"> <!-- The asset ID --> <input type="hidden" name="asset_type" value="CompAsset"> <!-- The asset type --> <label for="action-{{ $Ad->id }}">Choose Action:</label> <select name="action" id="action-{{ $Ad->id }}" required> <option value="">Select...</option> <option value="approve">Approve</option> <option value="reject">Reject</option> </select> <br> <input type="submit" value="Submit" class="button small"> </form> @endif @endif </td> </tr> @endforeach </table> <br><br><br> {{-- List of Printer Assets --}} <h3> List of Printer</h3> <table style="text-align: center;"> <tr> <th style="display: none;" >Id</th> <th style="text-align: center;">TYPE</th> <th style="text-align: center;">DEPARTMENT</th> <th style="text-align: center;">BRAND</th> <th style="text-align: center;">MODEL</th> <th style="text-align: center;">ASSET TAG</th> <th style="text-align: center;">SERIAL NO</th> <th style="text-align: center;">REMARKS</th> <th style="text-align: center;">STATUS</th> <th style="text-align: center;">LOCATION</th> <th colspan="3" style="text-align: center;">ACTION</th> </tr> @foreach($PrintAsset as $d) <tr> <td style="display: none;">{{$d->id}}</td> <td>{{$d->type}}</td> <td>{{$d->dept}}</td> <td>{{$d->brand}}</td> <td>{{$d->model}}</td> <td>{{$d->assetTag}}</td> <td>{{$d->Serial_No}}</td> <td>{{$d->remarks}}</td> <td>{{$d->status}}</td> <td>{{$d->location}}</td> <td> {{-- Display the request form if the asset is available --}} @if($d->status == 'Available') <form action="request-asset" method="POST"> @csrf <input type="hidden" name="asset_id" value="{{ $d->id }}"> <input type="hidden" name="asset_type" value="PrintAsset"> <input type="text" name="location" placeholder="Enter location" required><br> <input type="submit" value="Request Asset" class="button small"> </form> @elseif($d->status == 'In Use') <span>Asset is currently in use.</span> @endif </td> <td> @if($d->status == 'In Use') {{-- Check if the logged-in user is the one who requested the asset --}} @php $assetHistory = DB::table('AssetHistory')->where('asset_id', $d->id) ->where('user_id', Session::get('user_id')) // Match with current user from session ->where('status', 'In Use') ->first(); @endphp @if($assetHistory) <form action="return-asset" method="POST"> @csrf <input type="hidden" name="asset_id" value="{{ $d->id }}"> <input type="hidden" name="asset_type" value="PrintAsset"> <input type="submit" value="Return Asset" class="button small"> </form> @endif @endif </td> <td> @if (Session::get('userlevel') === 'admin') @if ($d->status === 'Pending') <form action="manage-request" method="POST"> @csrf <input type="hidden" name="asset_id" value="{{ $d->id }}"> <!-- The asset ID --> <input type="hidden" name="asset_type" value="PrintAsset"> <!-- The asset type --> <label for="action-{{ $d->id }}">Choose Action:</label> <select name="action" id="action-{{ $d->id }}" required> <option value="">Select...</option> <option value="approve">Approve</option> <option value="reject">Reject</option> </select> <br> <input type="submit" value="Submit" class="button small"> </form> @endif @endif </td> </tr> @endforeach </table> <br><br><br> {{-- List of Other Assets --}} <h3> List of Other Assets</h3> <table style="text-align: center;"> <tr> <th style="display: none;" >Id</th> <th style="text-align: center;">ITEM</th> <th style="text-align: center;">SERIAL NO</th> <th style="text-align: center;">ASSET TAG</th> <th style="text-align: center;">REMARKS</th> <th style="text-align: center;">STATUS</th> <th style="text-align: center;">LOCATION</th> <th colspan="3" style="text-align: center;">ACTION</th> </tr> @foreach($Asset as $a) <tr> <td style="display: none;">{{$a->id}}</td> <td>{{$a->item}}</td> <td>{{$a->serial_no}}</td> <td>{{$a->assetTag}}</td> <td>{{$a->remarks}}</td> <td>{{$a->status}}</td> <td>{{$a->location}}</td> <td> {{-- Display the request form if the asset is available --}} @if($a->status == 'Available') <form action="request-asset" method="POST"> @csrf <input type="hidden" name="asset_id" value="{{ $a->id }}"> <input type="hidden" name="asset_type" value="Asset"> <input type="text" name="location" placeholder="Enter location" required><br> <input type="submit" value="Request Asset" class="button small"> </form> @elseif($a->status == 'In Use') <span>Asset is currently in use.</span> @endif </td> <td> @if($a->status == 'In Use') {{-- Check if the logged-in user is the one who requested the asset --}} @php $assetHistory = DB::table('AssetHistory')->where('asset_id', $a->id) ->where('user_id', Session::get('user_id')) // Match with current user from session ->where('status', 'In Use') ->first(); @endphp @if($assetHistory) <form action="return-asset" method="POST"> @csrf <input type="hidden" name="asset_id" value="{{ $a->id }}"> <input type="hidden" name="asset_type" value="Asset"> <input type="submit" value="Return Asset" class="button small"> </form> @endif @endif </td> <td> @if (Session::get('userlevel') === 'admin') @if ($a->status === 'Pending') <form action="manage-request" method="POST"> @csrf <input type="hidden" name="asset_id" value="{{ $a->id }}"> <!-- The asset ID --> <input type="hidden" name="asset_type" value="Asset"> <!-- The asset type --> <label for="action-{{ $a->id }}">Choose Action:</label> <select name="action" id="action-{{ $a->id }}" required> <option value="">Select...</option> <option value="approve">Approve</option> <option value="reject">Reject</option> </select> <br> <input type="submit" value="Submit" class="button small"> </form> @endif @endif </td> </tr> @endforeach </table> </center> @endif </body> @endsection {{-- <div id="google_translate_element"></div> <script type="text/javascript"> function googleTranslateElementInit() { new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element'); } </script> <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> --}}