| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <?php
- /**
- * dashboard/crop-analysis/animal-dietary-balance/animal-dietary-balance.php
- *
- * Animal dietary balance results display page.
- * Supports normal browser access (session login) and headless Chrome (ptoken).
- */
- require_once __DIR__ . '/../../../config/database.php';
- require_once __DIR__ . '/../../../lib/auth.php';
- require_once __DIR__ . '/../../../lib/print_auth.php';
- if (session_status() === PHP_SESSION_NONE) {
- session_start();
- }
- $recordId = (int) ($_GET['rid'] ?? 0);
- $randId = trim( $_GET['rand'] ?? '');
- $clientId = (int) ($_GET['cid'] ?? 0);
- $printMode = isset($_GET['print']) || isset($_GET['ptoken']);
- if (!$recordId || $randId === '') {
- http_response_code(400);
- die('Invalid request parameters');
- }
- $chromeAccess = authenticatePrintPage($recordId, $randId);
- $pdo = getDBConnection();
- $userId = $chromeAccess ? null : getCurrentUserId();
- $row = null;
- $stmt = $pdo->prepare('SELECT * FROM animal_records WHERE id = ? AND rand = ? LIMIT 1');
- $stmt->execute([$recordId, $randId]);
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- $h = fn($v) => htmlspecialchars((string)($v ?? ''), ENT_QUOTES, 'UTF-8');
- $today = date('jS F Y');
- $pageTitle = 'Animal Dietary Balance' . (!empty($row['client_name']) ? ' — ' . $row['client_name'] : '');
- $siteName = 'Crop Monitor';
- if (!$printMode) {
- include __DIR__ . '/../../../layouts/header.php';
- }
- ?>
- <link rel="stylesheet" href="/client-assets/home/css/graphPrint.css" media="print">
- <style>
- @media print {
- @page { size: A4 portrait; }
- body { min-width: 992px !important; }
- .container { min-width: 992px !important; }
- }
- .progress { border-radius: 0 !important; }
- </style>
- <div class="container" id="content">
- <?php if (!$row): ?>
- <div class="alert alert-danger mt-4">Record not found or access denied.</div>
- <?php else: ?>
- <!-- ── Header ──────────────────────────────────────────────────────────── -->
- <div class="row mb-2 mt-3">
- <div class="col-md-3">
- <img class="img-fluid" src="/client-assets/images/crop-monitor.png" alt="Crop Monitor">
- </div>
- </div>
- <table class="title w-100 mb-3 small">
- <tbody>
- <tr>
- <td class="text-end fw-bold text-nowrap">DATE:</td>
- <td><?= $h($today) ?></td>
- <td></td>
- <td class="text-end fw-bold text-nowrap">SAMPLE ID:</td>
- <td><?= $h($row['sample_id']) ?></td>
- </tr>
- <tr>
- <td class="text-end fw-bold text-nowrap">CLIENT:</td>
- <td><?= $h($row['client_name']) ?></td>
- <td></td>
- <td class="text-end fw-bold text-nowrap">DATE SAMPLED:</td>
- <td><?= $h($row['date_sampled']) ?></td>
- </tr>
- <tr>
- <td class="text-end fw-bold text-nowrap">LAB NO:</td>
- <td><?= $h($row['lab_no']) ?></td>
- <td></td>
- <td class="text-end fw-bold text-nowrap">SITE ID:</td>
- <td><?= $h($row['site_id']) ?></td>
- </tr>
- <tr>
- <td class="text-end fw-bold text-nowrap">ANALYSIS TYPE:</td>
- <td><?= $h($row['analysis_type'] ?? '') ?></td>
- <td></td>
- <td></td>
- <td></td>
- </tr>
- </tbody>
- </table>
- <!-- ── Action buttons ──────────────────────────────────────────────────── -->
- <?php if (!$printMode): ?>
- <div class="d-print-none mb-3 d-flex gap-2 flex-wrap">
- <a href="/dashboard/crop-analysis/animal-dietary-balance/animal-report.php?rid=<?= $recordId ?>&rand=<?= urlencode($randId) ?>&cid=<?= $clientId ?>"
- class="btn btn-outline-primary btn-sm">
- <i class="fas fa-file-alt me-1"></i>View Report
- </a>
- <a href="/pdf-files/headlessChrome_pdf.php?type=animal-analysis&rid=<?= $recordId ?>&rand=<?= urlencode($randId) ?>&cid=<?= $clientId ?>"
- class="btn btn-outline-secondary btn-sm">
- <i class="fas fa-file-pdf me-1"></i>PDF — Analysis
- </a>
- <a href="/pdf-files/headlessChrome_pdf.php?type=animal&rid=<?= $recordId ?>&rand=<?= urlencode($randId) ?>&cid=<?= $clientId ?>"
- class="btn btn-success btn-sm">
- <i class="fas fa-file-pdf me-1"></i>PDF — Analysis & Report
- </a>
- </div>
- <?php endif; ?>
- <div class="row">
- <div class="col-md-12 text-center fw-bold h4">ANIMAL DIETARY MINERAL BALANCE</div>
- </div>
- <hr class="p-1 m-1">
- <!-- Analysis calculation rows — pending PHP migration of animalAnalysisCalcs -->
- <div class="alert alert-info mt-3">
- <i class="fas fa-info-circle me-1"></i>
- Animal dietary analysis calculation display is pending full PHP migration.
- </div>
- <p>Note: The above assessment is for individual nutrient levels. The influence of nutrient interactions is not considered above.</p>
- <p><b>References:</b></p>
- <ul>
- <li>AFIA Laboratory Methods Manual v7 Appendix 2.2R(1), p93</li>
- <li>NRC Nutrient Requirements of Dairy Cattle. National Academy Press, Washington DC. 7th Revised Edition, 2001</li>
- <li>Milk Production from Pasture – Principles and Practices. Massey University, NZ, 2002</li>
- </ul>
- <?php endif; ?>
- </div><!-- /.container -->
|