File manager - Edit - /home/cipherteam/htdocs/cipherteam.in/admin3/sequence.php
Back
<?php include 'config.php'; session_start(); if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) { header("Location: login.php"); exit; } function fetchIPOsByStatusAndType($pdo, $status, $type) { $stmt = $pdo->prepare("SELECT id, c_name, NO, ipo_open, ipo_close, ipo_listing, ipo_allotment, ipo_refund FROM ipo_post WHERE status = ? AND TYPE = ? ORDER BY NO ASC, id DESC"); $stmt->execute([$status, $type]); return $stmt->fetchAll(PDO::FETCH_ASSOC); } $statuses = ['PRESENT', 'NEW', 'PAST']; $types = ['M' => 'Mainline', 'S' => 'SME']; $activeTab = $_GET['tab'] ?? 'PRESENT'; $selectedType = $_GET['type'] ?? 'M'; $successMessage = false; if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['order'])) { foreach ($_POST['order'] as $position => $id) { $stmt = $pdo->prepare("UPDATE ipo_post SET NO = ? WHERE id = ?"); $stmt->execute([$position + 1, $id]); } $successMessage = true; } $today = date('Y-m-d'); function formatDate($date) { return $date ? date('d-m-Y', strtotime($date)) : 'No date available'; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Change IPO Sequence</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> <link rel="preconnect" href="https://fonts.googleapis.com"> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.js"></script> <style> :root { --primary: #4f46e5; --primary-light: #e0e7ff; --primary-dark: #3730a3; --surface: #ffffff; --surface-alt: #f8fafc; --border: #e2e8f0; --text: #1e293b; --text-muted: #64748b; --success: #059669; --success-light: #ecfdf5; --warning: #d97706; --danger: #dc2626; --info: #0284c7; --radius: 12px; --radius-sm: 8px; --shadow-sm: 0 1px 2px rgba(0,0,0,0.05); --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04); --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.04); } * { box-sizing: border-box; } body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: #f1f5f9; color: var(--text); min-height: 100vh; margin: 0; padding: 0; } /* ── Top Bar ── */ .top-bar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 16px 0; position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow-sm); } .top-bar .inner { max-width: 960px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; } .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; color: var(--primary); } .brand-icon { width: 36px; height: 36px; background: var(--primary); color: #fff; border-radius: 10px; display: grid; place-items: center; font-size: 18px; flex-shrink: 0; } .btn-back { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); padding: 8px 18px; border-radius: var(--radius-sm); font-weight: 500; font-size: 13px; text-decoration: none; transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px; } .btn-back:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); } /* ── Main Container ── */ .main-wrap { max-width: 960px; margin: 0 auto; padding: 28px 24px 40px; } /* ── Success Alert ── */ .alert-modern { background: var(--success-light); color: var(--success); border: 1px solid #a7f3d0; border-radius: var(--radius-sm); padding: 14px 20px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; margin-bottom: 20px; animation: slideDown 0.3s ease; } @keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } /* ── Tab Navigation ── */ .tab-nav { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 16px; box-shadow: var(--shadow-sm); width: fit-content; } .tab-nav a { padding: 9px 22px; font-size: 13px; font-weight: 500; color: var(--text-muted); text-decoration: none; border-radius: 6px; transition: all 0.2s; } .tab-nav a:hover { background: var(--surface-alt); color: var(--text); } .tab-nav a.active { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); } /* ── Type Selector ── */ .type-selector { display: flex; gap: 8px; margin-bottom: 20px; } .type-btn { padding: 8px 20px; border-radius: 20px; font-size: 13px; font-weight: 500; text-decoration: none; transition: all 0.2s; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); } .type-btn:hover { border-color: var(--primary); color: var(--primary); } .type-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); } /* ── Save Button ── */ .save-bar { display: flex; justify-content: center; margin-bottom: 24px; } .btn-save { padding: 12px 36px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; border: none; cursor: pointer; background: var(--success); color: #fff; transition: all 0.2s; display: inline-flex; align-items: center; gap: 8px; box-shadow: var(--shadow); } .btn-save:hover { background: #047857; transform: translateY(-1px); box-shadow: var(--shadow-md); } /* ── Sortable Items ── */ .sortable-group { display: flex; flex-direction: column; gap: 10px; } .sortable-item { cursor: grab; background: var(--surface); padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--radius); transition: all 0.2s; box-shadow: var(--shadow-sm); position: relative; } .sortable-item:active { cursor: grabbing; } .sortable-item:hover { box-shadow: var(--shadow-md); border-color: #cbd5e1; } .sortable-item.sortable-chosen { box-shadow: 0 8px 25px rgba(79, 70, 229, 0.15); border-color: var(--primary); background: #fafaff; } .sortable-item.sortable-ghost { opacity: 0.4; } .item-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; } .item-title { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; color: var(--text); } .drag-handle { color: #cbd5e1; font-size: 16px; flex-shrink: 0; } .seq-badge { background: var(--primary-light); color: var(--primary); font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 6px; flex-shrink: 0; } /* ── Date Badges ── */ .date-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; } .date-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 5px 12px; border-radius: 6px; white-space: nowrap; } .date-badge i { font-size: 10px; } .db-start { background: #ecfdf5; color: #059669; } .db-end { background: #fef2f2; color: #dc2626; } .db-allotment { background: #fffbeb; color: #d97706; } .db-refund { background: #faf5ff; color: #7c3aed; } .db-listing { background: #f0f9ff; color: #0284c7; } .listing-float { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 5px 12px; border-radius: 6px; background: #f0f9ff; color: #0284c7; } /* ── Timeline Progress ── */ .timeline-bar { height: 5px; background: var(--border); border-radius: 5px; overflow: hidden; margin-top: 14px; } .timeline-fill { height: 100%; background: linear-gradient(90deg, #059669, #0284c7, #7c3aed); border-radius: 5px; transition: width 0.8s ease-in-out; } /* ── Count badge ── */ .count-info { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; font-weight: 500; } .count-info span { background: var(--primary-light); color: var(--primary); padding: 2px 10px; border-radius: 20px; font-weight: 600; font-size: 12px; } /* ── Responsive ── */ @media (max-width: 640px) { .main-wrap { padding: 16px; } .sortable-item { padding: 14px 16px; } .item-title { font-size: 13px; } .date-badges { gap: 6px; } .date-badge { font-size: 11px; padding: 4px 8px; } .tab-nav { width: 100%; } .tab-nav a { flex: 1; text-align: center; padding: 9px 10px; } .type-selector { flex-wrap: wrap; } } </style> </head> <body> <!-- Top Bar --> <div class="top-bar"> <div class="inner"> <div class="brand"> <div class="brand-icon">🔃</div> IPO Sequence </div> <a href="index.php" class="btn-back">← Back to List</a> </div> </div> <div class="main-wrap"> <?php if ($successMessage): ?> <div class="alert-modern" id="success-alert">✅ Sequence updated successfully!</div> <script> setTimeout(() => { const alert = document.getElementById('success-alert'); if (alert) alert.style.display = 'none'; }, 3000); </script> <?php endif; ?> <!-- Tab Navigation --> <div class="tab-nav"> <?php foreach ($statuses as $status): ?> <a class="<?= $status === $activeTab ? 'active' : '' ?>" href="?tab=<?= $status ?>&type=<?= $selectedType ?>"><?= ucfirst(strtolower($status)) ?></a> <?php endforeach; ?> </div> <!-- Type Selector --> <div class="type-selector"> <?php foreach ($types as $code => $label): ?> <a href="?tab=<?= $activeTab ?>&type=<?= $code ?>" class="type-btn <?= $selectedType === $code ? 'active' : '' ?>"><?= $label ?></a> <?php endforeach; ?> </div> <form method="post"> <!-- Save Button --> <div class="save-bar"> <button type="submit" class="btn-save">💾 Save Sequence</button> </div> <?php $ipos = fetchIPOsByStatusAndType($pdo, $activeTab, $selectedType); ?> <div class="count-info">Drag to reorder — <span><?= count($ipos) ?></span> IPO<?= count($ipos) !== 1 ? 's' : '' ?></div> <div class="sortable-group" id="sortable-group"> <?php foreach ($ipos as $ipo): $dates = [ 'Start' => $ipo['ipo_open'], 'End' => $ipo['ipo_close'], 'Allotment' => $ipo['ipo_allotment'], 'Refund' => $ipo['ipo_refund'], 'Listing' => $ipo['ipo_listing'] ]; $completed = 0; $total = 0; foreach ($dates as $d) { if (!empty($d) && strtotime($d)) { $total++; if (strtotime($d) <= strtotime($today)) { $completed++; } } } $progress = ($activeTab === 'PRESENT' && $total > 0) ? round(($completed / $total) * 100) : 0; ?> <div class="sortable-item" data-id="<?= $ipo['id'] ?>"> <input type="hidden" name="order[]" value="<?= $ipo['id'] ?>"> <div class="item-header"> <div class="item-title"> <span class="drag-handle"><i class="fa fa-grip-vertical"></i></span> <span class="seq-badge">#<?= $ipo['NO'] ?></span> <?= htmlspecialchars($ipo['c_name']) ?> </div> <?php if ($activeTab !== 'PRESENT'): ?> <span class="listing-float" title="Listing Date"><i class="fa fa-clipboard"></i> <?= formatDate($ipo['ipo_listing']) ?></span> <?php endif; ?> </div> <?php if ($activeTab === 'PRESENT'): ?> <div class="date-badges"> <span class="date-badge db-start" title="Start Date"><i class="fa fa-play"></i> Start: <?= formatDate($ipo['ipo_open']) ?></span> <span class="date-badge db-end" title="End Date"><i class="fa fa-stop"></i> End: <?= formatDate($ipo['ipo_close']) ?></span> <span class="date-badge db-allotment" title="Allotment"><i class="fa fa-ticket"></i> Allotment: <?= formatDate($ipo['ipo_allotment']) ?></span> <span class="date-badge db-refund" title="Refund"><i class="fa fa-undo"></i> Refund: <?= formatDate($ipo['ipo_refund']) ?></span> <span class="date-badge db-listing" title="Listing"><i class="fa fa-clipboard"></i> Listing: <?= formatDate($ipo['ipo_listing']) ?></span> </div> <div class="timeline-bar" title="Progress: <?= $progress ?>%"> <div class="timeline-fill" style="width: <?= $progress ?>%"></div> </div> <?php endif; ?> </div> <?php endforeach; ?> </div> </form> </div> <script> new Sortable(document.getElementById('sortable-group'), { animation: 150, handle: '.sortable-item', ghostClass: 'sortable-ghost', chosenClass: 'sortable-chosen', onEnd: function (evt) { const inputs = document.querySelectorAll('.sortable-item input[name="order[]"]'); const ids = Array.from(inputs).map(i => i.closest('.sortable-item').dataset.id); inputs.forEach((input, idx) => input.value = ids[idx]); } }); </script> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 8.2.9 | Generation time: 1.11 |
proxy
|
phpinfo
|
Settings