<?php

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

    /////////////////////////////////////RIGHTS/////////////////////////////////////

    ################## REPORTS ##################

    // $stock = $_POST["stock"];
    // $inwout = $_POST["inwout"];
    // $invoicefs = $_POST["invoicefs"];
    // $invoicefm = $_POST["invoicefm"];
    // $slipqry = $_POST["slipqry"];
    // $vehqry = $_POST["vehqry"];
    // $ledger = $_POST["ledger"];
    // $bankbook = $_POST["bankbook"];
    // $cashbook = $_POST["cashbook"];
    // $payslip = $_POST["payslip"];
    // $chqqryno = $_POST["chqqryno"];
    // $chqqry = $_POST["chqqry"];
    // $accstmt = $_POST["accstmt"];
    // $expreg = $_POST["expreg"];
    // $replremd = $_POST["replremd"];
    // $recorep = $_POST["recorep"];
    // $dayrep = $_POST["dayrep"];
    // $recmulti = $_POST["recmulti"];
    // $receivablerep = $_POST["receivablerep"];
    // $payablerep = $_POST["payablerep"];
    // $salediff = $_POST["salediff"];
    // $tcsreg = $_POST["tcsreg"];
    // $tdsregsl = $_POST["tdsregsl"];
    // $tdsregpu = $_POST["tdsregpu"];
    // $envlop = $_POST["envlop"];

    // ################## REGISTERS ##################

    // $slipreg = $_POST["slipreg"];
    // $salereg = $_POST["salereg"];
    // $invreg = $_POST["invreg"];
    // $dreadreg = $_POST["dreadreg"];
    // $preadreg = $_POST["preadreg"];
    // $sreadreg = $_POST["sreadreg"];
    // $cacareg = $_POST["cacareg"];
    // $acccred = $_POST["acccred"];
    // $damreg = $_POST["damreg"];
    // $purreg = $_POST["purreg"];
    // $prgstreg = $_POST["prgstreg"];
    // $debnotereg = $_POST["debnotereg"];
    // $debothreg = $_POST["debothreg"];
    // $pendledr = $_POST["pendledr"];
    // $stktrnrg = $_POST["stktrnrg"];
    // $depinou = $_POST["depinou"];

    // ################## SUMMARIES ##################

    // $acmnsumm = $_POST["acmnsumm"];
    // $credsumm = $_POST["credsumm"];
    // $salesumm = $_POST["salesumm"];
    // $invsumm = $_POST["invsumm"];
    // $banksumm = $_POST["banksumm"];
    // $cashsumm = $_POST["cashsumm"];
    // $pursumm = $_POST["pursumm"];
    // $prodsumm = $_POST["prodsumm"];
    // $pgrpsumm_p = $_POST["pgrpsumm_p"];
    // $pgrpsumm_s = $_POST["pgrpsumm_s"];
    // $mon_prsl = $_POST["mon_prsl"];

    // ################## GST ##################

    // $gstr1_b2b = $_POST["gstr1_b2b"];
    // $gstr1_b2bl = $_POST["gstr1_b2bl"];
    // $gstr1_b2cs = $_POST["gstr1_b2cs"];

    // ################## MIS ##################

    // $shiftrep = $_POST["shiftrep"];
    // $daychart = $_POST["daychart"];
    // $rmrep = $_POST["rmrep"];
    // $rmrep_d = $_POST["rmrep_d"];
    // $prodsale = $_POST["prodsale"];
    // $grpsale = $_POST["grpsale"];
    // $creditac = $_POST["creditac"];
    // $ministk = $_POST["ministk"];
    // $vatmon = $_POST["vatmon"];
    // $vatmon_s = $_POST["vatmon_s"];
    // $gstr1_2 = $_POST["gstr1_2"];

    // ################## FINALISATION ##################

    // $closstk = $_POST["closstk"];
    // $trbal = $_POST["trbal"];
    // $profit = $_POST["profit"];
    // $profshar = $_POST["profshar"];
    // $balsheet = $_POST["balsheet"];
    ///////////////////////////////////// end refence for rights

    $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['cacacust'] == '') {
        $cacacust = $none;
    }
    if ($guser['prodgrp'] == '') {
        $prodgrp = $none;
    }
    if ($guser['product'] == '') {
        $product = $none;
    }
    if ($guser['changeofrates'] == '') {
        $changeofrates = $none;
    }
    if ($guser['unit'] == '') {
        $unit = $none;
    }
    if ($guser['pump'] == '') {
        $pump = $none;
    }
    if ($guser['stockoil'] == '') {
        $stockoil = $none;
    }
    if ($guser['credcard'] == '') {
        $credcard = $none;
    }
    if ($guser['tank'] == '') {
        $tank = $none;
    }
    if ($guser['dipconv'] == '') {
        $dipconv = $none;
    }
    if ($guser['openbal'] == '') {
        $openbal = $none;
    }
    if ($guser['supplier'] == '') {
        $supplier = $none;
    }
    if ($guser['shift'] == '') {
        $shift = $none;
    }
    if ($guser['department'] == '') {
        $department = $none;
    }
    if ($guser['staff'] == '') {
        $staff = $none;
    }
    if ($guser['vehiclemod'] == '') {
        $vehiclemod = $none;
    }
    if ($guser['mgroup'] == '') {
        $mgroup = $none;
    }
    if ($guser['bank'] == '') {
        $bank = $none;
    }
    if ($guser['cash'] == '') {
        $cash = $none;
    }
    if ($guser['expense'] == '') {
        $expense = $none;
    }
    if ($guser['other'] == '') {
        $other = $none;
    }
    if ($guser['gsttype'] == '') {
        $gsttype = $none;
    }
    if ($guser['drawbank'] == '') {
        $drawbank = $none;
    }
    if ($guser['narration'] == '') {
        $narration = $none;
    }

    if (
            $guser['customer'] == '' && $guser['cacacust'] == '' && $guser['prodgrp'] == '' && $guser['product'] == '' && $guser['changeofrates'] == '' 
            && $guser['unit'] == '' && $guser['pump'] == '' && $guser['stockoil'] == '' && $guser['credcard'] == '' && $guser['tank'] == ''
            && $guser['dipconv'] == '' && $guser['openbal'] == '' && $guser['supplier'] == '' && $guser['shift'] == '' && $guser['department'] == '' 
            && $guser['staff'] == '' && $guser['vehiclemod'] == '' && $guser['group'] == '' && $guser['bank'] == '' && $guser['cash'] == '' 
            && $guser['expense'] == '' && $guser['other'] == '' && $guser['gsttype'] == '' && $guser['drawbank'] == '' && $guser['narration'] == '' 
    ) {
        $master = $none;
    }

    ###################### TRANSACTIONS ######################
   

    if ($guser['sale'] == '') {
        $sale = $none;
    }
    if ($guser['salecash'] == '') {
        $salecash = $none;
    }
    if ($guser['cardsale'] == '') {
        $cardsale = $none;
    }
    if ($guser['cashandcarry'] == '') {
        $cashandcarry = $none;
    }
    if ($guser['pumpreading'] == '') {
        $pumpreading = $none;
    }
    if ($guser['stockreading'] == '') {
        $stockreading = $none;
    }
    if ($guser['dipread'] == '') {
        $dipread = $none;
    }
    if ($guser['purfuel'] == '') {
        $purfuel = $none;
    }
    if ($guser['purchoil'] == '') {
        $purchoil = $none;
    }
    if ($guser['debnote'] == '') {
        $debnote = $none;
    }
    if ($guser['deboth'] == '') {
        $deboth = $none;
    }
    if ($guser['damage'] == '') {
        $damage = $none;
    }
    if ($guser['bankrecp'] == '') {
        $bankrecp = $none;
    }
    if ($guser['bankpay'] == '') {
        $bankpay = $none;
    }
    if ($guser['cashrecp'] == '') {
        $cashrecp = $none;
    }
    if ($guser['cashpay'] == '') {
        $cashpay = $none;
    }
    if ($guser['cardrecp'] == '') {
        $cardrecp = $none;
    }
    if ($guser['contra'] == '') {
        $contra = $none;
    }
    if ($guser['discrecv'] == '') {
        $discrecv = $none;
    }
    if ($guser['jv'] == '') {
        $jv = $none;
    }
    if ($guser['bankrecon'] == '') {
        $bankrecon = $none;
    }
    if ($guser['rementry'] == '') {
        $rementry = $none;
    }
    if ($guser['slipent'] == '') {
        $slipent = $none;
    }
    
    if (
        $guser['sale'] == '' && $guser['salecash'] == '' && $guser['cardsale'] == '' && $guser['cashandcarry'] == '' && $guser['pumpreading'] == '' 
        && $guser['stockreading'] == '' && $guser['dipread'] == '' && $guser['purfuel'] == '' && $guser['purchoil'] == '' && $guser['debnote'] == ''
        && $guser['deboth'] == '' && $guser['damage'] == '' && $guser['bankrecp'] == '' && $guser['bankpay'] == '' && $guser['cashrecp'] == '' 
        && $guser['cashpay'] == '' && $guser['cardrecp'] == '' && $guser['contra'] == '' && $guser['discrecv'] == '' && $guser['jv'] == '' 
        && $guser['bankrecon'] == '' && $guser['rementry'] == '' && $guser['slipent'] == '' 
) {
    $transactions = $none;
}  
  ################## REPORTS #####################
  
    if ($guser['stock'] == '') {
        $stock = $none;
    }
    if ($guser['inwout'] == '') {
        $inwout = $none;
    }
    if ($guser['invoicefs'] == '') {
        $invoicefs = $none;
    }
    if ($guser['proforma'] == '') {
        $invoicefm = $none;
    }
    if ($guser['slipqry'] == '') {
        $slipqry = $none;
    }
    if ($guser['vehqry'] == '') {
        $vehqry = $none;
    }
    if ($guser['ledger'] == '') {
        $ledger = $none;
    }
    if ($guser['bankbook'] == '') {
        $bankbook = $none;
    }
    if ($guser['cashbook'] == '') {
        $cashbook = $none;
    }
    if ($guser['payslip'] == '') {
        $payslip = $none;
    }
    if ($guser['chqqryno'] == '') {
        $chqqryno = $none;
    }
    if ($guser['chqqry'] == '') {
        $chqqry = $none;
    }
    if ($guser['accstmt'] == '') {
        $accstmt = $none;
    }
    if ($guser['expreg'] == '') {
        $expreg = $none;
    }
    if ($guser['replremd'] == '') {
        $replremd = $none;
    }
    if ($guser['recorep'] == '') {
        $recorep = $none;
    }
    if ($guser['dayrep'] == '') {
        $dayrep = $none;
    }
    if ($guser['recmulti'] == '') {
        $recmulti = $none;
    }
    if ($guser['receivablerep'] == '') {
        $receivablerep = $none;
    }
    if ($guser['payablerep'] == '') {
        $payablerep = $none;
    }
    if ($guser['salediff'] == '') {
        $salediff = $none;
    }
    if ($guser['tcsreg'] == '') {
        $tcsreg = $none;
    }
    if ($guser['tdsregsl'] == '') {
        $tdsregsl = $none;
    }
    if ($guser['tdsregpu'] == '') {
        $tdsregpu = $none;
    }
    if ($guser['envlop'] == '') {
        $envlop = $none;
    }
    if (
            $guser['stock'] == '' && $guser['inwout'] == '' && $guser['invoicefs'] == '' && $guser['invoicefm'] == '' && $guser['slipqry'] == '' && $guser['vehqry'] == '' && $guser['ledger'] == '' && $guser['bankbook'] == '' && $guser['cashbook'] == '' && $guser['payslip'] == '' && $guser['chqqryno'] == '' && $guser['chqqry'] == '' && $guser['accstmt'] == '' && $guser['expreg'] == '' && $guser['replremd'] == '' && $guser['recorep'] == '' && $guser['dayrep'] == ''
            && $guser['recmulti'] == '' && $guser['receivablerep'] == '' && $guser['payablerep'] == '' && $guser['salediff'] == '' && $guser['tcsreg'] == '' && $guser['tdsregsl'] == '' && $guser['tdsregpu'] == '' && $guser['envlop'] == ''
    ) {
        $reports = $none;
    }

    ################## REGISTERS ###################
    
    if ($guser['slipreg'] == '') {
        $slipreg = $none;
    }
    if ($guser['salereg'] == '') {
        $salereg = $none;
    }
    if ($guser['invreg'] == '') {
        $invreg = $none;
    }
    if ($guser['dreadreg'] == '') {
        $dreadreg = $none;
    }
    if ($guser['preadreg'] == '') {
        $preadreg = $none;
    }
    if ($guser['sreadreg'] == '') {
        $sreadreg = $none;
    }
    if ($guser['cacareg'] == '') {
        $cacareg = $none;
    }
    if ($guser['acccred'] == '') {
        $acccred = $none;
    }
    if ($guser['damreg'] == '') {
        $damreg = $none;
    }
    if ($guser['purreg'] == '') {
        $purreg = $none;
    }
    if ($guser['prgstreg'] == '') {
        $prgstreg = $none;
    }
    if ($guser['debnotereg'] == '') {
        $debnotereg = $none;
    }
    if ($guser['debothreg'] == '') {
        $debothreg = $none;
    }
    if ($guser['pendledr'] == '') {
        $pendledr = $none;
    }
    if ($guser['stktrnrg'] == '') {
        $stktrnrg = $none;
    }
    if ($guser['depinou'] == '') {
        $depinou = $none;
    }
    if (
            $guser['slipreg'] == '' && $guser['salereg'] == '' && $guser['invreg'] == '' && $guser['dreadreg'] == '' && $guser['preadreg'] == '' && $guser['sreadreg'] == '' && $guser['cacareg'] == ''
            && $guser['acccred'] == '' && $guser['damreg'] == '' && $guser['purreg'] == '' && $guser['prgstreg'] == '' && $guser['debnotereg'] == '' && $guser['debothreg'] == '' && $guser['pendledr'] == '' && $guser['stktrnrg'] == '' && $guser['depinou'] == ''
    ) {
        $registers = $none;
    }

    ################### SUMMARIES ###################
    if ($guser['acmnsumm'] == '') {
        $acmnsumm = $none;
    }
    if ($guser['credsumm'] == '') {
        $credsumm = $none;
    }
    if ($guser['salesumm'] == '') {
        $salesumm = $none;
    }
    if ($guser['invsumm'] == '') {
        $invsumm = $none;
    }
    if ($guser['banksumm'] == '') {
        $banksumm = $none;
    }
    if ($guser['cashsumm'] == '') {
        $cashsumm = $none;
    }
    if ($guser['pursumm'] == '') {
        $pursumm = $none;
    }
    if ($guser['prodsumm'] == '') {
        $prodsumm = $none;
    }
    if ($guser['pgrpsumm_p'] == '') {
        $pgrpsumm_p = $none;
    }
    if ($guser['pgrpsumm_s'] == '') {
        $pgrpsumm_s = $none;
    }
    if ($guser['mon_prsl'] == '') {
        $mon_prsl = $none;
    }
    if (
            $guser['acmnsumm'] == '' && $guser['credsumm'] == '' && $guser['salesumm'] == '' && $guser['invsumm'] == '' && $guser['banksumm'] == '' && $guser['cashsumm'] == '' &&
            $guser['pursumm'] == '' && $guser['prodsumm'] == '' && $guser['pgrpsumm_p'] == '' && $guser['pgrpsumm_s'] == '' && $guser['mon_prsl'] == '' 
    ) {
        $summaries = $none;
    }

    ################### GST ###################

    if ($guser['gstr1_b2b'] == '') {
        $gstr1_b2b = $none;
    }
    if ($guser['gstr1_b2bl'] == '') {
        $gstr1_b2bl = $none;
    }
    if ($guser['gstr1_b2cs'] == '') {
        $gstr1_b2cs = $none;
    }
    if (
            $guser['gstr1_b2b'] == '' && $guser['gstr1_b2bl'] == '' && $guser['gstr1_b2cs'] == '' ) {
        $gst = $none;
    }

    ################### MIS ###################
    
    if ($guser['shiftrep'] == '') {
        $shiftrep = $none;
    }
    if ($guser['daychart'] == '') {
        $daychart = $none;
    }
    if ($guser['rmrep'] == '') {
        $rmrep = $none;
    }
    if ($guser['rmrep_d'] == '') {
        $rmrep_d = $none;
    }
    if ($guser['prodsale'] == '') {
        $prodsale = $none;
    }
    if ($guser['grpsale'] == '') {
        $grpsale = $none;
    }
    if ($guser['creditac'] == '') {
        $creditac = $none;
    }
    if ($guser['ministk'] == '') {
        $ministk = $none;
    }
    if ($guser['vatmon'] == '') {
        $vatmon = $none;
    }
    if ($guser['vatmon_s'] == '') {
        $vatmon_s = $none;
    }
    if ($guser['gstr1_2'] == '') {
        $gstr1_2 = $none;
    }
    if (
            $guser['shiftrep'] == '' && $guser['daychart'] == '' && $guser['rmrep'] == '' && $guser['rmrep_d'] == '' && $guser['prodsale'] == '' &&
            $guser['grpsale'] == '' && $guser['creditac'] == '' && $guser['ministk'] == '' && $guser['vatmon'] == '' && $guser['vatmon_s'] == '' &&
            $guser['gstr1_2'] == ''
    ) {
        $mis = $none;
    }
    ################### FINALIZATION ###################
    
    if ($guser['closstk'] == '') {
        $closstk = $none;
    }
    if ($guser['trbal'] == '') {
        $trbal = $none;
    }
    if ($guser['profit'] == '') {
        $profit = $none;
    }
    if ($guser['profshar'] == '') {
        $profshar = $none;
    }
    if ($guser['balsheet'] == '') {
        $balsheet = $none;
    }
    if (
            $guser['balsheet'] == '' && $guser['profshar'] == '' && $guser['profit'] == '' && $guser['trbal'] == '' && $guser['closstk'] == ''
    ) {
        $finalization = $none;
    }
}
