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

//include("includes/menu_rights.php");
//browse(1);
$project_title = "TILEWEB";
$admin = $_SESSION["admin_" . $dbname];
$usertype = $_SESSION["usertype"];
$src = "";
$action = isset($_GET["action"]) ? $_GET["action"] : "";
$dispyear = right(($_SESSION["zdbyear_" . $dbname]), 4);
$yearname = right(($_SESSION["zdbyearname_" . $dbname]), 9);

$myear = $_SESSION[$myyear];

if ($usertype != 1) {
    include("includes/menu_rights.php");
}

//browse($reports);
switch ($action) {
    ####################### PROFILES ##########################

    case "profile";
        $head = "Create User";
        $src = '';
        if ($usertype == 1) {
            $src = "user.php?mode=last";
        } else {
            $src = "user2.php?mode=last";
        }
        break;
    ####################### DASHBOARD ########################
    case "generate";
        if ($guser['generate'] == '') {
            $src = "";
        } else {
            $src = "wordpress-api.php?mode=last";
        }
        break;

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

    case "addcustomer";
//        if ($guser['customer'] == '') {
//            $src = "";
//        } else {
        $src = "custdata.php?mode=true";
//        }
        break;

    case "custprint";
//        if ($guser['ticredothreg'] == '') {
//            $src = "";
//        } else {
        $src = "custdata_print.php";
//        }
        break;
    
        case "ticredothregoth";
//        if ($guser['ticredothreg'] == '') {
//            $src = "";
//        } else {
        $src = "ticredothregoth.php";
//        }
        break;

    case "ticredoth";
//        if ($guser['ticredoth'] == '') {
//            $src = "";
//        } else {
        $src = "credoth.php?mode=last&credtype=O";
//        }
        break;

    case "tideboth";
//        if ($guser['tideboth'] == '') {
//            $src = "";
//        } else {
        $src = "deboth.php?mode=last&debtype=O";
//        }
        break;

    case "sale";
//        if ($guser['sale'] == '') {
//            $src = "";
//        } else {
        $src = "sale.php?mode=last";
//        }
        break;

    case "transport";
//        if ($guser['transport'] == '') {
//            $src = "";
//        } else {
        $src = "transport.php?mode=last";
//        }
        break;

    case "transfer";
//        if ($guser['transport'] == '') {
//            $src = "";
//        } else {
        $src = "transfer.php?mode=last";
//        }
        break;

    case "supplier";
//        if ($guser['supplier'] == '') {
//            $src = "";
//        } else {
        $src = "supplier.php?mode=last";
//        }
        break;

    case "architecture";
//        if ($guser['supplier'] == '') {
//            $src = "";
//        } else {
        $src = "architecture.php?mode=last";
//        }
        break;

    case "itemgrp";
//        if ($guser['itemgrp'] == '') {
//            $src = "";
//        } else {
        $src = "prodgrp.php?mode=last";
//        }
        break;

    case "item";
//        if ($guser['item'] == '') {
//            $src = "";
//        } else {
        $src = "product.php?mode=last";
//        }
        break;

    case "saleret";
//        if ($guser['saleret'] == '') {
//            $src = "";
//        } else {
        $src = "saleret.php?mode=last&debtype=G";
//        }
        break;



    case "inward";
//        if ($guser['inward'] == '') {
//            $src = "";
//        } else {
        $src = "inward.php?mode=last";
//        }
        break;

    case "outward";
//        if ($guser['itemgrp'] == '') {
//            $src = "";
//        } else {
        $src = "outward.php?mode=last";
//        }
        break;

    case "tidamage";
//        if ($guser['tidamage'] == '') {
//            $src = "";
//        } else {
        $src = "damaged.php?mode=last";
//        }
        break;

    case "purchase";
//        if ($guser['purchase'] == '') {
//            $src = "";
//        } else {
        $src = "purchase.php?mode=last";
//        }
        break;

    case "debnote";
//        if ($guser['purchase'] == '') {
//            $src = "";
//        } else {
        $src = "debnote.php?mode=last";
//        }
        break;

    case "drawbank";
//        if ($guser['drawbank'] == '') {
//            $src = "";
//        } else {
        $src = "drawbank.php?mode=last";
//        }
        break;


    case "staff";
//        if ($guser['drawbank'] == '') {
//            $src = "";
//        } else {
        $src = "staff.php?mode=last";
//        }
        break;

    case "openbal";
//        if ($guser['openbal'] == '') {
//            $src = "";
//        } else {
        $src = "openbal.php?mode=last&form=openbal";
//        }
        break;

    case "purret";
//        if ($guser['purret'] == '') {
//            $src = "";
//        } else {
        $src = "purret.php?mode=last&debtype=G";
//        }
        break;

    case "bank";
//        if ($guser['bank'] == '') {
//            $src = "";
//        } else {
        $src = "bank.php?mode=last";
//        }
        break;

    case "cash";
//        if ($guser['cash'] == '') {
//            $src = "";
//        } else {
        $src = "cash.php?mode=last";
//        }
        break;

    case "expense";
//        if ($guser['expense'] == '') {
//            $src = "";
//        } else {
        $src = "expense.php?mode=last";
//        }
        break;

    case "expenserep";
//        if ($guser['expense'] == '') {
//            $src = "";
//        } else {
        $src = "expenserep.php?mode=last";
//        }
        break;

    case "otherac";
//        if ($guser['otherac'] == '') {
//            $src = "";
//        } else {
        $src = "otherac.php?mode=last";
//        }
        break;

    case "group";
//        if ($guser['group'] == '') {
//            $src = "";
//        } else {
        $src = "group.php?mode=last";
//        }
        break;

    case "narration";
//        if ($guser['narration'] == '') {
//            $src = "";
//        } else {
        $src = "narration.php?mode=last";
//        }
        break;

    case "area";
//        if ($guser['area'] == '') {
//            $src = "";
//        } else {
        $src = "area.php?mode=last";
//        }
        break;

    case "unit";
//        if ($guser['unit'] == '') {
//            $src = "";
//        } else {
        $src = "unit.php?mode=last";
//        }
        break;

    case "bankrecp";
//        if ($guser['bankrecp'] == '') {
//            $src = "";
//        } else {
        $src = "bankrecp.php?mode=last";
//        }
        break;

    case "cashrecp";
//        if ($guser['cashrecp'] == '') {
//            $src = "";
//        } else {
        $src = "cashrecp.php?mode=last";
//        }
        break;

    case "bankpay";
//        if ($guser['bankpay'] == '') {
//            $src = "";
//        } else {
        $src = "bankpay.php?mode=last";
//        }
        break;

    case "multibankpay";
//        if ($guser['bankpay'] == '') {
//            $src = "";
//        } else {
        $src = "bankmultipay.php?mode=last";
//        }
        break;

    case "multicashpay";
//        if ($guser['bankpay'] == '') {
//            $src = "";
//        } else {
        $src = "cashmultipay.php?mode=last";
//        }
        break;

    case "cashpay";
//        if ($guser['cashpay'] == '') {
//            $src = "";
//        } else {
        $src = "cashpay.php?mode=last";
//        }
        break;

    case "contra";
//        if ($guser['contraent'] == '') {
//            $src = "";
//        } else {
        $src = "contra.php?mode=last";
//        }
        break;

    case "contreg";
//        if ($guser['contreg'] == '') {
//            $src = "";
//        } else {
        $src = "contreg.php?mode=last";
//        }
        break;

    case "journal";
//        if ($guser['journal'] == '') {
//            $src = "";
//        } else {
        $src = "jv.php?mode=last";
//        }
        break;

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

    case "bankrecorep";
        $src = "bankreco_rep.php";
        break;

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


    case "receivablerep";
//        if ($guser['outsrecevrp'] == '') {
//            $src = "";
//        } else {
        $src = "osbill.php?para=R";
//        }
        break;

    case "ospay";
//        if ($guser['outspayrp'] == '') {
//            $src = "";
//        } else {
        $src = "osbill.php?para=P";
//        }
        break;

    case "ledger";
//        if ($guser['ledger'] == '') {
//            $src = "";
//        } else {
        $src = "ledger.php";
//        }
        break;

    case "stock";
//        if ($guser['stock'] == '') {
//            $src = "";
//        } else {
        $src = "stock.php";
//        }
        break;

    case "stockall";
//        if ($guser['stock'] == '') {
//            $src = "";
//        } else {
        $src = "stockall.php";
//        }
        break;

    case "inwout";
//        if ($guser['inwout'] == '') {
//            $src = "";
//        } else {
        $src = "inwoutrep.php";
//        }
        break;

    case "itemwise";
//        if ($guser['itemwise'] == '') {
//            $src = "";
//        } else {
        $src = "itemwise.php";
//        }
        break;

    case "itemwisesale";
        $src = "itemwise_sale.php";
        break;

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

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


    case "dailyreport";
        $src = "dailyrep.php";
        break;

    case "itemgrpwisesale";
//        $src = "itemgrpsale.php";
        $src = "saleitemgrp.php";
        break;

//    case "tdsrep";
//        if ($guser['stkpack'] == '') {
//            $src = "";
//        } else {
//        $src = "tdsrep.php?";
//        }
//        break;

    case "changeofrates";
//        if ($guser['changeofrates'] == '') {
//            $src = "";
//        } else {
        $src = "changeRate.php";
//        }
        break;


    case "salereg";
//        if ($guser['salereg'] == '') {
//            $src = "";
//        } else {
        $src = "salereg.php";
//        }
        break;

    case "bankbook";
//                if ($guser[bankbook] == '') {
//                    $src = "";
//                } else {
        $src = "bankbook.php?para=B";
//                }
        break;

    case "cashbook";
        //        if ($guser[rpcashbook] == '') {
        //            $src = "";
        //        } else {
        $src = "bankbook.php?para=C";
        //        }
        break;

    case "jvbook";
//                if ($guser[jvbook] == '') {
//                    $src = "";
//                } else {
        $src = "jvbook.php?para=C";
//                }
        break;

//    case "jvgst";
//        //        if ($guser[rpcashbook] == '') {
//        //            $src = "";
//        //        } else {
//        $src = "jvgst.php";
//        //        }
//        break;
//    case "bpaychq";
//        if ($guser['bpaychq'] == '') {
//            $src = "";
//        } else {
//            $src = "bkpy_chq.php";
//        }
//        break;

    case "chqrep";
//        if ($guser['chqrep'] == '') {
//            $src = "";
//        } else {
        $src = "chqrep.php";
//        }
        break;

    case "amtrep";
//        if ($guser['rpamountqry'] == '') {
//            $src = "";
//        } else {
        $src = "amtrep.php";
//        }
        break;

    case "inwreg";
//        if ($guser['tiinwdreg'] == '') {
//            $src = "";
//        } else {
        $src = "inwreg.php";
//        }
        break;

    case "outreg";
//        if ($guser['tiinwdreg'] == '') {
//            $src = "";
//        } else {
        $src = "outreg.php";
//        }
        break;

    case "debreg";
//        if ($guser['debnoterg'] == '') {
//            $src = "";
//        } else {
        $src = "debreg.php";
//        }
        break;
    
        case "debregoth";
//        if ($guser['debnoterg'] == '') {
//            $src = "";
//        } else {
        $src = "debregoth.php";
//        }
        break;

    case "credreg";
//        if ($guser['crednoterg'] == '') {
//            $src = "";
//        } else {
        $src = "credreg.php";
//        }
        break;

    case "credothreg";

        $src = "credothreg.php";

        break;

    case "pendpurchase";

        $src = "pendpurchase.php";

        break;

    case "damreg";
//        if ($guser['tidamreg'] == '') {
//            $src = "";
//        } else {
        $src = "damreg.php";
//        }
        break;

    ####################### FINALIZATION ##########################
    case "godown";
//        if ($guser['godown'] == '') {
//            $src = "";
//        } else {
        $src = "godown.php?mode=last";
//        }
        break;

    case "trbal";
        //        if ($guser[fntrialbal] == '') {
        //            $src = "";
        //        } else {
        $src = "trbal.php?mode=last";
        //        }
        break;

    case "profit";
        //        if ($guser[fnprofit] == '') {
        //            $src = "";
        //        } else {
        $src = "profit.php?mode=last";
        //        }
        break;

    case "profshar";
        //        if ($guser[fnprofshar] == '') {
        //            $src = "";
        //        } else {
        $src = "profshar.php?mode=last";
        //        }
        break;

    case "balsheet";
        //        if ($guser[fnbalsheet] == '') {
        //            $src = "";
        //        } else {
        $src = "balsheet.php?mode=last";
        //        }
        break;

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

    case "tranreg";

        $src = "tranreg.php";

        break;

    ####################### TOOLS ##########################

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

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

    case "company";
        //        if ($guser[tlcompany] == '') {
        //            $src = "";
        //        } else {
        $src = "company.php?mode=last";
        //        }
        break;

    case "graph";
        $src = "misdashboard.php";
        break;

    case "yearselection";
//        if ($guser['yearselection'] == '') {
//            $src = "";
//        } else {
        $src = "yea.php?mode=last";
//        }
        break;

    case "backup";
//        if ($guser['tlbackup'] == '') {
//            $src = "";
//        } else {
        $src = "backup.php";
//        }
        break;
    
    case "pendlv";
//        if ($guser['tlbackup'] == '') {
//            $src = "";
//        } else {
        $src = "pendlv.php";
//        }
        break;
    
    case "pendcp";
//        if ($guser['tlbackup'] == '') {
//            $src = "";
//        } else {
        $src = "pendcp.php";
//        }
        break;

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

    case "unmarkrecp";
        $src = "unmark.php?para=R";
        break;

    case "purreg";
//        if ($guser['purrawreg'] == '') {
//            $src = "";
//        } else {
        $src = "purreg.php";
//        }
        break;

    case "unmarkpay";
        $src = "unmark.php?para=P";
        break;

    default :
//        $head = "Home";
//        $src = "misdashboard.php";
//        if ($usertype == 1) {
//            $src = "misdashboard.php";
//        } else {
//            $src = "default.php";
//        }
        $src = "default.php";
}

$mbank = "";
if ($guser['bankpay'] != "1" && $guser['bankrecp'] != "1") {
    $mbank = "style='display: none'";
}

$mcash = "";
if ($guser['cashpay'] != "1" && $guser['cashrecp'] != "1") {
    $mcash = "style='display: none'";
}

$rpquery = "";
if ($guser['rpchqnoqry'] != "1" && $guser['rpamountqry'] != "1") {
    $rpquery = "style='display: none'";
}

$rpoutstanding = "";
if ($guser['outsrecevrp'] != "1" && $guser['outspayrp'] != "1") {
    $rpoutstanding = "style='display: none'";
}

include("includes/linkshead.php");
?>
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    <title></title>
    <meta name="description" content="Blueprint: Horizontal Slide Out Menu" />
    <meta name="keywords" content="horizontal, slide out, menu, navigation, responsive, javascript, images, grid" />
    <meta name="author" content="Codrops" />
    <link rel="shortcut icon" href="../favicon.ico">
    <link rel="stylesheet" type="text/css" href="menu/css/default.css" />
    <link rel="stylesheet" type="text/css" href="menu/css/component.css" />
    <script src="menu/js/modernizr.custom.js"></script>
<!--    <style>
        .cbp-hssubmenu > li:hover{
            color: red
        }
    </style>-->
</head>

<body>
    <!--<div class="container-scroller">-->
    <!-- partial:partials/_horizontal-navbar.html -->
    <div class="main">
        <nav class="cbp-hsmenu-wrapper" id="cbp-hsmenu-wrapper">
            <div class="cbp-hsinner">
                <ul class="cbp-hsmenu" style="margin-left: 0px;max-width: 250em;width:100%">
                    <li class="text-left"><b><u><a href="menuapp.php" style="color:#8F4131; font-size:20px ">TILE DATA</a></u></b></li>
                    <!--<li <?= $generate; ?> ><a href="menu.php?action=generate"><button type="button" class="btn" style="padding-top: 6px;font-size: 15px;color: orange;border: 1px solid #129edc;background: white;font-weight: 600;" >GENERTAE</button></a></li>-->

                    <li <?= $addsale ?> class="dropdown settings"><a href="?action=addcustomer"><button type="button" class="btn btn-primary" style="color: black;background: transparent;border: 1px solid brown">Add Customer</button></a></li>
                    <li <?= $addsale ?> class="dropdown settings"><a href="?action=custprint"><button type="button" class="btn btn-primary" style="color: black;background: transparent;border: 1px solid brown">View  List</button></a></li>

                    

                   
                    <li class="dropdown settings" style="float: right">
                        <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 'Year : ' . $yearname; ?></label>
                        </a>
                    </li>
                    <li class="dropdown settings" style="float: right">
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                            <b><? echo $_SESSION["username_" . $dbname] ?></b>
                        </a>
                        <ul class="dropdown-menu">
                            <li <? $tlcompany; ?>><a href="?action=company"><i class="fa fa-building-o"></i> Company Setup</a></li>
                            <li <? $tlprofile; ?>><a href="?action=profile"><i class="fa fa-user"></i> Profile</a></li>
                            <?php if ($guser['usertype'] == 1) { ?>
                                <li <? // $tlgraph;           ?>><a href="?action=graph"><i class="fa fa-bar-chart"></i> Graph</a></li>
                            <?php } ?>  
                            <li <? $tlbackup; ?>><a href="?action=backup"><i class="fa fa-cloud-download"></i> Backup</a></li>
                            <?php
                            if ($myear == "1001") {
                                echo "<li $tlbackup><a href='?action=upload_backup'><i class='fa fa-cloud-download'></i> Upload Backup</a></li>";
                            }
                            ?>
                            <li><a href="logout.php"><i class="fa fa-power-off"></i> Logout</a></li>
                        </ul>
                    </li>
                    
                </ul>
            </div>
        </nav>
    </div>
    <div class="">
        <iframe src="<?php echo $src; ?>" name="frame1" class="frame1" style="width: 100%; height:5000px;" frameBorder="0" scrolling="no"></iframe>
    </div>
    <script src="menu/js/cbpHorizontalSlideOutMenu.min.js"></script>
    <script>
        var menu = new cbpHorizontalSlideOutMenu(document.getElementById('cbp-hsmenu-wrapper'));
    </script>    
</body>
</html>