<%- include('partials/header', { title, flash, session, csrf }) %>
<section class="card">
  <div class="section-head"><div><h2>قائمة المتابعة</h2><p class="muted">الفحص التلقائي يستخدم نفس جلسة واتساب.</p></div><form method="post" action="/partial/run"><input type="hidden" name="_csrf" value="<%= csrf %>"><button class="button primary">تشغيل الفحص الآن</button></form></div>
  <div class="table-wrap"><table><thead><tr><th>الطلب</th><th>العميل</th><th>المزود</th><th>الحالة</th><th>آخر حالة</th><th>التذكيرات</th><th>الفحص القادم</th><th></th></tr></thead><tbody>
  <% rows.forEach(row => { %><tr><td><%= row.order_id %></td><td><%= row.linked_username || '-' %></td><td><%= row.provider_key || '-' %></td><td><%= row.status %></td><td><%= row.last_order_status || '-' %></td><td><%= row.reminder_count %></td><td><%= row.next_check_at %></td><td><% if (row.status === 'active') { %><form method="post" action="/partial/<%= row.id %>/stop"><input type="hidden" name="_csrf" value="<%= csrf %>"><button class="button danger small">إيقاف</button></form><% } %></td></tr><% }) %>
  <% if (!rows.length) { %><tr><td colspan="8">لا توجد طلبات متابعة.</td></tr><% } %>
  </tbody></table></div>
</section>
<%- include('partials/footer') %>
