Переглянути джерело

changes need acknowledgement

Bernn 1 тиждень тому
батько
коміт
d3cd67a590
5 змінених файлів з 40 додано та 5 видалено
  1. 2 0
      PDQ.php
  2. 16 0
      assets/app.css
  3. 8 0
      bin/jobs_update.php
  4. 6 0
      lib/db.php
  5. 8 5
      lib/render.php

+ 2 - 0
PDQ.php

@@ -45,6 +45,7 @@ window.PDQ = {
     <div id="jobs-table"><?= render_jobs_table('ICG') ?></div>
 </div>
 
+<div class="threads-container">
 <?php foreach ($vendors as $v):
     $vid = (int) $v['id'];
     $maxId = max_message_id($vid);
@@ -63,6 +64,7 @@ window.PDQ = {
     </form>
 </section>
 <?php endforeach; ?>
+</div>
 
 </body>
 </html>

+ 16 - 0
assets/app.css

@@ -78,6 +78,12 @@ tr.status-received { background: rgba(0, 0, 0, 0.04); color: var(--c-muted); }
     font-weight: 700;
     border-radius: 4px;
 }
+.ack-changed {
+    background: #ff9800;
+    color: #000;
+    font-weight: 700;
+    border-radius: 4px;
+}
 
 .editable {
     display: inline-block;
@@ -123,13 +129,23 @@ input.inline-edit {
 .received   { color: var(--c-muted); font-style: italic; }
 
 /* ----- messages ----- */
+.threads-container {
+    display: flex;
+    flex-wrap: wrap;
+    gap: 1rem;
+    align-items: flex-start;
+}
+
 .thread {
     border: 1px solid #ddd;
     border-radius: 6px;
     margin-bottom: 1.5rem;
     background: #fff;
+    width: 100%;
     max-width: 720px;
 }
+/* Inside the flex row on PDQ.php, gap handles spacing. */
+.threads-container > .thread { margin-bottom: 0; }
 .thread h2 {
     margin: 0;
     padding: 0.5rem 0.75rem;

+ 8 - 0
bin/jobs_update.php

@@ -85,4 +85,12 @@ if ($column === 'qty') {
 }
 
 apply_job_change($job, $column, $value, $actor);
+
+// An ICG edit to a content field bumps an already-acknowledged row back to
+// 'changed' so the vendor sees it at the top of their list. We leave 'new'
+// alone — the row still needs acknowledgement, just for a different reason.
+if ($job['ack'] === '') {
+    apply_job_change($job, 'ack', 'changed', $actor);
+}
+
 echo 'Success';

+ 6 - 0
lib/db.php

@@ -81,6 +81,12 @@ function db_migrate(PDO $pdo): void {
 
         $pdo->exec('PRAGMA user_version = 1');
     }
+
+    if ($version < 2) {
+        $pdo->prepare('INSERT INTO vendors(slug, name) VALUES(?, ?)')
+            ->execute(['hiep', 'Hiep']);
+        $pdo->exec('PRAGMA user_version = 2');
+    }
 }
 
 function find_vendor_by_slug(string $slug): ?array {

+ 8 - 5
lib/render.php

@@ -34,10 +34,10 @@ function render_jobs_table(string $audience, ?int $vendor_id = null): string {
         FROM jobs j
         JOIN vendors v ON v.id = j.vendor_id
         WHERE $where
-        ORDER BY (j.status = '') DESC,
+        ORDER BY (j.ack != '') DESC,
+                 (j.status = '') DESC,
                  (j.status = 'Finished') DESC,
                  (j.status = 'Shipped') DESC,
-                 (j.ack = 'new') DESC,
                  j.due_date IS NULL,
                  j.due_date ASC,
                  j.job
@@ -71,7 +71,10 @@ function render_jobs_table(string $audience, ?int $vendor_id = null): string {
             $editable = ($audience === 'ICG');
             $jobClass = strlen($r['job']) > 9 ? 'smaller' : '';
             $statusClass = $r['status'] !== '' ? 'status-' . strtolower($r['status']) : '';
-            $ackClass = $r['ack'] === 'new' ? 'ack-new' : '';
+            $ackClass = '';
+            $ackLabel = '';
+            if ($r['ack'] === 'new')      { $ackClass = 'ack-new';     $ackLabel = 'NEW'; }
+            elseif ($r['ack'] === 'changed') { $ackClass = 'ack-changed'; $ackLabel = 'CHANGED'; }
         ?>
             <tr data-job-id="<?= (int) $r['id'] ?>" class="<?= h($statusClass) ?>">
                 <td class="<?= h($jobClass) ?>"><?= render_field($r, 'job', $editable) ?></td>
@@ -80,7 +83,7 @@ function render_jobs_table(string $audience, ?int $vendor_id = null): string {
                 <td class="right"><?= render_field($r, 'qty', $editable) ?></td>
                 <td class="center"><?= render_due($r, $editable) ?></td>
                 <?php if ($audience === 'ICG'): ?><td><?= h($r['vendor_name']) ?></td><?php endif; ?>
-                <td class="center <?= h($ackClass) ?>"><?= $r['ack'] === 'new' ? 'NEW' : '' ?></td>
+                <td class="center <?= h($ackClass) ?>"><?= h($ackLabel) ?></td>
                 <td class="center"><?= render_status($r, $audience) ?></td>
                 <td class="center actions"><?= render_actions($r, $audience) ?></td>
             </tr>
@@ -138,7 +141,7 @@ function format_short_date(?string $ts): string {
 function render_actions(array $r, string $audience): string {
     $btns = [];
     if ($audience === 'vendor') {
-        if ($r['ack'] === 'new') {
+        if ($r['ack'] === 'new' || $r['ack'] === 'changed') {
             $btns[] = '<button class="btn btn-ack" data-action="acknowledge">Acknowledge</button>';
         }
         if ($r['status'] === '') {