<?php
$where = "";
switch ($_SESSION['usrLevel']) {
    case 1:
        $where = " ((HEAD.dtSubmitDIR = '1000-01-01' AND HEAD.dtSubmitMGR <> '1000-01-01' AND HEAD.dtSubmitSPV <> '1000-01-01') OR 
                    (HEAD.strMailDIR=HEAD.strMailMGR AND HEAD.dtSubmitMGR = '1000-01-01' AND HEAD.dtSubmitSPV <> '1000-01-01') OR 
                    (HEAD.strMailDIR=HEAD.strMailSPV AND HEAD.dtSubmitSPV = '1000-01-01')) AND strMailDIR='" . $_SESSION['strEmail'] . "'
                    ";
        break;
    case 2:
        $where = " ((HEAD.dtSubmitMGR = '1000-01-01' AND HEAD.dtSubmitSPV <> '1000-01-01') OR 
                    (HEAD.strMailMGR=HEAD.strMailSPV AND HEAD.dtSubmitSPV = '1000-01-01')) AND strMailMGR='" . $_SESSION['strEmail'] . "' 
                    ";
        break;
    case 3:
        $where = " HEAD.dtSubmitSPV = '1000-01-01' AND strMailSPV='" . $_SESSION['strEmail'] . "'";
        break;
}

if ($where <> "") {
    $MySQLi = new MySQLi($strDBHostName, $strDBUsername, $strDBPassword, $strDBName);
    $query = "SELECT IFNULL(SUM(HEAD.stsAktif), '0') AS iJumlahItem 
            FROM tpc_h_lpbj AS HEAD 
            WHERE " . $where . " AND 
                HEAD.stsAktif = 1 
            "; // die($query);//echo $query; 
    $result = $MySQLi->query($query);
    $row = $result->fetch_array();
}

?>

<li class="nav-item">
    <a class="nav-link " href="index2.php">
        <i class="bi bi-grid"></i>
        <span>Dashboard</span>
    </a>
</li>

<li class="nav-item">
    <a class="nav-link collapsed" data-bs-target="#components-nav" data-bs-toggle="collapse" href="#">
        <i class="bi bi-cart3"></i><span>Pembelian</span><i class="bi bi-chevron-down ms-auto"></i>
    </a>
    <ul id="components-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav">

        <li>
            <a href="?menu=tambah-lpbj">
                <i class="bi bi-circle"></i><span>Tambah LPBJ</span>
            </a>
        </li>
        <li>
            <a href="?menu=laporan-lpbj">
                <i class="bi bi-circle"></i><span>Laporan LPBJ</span>
            </a>
        </li>
    </ul>
</li>