<?php

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

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

    $none = "style='display:none'";
    
    ######## Masters ########
    
    if ($guser['customer'] == '') { $customer = $none; }
    if ($guser['supplier'] == '') { $supplier = $none; }
    if ($guser['agent'] == '') { $agent = $none; }
    if ($guser['bank'] == '') { $bank = $none; }
    if ($guser['cash'] == '') { $cash = $none; }
    if ($guser['setting'] == '') { $setting = $none; }
    
    if (
        $guser['customer'] == '' && $guser['supplier'] == '' && $guser['agent'] == '' && $guser['bank'] == '' && $guser['cash'] == '' && $guser['setting'] == ''
    ) {
        $master = $none;
    }

    ######## HR ########
    
    if ($guser['hr_ent'] == '') { $hr_ent = $none; }
    if ($guser['pending'] == '') { $pending = $none; }
    if ($guser['hrreg'] == '') { $hrreg = $none; }
    
    if (
        $guser['hr_ent'] == '' && $guser['pending'] == '' && $guser['hrreg'] == ''
    ) {
        $hr = $none;
    }
    
    ######## Courier ########
    
    if ($guser['courin'] == '') { $courin = $none; }
    if ($guser['courout'] == '') { $courout = $none; }
    if ($guser['pendppcour'] == '') { $pendppcour = $none; }
    
    if (
        $guser['courin'] == '' && $guser['courout'] == '' && $guser['pendppcour'] == ''
    ) {
        $courier = $none;
    }

    ######## Entries ########
    
    if ($guser['addnewvisa'] == '')     { $addnewvisa = $none; }
    if ($guser['submission_ent'] == '') { $submission_ent = $none; }
    if ($guser['stampdate_upd'] == '')  { $stampdate_upd = $none; }
    if ($guser['mofa_ent'] == '')       { $mofa_ent = $none; }
    if ($guser['release'] == '')        { $release = $none; }
    if ($guser['crm'] == '')            { $crm = $none; }
    if ($guser['movefile'] == '')       { $movefile = $none; }
    
    if (
        $guser['addnewvisa'] == '' && $guser['submission_ent'] == '' && $guser['stampdate_upd'] == '' && $guser['mofa_ent'] == '' && $guser['release'] == '' &&
        $guser['crm'] == '' && $guser['movefile'] == ''
    ) {
        $entries = $none;
    }
    
    ######## Immigration ########
    
    if ($guser['immig'] == '')     { $immig = $none; }
    if ($guser['immiglist'] == '') { $immiglist = $none; }
    
    if (
        $guser['immig'] == '' && $guser['immiglist'] == ''
    ) {
        $immigration = $none;
    }
   
    ######## Purchase ########
    
    if ($guser['tiktnew'] == '')     { $tiktnew = $none; }
    if ($guser['tiktnewreg'] == '')  { $tiktnewreg = $none; }
    if ($guser['agentreg'] == '')    { $agentreg = $none; }
    
    if (
        $guser['tiktnew'] == '' && $guser['tiktnewreg'] == '' && $guser['agentreg'] == ''
    ) {
        $purchase = $none;
    }
    
    ######## Invoice ########
    
    if ($guser['entinvoice'] == '') { $entinvoice = $none; }
    if ($guser['settent'] == '')    { $settent = $none; }
    if ($guser['agentreg'] == '')   { $agentreg = $none; }
    if ($guser['osbill'] == '')     { $osbill = $none; }
    if ($guser['settreg'] == '')     { $settreg = $none; }
    
    if (
        $guser['entinvoice'] == '' && $guser['agentreg'] == '' && $guser['osbill'] == '' && $guser['settent'] == '' && $guser['settreg'] == ''
    ) {
        $invoice = $none;
    }
    
    ######## Accounts ########
    
    if ($guser['agentreg'] == '') { $agentreg = $none; }
    if ($guser['bankrecp'] == '') { $bankrecp = $none; }
    if ($guser['bankpay'] == '')  { $bankpay = $none; }
    if ($guser['cashrecp'] == '') { $cashrecp = $none; }
    if ($guser['cashpay'] == '')  { $cashpay = $none; }
    if ($guser['ledger'] == '')   { $ledger = $none; }
    if ($guser['agentreg'] == '') { $agentreg = $none; }
    
    if (
        $guser['agentreg'] == '' && $guser['bankrecp'] == '' && $guser['bankpay'] == '' && $guser['cashrecp'] == '' && $guser['cashpay'] == '' && $guser['ledger'] == '' &&
        $guser['agentreg'] == ''

    ) {
        $accounts = $none;
    }
    
    ######## Reports ########
    
    if ($guser['visareg'] == '')       { $visareg = $none; }
    if ($guser['agentreg'] == '')      { $agentreg = $none; }
    if ($guser['submission'] == '')    { $submission = $none; }
    if ($guser['nonsubmission'] == '') { $nonsubmission = $none; }
    if ($guser['mofalist'] == '')      { $mofalist = $none; }
    
    if (
        $guser['visareg'] == '' && $guser['agentreg'] == '' && $guser['submission'] == '' && $guser['nonsubmission'] == '' && $guser['mofalist'] == ''
    ) {
        $reports = $none;
    }
    
    
    ######## Tools ########

    if ($guser['searchvisa'] == '') { $searchvisa = $none; }
    if ($guser['pastatus'] == '')   { $pastatus = $none; }


}
