« Back to History
karigar_list.php
|
20260721_154032.php
Initial Bulk Import
Copy Code
<?php /* ============================================================================ File: /erp/karigar_list.php Purpose: Show Karigar list (loom_karigar_master table) Scope : Page-local only; company scoped; debug inline CSS added ============================================================================ */ error_reporting(E_ALL); ini_set('display_errors',1); require __DIR__ . '/modules/auth/auth.php'; require_login(); $u = auth_user(); $company_id = (int)($u['company_id'] ?? 0); $pdo = $GLOBALS['pdo'] ?? null; if (!$pdo) { require __DIR__ . '/core/db.php'; } function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); } /* --- Fetch rows (company scope) --- */ $sql = "SELECT id, khata_code, karigar_name, entry_name, machine_from, machine_to, is_active, created_at FROM loom_karigar_master WHERE company_id = :cid ORDER BY id DESC"; $st = $pdo->prepare($sql); $st->execute([':cid'=>$company_id]); $rows = $st->fetchAll(PDO::FETCH_ASSOC); $total = count($rows); ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Loom Karigar — List</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- DEBUG INLINE OVERRIDE CSS (remove later when fixed in main.css) --> <style> .wrap, .card, .tablewrap, .employee-list-card, .employee-list-table { display:block !important; visibility:visible !important; opacity:1 !important; } table.kgrid, table.employee-list-table { display:table !important; width:100% !important; border-collapse:collapse !important; } table.kgrid th, table.kgrid td { border:1px solid #ddd; padding:8px; font-size:14px; text-align:left; } table.kgrid thead th { background:#f0fbf0; font-weight:700; color:#145a2a; } .badge { display:inline-block; padding:2px 8px; border-radius:12px; background:#eee; } .yes { color:green; font-weight:600; } .no { color:red; font-weight:600; } .empty { padding:20px; color:#666; text-align:center; } </style> </head> <body> <?php include __DIR__.'/partials/header.php'; ?> <div class="wrap wrap-centered"> <div class="hdr hdr-stackable"> <div> <div class="h1">Loom Karigar — List</div> <div class="small mt-6"><span class="badge">Total: <?=h($total)?></span></div> </div> <a class="btn btn-primary btn-lg" href="/erp/karigar_register.php">+ Add Karigar</a> </div> <div class="card card--wide employee-list-card"> <?php if (!$rows): ?> <div class="empty">No karigars found for this company.</div> <?php else: ?> <div class="tablewrap" role="region" aria-live="polite"> <table class="kgrid"> <thead> <tr> <th>ID</th> <th>Khata</th> <th>Name</th> <th>Entry</th> <th>Machines</th> <th>Active</th> <th>Created</th> <th>Actions</th> </tr> </thead> <tbody> <?php foreach ($rows as $r): ?> <tr> <td><?=h($r['id'])?></td> <td><?=h($r['khata_code'])?></td> <td><?=h($r['karigar_name'])?></td> <td><?=h($r['entry_name'])?></td> <td><?= ($r['machine_from'] ?: '-') . " - " . ($r['machine_to'] ?: '-') ?></td> <td><?= $r['is_active'] ? '<span class="yes">Yes</span>' : '<span class="no">No</span>' ?></td> <td><?=h($r['created_at'])?></td> <td> <a href="karigar_edit.php?id=<?=h($r['id'])?>&mode=view">View</a> | <a href="karigar_edit.php?id=<?=h($r['id'])?>">Edit</a> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> <?php endif; ?> </div> </div> <?php include __DIR__.'/partials/footer.php'; ?> </body> </html>