<?php

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

    $getuser = mysqli_query($conn, "SELECT * FROM `passmain` WHERE `user`='$user' and `spltype`='$spec'") or die(mysqli_error($conn));
    //    print table ($getuser);
    $guser = mysqli_fetch_array($getuser);
    $line = '';

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

    ################## MASTERS ##################

    //    $g = array("$guser[customer]","$guser[supplier]","$guser[openbal]","$guser[chcustdtl]","$guser[transport]","$guser[staff]");
    //    $f = array("$customer","$supplier","$openbal","$chcustdtl","$transport","$staff");
    //    $gl = count($g);
    //    for($x = 0; $x < $gl; $x++) {
    //        if($g[$x] == ''){
    //            $f[$x] = $none;
    //        }
    //    }
    if ($guser['customer'] == '') {
        $customer = $none;
    }
    if ($guser['supplier'] == '') {
        $supplier = $none;
    }
    if ($guser['openbal'] == '') {
        $openbal = $none;
    }
    if ($guser['chcustdtl'] == '') {
        $chcustdtl = $none;
    }

    if ($guser['transport'] == '') {
        $transport = $none;
    }
    if ($guser['staff'] == '') {
        $staff = $none;
    }

    if ($guser['unit'] == '') {
        $unit = $none;
    }
    if ($guser['color'] == '') {
        $color = $none;
    }
    if ($guser['rawmatgrp'] == '') {
        $rawmatgrp = $none;
    }
    if ($guser['rawmat'] == '') {
        $rawmat = $none;
    }
    if ($guser['rawchrateop'] == '') {
        $rawchrateop = $none;
    }
    if ($guser['itemgrp'] == '') {
        $itemgrp = $none;
    }
    if ($guser['item'] == '') {
        $item = $none;
    }

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

    if ($guser['chrateop'] == '') {
        $chrateop = $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['chrateop'] == '') {
        $chrateop = $none;
    }



    if (
        $guser['customer'] == '' && $guser['supplier'] == '' && $guser['openbal'] == '' && $guser['chcustdtl'] == ''
        && $guser['transport'] == '' && $guser['staff'] == '' && $guser['openbal'] == '' && $guser['transport'] == ''
        && $guser['courier'] == '' && $guser['staff'] == '' && $guser['unit'] == '' && $guser['color'] == ''
        && $guser['rawmatgrp'] == '' && $guser['rawmat'] == '' && $guser['rawchrateop'] == '' && $guser['itemgrp'] == ''
        && $guser['item'] == '' && $guser['chrateop'] == '' && $guser['bank'] == '' && $guser['agency'] == '' 
        && $guser['cash'] == '' && $guser['expense'] == '' && $guser['group'] == '' && $guser['otherac'] == ''
        && $guser['chrateop'] == ''
    ) {
        $master = $none;
    }


    ################## Raw Material #################

    //    if ($guser[Srawmaterial] == '') {
    //        $Srawmaterial = $none;
    //    }

    if ($guser['purchmat'] == '') {
        $purchmat = $none;
    }
    if ($guser['salematmulti'] == '') {
        $salematmulti = $none;
    }
    if ($guser['inwardraw'] == '') {
        $inwardraw = $none;
    }
    if ($guser['damagedraw'] == '') {
        $damagedraw = $none;
    }
    if ($guser['purchraw'] == '') {
        $purchraw = $none;
    }
    if ($guser['slmatreg'] == '') {
        $slmatreg = $none;
    }
    //    BROWSE($guser[slmatreg]);
    if ($guser['inwregraw'] == '') {
        $inwregraw = $none;
    }
    if ($guser['damregraw'] == '') {
        $damregraw = $none;
    }
    if ($guser['rawstock'] == '') {
        $rawstock = $none;
    }
    if ($guser['rawinwout'] == '') {
        $rawinwout = $none;
    }
    if ($guser['rawmatwise'] == '') {
        $rawmatwise = $none;
    }
    if ($guser['rawmatwisesale'] == '') {
        $rawmatwisesale = $none;
    }
    if ($guser['partygrpwisesaleraw'] == '') {
        $partygrpwisesaleraw = $none;
    }
    if ($guser['rawmgrpsl'] == '') {
        $rawmgrpsl = $none;
    }
    if (
        $guser['purchmat'] == '' && $guser['salematmulti'] == '' && $guser['inwardraw'] == '' && $guser['damagedraw'] == ''
        && $guser['purchraw'] == '' && $guser['slmatreg'] == '' && $guser['inwregraw'] == '' && $guser['damregraw'] == ''
        && $guser['rawstock'] == '' && $guser['rawinwout'] == '' && $guser['rawmatwise'] == '' && $guser['rawmatwisesale'] == ''
        //                && $guser['rawmatgrp'] == '' && $guser['rawmat'] == '' && $guser['rawchrateop'] == '' && $guser['itemgrp'] == ''
        && $guser['partygrpwisesaleraw'] == '' && $guser['rawmgrpsl'] == ''


    ) {
        $rawmaterial = $none;
    }



    ################## Products ##################
    if ($guser['purchase'] == '') {
        $purchase = $none;
    }
    if ($guser['sale'] == '') {
        $sale = $none;
    }
    if ($guser['reptaken'] == '') {
        $reptaken = $none;
    }
    if ($guser['creditnotemulti'] == '') {
        $creditnotemulti = $none;
    }
    //    browse($guser[creditnotemulti]);
    if ($guser['credoth'] == '') {
        $credoth = $none;
    }
    if ($guser['inwardgst'] == '') {
        $inwardgst = $none;
    }
    if ($guser['damagedgst'] == '') {
        $damagedgst = $none;
    }
    if ($guser['purchreg'] == '') {
        $purchreg = $none;
    }
    if ($guser['salereg'] == '') {
        $rgsale = $none;
    }
    if ($guser['reprecreg'] == '') {
        $reprecreg = $none;
    }
    if ($guser['crdgrreg'] == '') {
        $crdgrreg = $none;
    }
    //    browse($crdntreg);
    if ($guser['crdothreg'] == '') {
        $crdothreg = $none;
    }
    if ($guser['inwreg'] == '') {
        $rginward = $none;
    }
    if ($guser['damreg'] == '') {
        $rgdamaged = $none;
    }
    if ($guser['stock'] == '') {
        $rpstock = $none;
    }
    if ($guser['inwout'] == '') {
        $rphist = $none;
    }
    if ($guser['itemwise'] == '') {
        $rpitemwise = $none;
    }
    if ($guser['itemwisesale'] == '') {
        $rpitemwisesale = $none;
    }
    if ($guser['itemgrpwisesale'] == '') {
        $rpitemgrpwisesale = $none;
    }
    if ($guser['partygrpwise'] == '') {
        $rppartygrpwise = $none;
    }
    if ($guser['partygrpwisesale'] == '') {
        $rppartygrpwisesale = $none;
    }


    if (
        $guser['purchase'] == '' && $guser['sale'] == '' && $guser['reptaken'] == '' && $guser['creditnotemulti'] == ''
        && $guser['credoth'] == '' && $guser['inwardgst'] == '' && $guser['damagedgst'] == '' && $guser['purchreg'] == ''
        && $guser['salereg'] == '' && $guser['reprecreg'] == '' && $guser['crdgrreg'] == '' && $guser['crdothreg'] == ''
        && $guser['inwreg'] == '' && $guser['damreg'] == '' && $guser['stock'] == '' && $guser['inwout'] == ''
        && $guser['itemwise'] == '' && $guser['itemwisesale'] == '' && $guser['itemgrpwisesale'] == '' && $guser['partygrpwisesale'] == ''


    ) {
        $product = $none;
    }
    //     if ($guser[taxinv] == '') {
    //        $taxinv = $none;
    //    }
    //    if ($guser[transfer] == '') {
    //        $transfer = $none;
    //    }



    ############### ACCOUNT #####################
    if ($guser['account'] == '') {
        $account = $none;
    }
    if ($guser['bankrecp'] == '') {
        $bankrecp = $none;
    }
    if ($guser['bankpay'] == '') {
        $bankpay = $none;
    }
    if ($guser['cashrecp'] == '') {
        $cashrecp = $none;
    }
    if ($guser['cashpay'] == '') {
        $cashpay = $none;
    }
    if ($guser['contra'] == '') {
        $contra = $none;
    }
    if ($guser['journal'] == '') {
        $journal = $none;
    }
    if ($guser['ledger'] == '') {
        $rpledger = $none;
    }
    if ($guser['leadparty'] == '') {
        $rpleadparty = $none;
    }
    if ($guser['dailyreport'] == '') {
        $rpdailyreport = $none;
    }
    if ($guser['dailycashrp'] == '') {
        $dailycashrp = $none;
    }
    if ($guser['bankbook'] == '') {
        $rpbankbook = $none;
    }
    if ($guser['cashbook'] == '') {
        $rpcashbook = $none;
    }
    if ($guser['jvbook'] == '') {
        $jvbook = $none;
    }
    if (
        $guser['account'] == '' && $guser['bankrecp'] == '' && $guser['bankpay'] == '' && $guser['cashrecp'] == ''
        && $guser['cashpay'] == '' && $guser['contra'] == '' && $guser['journal'] == '' && $guser['ledger'] == ''
        && $guser['leadparty'] == '' && $guser['dailyreport'] == '' && $guser['dailycashrp'] == '' && $guser['bankbook'] == ''
        && $guser['cashbook'] == '' && $guser['jvbook'] == ''


    ) {
        $register = $none;
    }
    if (
        $guser['bankrecp'] == '' && $guser['bankpay'] == ''


    ) {
        $mbank = $none;
    }
    if (
        $guser['cashrecp'] == '' && $guser['cashpay'] == ''


    ) {
        $mcash = $none;
    }





    ################## REPORTS ##################
    if ($guser['stock'] == '') {
        $rpstock = $none;
    }
    if ($guser['inwout'] == '') {
        $rphist = $none;
    }
    if ($guser['vatrep'] == '') {
        $rpvat = $none;
    }
    if ($guser['ledger'] == '') {
        $rpledger = $none;
    }
    if ($guser['labels'] == '') {
        $rplabels = $none;
    }
    if ($guser['chqrep'] == '') {
        $rpchqnoqry = $none;
    }
    if ($guser['amtrep'] == '') {
        $rpamountqry = $none;
    }
    if ($guser['itemwise'] == '') {
        $rpitemwise = $none;
    }
    if ($guser['itemwisesale'] == '') {
        $rpitemwisesale = $none;
    }


    if ($guser['leadparty'] == '') {
        $rpleadparty = $none;
    }
    if ($guser['dailyreport'] == '') {
        $rpdailyreport = $none;
    }
    if ($guser['dailysalereport'] == '') {
        $rpdailysalereport = $none;
    }
    if ($guser['bankbook'] == '') {
        $rpbankbook = $none;
    }
    if ($guser['cashbook'] == '') {
        $rpcashbook = $none;
    }
    if ($guser['jvrep'] == '') {
        $rpjvrep = $none;
    }
    if ($guser['exprep'] == '') {
        $rpexpense = $none;
    }
    if ($guser['payablerep'] == '') {
        $rppayable = $none;
    }
    if ($guser['receivable'] == '') {
        $rpreceivable = $none;
    }
    if ($guser['reptaken'] == '') {
        $reptaken = $none;
    }



    ################## REGISTERS ##################
    if ($guser['purreg'] == '') {
        $rgpurch = $none;
    }
    if ($guser['salereg'] == '') {
        $rgsale = $none;
    }
    if ($guser['debnotreg'] == '') {
        $rgdebnote = $none;
    }
    if ($guser['debothreg'] == '') {
        $rgdeboth = $none;
    }
    if ($guser['crednotreg'] == '') {
        $rgcrednote = $none;
    }
    if ($guser['credothreg'] == '') {
        $rgcredoth = $none;
    }
    if ($guser['inwreg'] == '') {
        $rginward = $none;
    }
    if ($guser['outreg'] == '') {
        $rgoutward = $none;
    }
    if ($guser['damreg'] == '') {
        $rgdamaged = $none;
    }
    if ($guser['excreg'] == '') {
        $rgexcess = $none;
    }
    if ($guser['driverreg'] == '') {
        $rgdriver = $none;
    }
    if ($guser['taxinvreg'] == '') {
        $rgtaxinv = $none;
    }
    if ($guser['balreg'] == '') {
        $rgbalance = $none;
    }

    ################## TOOLS & DASHBOARD ##################
    if ($guser['trbal'] == '') {
        $fnbalance = $none;
    }
    if ($guser['profit'] == '') {
        $fnprofit = $none;
    }
    if ($guser['profshar'] == '') {
        $fnprofshar = $none;
    }
    if ($guser['balsheet'] == '') {
        $fnbalsheet = $none;
    }


    ################## TOOLS & DASHBOARD ##################
    if ($guser['compsetup'] == '') {
        $tlcompany = $none;
    }
    if ($guser['backup'] == '') {
        $tlbackup = $none;
    }
    if ($guser['profile'] == '') {
        $tlprofile = $none;
    }
    if ($guser['dstock'] == '') {
        $dstock = $none;
    }


    ################## New Fields ##################
    if ($guser['purexp'] == '') {
        $purexp = $none;
    }
    if ($guser['salegmul'] == '') {
        $salemul = $none;
    }
    if ($guser['dailycashrep'] == '') {
        $dailycashrep = $none;
    }
    if ($guser['purexpreg'] == '') {
        $purexpreg = $none;
    }
    if ($guser['purgstreg'] == '') {
        $purgstreg = $none;
    }
    if ($guser['salegstreg'] == '') {
        $salegstreg = $none;
    }
    if ($guser['salemulreg'] == '') {
        $salemulreg = $none;
    }
    if ($guser['b2brep'] == '') {
        $b2brep = $none;
    }
    if ($guser['b2bsmrep'] == '') {
        $b2bsmrep = $none;
    }
    if ($guser['b2blgrep'] == '') {
        $b2blgrep = $none;
    }
    if ($guser['gstcreddebrep'] == '') {
        $gstcreddebrep = $none;
    }
    if ($guser['gstcreddeburdrep'] == '') {
        $gstcreddeburdrep = $none;
    }
    if ($guser['gstexprep'] == '') {
        $gstexprep = $none;
    }
    if ($guser['gstadvrecdrep'] == '') {
        $gstadvrecdrep = $none;
    }
    if ($guser['gstadvadjrep'] == '') {
        $gstadvadjrep = $none;
    }
    if ($guser['gstnilrep'] == '') {
        $gstnilrep = $none;
    }
    if ($guser['gsthsnrep'] == '') {
        $gsthsnrep = $none;
    }
    if ($guser['gstdocrep'] == '') {
        $gstdocrep = $none;
    }
}
