<?php 
$url = $_SERVER['REQUEST_URI'];
$url_arr = explode('/', $url);
for ($i=0; $i < @count($url_arr); $i++) { 
    if($i > 2){   
        $str = $url_arr[$i];
        if(strpos($str,'list') !== false ){
            $url_arr[$i] = strtok($str, '?'); 
            $url_arr[$i] = $url_arr[$i]."1";
        }else{
            $url_arr[$i] = strtok($str, '?'); 
            $url_arr[$i] = $url_arr[$i]."2";
        }
    }
} 
?>
<style type="text/css">
    .ps {
        background: none;
    }
    .left-sidenav-menu li.mm-active .mm-active>a.active {
        color: #1761FE !important;
    }
</style>
        <!-- Left Sidenav -->
        <div class="left-sidenav">
            <!-- LOGO -->
            <div class="brand">
                <a href="javascript:void();" class="logo">
                    <!-- <span>
                        <img src="<?php echo DOCUMENT_ROOT_CLASS;?>assets/images/logo-sm.png" alt="logo-small" class="logo-sm">
                    </span> -->
                    <span>
                        <img src="<?php echo DOCUMENT_ROOT_CLASS;?>assets/images/accessystem-logo-long-white-og.png" alt="ACCESSYSTEM" class="logo-lg logo-light">
                        <img src="<?php echo DOCUMENT_ROOT_CLASS;?>assets/images/accessystem-logo-long.png" alt="ACCESSYSTEM" class="logo-lg logo-dark">
                    </span>
                </a>
            </div>
            <!--end logo-->
            <div class="menu-content h-100" data-simplebar>
                <ul class="metismenu left-sidenav-menu">
                    <!-- <li class="menu-label mt-0">Main</li> -->
                    <li>
                        <a href="<?php echo DOCUMENT_ROOT_CLASS;?>index.php"> <i data-feather="home" class="align-self-center menu-icon"></i><span>Dashboard</span></a>
                    </li>
                    <hr class="hr-dashed hr-menu">
                    <li class="menu-label my-2">Modules</li>
                    <!-- Start - Sales & Purchases ( Left Side Navigation Bar ) -->
                    <!-- Start - Sales & Purchases ( Left Side Navigation Bar ) -->
                    <?php 
                    $display = $commonFunctions->check_module_permission("Sales & Purchases",$_SESSION['roleid']);
                    if($display == 1 OR $_SESSION["role"] == "Super-Admin"){
                    ?>
                    <li>
                        <a href="javascript: void(0);"><i data-feather="grid" class="align-self-center menu-icon"></i><span>Sales & Purchases</span><span class="menu-arrow"><i class="mdi mdi-chevron-right"></i></span></a>
                        <ul class="nav-second-level" aria-expanded="false">
                            <li>
                                <a href="javascript: void(0);"><i class="ti-control-record"></i>Sales & Invoice <span class="menu-arrow left-has-menu"><i class="mdi mdi-chevron-right"></i></span></a>
                                <ul class="nav-second-level" aria-expanded="false">
                                    <li class="<?php echo (in_array('invoice.php1', $url_arr) OR in_array('invoice.php2', $url_arr) OR in_array('invoice-view.php2', $url_arr))?'mm-active':'';?>"><a href="<?php echo DOCUMENT_ROOT_CLASS;?>sales-purchases/sales-and-invoices/invoice.php?state=list"><i class="ti-control-record"></i>Sales & Invoices</a></li>

                                    <li class="<?php echo (in_array('quotation.php1', $url_arr) OR in_array('quotation.php2', $url_arr) OR in_array('quotation-view.php2', $url_arr))?'mm-active':'';?>" ><a href="<?php echo DOCUMENT_ROOT_CLASS;?>sales-purchases/sales-and-invoices/quotation.php?state=list"><i class="ti-control-record"></i>Quotations</a></li>

                                    <li class="<?php echo (in_array('delivery-note.php1', $url_arr) OR in_array('delivery-note.php2', $url_arr) OR in_array('delivery-note-view.php2', $url_arr) )?'mm-active':'';?>" ><a href="<?php echo DOCUMENT_ROOT_CLASS;?>sales-purchases/sales-and-invoices/delivery-note.php?state=list"><i class="ti-control-record"></i>Delivery Note</a></li>
                                    <li><a href="#"><i class="ti-control-record"></i>Un-Paid Invoices</a></li>
                                    <li><a href="#"><i class="ti-control-record"></i>Overdue Invoices</a></li>
                                </ul>
                            </li>

                            <li>
                                <a href="javascript: void(0);"><i class="ti-control-record"></i>Purchases <span class="menu-arrow left-has-menu"><i class="mdi mdi-chevron-right"></i></span></a>
                                <ul class="nav-second-level" aria-expanded="false">
                                    <li><a href="#"><i class="ti-control-record"></i>Purchase Order's</a></li>
                                    <li><a href="#"><i class="ti-control-record"></i>Purchase Invoices</a></li>
                                    <li><a href="#"><i class="ti-control-record"></i>Purchase Returns</a></li>
                                </ul>
                            </li>  
                            
                        </ul>
                    </li>
                    <?php } ?>
                    <!-- End - Sales & Purchases ( Left Side Navigation Bar ) -->

                    <!-- Start - CRM ( Left Side Navigation Bar ) -->
                    <?php 
                    $display = $commonFunctions->check_module_permission("CRM",$_SESSION['roleid']);
                    if($display == 1 OR $_SESSION["role"] == "Super-Admin"){
                    ?>
                    <li>
                        <a href="javascript: void(0);"><i data-feather="lock" class="align-self-center menu-icon"></i><span>CRM</span><span class="menu-arrow"><i class="mdi mdi-chevron-right"></i></span></a>
                        <ul class="nav-second-level" aria-expanded="false">
                            <li class="nav-item <?php echo (in_array('customer.php2', $url_arr))?'mm-active':'';?> <?php echo (in_array('customer.php1', $url_arr))?'mm-active':'';?>"><a class="nav-link" href="<?php echo DOCUMENT_ROOT_CLASS;?>crm/customer.php?state=customer-list"><i class="ti-control-record"></i>Customer List</a></li>

                            <li class="nav-item <?php echo (in_array('address-book.php1', $url_arr))?'mm-active':'';?> "><a class="nav-link" href="<?php echo DOCUMENT_ROOT_CLASS;?>crm/address-book.php?state=list"><i class="ti-control-record"></i>Contact Book</a></li>

                            <li class="nav-item"><a class="nav-link" href="#"><i class="ti-control-record"></i>Leads</a></li>

                            <li class="nav-item <?php echo (in_array('category.php1', $url_arr) and in_array('crm', $url_arr) )?'mm-active':'';?>"><a class="nav-link" href="<?php echo DOCUMENT_ROOT_CLASS;?>crm/category.php?state=list"><i class="ti-control-record"></i>Customer Categories / Tags</a></li>
                        </ul>
                    </li> 
                    <?php } ?>
                    <!-- End - CRM ( Left Side Navigation Bar ) -->

                    <!-- Start - Products & Services ( Left Side Navigation Bar ) -->
                    <?php 
                    $display = $commonFunctions->check_module_permission("Products & Services",$_SESSION['roleid']);
                    if($display == 1 OR $_SESSION["role"] == "Super-Admin"){
                    ?>
                    <li>
                        <a href="javascript: void(0);"><i data-feather="grid" class="align-self-center menu-icon"></i><span>Products & Services</span><span class="menu-arrow"><i class="mdi mdi-chevron-right"></i></span></a>
                        <ul class="nav-second-level" aria-expanded="false">
                            <li class="<?php echo (in_array('products', $url_arr))?'mm-active':'';?>">
                                <a href="javascript: void(0);"><i class="fas fa-archive"></i>Products <span class="menu-arrow left-has-menu"><i class="mdi mdi-chevron-right"></i></span></a>
                                <ul class="nav-second-level" aria-expanded="false">
                                    <li class="<?php echo (in_array('product.php1', $url_arr) OR in_array('product-card.php2', $url_arr))?'mm-active':'';?>" ><a href="<?php echo DOCUMENT_ROOT_CLASS;?>product-services/products/product.php?state=list"><i class="ti-control-record"></i>Product List</a></li>
                                    <li class="<?php echo (in_array('product-category.php1', $url_arr))?'mm-active':'';?>"><a href="<?php echo DOCUMENT_ROOT_CLASS;?>product-services/products/product-category.php?state=list"><i class="ti-control-record"></i>Products Categories / Tags</a></li>
                                    <li class="<?php echo (in_array('product-variant.php1', $url_arr))?'mm-active':'';?>" ><a href="<?php echo DOCUMENT_ROOT_CLASS;?>product-services/products/product-variant.php?state=list"><i class="ti-control-record"></i>Products Variant / Attributes</a></li>
                                </ul>
                            </li>

                            <li class="<?php echo (in_array('services', $url_arr))?'mm-active':'';?>">
                                <a href="javascript: void(0);"><i class="ti-control-record"></i>Services <span class="menu-arrow left-has-menu"><i class="mdi mdi-chevron-right"></i></span></a>
                                <ul class="nav-second-level" aria-expanded="false">
                                    <li class="<?php echo (in_array('services.php1', $url_arr) OR in_array('services-card.php2', $url_arr) )?'mm-active':'';?>"><a href="<?php echo DOCUMENT_ROOT_CLASS;?>product-services/services/services.php?state=list"><i class="ti-control-record"></i>Services List</a></li>
                                    <li class="<?php echo (in_array('services-category.php1', $url_arr))?'mm-active':'';?>" ><a href="<?php echo DOCUMENT_ROOT_CLASS;?>product-services/services/services-category.php?state=list"><i class="ti-control-record"></i>Services Categories / Tags</a></li>
                                    <li class="<?php echo (in_array('services-variant.php1', $url_arr))?'mm-active':'';?>"><a href="<?php echo DOCUMENT_ROOT_CLASS;?>product-services/services/services-variant.php?state=list"><i class="ti-control-record"></i>Services Variant / Attributes</a></li>
                                </ul>
                            </li>

                            <li>
                                <a href="javascript: void(0);"><i class="fas fa-piggy-bank align-self-center menu-icon"></i>Inventory<span class="menu-arrow left-has-menu"><i class="mdi mdi-chevron-right"></i></span></a>
                                <ul class="nav-second-level" aria-expanded="false">
                                    <li class="<?php echo (in_array('inventory.php1', $url_arr) OR in_array('inventory.php2', $url_arr))?'mm-active':'';?>"><a href="<?php echo DOCUMENT_ROOT_CLASS;?>product-services/inventory/inventory.php?state=list"><i class="ti-control-record"></i>Inventory & Stock List</a></li>
                                    <li class="<?php echo (in_array('stock-movements.php1', $url_arr) OR in_array('stock-movements.php2', $url_arr))?'mm-active':'';?>"><a href="<?php echo DOCUMENT_ROOT_CLASS;?>product-services/inventory/stock-movements.php?state=list"><i class="ti-control-record"></i>Stock Movement</a></li>
                                    <li class="<?php echo (in_array('inventory-correction.php1', $url_arr) OR in_array('inventory-correction.php2', $url_arr))?'mm-active':'';?>"><a href="<?php echo DOCUMENT_ROOT_CLASS;?>product-services/inventory/inventory-correction.php?state=list"><i class="ti-control-record"></i>Stock Correction</a></li>
                                </ul>
                            </li>  

                            <li>
                                <a href="javascript: void(0);"><i class="fas fa-warehouse align-self-center menu-icon"></i>Warehouses <span class="menu-arrow left-has-menu"><i class="mdi mdi-chevron-right"></i></span></a>
                                <ul class="nav-second-level" aria-expanded="false">
                                    <li class="<?php echo (in_array('warehouse.php1', $url_arr))?'mm-active':'';?>"><a href="<?php echo DOCUMENT_ROOT_CLASS;?>product-services/warehouse/warehouse.php?state=list"><i class="ti-control-record"></i>Warehouses List</a></li>
                                </ul>
                            </li>

                            <li>
                                <a href="javascript: void(0);"><i class="fas fa-shipping-fast align-self-center menu-icon"></i>Shipment & Logistics <span class="menu-arrow left-has-menu"><i class="mdi mdi-chevron-right"></i></span></a>
                                <ul class="nav-second-level" aria-expanded="false">
                                    <!-- <li class="<?php echo (in_array('shipment.php1', $url_arr))?'mm-active':'';?>"><a href="<?php echo DOCUMENT_ROOT_CLASS;?>product-services/shipment/shipment.php?state=list"><i class="ti-control-record"></i>Shipment & Logistics List</a></li> -->
                                    <li class="<?php echo (in_array('shipment.php1', $url_arr))?'mm-active':'';?>"><a href="#"><i class="ti-control-record"></i>Shipment & Logistics List</a></li>
                                    <li><a href="#"><i class="ti-control-record"></i>Shipment & Logistics Statistics</a></li>
                                </ul>
                            </li>
                            
                        </ul>
                    </li>
                    <!-- End - Products & Services ( Left Side Navigation Bar ) -->
                    <?php } 

                    $display = $commonFunctions->check_module_permission("Vendor & Suppliers",$_SESSION['roleid']);
                    if($display == 1 OR $_SESSION["role"] == "Super-Admin"){
                    ?>
                    <!-- Start - Vendor & Suppliers( Left Side Navigation Bar ) -->
                    <li>
                        <a href="javascript: void(0);"><i data-feather="lock" class="align-self-center menu-icon"></i><span>Vendor & Suppliers</span><span class="menu-arrow"><i class="mdi mdi-chevron-right"></i></span></a>
                        <ul class="nav-second-level" aria-expanded="false">
                            <li class="nav-item <?php echo (in_array('vendor.php1', $url_arr) OR in_array('vendor.php2', $url_arr) OR in_array('vendor-card.php1', $url_arr) OR in_array('vendor-card.php2', $url_arr) )?'mm-active':'';?>"><a class="nav-link" href="<?php echo DOCUMENT_ROOT_CLASS;?>supplier-vendor/vendor.php?state=list"><i class="ti-control-record"></i>Vendor & Suppliers List</a></li>
                            <li class="nav-item <?php echo (in_array('purchase-order.php2', $url_arr))?'mm-active':'';?>"><a class="nav-link" href="<?php echo DOCUMENT_ROOT_CLASS;?>supplier-vendor/purchase-order.php?state=form"><i class="ti-control-record"></i>Purchase Order's</a></li>
                            <li class="nav-item"><a class="nav-link" href="#"><i class="ti-control-record"></i>Purchase Invoices</a></li>
                            <li class="nav-item"><a class="nav-link" href="#"><i class="ti-control-record"></i>Purchase Returns</a></li>

                            <li class="nav-item <?php echo (in_array('category.php1', $url_arr) and in_array('vendor', $url_arr) )?'mm-active':'';?>"><a class="nav-link" href="<?php echo DOCUMENT_ROOT_CLASS;?>supplier-vendor/category.php?state=list"><i class="ti-control-record"></i>Vendor & Suppliers - Categories / Tags</a></li>
                        </ul>
                    </li> 
                    <!-- End - Vendor & Suppliers ( Left Side Navigation Bar ) -->
                    <?php } 
                    $display = $commonFunctions->check_module_permission("Finance & Accounts",$_SESSION['roleid']);
                    if($display == 1 OR $_SESSION["role"] == "Super-Admin"){
                    ?>
                    <!-- Start - Finance & Accounts ( Left Side Navigation Bar ) -->
                    <li>
                        <a href="javascript: void(0);"><i data-feather="grid" class="align-self-center menu-icon"></i><span>Finance & Accounts</span><span class="menu-arrow"><i class="mdi mdi-chevron-right"></i></span></a>
                        <ul class="nav-second-level" aria-expanded="false">
                            <li>
                                <a href="javascript: void(0);"><i class="ti-control-record"></i>Finance <span class="menu-arrow left-has-menu"><i class="mdi mdi-chevron-right"></i></span></a>
                                <ul class="nav-second-level" aria-expanded="false">
                                    <li><a href="#"><i class="ti-control-record"></i>Bank Accounts</a></li>
                                    <li><a href="#"><i class="ti-control-record"></i>Cash Accounts</a></li>
                                    <li><a href="#"><i class="ti-control-record"></i>E-Commerce Accounts</a></li>
                                    <li><a href="#"><i class="ti-control-record"></i>Wallet Accounts</a></li>
                                </ul>
                            </li>

                            <li>
                                <a href="javascript: void(0);"><i class="ti-control-record"></i>Accounting <span class="menu-arrow left-has-menu"><i class="mdi mdi-chevron-right"></i></span></a>
                                <ul class="nav-second-level" aria-expanded="false">
                                    <li><a href="#"><i class="ti-control-record"></i>General Ledger</a></li>
                                    <li><a href="#"><i class="ti-control-record"></i>TAXES</a></li>
                                    <li><a href="#"><i class="ti-control-record"></i>Multi Currency</a></li>
                                    
                                    <li class="nav-item <?php echo ( in_array('payment-voucher.php1', $url_arr) OR in_array('view-payment-voucher.php1', $url_arr) OR in_array('view-payment-voucher.php2', $url_arr) OR in_array('create-payment-voucher.php1', $url_arr) OR in_array('create-payment-voucher.php2', $url_arr) OR in_array('payment-voucher-card.php2', $url_arr) )?'mm-active':'';?> "><a class="nav-link" href="<?php echo DOCUMENT_ROOT_CLASS;?>accounts-basic/payment-voucher.php?state=list"><i class="ti-control-record"></i>Payment Voucher</a></li>

                                    <li class="nav-item <?php echo ( in_array('receipt-voucher.php1', $url_arr) OR in_array('view-receipt-voucher.php1', $url_arr) OR in_array('view-receipt-voucher.php2', $url_arr) OR in_array('create-receipt-voucher.php1', $url_arr) OR in_array('create-receipt-voucher.php2', $url_arr) OR in_array('receipt-voucher-card.php2', $url_arr) )?'mm-active':'';?> "><a class="nav-link" href="<?php echo DOCUMENT_ROOT_CLASS;?>accounts-basic/receipt-voucher.php?state=list"><i class="ti-control-record"></i>Receipt Voucher</a></li>

                                </ul>
                            </li>
                            
                        </ul>
                    </li>
                    <!-- End - Finance & Accounts ( Left Side Navigation Bar ) -->
                    <?php } 
                    $display = $commonFunctions->check_module_permission("HR Management",$_SESSION['roleid']);
                    if($display == 1 OR $_SESSION["role"] == "Super-Admin"){
                    ?>
                    <!-- Start - HR Management ( Left Side Navigation Bar ) -->
                    <li>
                        <a href="javascript: void(0);"><i data-feather="lock" class="align-self-center menu-icon"></i><span>HR Management</span><span class="menu-arrow"><i class="mdi mdi-chevron-right"></i></span></a>
                        <ul class="nav-second-level" aria-expanded="false">
                            <li class="nav-item <?php echo (in_array('staff.php1', $url_arr) OR in_array('staff-card.php2', $url_arr) OR in_array('staff-card.php1', $url_arr) OR in_array('staff-form.php2', $url_arr) OR in_array('staff-form.php1', $url_arr) OR in_array('staff.php2', $url_arr) )?'mm-active':'';?>"><a class="nav-link" href="<?php echo DOCUMENT_ROOT_CLASS;?>hrm-basic/staff.php?state=list"><i class="ti-control-record"></i>Staff Details</a></li>
                            <li class="nav-item"><a class="nav-link" href="#"><i class="ti-control-record"></i>Leave Request</a></li>
                            <li class="nav-item"><a class="nav-link" href="#"><i class="ti-control-record"></i>Payroll & Benefits</a></li>
                            <li class="nav-item"><a class="nav-link" href="#"><i class="ti-control-record"></i>Attendance</a></li>
                        </ul>
                    </li> 
                    <!-- End - HR Management ( Left Side Navigation Bar ) -->
                    <?php } ?>
                    <hr class="hr-dashed hr-menu">
                    <?php
                    $display = $commonFunctions->check_module_permission("Company",$_SESSION['roleid']);
                    if($display == 1 OR $_SESSION["role"] == "Super-Admin"){
                    ?>
                    <li class="menu-label my-2">Admin & Settings</li>
                    <!-- Start - ERP Organization ( Left Side Navigation Bar ) -->
                    <li>
                        <a href="javascript: void(0);"><i data-feather="lock" class="align-self-center menu-icon"></i><span>Company</span><span class="menu-arrow"><i class="mdi mdi-chevron-right"></i></span></a>
                        <ul class="nav-second-level" aria-expanded="false">
                            <li class="nav-item <?php echo (in_array('organization.php1', $url_arr))?'mm-active':'';?>"><a class="nav-link" href="<?php echo DOCUMENT_ROOT_CLASS;?>admin-setting/organization/organization.php?state=list"><i class="ti-control-record"></i>Company Details</a></li>
                            <li class="nav-item"><a class="nav-link" href="#"><i class="ti-control-record"></i>Branches</a></li>
                        </ul>
                    </li> 
                    <!-- End - ERP Organization ( Left Side Navigation Bar ) -->
                    <?php } ?>
                    <?php
                    $display = $commonFunctions->check_module_permission("User Settings",$_SESSION['roleid']);
                    if($display == 1 OR $_SESSION["role"] == "Super-Admin"){
                    ?>
                    <!-- Start - User Settings ( Left Side Navigation Bar ) -->
                    <li>
                        <a href="javascript: void(0);"><i class="fas fa-user-cog align-self-center"></i><span>User Settings</span><span class="menu-arrow"><i class="mdi mdi-chevron-right"></i></span></a>
                        <ul class="nav-second-level" aria-expanded="false">
                            <li class="nav-item <?php echo ( in_array('users.php1', $url_arr) OR in_array('users-card.php2', $url_arr) )?'mm-active':'';?>"><a class="nav-link" href="<?php echo DOCUMENT_ROOT_CLASS;?>admin-setting/users.php?state=list"><i class="fas fa-users"></i>User List</a></li>
                            <li class="nav-item"><a class="nav-link" href="#"><i class="ti-control-record"></i> User Email Settings</a></li>
                        </ul>
                    </li> 
                    <!-- End - User Settings ( Left Side Navigation Bar ) --> 
                    <?php } ?>
                    <?php
                    $display = $commonFunctions->check_module_permission("Module Settings",$_SESSION['roleid']);
                    if($display == 1 OR $_SESSION["role"] == "Super-Admin"){
                    ?>
                    <!-- Start - Module Settings ( Left Side Navigation Bar ) -->
                    <li>
                        <a href="javascript: void(0);"><i class="fas fa-folder align-self-center"></i><span>Module Settings</span><span class="menu-arrow"><i class="mdi mdi-chevron-right"></i></span></a>
                        <ul class="nav-second-level" aria-expanded="false">
                            <?php if(@$_SESSION["role"] == "Super-Admin"){ ?>
                                <li class="nav-item"><a class="nav-link <?php echo ( in_array('module-permission.php1', $url_arr) OR in_array('module-permission.php2', $url_arr) )?'mm-active':'';?>" href="<?php echo DOCUMENT_ROOT_CLASS;?>admin-setting/module-permission.php?state=list"><i class="fas fa-unlock"></i>Module Permissions</a></li>
                            <?php } ?>

                            <li class="nav-item <?php echo (in_array('setup.php2', $url_arr))?'mm-active':'';?>"><a class="nav-link" href="<?php echo DOCUMENT_ROOT_CLASS;?>dictionary/setup.php"><i class="fas fa-brain"></i>Module List</a></li>
                            <li class="nav-item"><a class="nav-link" href="#"><i class="fas fa-cogs"></i>Email Settings</a></li>
                            <li class="nav-item"><a class="nav-link" href="#"><i class="fas fa-file-signature"></i>Tamplates</a></li>
                            <li class="nav-item"><a class="nav-link" href="#"><i class="fas fa-barcode"></i>Barcode</a></li>
                        </ul>
                    </li> 
                    <!-- End - Module Settings ( Left Side Navigation Bar ) --> 
                    <?php } ?>
                    
    
                    <div class="update-msg text-center">
                        <a href="javascript: void(0);" class="float-right close-btn text-muted" data-dismiss="update-msg" aria-label="Close" aria-hidden="true">
                            <i class="mdi mdi-close"></i>
                        </a>
                        <h5 class="mt-3">Infidux ERP & CRM</h5>
                        <p class="mb-3">Solution for your Business</p>
                        <a href="javascript: void(0);" class="btn btn-outline-warning btn-sm">Upgrade your plan</a>
                    </div>

                </ul>
            </div>
        </div>
        <!-- end left-sidenav-->