<?php

if (isset($_SESSION["username_" . $dbname])) {
    $user = $_SESSION["username_" . $dbname];
    $zdbroot = $_SESSION["zdbroot"];
    $zdir = $_SESSION["zdir"];

    $getuser = mysqli_query($conn, "SELECT * FROM `$zdbroot`.`passmain` WHERE `user`='$user'") or die(mysqli_error($conn));
    $guser = mysqli_fetch_array($getuser);
    $line = '';

    $none = "style='display:none'";


    ###################### Clinic ######################
    if ($guser['patient'] == '') {
        $patient = $none;
    }
    if ($guser['consult_ent'] == '') {
        $consult_ent = $none;
    }

    if (
        $guser['patient'] == '' && $guser['consult_ent'] == ''
    ) {
        $clinic = $none;
    }



    ###################### MASTERS ######################
    if ($guser['treatment'] == '') {
        $treatment = $none;
    }
    if ($guser['item'] == '') {
        $item = $none;
    }
    if ($guser['supplier'] == '') {
        $supplier = $none;
    }
    if ($guser['staff'] == '') {
        $staff = $none;
    }
    if ($guser['cash'] == '') {
        $cash = $none;
    }
    if ($guser['bank'] == '') {
        $bank = $none;
    }
    if ($guser['expense'] == '') {
        $expense = $none;
    }

    if (
        $guser['treatment'] == '' && $guser['item'] == '' && $guser['supplier'] == '' && $guser['staff'] == '' && $guser['cash'] == '' && $guser['bank'] == '' && $guser['expense'] == ''
    ) {
        $master = $none;
    }

    ###################### Entries ######################

    if ($guser['sale'] == '') {
        $sale = $none;
    }
    if ($guser['purchase'] == '') {
        $purchase = $none;
    }
    if ($guser['inward'] == '') {
        $inward = $none;
    }
    if ($guser['cashrecp'] == '') {
        $cashrecp = $none;
    }
    if ($guser['cashpay'] == '') {
        $cashpay = $none;
    }
    if ($guser['bankrecp'] == '') {
        $bankrecp = $none;
    }
    if ($guser['bankpay'] == '') {
        $bankpay = $none;
    }

    if (
        $guser['sale'] == '' && $guser['purchase'] == '' && $guser['cashrecp'] == '' && $guser['cashpay'] == '' && $guser['bankrecp'] == '' && $guser['bankpay'] == '' && $guser['inward'] == ''
    ) {
        $entries = $none;
    }
    ###################### REPORTS ######################

    if ($guser['stock'] == '') {
        $stock = $none;
    }
    if ($guser['inwout'] == '') {
        $inwout = $none;
    }
    if ($guser['ledger'] == '') {
        $ledger = $none;
    }
    if ($guser['cashbook'] == '') {
        $cashbook = $none;
    }
    if ($guser['bankbook'] == '') {
        $bankbook = $none;
    }
    if ($guser['salesummary'] == '') {
        $salesummary = $none;
    }
    if ($guser['pathistory'] == '') {
        $pathistory = $none;
    }
    if ($guser['gstrevenue'] == '') {
        $gstrevenue = $none;
    }

    if (
        $guser['stock'] == '' && $guser['gstrevenue'] == ''  && $guser['inwout'] == '' && $guser['ledger'] == '' && $guser['cashbook'] == '' && $guser['bankbook'] == '' && $guser['salesummary'] == '' && $guser['pathistory'] == ''
    ) {
        $reports = $none;
    }

    ################### Registser ###################
    if ($guser['purreg'] == '') {
        $purreg = $none;
    }
    if ($guser['salereg'] == '') {
        $salereg = $none;
    }
    if ($guser['consultreg'] == '') {
        $consultreg = $none;
    }
    if ($guser['inwardreg'] == '') {
        $inwardreg = $none;
    }
    if (
        $guser['purreg'] == '' && $guser['salereg'] == '' && $guser['consultreg'] == '' && $guser['inwardreg'] == ''
    ) {
        $register = $none;
    }

    ################### Finalization ###################
    if ($guser['mainsearch'] == '') {
        $mainsearch = $none;
    }
    if ($guser['calendar'] == '') {
        $calendar = $none;
    }
    if ($guser['revenue'] == '') {
        $revenue = $none;
        $schedcalendar = $none;
    }
    if ($guser['topselltreat'] == '') {
        $topselltreat = $none;
    }
    if ($guser['topsellmed'] == '') {
        $topsellmed = $none;
    }
    if ($guser['newappointment'] == '') {
        $newappointment = $none;
    }
    if ($guser['billing'] == '') {
        $billing = $none;
    }
}
