<?php $__env->startSection('content'); ?>
<div class="p-6" x-data="{ showModal:false, editData:{} }">
  <h1 class="text-2xl font-bold mb-6 text-slate-700">Asset Registry</h1>

  <?php if(session('success')): ?>
    <div class="mb-4 bg-green-100 border-l-4 border-green-500 text-green-700 p-3 rounded">
      <?php echo e(session('success')); ?>

    </div>
  <?php endif; ?>

  
  <form method="GET" class="mb-4 flex flex-wrap gap-3">
    <input type="text" name="search" value="<?php echo e(request('search')); ?>" placeholder="Search Tag / Brand / Model"
           class="border rounded-lg px-3 py-2 focus:ring-2 focus:ring-sky-500 w-64">
    <select name="device_type" class="border rounded-lg px-3 py-2 focus:ring-2 focus:ring-sky-500">
      <option value="">Device Type</option>
      <option>Laptop</option><option>Desktop</option><option>Phone</option>
    </select>
    <select name="status" class="border rounded-lg px-3 py-2 focus:ring-2 focus:ring-sky-500">
      <option value="">Status</option>
      <option>In-Stock</option><option>Assigned</option>
      <option>Repair</option><option>Scrap</option>
    </select>
    <button type="submit"
      class="bg-gradient-to-r from-sky-500 to-blue-600 text-white px-4 py-2 rounded-lg font-medium hover:opacity-90">
      Filter
    </button>
    <a href="<?php echo e(route('asset.assets.index')); ?>" class="text-slate-500 px-3 py-2">Clear</a>
  </form>

  
  <form method="POST" action="<?php echo e(route('asset.assets.store')); ?>"
        class="bg-white shadow p-4 rounded-xl grid md:grid-cols-6 gap-3 mb-6">
    <?php echo csrf_field(); ?>
    <input name="asset_tag" placeholder="Asset Tag" required class="border rounded-lg px-3 py-2 focus:ring-2 focus:ring-sky-500">
    <select name="device_type" required class="border rounded-lg px-3 py-2 focus:ring-2 focus:ring-sky-500">
      <option value="">Device Type</option>
      <option>Laptop</option><option>Desktop</option><option>Phone</option>
    </select>
    <input name="brand" placeholder="Brand" class="border rounded-lg px-3 py-2 focus:ring-2 focus:ring-sky-500">
    <input name="model" placeholder="Model" class="border rounded-lg px-3 py-2 focus:ring-2 focus:ring-sky-500">
    <input name="serial_number" placeholder="Serial No." class="border rounded-lg px-3 py-2 focus:ring-2 focus:ring-sky-500">
    <select name="condition" required class="border rounded-lg px-3 py-2 focus:ring-2 focus:ring-sky-500">
      <option>New</option><option>Old</option><option>Refurbished</option>
    </select>
    <input name="microsoft_account" placeholder="Microsoft Account" class="border rounded-lg px-3 py-2 focus:ring-2 focus:ring-sky-500">
    <input name="ram" placeholder="RAM (e.g. 16GB)" class="border rounded-lg px-3 py-2 focus:ring-2 focus:ring-sky-500">
    <input name="storage" placeholder="Storage (e.g. 512GB SSD)" class="border rounded-lg px-3 py-2 focus:ring-2 focus:ring-sky-500">
    <input type="number" name="cost" step="0.01" placeholder="Cost ₹" class="border rounded-lg px-3 py-2 focus:ring-2 focus:ring-sky-500">
    <select name="status" required class="border rounded-lg px-3 py-2 focus:ring-2 focus:ring-sky-500">
      <option>In-Stock</option><option>Assigned</option><option>Repair</option><option>Scrap</option>
    </select>
    <textarea name="remarks" placeholder="Remarks" class="border rounded-lg px-3 py-2 focus:ring-2 focus:ring-sky-500 col-span-full"></textarea>
    <button class="bg-gradient-to-r from-sky-500 to-blue-600 text-white px-6 py-2 rounded-lg hover:opacity-90 font-medium col-span-full">
      + Add Asset
    </button>
  </form>

  
  <div class="bg-white rounded-xl shadow overflow-hidden">
    <table class="min-w-full text-sm text-slate-700">
      <thead class="bg-gradient-to-r from-slate-800 to-slate-700 text-white">
        <tr>
          <th class="px-4 py-3">#</th><th class="px-4 py-3 text-left">Tag</th>
          <th class="px-4 py-3 text-left">Type</th><th class="px-4 py-3 text-left">Brand</th>
          <th class="px-4 py-3 text-left">Model</th><th class="px-4 py-3 text-left">Condition</th>
          <th class="px-4 py-3 text-left">Status</th><th class="px-4 py-3 text-right">Actions</th>
        </tr>
      </thead>
      <tbody>
        <?php $__currentLoopData = $assets; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i=>$a): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <tr class="border-b hover:bg-slate-50">
          <td class="px-4 py-3"><?php echo e($assets->firstItem()+$i); ?></td>
          <td class="px-4 py-3 font-semibold"><?php echo e($a->asset_tag); ?></td>
          <td class="px-4 py-3"><?php echo e($a->device_type); ?></td>
          <td class="px-4 py-3"><?php echo e($a->brand); ?></td>
          <td class="px-4 py-3"><?php echo e($a->model); ?></td>
          <td class="px-4 py-3"><?php echo e($a->condition); ?></td>
          <td class="px-4 py-3"><?php echo e($a->status); ?></td>
          <td class="px-4 py-3 text-right space-x-2">
            <button type="button" class="text-indigo-600 hover:underline"
                    @click="fetch('/asset/assets/<?php echo e($a->id); ?>/edit')
                              .then(r=>r.json()).then(d=>{editData=d;showModal=true;})">Edit</button>
            <form action="<?php echo e(route('asset.assets.destroy',$a->id)); ?>" method="POST" class="inline">
              <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
              <button onclick="return confirm('Delete this asset?')" class="text-red-600 hover:underline">Delete</button>
            </form>
          </td>
        </tr>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
      </tbody>
    </table>

    <div class="px-4 py-3 bg-slate-50 border-t border-slate-200">
      <?php echo e($assets->links('pagination::tailwind')); ?>

    </div>
  </div>

  
  <div x-show="showModal" x-cloak class="fixed inset-0 flex items-center justify-center bg-black/50 z-50">
    <div class="bg-white rounded-xl p-6 w-full max-w-lg">
      <h2 class="text-lg font-semibold mb-4 text-slate-800">Edit Asset</h2>
      <form method="POST" :action="'/asset/assets/' + editData.id">
        <?php echo csrf_field(); ?> <?php echo method_field('PUT'); ?>
        <div class="grid grid-cols-2 gap-3">
          <input name="asset_tag" x-model="editData.asset_tag" class="border rounded-lg px-3 py-2">
          <select name="device_type" x-model="editData.device_type" class="border rounded-lg px-3 py-2">
            <option>Laptop</option><option>Desktop</option><option>Phone</option>
          </select>
          <input name="brand" x-model="editData.brand" class="border rounded-lg px-3 py-2">
          <input name="model" x-model="editData.model" class="border rounded-lg px-3 py-2">
          <input name="serial_number" x-model="editData.serial_number" class="border rounded-lg px-3 py-2">
          <input name="microsoft_account" x-model="editData.microsoft_account" class="border rounded-lg px-3 py-2">
          <input name="ram" x-model="editData.ram" class="border rounded-lg px-3 py-2">
          <input name="storage" x-model="editData.storage" class="border rounded-lg px-3 py-2">
          <select name="condition" x-model="editData.condition" class="border rounded-lg px-3 py-2">
            <option>New</option><option>Old</option><option>Refurbished</option>
          </select>
          <select name="status" x-model="editData.status" class="border rounded-lg px-3 py-2">
            <option>In-Stock</option><option>Assigned</option><option>Repair</option><option>Scrap</option>
          </select>
        </div>
        <div class="mt-5 flex justify-end gap-3">
          <button type="button" @click="showModal=false" class="px-4 py-2 bg-slate-200 rounded-lg hover:bg-slate-300">Cancel</button>
          <button class="px-5 py-2 bg-gradient-to-r from-sky-500 to-blue-600 text-white rounded-lg hover:opacity-90">Update</button>
        </div>
      </form>
    </div>
  </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('asset.partials.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /media/linux/Archive/pac technologies/7oct25_backup/resources/views/asset/assets/index.blade.php ENDPATH**/ ?>