<?php
require ("includes/check_auth_user.php");
require ("includes/dbconnect.php");
include ('includes/function.php');

include("includes/menu_rights.php");
$admin = $_SESSION["admin_" . $dbname];
$usertype = $_SESSION["usertype_" . $dbname];

//browse($usertype);
if ($usertype != 1) {
    include("includes/menu_rights.php");
}
$zroot = $_SESSION["zdir"];
//browse($zroot);
$src = "";
$ttl = "";
$action = isset($_GET["action"]) ? $_GET["action"] : "";
switch ($action) {

    ####################### MASTERS ##########################
    case "customer";
        $src = "customer.php?mode=last";
        $ttl = 'Customer';
        break;

    case "supplier";
        $src = "supplier.php?mode=last";
        $ttl = 'Supplier';

        break;

    case "openbal";
        $src = "openbal.php?mode=last";
        $ttl = 'Opening Balance';
        break;

    case "chcustdtls";
        $src = "chcustdtls.php?mode=last";
        $ttl = 'Change Customer Details';
        break;

    case "transport";
        $src = "transport.php?mode=last";
        $ttl = 'Transporter';
        break;

    case "unit";
        $src = "unit.php?mode=last";
        $ttl = 'Unit';
        break;

    case "color";
        $src = "color.php?mode=last";
        $ttl = 'Colour';
        break;

    case "chrateop";
        $src = "openstock.php?mode=last";
        $ttl = 'Opening Stock';
        break;

    case "item";
        $src = "itemmain.php?mode=last";
        $ttl = 'Item';
        break;

    case "itemgrp";
        $src = "itemgrp.php?mode=last";
        $ttl = 'Item Group';
        break;


    case "itsubgrp";
        $src = "itsubgrp.php?mode=last";
        $ttl = 'Item Sub Group';
        break;

    case "expense";
        $src = "expense.php?mode=last";
        $ttl = 'Expense';
        break;

    case "driver";
        $src = "driver.php?mode=last";
        $ttl = 'Driver';
        break;

    case "staff";
        $src = "staff.php?mode=last";
        $ttl = 'Staff';
        break;

    case "rawmat";
        $src = "rawmat.php?mode=last";
        $ttl = 'Raw Material';
        break;

    case "godown";
        $src = "godown.php?mode=last";
        $ttl = 'Godown';
        break;

    case "transport";
        $src = "transport.php?mode=last";
        break;

    case "group";
        $src = "grpmast.php?mode=last";
        $ttl = 'Group Master';
        break;

    case "otherac";
        $src = "otherac.php?mode=last";
        $ttl = 'Other A/c';
        break;

    case "bank";
        $src = "bank.php?mode=last";
        $ttl = 'Bank';
        break;

    case "cash";
        $src = "cash.php?mode=last";
        $ttl = 'Cash';
        break;

    case "saletype";
        $src = "saletype.php?mode=last";
        $ttl = 'Sale Type';
        break;

    ####################### TRANSACTION ##########################
    
    case "purchgst";
        $src = "purchgst.php?mode=last";
        $ttl = 'Purchase Expense';
        break;

    case "salegst";
        $src = "salegstmulti.php?mode=last";
        $ttl = 'Sale GST';
        break;

    case "debitnote";
        $src = "debnote.php?mode=last&credtype=G";
        $ttl = 'Debit Note';
        break;
    
//    case "cashrecp";
//        $src = "cashrecp.php?mode=last";
//        $ttl = 'Cash Receipt';
//        break;
//
//    case "bankrecp";
//        $src = "bankrecp.php?mode=last";
//        $ttl = 'Bank Receipt';
//        break;
//
//    case "cashpay";
//        $src = "cashpay.php?mode=last";
//        $ttl = 'Cash Payment';
//        break;
//
//    case "bankpay";
//        $src = "bankpay.php?mode=last";
//        $ttl = 'Bank Payment';
//        break;

    ######################### REPORTS ###########################
//    case "stock";
//        $src = "stock.php";
//        $ttl = 'Stock';
//        break;

//    case "inwout";
//        $src = "inwoutrep.php";
//        $ttl = 'Inward/Outward History';
//        break;


//    case "ledgergst";
//        $src = "ledgergst.php";
//        $ttl = 'Ledger GST';
//        break;

    ########################## REGISTERS ########################

//    case "slgstreg";
//        $src = "slgstreg.php";
//        $ttl = 'Sale Register';
//        break;

    case "slmultigstreg";
        $src = "slmultigstreg.php";
        $ttl = 'Sale Material Register';
        break;

    case "purreggst";
        $src = "purreggst.php";
        $ttl = 'Purchase Register';
        break;

   
    ########################## FINAALIZATION ########################

//    case "custnopay";
//        $src = "custnopay.php";
//        $ttl = 'Customer No Pay Register';
//
//        break;
//
//    case "custnosale";
//        $src = "custnosale.php";
//        $ttl = 'Customer No Sale Register';
//
//        break;
//    case "karigpay";
//        $src = "karigpay.php";
//        $ttl = 'Karigar Pay Register';
//
//        break;
//    case "karadvbal";
//        $src = "karadvbal.php";
//        $ttl = 'Karigar Adv. Bal. Register';
//
//        break;
//    case "karigmatgv";
//        $src = "karigmatgv.php";
//        $ttl = 'Karigar Material Given Register';
//
//        break;
//    case "kargoodrc";
//        $src = "kargoodrc.php";
//        $ttl = 'Karigar Good Received Register';
//
//        break;
//
//
//    case "trbal";
//        $src = "trbal.php";
//        break;
//
//    case "profit";
//        $src = "profit.php";
//        break;
//
//    case "profshar";
//        $src = "profshar.php";
//        break;
//
//    case "balsheet";
//        $src = "balsheet.php";
//        break;
//

##############Combine Stock##############
//    case "combstock";
//        $src = "combstock.php";
//        break;
//
//    case "autotran";
//        $src = "autotran.php";
//        break;
    #########################TOOLS#########################
    case "company";
        $src = "company.php?mode=last";
        break;

    case "profile";

        if ($usertype == 1) {
            $src = "user.php?mode=last";
        } else {
            $src = "user2.php?mode=last";
        }
        break;

    case "backup";
        $src = "backup.php";
        break;

//    case "balsms";
//        $src = "http://vas.gsmash.com/balance.php?username=ABDRAS&password=ABDRAS2017&route=1";
//        break;

    case "yearend";
        $src = "yearend.php";
        break;

    default :
        $head = "Home";
        $src = "defaultgst.php?mode=last";
}

//$mdeb = "";
//if ($guser[debnote] != "1" && $guser[deboth] != "1") {
//    $mdeb = "style='display:none'";
//}
//
//$mcred = "";
//if ($guser[crednote] != "1" && $guser[credoth] != "1") {
//    $mcred = "style='display:none'";
//}
//
//$mbank = "";
//if ($guser[bankrecp] != "1" && $guser[bankpay] != "1") {
//    $mbank = "style='display:none'";
//}
//
//$mcash = "";
//if ($guser[cashrecp] != "1" && $guser[cashpay] != "1") {
//    $mcash = "style='display:none'";
//}
//
//$rpquery = "";
//if ($guser[chqrep] != "1" && $guser[amtrep] != "1") {
//    $rpquery = "style='display:none'";
//}
//
//$rpoutstanding = "";
//if ($guser[payablerep] != "1" && $guser[receivable] != "1") {
//    $rpoutstanding = "style='display:none'";
//}
//
//
//$rgdebitnote = "";
//if ($guser[debnotreg] != "1" && $guser[debothreg] != "1") {
//    $rgdebitnote = "style='display:none'";
//}
//
//$rgcreditnote = "";
//if ($guser[crednotreg] != "1" && $guser[credothreg] != "1") {
//    $rgcreditnote = "style='display:none'";
//}

include("includes/linkshead.php");
$dispyear = right(($_SESSION["zdbyear_" . $dbname]), 4);

$zdb = $_SESSION["zdbyear_" . $dbname];
//browse($zdb);
$compcd = $_SESSION["comp_" . $dbname];

$getcomp = mysqli_query($conn, "SELECT code, name FROM `company` where `code`= '$compcd'") or die(mysqli_error($conn));
$fetcomp = mysqli_fetch_array($getcomp);
$cmpname = $fetcomp['name'];
mysqli_select_db($conn, $zdb);


?>
<script>
    $(document).ready(function () {

        document.addEventListener("keydown", function (zEvent) {
            if (zEvent.ctrlKey && zEvent.altKey && zEvent.code === "KeyE") {
//                alert('Invalid key Nagvigate Through Menu');

                $(window).keydown(function (event) {
                    if (event.ctrlKey && event.keyCode == 52) { //ctrl + 4
                        var href = $('#crlink').attr('href');
                        window.location.href = href;
                    }
                });
            }
            if (zEvent.ctrlKey && zEvent.altKey && zEvent.code === "KeyR") {

                $(window).keydown(function (event) {
                    if (event.ctrlKey && event.keyCode == 55) {  //ctrl + 7
                        var href = $('#dclink').attr('href');
                        window.location.href = href;
                    }
                });
            }
        });

    });
</script>

</head>
<body class="off-canvas">
    <div id="container" class="sidebar-mini">
        <header id="header">
            <!--logo start-->
            <div class="brand"><a href="menu.php" class="logo"><?php Echo $cmpname; ?></a></div>
            <!--<div class="brand"><a href="menu.php" class="logo"><?php // Echo $project_name;                                                         ?></a></div>-->
            <!--logo end-->
            <div class="toggle-navigation toggle-left">
                <button type="button" class="btn btn-default" id="toggle-left" data-toggle="tooltip" data-placement="right" title="Toggle Navigation">
                    <i class="fa fa-bars"></i>
                </button>
            </div>

            <div class="user-nav">
                <ul>
                    <?php if ($_SESSION["comp_" . $dbname] == 101) { ?>
                        <!--<li class="dropdown settings"><a href="?action=smsnosales"><button type="button" class="btn btn-primary" style="color: #337ab7;background: white">No Sale Whatsapp</button></a></li>-->
                    <?php } ?>
                    <!--<li <?= $karigrep ?> class="dropdown settings"><a href="?action=karigrep"><button type="button" class="btn btn-primary" style="color: #337ab7;background: white">KARIGAR REPORT</button></a></li>-->
                    <!--<li <?= $ledger ?>  class="dropdown settings"><a href="?action=ledgergst"><button type="button" class="btn btn-primary" style="color: #337ab7;background: white">LEDGER</button></a></li>-->

                    <li class="dropdown settings"><a href="<?
                        if ($usertype == 1) {
                            Echo "comp.php";
                        } else {
                            Echo "#";
                        }
                        ?>"><label class="label-control" style="font-size: 12px;color: #337ab7;"> Company : <?php echo $cmpname; ?></label></a></li>
                    <li class="dropdown settings">
                        <a class="dropdown-toggle" href="year.php">
                            <label class="label-control" style="font-size: 13px"><i class="fa fa-calendar" aria-hidden="true"></i> <?php echo 'Financial Year : ' . $dispyear; ?></label>
                        </a>
                    </li>

                    <li <?= $company1; ?> class="dropdown settings">
                        <a class="dropdown-toggle balsms" data-toggle="dropdown" href="#">
                            <label class='username' style="font-size: 14px"><?php echo $_SESSION["username_" . $dbname]; ?></label> 
                            <i class="fa fa-angle-down" style="font-size: 15px"></i>
                        </a>
                        <ul class="dropdown-menu animated fadeInDown">
                            <li <?= $company; ?>><a href="?action=company"><i class="fa fa-building-o"></i>Company SetUp</a></li>
                            <li <?= $backup; ?>><a href="backup.php"><i class="fa fa-cloud-download"></i> Backup</a></li>
                            <li <?= $profile; ?>><a href="?action=profile"><i class="fa fa-user"></i> Profile</a></li>
                            <!--<li <?= $tlyearend; ?>><a href="?action=yearend"><i class="fa fa-calendar"></i>Year End</a></li>-->
                            <li><a href="logout.php"><i class="fa fa-power-off"></i> Logout</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </header>

        <!-- AUTO LINKS-->
        <a href="ch_recd.php?mode=last" id="crlink" ></a>
        <a <?= $dailycash ?> href="dailycash.php" id="dclink" ></a>

        <!--sidebar left start-->
        <nav class="sidebar sidebar-left">
            <h5 class="sidebar-header">Navigation</h5>
            <ul class="nav nav-pills nav-stacked">
                <li <?= $masters; ?> class="nav-dropdown">
                    <a href="#" title="UI Elements"><i class="fa fa-graduation-cap"></i>Masters</a>
                    <ul class="nav-sub">
                        <li <?= $customer; ?>><a href="?action=customer">Customer</a></li>
                        <li <?= $supplier; ?>><a href="?action=supplier">Karigar</a></li>
                        <li <?= $openbal; ?>><a href="?action=openbal">Opening Balance</a></li>
                        <li <?= $chcustdtl; ?>><a href="?action=chcustdtls">Change of Customer Details</a></li>
                        <li <?= $transport; ?>><a href="?action=transport">Transporter</a></li>
                        <li <?= $unit; ?>><a href="?action=unit">Unit</a></li>
                        <li <?= $color; ?>><a href="?action=color">Color</a></li>
                        <!--<li <?= $driver; ?>><a href="?action=driver">Driver</a></li>-->
                        <!--<li <?= $chrateop; ?>><a href="?action=chrateop">Change of Rates/Opening Stock</a></li>-->
                        <!--<li <?= $staff; ?>><a href="?action=staff">Staff</a></li>-->
<!--                        <li <?= $bank; ?>><a href="?action=bank">Bank</a></li>
                        <li <?= $cash; ?>><a href="?action=cash">Cash</a></li>-->
                        <!--<li <?= $expense; ?>><a href="?action=expense">Expense</a></li>-->

                        <li <?= $itemgrp; ?>><a href="?action=itemgrp">Item Group</a></li>
                        <li <?= $itemsubgrp; ?>><a href="?action=itsubgrp">Item Sub Group</a></li>
                        <li <?= $item; ?>><a href="?action=item">Item</a></li>
                        <li <?= $rawmat; ?>><a href="?action=rawmat">Raw Material</a></li>
                        <li <?= $group; ?>><a href="?action=group">Group</a></li>
                        <li <?= $otherac; ?>><a href="?action=otherac">Other A/C</a></li>
                        <li <?= $saletype; ?>><a href="?action=saletype">Sale Type</a></li>
                    </ul>
                </li>
                <li <?= $transaction; ?>class="nav-dropdown">
                    <a href="#" title="Transaction"><i class="fa fa-usd"></i>Transaction</a>
                    <ul class='nav-sub'>
                        <!--<li <?= $sale; ?>><a href="?action=sale">Sale</a></li>-->
                        <li <?= $purchgstmulti; ?>><a href="?action=purchgst">Purchase</a></li>
                        <li <?= $salegmul; ?>><a href="?action=salegst">Sale</a></li>
<!--                        <li <?= $purchase; ?>><a href="?action=purchase">Purchase</a></li>-->
<!--                        <li <?= $mcred; ?> class="nav-dropdown">
                            <a href="#">Sale Return/Credit Note</a>
                            <ul class="nav-sub">
                                <li <?= $creditnotegstmulti; ?> ><a href="?action=creditnotegstmulti">Goods Return Multi</a></li>
                                <li <?= $credothgst; ?> ><a href="?action=credothgst">Others</a></li>
                            </ul>
                        </li>-->

<!--                        <li <?= $inward; ?>><a href="?action=inwardgst">Inward</a></li>
                        <li <?= $damaged; ?>><a href="?action=damaged">Damaged</a></li>
                        <li <?= $salematmulti; ?>><a href="?action=salematmulti">Material Given to Karigar</a></li>-->
                        <!--<li <?= $purchase; ?>><a href="?action=purchase">Goods Received From Karigar</a></li>-->
<!--                        <li <?= $repgiven; ?>><a href="?action=repgiven">Repair Given To Karigar</a></li>
                        <li <?= $reptaken; ?>><a href="?action=reptaken">Repair Recd. From Karigar</a></li>
                        <li <?= $amtrequest; ?>><a href="?action=amtrep">Amount Request</a></li>-->
<!--                        <li <?= $outward; ?>><a href="?action=outward">Outward</a></li>
                        <li <?= $excess; ?>><a href="?action=excess">Excess</a></li>-->
<!--                        <li <?= $mbank; ?> class="nav-dropdown">
                            <a href="#">Bank<i></i></a>  
                            <ul class="nav-sub">
                                <li <?= $bankrecp; ?> ><a href="?action=bankrecp">Receipt</a></li>
                                <li <?= $bankpay; ?> ><a href="?action=bankpay">Payment</a></li>
                                <li <?= $custtokari; ?>><a href="?action=custtokari">Customer to Karigar</a></li>
                            </ul>
                        </li>
                        <li <?= $mcash; ?> class="nav-dropdown">
                            <a href="#">Cash<i></i></a>
                            <ul class="nav-sub">
                                <li <?= $cashrecp; ?> ><a href="?action=cashrecp">Receipt</a></li>
                                <li <?= $cashpay; ?> ><a href="?action=cashpay">Payment</a></li>
                            </ul>
                        </li>
                        <li <?= $contra; ?>><a href="?action=contra">Contra</a></li>
                        <li <?= $journal; ?>><a href="?action=journal">Journal</a></li>-->
                    </ul>
                </li>
<!--                <li <?= $reports; ?>class="nav-dropdown">
                    <a href='#'><i class="fa fa-file"></i>Reports</a>
                    <ul class='nav-sub'>
                        <li <?= $stock; ?>><a href="?action=stock">Stock</a></li>
                        <li <?= $ledgergst; ?>><a href="?action=ledgergst">Ledger</a></li>
                        <li <?= $inwout; ?>><a href="?action=inwout"> Inward/Outward History</a></li>
                        <li <?= $vatrep; ?>><a href="?action=vatrep">VAT</a></li>
                        <li <?= $ledger; ?>><a href="?action=ledger">Ledger</a></li>
                        <li <?= $karigrep; ?>><a href="?action=karigrep">Karigar Report</a></li>
                        <li <?= $itemwise; ?>><a href="?action=itemwise">Itemwise P/L</a></li>
                        <li <?= $itemwisesale; ?>><a href="?action=itemwisesale">Itemwise Sale</a></li>
                        <li <?= $itemgrpwisesale; ?>><a href="?action=itemgrpwisesale">Item Groupwise Sale</a></li>
                        <li <?= $partygrpwisesale; ?>><a href="?action=partygrpwisesale">Partywise Item Group Sale</a></li>
                        <li <?= $leadparty; ?>><a href="?action=leadparty">Leading Parties</a></li>
                        <li <?= $dailyreport; ?>><a href="?action=dailyreport">Daily Report</a></li>
                        <li <?= $dailycash; ?>><a href="?action=dailycashrp">Daily Cash</a></li>
                        <li <?= $dailysalereport; ?>><a href="?action=dailysalereport">Daily Sale Report</a></li>
                        <li <?= $bankbook; ?>><a href="?action=bankbook">Bank Book</a></li>
                        <li <?= $cashbook; ?>><a href="?action=cashbook">Cash Book</a></li>
                        <li <?= $jvbook; ?>><a href="?action=jvbook">Journal Book</a></li>
                        <li <?= $pendrep; ?>><a href="?action=pendrep">Pending Repair</a></li>
                        <li <?= $cartreg; ?>><a href="?action=cartreg">Cartoonwise Report</a></li>
                        <li <?= $expenserep; ?>><a href="?action=expenserep">Expense Report</a></li>
                        <li <?= $rpoutstanding; ?> class="nav-dropdown">
                            <a href="#">Outstanding<i></i></a>
                            <ul class="nav-sub">
                                <li <?= $payablerep; ?> ><a href="?action=payablerep">Payable</a></li>
                                <li <?= $receivable; ?> ><a href="?action=receivable">Receivable</a></li>
                            </ul>
                        </li>
                    </ul>
                </li> -->
                <li <?= $registers; ?>class="nav-dropdown">
                    <a href='#'><i class="fa fa-registered"></i>Registers</a>
                    <ul class='nav-sub'>

                        <!--<li <?= $salereg; ?>><a href="?action=salereg">Sale</a></li>-->
                        <li <?= $purchreg; ?>><a href="?action=purreggst">Purchase</a></li>
                        <li <?= $slmultigstreg; ?>><a href="?action=slmultigstreg">Sale</a></li>
<!--                        <li <?= $rgcreditnote; ?> class="nav-dropdown">
                            <a href="#">Sale Return / Credit Note<i></i></a>
                            <ul class="nav-sub">
                                <li <?= $crdntreg; ?> ><a href="?action=crdntreg">Goods Return</a></li>
                                <li <?= $crdothreg; ?> ><a href="?action=crdothreg">Others</a></li>
                            </ul>
                        </li>
                        <li <?= $inwreg; ?>><a href="?action=inwreg">Inward</a></li>

                        <li <?= $damreg; ?>><a href="?action=damreg">Damaged</a></li>
                        <li <?= $excessreg; ?>><a href="?action=excessreg">Excess</a></li>
                        <li <?= $slmatreg; ?>><a href="?action=slmatreg">Material Given to Karigar</a></li>
                        <li <?= $rgtaxinv; ?>><a href="?action=taxinvreg">Tax Invoice</a></li>
                        <li <?= $balancereg; ?>><a href="?action=balancereg">Balance Register</a></li>
                        <li <?= $transreg; ?>><a href="?action=transreg">Internal Transfer</a></li>
                        <li <?= $custokar; ?>><a href="?action=custokar">Customer To Karigar</a></li>
                        <li <?= $repgivreg; ?>><a href="?action=repgivreg">Repair Given Register</a></li>
                        <li <?= $reprecreg; ?>><a href="?action=reprecreg">Repair Recd. Register</a></li>-->

                    </ul>
                </li>
<!--                <li <?= $mis; ?>class="nav-dropdown">
                    <a href='#'><i class="fa fa-bars"></i>MIS</a>
                    <ul class='nav-sub'>
                        <li <?= $karadvbal; ?>><a href="?action=karadvbal">Karigar Advance/Balance</a></li>
                        <li <?= $karigmatgv; ?>><a href="?action=karigmatgv">Karigar Material Given</a></li>
                        <li <?= $kargoodrc; ?>><a href="?action=kargoodrc">Karigar Item Received</a></li>
                        <li <?= $karigpay; ?>><a href="?action=karigpay">Karigar Payment</a></li>
                        <li <?= $custnopay; ?>><a href="?action=custnopay">Customer No Payment</a></li>
                        <li <?= $custnosale; ?>><a href="?action=custnosale">Customer No Sale</a></li>
                    </ul>
                </li>-->
            </ul>
        </nav>
        <!--sidebar left end-->
        <!--main content start-->
        <section class="main-content-wrapper">
            <section id="main-content">
                <div class="col-md-12 pad">
                    <iframe src="<?php echo $src; ?>" name="frame1" style="width: 100%; height:5000px;"  frameBorder="0" scrolling="no"></iframe>
                </div>
            </section>
        </section>
    </div>
    <!--main content end-->
    <?php include("includes/linksfoot.php") ?>
</body>
</html>
