<?php

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

    $getuser = mysqli_query($conn, "SELECT * FROM `passmain` WHERE `user`='$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['itemgrp'] == '') {
        $itemgrp = $none;
    }
    if ($guser['item'] == '') {
        $item = $none;
    }
    if ($guser['changeofrates'] == '') {
        $changeofrates = $none;
    }
    if ($guser['godown'] == '') {
        $godown = $none;
    }
    if ($guser['openbal'] == '') {
        $openbal = $none;
    }
    if ($guser['chcustdtl'] == '') {
        $chcustdtl = $none;
    }
    if ($guser['bank'] == '') {
        $bank = $none;
    }
    if ($guser['cash'] == '') {
        $cash = $none;
    }
    if ($guser['expense'] == '') {
        $expense = $none;
    }
    if ($guser['group'] == '') {
        $group = $none;
    }
    if ($guser['otherac'] == '') {
        $otherac = $none;
    }
    if ($guser['transport'] == '') {
        $transport = $none;
    }
    if ($guser['drawbank'] == '') {
        $drawbank = $none;
    }
    if ($guser['narration'] == '') {
        $narration = $none;
    }
    if (
            $guser['customer'] == '' && $guser['supplier'] == '' && $guser['itemgrp'] == '' && $guser['item'] == '' && $guser['changeofrates'] == ''
            && $guser['godown'] == '' && $guser['openbal'] == '' && $guser['chcustdtl'] == '' && $guser['bank'] == ''
            && $guser['cash'] == '' && $guser['expense'] == '' && $guser['group'] == '' && $guser['otherac'] == ''
            && $guser['transport'] == '' && $guser['drawbank'] == ''&& $guser['narration'] == ''
    ) {
        $master = $none;
    }

    ######################transactions######################
    if ($guser['purchase'] == '') {
        $purchase = $none;
    }
     if ($guser['sale'] == '') {
        $sale = $none;
    }
    if ($guser['purret'] == '') {
        $purret = $none;
    }
    if ($guser['saleret'] == '') {
        $saleret = $none;
    }
    if ($guser['ticredoth'] == '') {
        $ticredoth = $none;
    }
    if ($guser['tideboth'] == '') {
        $tideboth = $none;
    }
    if ($guser['inward'] == '') {
        $inward = $none;
    }
    if ($guser['outward'] == '') {
        $outward = $none;
    }
    if ($guser['tidamage'] == '') {
        $tidamage = $none;
    }
    if ($guser['transfer'] == '') {
        $transfer = $none;
    }
    if ($guser['bankrecp'] == '') {
        $bankrecp = $none;
    }
    if ($guser['bankpay'] == '') {
        $bankpay = $none;
    }
    if ($guser['cashrecp'] == '') {
        $cashrecp = $none;
    }
    if ($guser['cashpay'] == '') {
        $cashpay = $none;
    }
    if ($guser['journal'] == '') {
        $journal = $none;
    }
    if ($guser['contra'] == '' ) {
        $contra = $none;
    }


    if (
            $guser['purchase'] == '' && $guser['sale'] == '' && $guser['purret'] == '' && $guser['saleret'] == '' && $guser['ticredoth'] == ''
            && $guser['tideboth'] == '' && $guser['inward'] == '' && $guser['outward'] == '' && $guser['tidamage'] == ''
            && $guser['transfer'] == '' && $guser['bankrecp'] == '' && $guser['bankpay'] == '' && $guser['cashrecp'] == ''
            && $guser['cashpay'] == '' && $guser['journal'] == ''&& $guser['contra'] == ''
    ) {
        $transactions = $none;
    }
    ######################REPORTS######################

    if ($guser['stock'] == '') {
        $stock = $none;
    }
    if ($guser['stockall'] == '') {
        $stockall = $none;
    }
    if ($guser['inwout'] == '') {
        $inwout = $none;
    }
    if ($guser['bankrecorep'] == '') {
        $bankrecorep = $none;
    }
    if ($guser['itemwise'] == '') {
        $itemwise = $none;
    }
    if ($guser['itemwisesale'] == '') {
        $itemwisesale = $none;
    }
    if ($guser['leadparty'] == '') {
        $leadparty = $none;
    }
    if ($guser['dailyreport'] == '') {
        $dailyreport = $none;
    }
    if ($guser['itemgrpwisesale'] == '') {
        $itemgrpwisesale = $none;
    }
    if ($guser['ledger'] == '') {
        $ledger = $none;
    }
    if ($guser['cashbook'] == '') {
        $cashbook = $none;
    }
    if ($guser['bankbook'] == '') {
        $bankbook = $none;
    }
    if ($guser['jvbook'] == '') {
        $jvbook = $none;
    }
    if ($guser['contreg'] == '') {
        $contreg = $none;
    }
    if ($guser['chqrep'] == '') {
        $chqrep = $none;
    }
    if ($guser['amtrep'] == '') {
        $amtrep = $none;
    }
    if ($guser['expenserep'] == '') {
        $expenserep = $none;
    }
    
    
//    
    if (
            $guser['stock'] == '' 
            && $guser['stockall'] == '' 
            && $guser['inwout'] == ''
            && $guser['bankrecorep'] == ''
            && $guser['itemwise'] == '' 
            && $guser['itemwisesale'] == '' 
            && $guser['leadparty'] == ''
            && $guser['dailyreport'] == '' 
            && $guser['itemgrpwisesale'] == '' 
            && $guser['ledger'] == '' 
            && $guser['cashbook'] == ''
            && $guser['bankbook'] == '' 
            && $guser['jvbook'] == '' 
            && $guser['contreg'] == '' 
            && $guser['chqrep'] == ''
            && $guser['amtrep'] == ''
    ) {
        $reports = $none;
    } 
    ################### Registser ###################
    if ($guser['purreg'] == '') {
        $purreg = $none;
    }
     if ($guser['salereg'] == '') {
        $salereg = $none;
    }
    if ($guser['inwreg'] == '') {
        $inwreg = $none;
    }
    if ($guser['outreg'] == '') {
        $outreg = $none;
    }
    if ($guser['debreg'] == '') {
        $debreg = $none;
    }
    if ($guser['credreg'] == '') {
        $credreg = $none;
    }
    if ($guser['damreg'] == '') {
        $damreg = $none;
    }
    if ($guser['tranreg'] == '') {
        $tranreg = $none;
    }
    if ($guser['ticredothreg'] == '') {
        $ticredothreg = $none;
    }
    if (
            $guser['purreg'] == '' && $guser['salereg'] == '' && $guser['inwreg'] == '' && $guser['outreg'] == ''
            && $guser['debreg'] == '' && $guser['credreg'] == '' && $guser['damreg'] == '' && $guser['tranreg'] == ''
            && $guser['ticredothreg'] == '' 
    ) {
        $register = $none;
    }

    ################### Finalization ###################
    if ($guser['trbal'] == '') {
        $trbal = $none;
    }
    if ($guser['profit'] == '') {
        $profit = $none;
    }
    if ($guser['profshar'] == '') {
        $profshar = $none;
    }
    if ($guser['balsheet'] == '') {
        $balsheet = $none;
    }
    if (
            $guser['trbal'] == '' && $guser['profshar'] == '' && $guser['profit'] == '' && $guser['balsheet'] == ''
    ) {
        $finalization = $none;
    }
}
