<?php $__env->startSection('header'); ?> <?php echo $__env->make('asset.partials.header', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?> <?php $__env->stopSection(); ?>
<?php $__env->startSection('sidebar'); ?> <?php echo $__env->make('asset.partials.sidebar', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?> <?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="p-6 bg-slate-50 min-h-screen">
  <!-- Header Section -->
  <div class="flex flex-col md:flex-row md:items-center justify-between mb-8">
    <div>
      <h1 class="text-3xl font-bold text-slate-800">Asset Overview</h1>
      <p class="text-slate-600 mt-2">Monitor and manage your company assets</p>
    </div>
    <div class="mt-4 md:mt-0 flex items-center gap-3">
      <a href="<?php echo e(route('asset.dashboard.export')); ?>"
         class="inline-flex items-center gap-2 bg-emerald-600 hover:bg-emerald-700 text-white text-sm font-semibold px-4 py-2 rounded-lg shadow">
        <i class="fa-solid fa-file-excel"></i>
        Export Excel
      </a>
      <div class="flex items-center bg-white rounded-lg shadow-sm px-4 py-2 border border-slate-200">
        <i class="fas fa-calendar-alt text-slate-400 mr-2"></i>
        <span class="text-slate-700"><?php echo e(now()->format('F j, Y')); ?></span>
      </div>
    </div>
  </div>

  
  <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 gap-5 mb-8">
    <div class="bg-gradient-to-br from-blue-50 to-blue-100 p-5 rounded-2xl shadow-sm border border-blue-100 transition-all duration-300 hover:shadow-md hover:-translate-y-1">
      <div class="flex items-center justify-between">
        <div>
          <div class="text-blue-800 text-xs font-semibold uppercase tracking-wide">TOTAL ASSETS</div>
          <div class="text-2xl font-bold text-blue-900 mt-1"><?php echo e($totalAssets); ?></div>
        </div>
        <div class="bg-blue-500 p-3 rounded-xl">
          <i class="fas fa-boxes text-white text-lg"></i>
        </div>
      </div>
      <div class="mt-3 text-xs text-blue-700 flex items-center">
        <i class="fas fa-info-circle mr-1"></i>
        All company assets
      </div>
    </div>
    
    <div class="bg-gradient-to-br from-green-50 to-green-100 p-5 rounded-2xl shadow-sm border border-green-100 transition-all duration-300 hover:shadow-md hover:-translate-y-1">
      <div class="flex items-center justify-between">
        <div>
          <div class="text-green-800 text-xs font-semibold uppercase tracking-wide">ASSIGNED</div>
          <div class="text-2xl font-bold text-green-900 mt-1"><?php echo e($assignedCount); ?></div>
        </div>
        <div class="bg-green-500 p-3 rounded-xl">
          <i class="fas fa-user-check text-white text-lg"></i>
        </div>
      </div>
      <div class="mt-3 text-xs text-green-700 flex items-center">
        <i class="fas fa-arrow-up mr-1"></i>
        <?php echo e($totalAssets ? number_format(($assignedCount/$totalAssets)*100, 1) : 0); ?>% of total
      </div>
    </div>
    
    <div class="bg-gradient-to-br from-slate-50 to-slate-100 p-5 rounded-2xl shadow-sm border border-slate-100 transition-all duration-300 hover:shadow-md hover:-translate-y-1">
      <div class="flex items-center justify-between">
        <div>
          <div class="text-slate-800 text-xs font-semibold uppercase tracking-wide">IN STOCK</div>
          <div class="text-2xl font-bold text-slate-900 mt-1"><?php echo e($inStockCount); ?></div>
        </div>
        <div class="bg-slate-500 p-3 rounded-xl">
          <i class="fas fa-warehouse text-white text-lg"></i>
        </div>
      </div>
      <div class="mt-3 text-xs text-slate-700 flex items-center">
        <i class="fas fa-box mr-1"></i>
        Available for assignment
      </div>
    </div>
    
    <div class="bg-gradient-to-br from-amber-50 to-amber-100 p-5 rounded-2xl shadow-sm border border-amber-100 transition-all duration-300 hover:shadow-md hover:-translate-y-1">
      <div class="flex items-center justify-between">
        <div>
          <div class="text-amber-800 text-xs font-semibold uppercase tracking-wide">UNDER REPAIR</div>
          <div class="text-2xl font-bold text-amber-900 mt-1"><?php echo e($repairCount); ?></div>
        </div>
        <div class="bg-amber-500 p-3 rounded-xl">
          <i class="fas fa-tools text-white text-lg"></i>
        </div>
      </div>
      <div class="mt-3 text-xs text-amber-700 flex items-center">
        <i class="fas fa-clock mr-1"></i>
        In maintenance
      </div>
    </div>
    
    <div class="bg-gradient-to-br from-rose-50 to-rose-100 p-5 rounded-2xl shadow-sm border border-rose-100 transition-all duration-300 hover:shadow-md hover:-translate-y-1">
      <div class="flex items-center justify-between">
        <div>
          <div class="text-rose-800 text-xs font-semibold uppercase tracking-wide">SCRAPPED</div>
          <div class="text-2xl font-bold text-rose-900 mt-1"><?php echo e($scrapCount); ?></div>
        </div>
        <div class="bg-rose-500 p-3 rounded-xl">
          <i class="fas fa-trash-alt text-white text-lg"></i>
        </div>
      </div>
      <div class="mt-3 text-xs text-rose-700 flex items-center">
        <i class="fas fa-exclamation-triangle mr-1"></i>
        No longer in use
      </div>
    </div>
    
    <div class="bg-gradient-to-br from-indigo-50 to-indigo-100 p-5 rounded-2xl shadow-sm border border-indigo-100 transition-all duration-300 hover:shadow-md hover:-translate-y-1">
      <div class="flex items-center justify-between">
        <div>
          <div class="text-indigo-800 text-xs font-semibold uppercase tracking-wide">REPAIR COST</div>
          <div class="text-xl font-bold text-indigo-900 mt-1">₹<?php echo e(number_format($totalRepairCostThisMonth, 2)); ?></div>
        </div>
        <div class="bg-indigo-500 p-3 rounded-xl">
          <i class="fas fa-receipt text-white text-lg"></i>
        </div>
      </div>
      <div class="mt-3 text-xs text-indigo-700 flex items-center">
        <i class="fas fa-calendar mr-1"></i>
        <?php echo e(now()->format('M Y')); ?>

      </div>
    </div>
  </div>

  
  <div x-data="historyModals()" class="mt-8">
    <div class="flex items-center justify-between mb-4">
      <h2 class="text-xl font-bold text-slate-800">Asset Health Snapshot</h2>
      <div class="text-xs text-slate-500">Paginated view of assets with current holder & repairs</div>
    </div>

    <div class="bg-white rounded-2xl shadow-sm border border-slate-200 overflow-hidden">
      <table class="min-w-full text-sm text-slate-700">
        <thead class="bg-slate-50">
            
          <tr>
            <th class="px-4 py-3 text-left">Asset Tag</th>
            <th class="px-4 py-3 text-left">Type</th>
            <th class="px-4 py-3 text-left">Employee</th>
            <th class="px-4 py-3 text-left">Repairs</th>
            <th class="px-4 py-3 text-left">Repair Cost</th>
            <th class="px-4 py-3 text-right">Actions</th>
          </tr>
        </thead>
        <tbody class="divide-y divide-slate-200">
          <?php $__empty_1 = true; $__currentLoopData = $assetSummary; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <tr class="hover:bg-slate-50">
              <td class="px-4 py-3 font-semibold"><?php echo e($row->asset_tag); ?></td>
              <td class="px-4 py-3"><?php echo e($row->device_type); ?></td>
              <td class="px-4 py-3"><?php echo e($row->employee_name); ?></td>
              <td class="px-4 py-3"><?php echo e($row->repairs_count); ?></td>
              <td class="px-4 py-3">₹<?php echo e(number_format($row->repairs_cost,2)); ?></td>
              <td class="px-4 py-3 text-right">
                <div class="inline-flex gap-2">
                  <button
                    class="px-3 py-1.5 text-xs rounded-lg bg-indigo-50 text-indigo-700 hover:bg-indigo-100"
                    @click="openAssignHistory(<?php echo e($row->id); ?>, '<?php echo e($row->asset_tag); ?>')">
                    <i class="fa-solid fa-clock-rotate-left mr-1"></i> Assign History
                  </button>
                  <button
                    class="px-3 py-1.5 text-xs rounded-lg bg-amber-50 text-amber-700 hover:bg-amber-100"
                    @click="openRepairHistory(<?php echo e($row->id); ?>, '<?php echo e($row->asset_tag); ?>')">
                    <i class="fa-solid fa-screwdriver-wrench mr-1"></i> Repair History
                  </button>
                </div>
              </td>
            </tr>
          <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <tr><td colspan="6" class="px-4 py-6 text-center text-slate-500">No assets found.</td></tr>
          <?php endif; ?>
        </tbody>
      </table>

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

      </div>
    </div>

    
    <div x-show="showAssign" x-cloak
         class="fixed inset-0 flex items-center justify-center bg-black/50 backdrop-blur-sm z-50 p-4">
      <div class="bg-white rounded-xl shadow-lg w-full max-w-2xl max-h-[80vh] overflow-hidden">
        <div class="bg-gradient-to-r from-slate-800 to-slate-700 text-white px-6 py-4">
          <div class="flex justify-between items-center">
            <h3 class="text-lg font-semibold flex items-center gap-2">
              <i class="fas fa-history"></i>
              Assignment History
            </h3>
            <button @click="showAssign = false" class="text-white/80 hover:text-white transition">
              <i class="fas fa-times text-lg"></i>
            </button>
          </div>
          <p class="text-slate-300 text-sm mt-1"
            x-text="assignHistory.length>0 ? assignHistory[0].asset_tag + ' - ' + assignHistory[0].device_type : title"></p>
        </div>

        <div class="p-6 overflow-y-auto max-h-[60vh]">
          <template x-if="assignHistory.length>0">
            <div class="space-y-4">
              <template x-for="(history,index) in assignHistory" :key="index">
                <div class="border-l-2 border-sky-500 pl-4 pb-4 relative">
                  <div class="absolute -left-2 w-3 h-3 bg-sky-500 rounded-full border-2 border-white shadow"></div>
                  <template x-if="!history.returned_date">
                    <div class="absolute -left-3 w-4 h-4 bg-sky-500 rounded-full animate-ping"></div>
                  </template>

                  <div class="bg-slate-50 rounded-lg p-4 border border-slate-200">
                    <div class="flex justify-between items-start mb-3">
                      <div>
                        <h4 class="font-semibold text-slate-800 text-lg" x-text="history.employee"></h4>
                        <p class="text-slate-600 text-sm" x-text="history.designation"></p>
                      </div>
                      <div class="text-right text-sm">
                        <div class="text-slate-600">
                          <span class="font-medium">Assigned:</span>
                          <span x-text="history.assigned_date"></span>
                        </div>
                        <template x-if="history.returned_date">
                          <div class="text-slate-600 mt-1">
                            <span class="font-medium">Returned:</span>
                            <span x-text="history.returned_date"></span>
                          </div>
                        </template>
                        <template x-if="!history.returned_date">
                          <div class="text-green-600 font-medium mt-1 flex items-center gap-1">
                            <i class="fas fa-circle text-xs"></i> Currently Assigned
                          </div>
                        </template>
                      </div>
                    </div>

                    <div class="flex justify-between items-center">
                      <div>
                        <template x-if="history.remarks">
                          <p class="text-slate-600 text-sm">
                            <span class="font-medium">Remarks:</span>
                            <span x-text="history.remarks"></span>
                          </p>
                        </template>
                        <template x-if="!history.remarks">
                          <p class="text-slate-400 text-sm italic">No remarks</p>
                        </template>
                      </div>
                      <div>
                        <template x-if="history.status==='Assigned'">
                          <span class="px-2 py-1 text-xs rounded bg-green-100 text-green-700 font-medium">Active</span>
                        </template>
                        <template x-if="history.status==='Returned'">
                          <span class="px-2 py-1 text-xs rounded bg-slate-200 text-slate-700 font-medium">Returned</span>
                        </template>
                        <template x-if="history.status==='Reassigned'">
                          <span class="px-2 py-1 text-xs rounded bg-amber-100 text-amber-700 font-medium">Reassigned</span>
                        </template>
                      </div>
                    </div>
                  </div>
                </div>
              </template>
            </div>
          </template>

          <template x-if="assignHistory.length===0">
            <div class="text-center py-8">
              <i class="fas fa-inbox text-4xl text-slate-300 mb-3"></i>
              <p class="text-slate-500">No assignment history found for this asset.</p>
            </div>
          </template>
        </div>

        <div class="border-t border-slate-200 px-6 py-4 bg-slate-50">
          <div class="flex justify-between items-center text-sm text-slate-600">
            <span x-text="'Total records: ' + assignHistory.length"></span>
            <button @click="showAssign=false"
                    class="bg-slate-200 hover:bg-slate-300 text-slate-700 px-4 py-2 rounded-lg font-medium transition">
              Close
            </button>
          </div>
        </div>
      </div>
    </div>

    
    <div x-show="showRepair" x-cloak class="fixed inset-0 bg-black/50 flex items-center justify-center z-50">
      <div class="bg-white rounded-xl w-full max-w-lg shadow-2xl">
        <div class="px-5 py-3 border-b flex items-center justify-between">
          <div class="font-semibold text-slate-800">
            <i class="fa-solid fa-screwdriver-wrench text-amber-600 mr-2"></i>
            Repair History — <span x-text="title"></span>
          </div>
          <button class="text-slate-500 hover:text-slate-700" @click="showRepair=false">&times;</button>
        </div>
        <div class="p-5 space-y-3 max-h-[70vh] overflow-y-auto">
          <template x-if="repairLoading"><div class="text-sm text-slate-500">Loading…</div></template>
          <template x-if="!repairLoading && repairHistory.length===0">
            <div class="text-sm text-slate-500">No repair records.</div>
          </template>
          <template x-for="r in repairHistory" :key="r.id">
            <div class="p-3 rounded-lg border bg-white">
              <div class="text-sm font-medium" x-text="r.issue"></div>
              <div class="text-xs text-slate-500 mt-1">
                Vendor: <span x-text="r.vendor_name || '—'"></span> •
                Cost: ₹<span x-text="(r.cost||0).toLocaleString()"></span> •
                Status: <span x-text="r.status"></span>
              </div>
              <div class="text-[11px] text-slate-400 mt-1">
                Sent: <span x-text="r.sent_date || '—'"></span> •
                Return: <span x-text="r.return_date || '—'"></span>
              </div>
            </div>
          </template>
        </div>
        <div class="px-5 py-3 border-t text-right">
          <button class="px-4 py-2 bg-slate-200 rounded-lg" @click="showRepair=false">Close</button>
        </div>
      </div>
    </div>
  </div>

  <div class="grid grid-cols-1 xl:grid-cols-3 gap-6 mb-8 mt-10">
    
    <div class="xl:col-span-2 bg-white rounded-2xl shadow-sm p-6 border border-slate-200">
      <div class="flex items-center justify-between mb-6">
        <h3 class="text-lg font-semibold text-slate-800 flex items-center gap-2">
          <i class="fas fa-chart-pie text-indigo-600"></i> Asset Distribution by Type
        </h3>
        <div class="text-xs text-slate-500 bg-slate-100 px-2 py-1 rounded-lg">
          Total: <?php echo e($totalAssets); ?> assets
        </div>
      </div>
      <div class="h-80">
        <canvas id="typeChart"></canvas>
      </div>
    </div>

    
    <div class="bg-white rounded-2xl shadow-sm p-6 border border-slate-200">
      <h3 class="text-lg font-semibold mb-6 text-slate-800 flex items-center gap-2">
        <i class="fas fa-chart-bar text-blue-600"></i> Status Distribution
      </h3>
      <div class="space-y-4">
        <?php
          $statuses = [
            'Assigned' => ['count' => $assignedCount, 'color' => 'bg-green-500', 'text' => 'text-green-700'],
            'In-Stock' => ['count' => $inStockCount, 'color' => 'bg-slate-500', 'text' => 'text-slate-700'],
            'Repair'   => ['count' => $repairCount, 'color' => 'bg-amber-500', 'text' => 'text-amber-700'],
            'Scrap'    => ['count' => $scrapCount, 'color' => 'bg-rose-500', 'text' => 'text-rose-700'],
          ];
        ?>
        <?php $__currentLoopData = $statuses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $status => $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
          <div class="flex items-center justify-between">
            <div class="flex items-center">
              <div class="w-3 h-3 rounded-full <?php echo e($data['color']); ?> mr-3"></div>
              <span class="text-sm font-medium text-slate-700"><?php echo e($status); ?></span>
            </div>
            <div class="flex items-center">
              <span class="text-sm font-semibold <?php echo e($data['text']); ?> mr-2"><?php echo e($data['count']); ?></span>
              <span class="text-xs text-slate-500">(<?php echo e($totalAssets > 0 ? number_format(($data['count']/$totalAssets)*100, 1) : 0); ?>%)</span>
            </div>
          </div>
          <div class="w-full bg-slate-200 rounded-full h-2">
            <div class="h-2 rounded-full <?php echo e($data['color']); ?>" style="width: <?php echo e($totalAssets > 0 ? ($data['count']/$totalAssets)*100 : 0); ?>%"></div>
          </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
      </div>
    </div>
  </div>

  
  <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
    
    <div class="bg-white rounded-2xl shadow-sm p-6 border border-slate-200">
      <div class="flex items-center justify-between mb-6">
        <h3 class="text-lg font-semibold text-slate-800 flex items-center gap-2">
          <i class="fas fa-screwdriver-wrench text-amber-600"></i> Top 5 Most Repaired Assets
        </h3>
        <a href="#" class="text-xs text-indigo-600 font-medium hover:text-indigo-800 transition-colors">
          View All <i class="fas fa-chevron-right ml-1"></i>
        </a>
      </div>
      <div class="overflow-x-auto">
        <table class="min-w-full text-sm text-slate-700">
          <thead class="bg-slate-50 rounded-lg">
            <tr>
              <th class="px-4 py-3 text-left font-semibold text-slate-600 rounded-l-lg">Asset Tag</th>
              <th class="px-4 py-3 text-left font-semibold text-slate-600">Type</th>
              <th class="px-4 py-3 text-left font-semibold text-slate-600">Employee</th>
              <th class="px-4 py-3 text-left font-semibold text-slate-600 rounded-r-lg">Repairs</th>
            </tr>
          </thead>
          <tbody class="divide-y divide-slate-200">
            <?php $__empty_1 = true; $__currentLoopData = $mostRepaired; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
              <tr class="hover:bg-slate-50 transition-colors">
                <td class="px-4 py-3 font-semibold">
                  <div class="flex items-center">
                    <div class="w-2 h-2 rounded-full bg-amber-500 mr-2"></div>
                    <?php echo e($row->asset_tag ?? 'N/A'); ?>

                  </div>
                </td>
                <td class="px-4 py-3">
                  <span class="bg-slate-100 text-slate-700 text-xs px-2 py-1 rounded-full"><?php echo e($row->device_type ?? '-'); ?></span>
                </td>
                <td class="px-4 py-3"><?php echo e($row->employee_name ?? '—'); ?></td>
                <td class="px-4 py-3">
                  <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-amber-100 text-amber-800">
                    <?php echo e($row->total_repairs); ?> repair(s)
                  </span>
                </td>
              </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
              <tr>
                <td colspan="4" class="text-center py-6 text-slate-500">
                  <i class="fas fa-inbox text-3xl mb-2 text-slate-300"></i>
                  <div>No repair data found</div>
                </td>
              </tr>
            <?php endif; ?>
          </tbody>
        </table>
      </div>
    </div>

    
    <div class="bg-white rounded-2xl shadow-sm p-6 border border-slate-200">
      <div class="flex items-center justify-between mb-6">
        <h3 class="text-lg font-semibold text-slate-800 flex items-center gap-2">
          <i class="fas fa-clock text-green-600"></i> Recent Assignments
        </h3>
        <a href="#" class="text-xs text-indigo-600 font-medium hover:text-indigo-800 transition-colors">
          View All <i class="fas fa-chevron-right ml-1"></i>
        </a>
      </div>
      <div class="overflow-x-auto">
        <table class="min-w-full text-sm text-slate-700">
          <thead class="bg-slate-50 rounded-lg">
            <tr>
              <th class="px-4 py-3 text-left font-semibold text-slate-600 rounded-l-lg">Employee</th>
              <th class="px-4 py-3 text-left font-semibold text-slate-600">Asset Tag</th>
              <th class="px-4 py-3 text-left font-semibold text-slate-600 rounded-r-lg">Date</th>
            </tr>
          </thead>
          <tbody class="divide-y divide-slate-200">
            <?php $__empty_1 = true; $__currentLoopData = $recentAssignments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $a): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
              <tr class="hover:bg-slate-50 transition-colors">
                <td class="px-4 py-3">
                  <div class="flex items-center">
                    <div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center mr-3">
                      <i class="fas fa-user text-indigo-600 text-xs"></i>
                    </div>
                    <span><?php echo e($a->employee->name ?? '—'); ?></span>
                  </div>
                </td>
                <td class="px-4 py-3 font-semibold">
                  <span class="bg-blue-100 text-blue-700 text-xs px-2 py-1 rounded-full"><?php echo e($a->asset->asset_tag ?? 'N/A'); ?></span>
                </td>
                <td class="px-4 py-3">
                  <span class="text-slate-500"><?php echo e(\Carbon\Carbon::parse($a->assigned_date)->format('M j, Y')); ?></span>
                </td>
              </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
              <tr>
                <td colspan="3" class="text-center py-6 text-slate-500">
                  <i class="fas fa-clipboard-list text-3xl mb-2 text-slate-300"></i>
                  <div>No assignments yet</div>
                </td>
              </tr>
            <?php endif; ?>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</div>

<?php $__env->startPush('scripts'); ?>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
const ctx = document.getElementById('typeChart').getContext('2d');
new Chart(ctx, {
  type: 'doughnut',
  data: {
    labels: <?php echo json_encode($assetByType->keys()); ?>,
    datasets: [{
      data: <?php echo json_encode($assetByType->values()); ?>,
      backgroundColor: [
        '#0ea5e9','#22c55e','#f59e0b','#ef4444','#6366f1',
        '#10b981','#f97316','#8b5cf6','#ec4899','#06b6d4'
      ],
      borderWidth: 2,
      borderColor: '#fff',
      hoverOffset: 15
    }]
  },
  options: {
    responsive: true,
    maintainAspectRatio: false,
    plugins: {
      legend: {
        position: 'right',
        labels: { padding: 20, usePointStyle: true, pointStyle: 'circle' }
      },
      tooltip: {
        callbacks: {
          label: function(ctx) {
            const label = ctx.label || '';
            const value = ctx.raw || 0;
            const total = ctx.dataset.data.reduce((a,b)=>a+b,0);
            const pct = total ? Math.round((value/total)*100) : 0;
            return `${label}: ${value} (${pct}%)`;
          }
        }
      }
    }
  }
});

function historyModals(){
  return {
    showAssign:false, showRepair:false, title:'',
    assignHistory:[], repairHistory:[],
    assignLoading:false, repairLoading:false,

    openAssignHistory(assetId, tag){
      this.title = tag; this.showAssign = true; this.assignLoading = true; this.assignHistory = [];
      fetch(`/asset/assignments/history/${assetId}`)
        .then(r=>r.json()).then(d=>{ this.assignHistory = d; })
        .catch(()=>alert('Failed to load assignment history'))
        .finally(()=> this.assignLoading = false);
    },

    openRepairHistory(assetId, tag){
      this.title = tag; this.showRepair = true; this.repairLoading = true; this.repairHistory = [];
      fetch(`/asset/repairs/history/${assetId}`)
        .then(r=>r.json()).then(d=>{ this.repairHistory = d; })
        .catch(()=>alert('Failed to load repair history'))
        .finally(()=> this.repairLoading = false);
    }
  }
}
</script>
<?php $__env->stopPush(); ?>
<?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/overview.blade.php ENDPATH**/ ?>