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

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

$zroot = $_SESSION["zdir"];

$src = "";
$action = isset($_GET["action"]) ? $_GET["action"] : "";
switch ($action) {

    ####################### MASTERS ##########################
    case "school";
        $src = "school.php?mode=last";
        break;

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

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

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

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

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

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

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

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

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

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

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

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

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


    ####################### TRANSACTION ##########################
    case "dmndfrm";
        $src = "dmndfrm.php?mode=last";
        break;

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

    case "geninvs";
        $src = "geninv.php?mode=last&gentype=S";
        break;

    case "geninvm";
        $src = "geninv.php?mode=last&gentype=M";
        break;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    case "multenvp";
        $src = "multienvp.php";
        break;

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

    ########################## REGISTERS ########################
    case "dmndreg";
        $src = "dmndreg.php";
        break;

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

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

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

    case "bankbook";
        $src = "bankbook.php?para=B";
        break;

    case "cashbook";
        $src = "bankbook.php?para=C";
        break;

    case "paymrecd_c";
        $src = "paymrecd.php?para=C";
        break;

    case "paymrecd_b";
        $src = "paymrecd.php?para=B";
        break;

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

############################## Summary ##############################
    case "salesumppr";
        $src = "salesumppr.php";
        break;

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

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

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

    ########################## FINAALIZATION ########################
    case "trbal";
        $src = "trbal.php";
        break;

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

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

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

    #########################TOOLS#########################
    case "company";
        $src = "company.php?mode=last";
        break;

    case "profile";

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

    case "stock";
        $src = "default2.php";
        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;

    case "mail_msga";
        $src = "multi_mail.php?para=A";
        break;

    case "mail_msgm";
        $src = "multi_mail.php?para=M";
        break;

    default:
        $head = "Home";
        $src = "default.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];
?>
</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 $project_name; ?></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>
                    <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 class="profile-photo"><img src="assets/img/avatar.png" alt="" class="img-circle"></li>-->
                    <li class="dropdown settings">
                        <a class="dropdown-toggle balsms" data-toggle="dropdown" href="#">
                            <b style="font-size: 20px;"><?php echo $_SESSION["username_" . $dbname]; ?></b> <i class="fa fa-angle-down"></i>
                        </a>
                        <ul class="dropdown-menu animated fadeInDown">
                            <li <?= $tlcompany; ?>><a href="?action=company"><i class="fa fa-building-o"></i> Company SetUp</a></li>
                            <li><a href="backup.php"><i class="fa fa-cloud-download"></i> Backup</a></li>
                            <li <?= $tlprofile; ?>><a href="?action=profile"><i class="fa fa-user"></i> Profile</a></li>
                            <!--<li <?= $tlbalsms; ?>><a href="?action=balsms"><i class="fa fa-user"></i> Balance SMS</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 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 class="nav-dropdown">
                    <a href="#" title="UI Elements"><i class="fa fa-graduation-cap"></i>Masters</a>
                    <ul class="nav-sub">
                        <li <?= $school; ?>><a href="?action=school">School</a></li>
                        <li <?= $center; ?>><a href="?action=center">Center</a></li>
                        <li <?= $medium; ?>><a href="?action=medium">Medium</a></li>
                        <li <?= $subject; ?>><a href="?action=subject">Subject</a></li>
                        <li <?= $district; ?>><a href="?action=district">District</a></li>
                        <li <?= $exam; ?>><a href="?action=exam">Exam</a></li>
                        <li <?= $courier; ?>><a href="?action=courier">Courier</a></li>
                        <li <?= $stdepot; ?>><a href="?action=stdepot">S.T Depot</a></li>
                        <hr>
                        <li <?= $prprimary; ?>><a href="?action=prprimary">Paper Rate - Primary</a></li>
                        <li <?= $prsecondry; ?>><a href="?action=prsecondry">Paper Rate - Secondary</a></li>
                        <li <?= $prpreliums; ?>><a href="?action=prpreliums">Paper Rate - Preliums</a></li>
                        <li <?= $bank; ?>><a href="?action=bank">Bank</a></li>
                        <li <?= $cash; ?>><a href="?action=cash">Cash</a></li>
                        <li <?= $narration; ?>><a href="?action=narration">Narration</a></li>
                    </ul>
                </li>
                <li class="nav-dropdown">
                    <a href="#" title="Transaction"><i class="fa fa-usd"></i>Transaction</a>
                    <ul class='nav-sub'>
                        <li <?= $dmndfrm; ?>><a href="?action=dmndfrm">Demand Form</a></li>
                        <li <?= $gendemd; ?>><a href="?action=gendemd">Generate Demand Form</a></li>
                        <li <?= $geninvs; ?>><a href="?action=geninvs">Generate Bill Single</a></li>
                        <li <?= $geninvm; ?>><a href="?action=geninvm">Generate Bill Multi</a></li>
                        <li <?= $invoice; ?>><a href="?action=invoice">Invoice / Bill</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 <?= $bankrecp; ?> ><a href="?action=prevbkrecp">Previous Receipt</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>
                                <li <?= $cashrecp; ?> ><a href="?action=prevcsrecp">Previous Receipt</a></li>
                            </ul>
                        </li>
                        <li <?= $prevbill; ?>><a href="?action=prevbill">Previous Bill</a></li>
                        <li <?= $mdiscount; ?> class="nav-dropdown">
                            <a href="#">Discount<i></i></a>
                            <ul class="nav-sub">
                                <li <?= $discgvn; ?> ><a href="?action=discgvn">Given</a></li>
                                <li <?= $discrecd; ?> ><a href="?action=discrecd">Received</a></li>
                            </ul>
                        </li>
                    </ul>
                </li>
                <li class="nav-dropdown">
                    <a href='#'><i class="fa fa-file"></i>Reports</a>
                    <ul class='nav-sub'>
                        <li <?= $invprin; ?>><a href="?action=invprin">Invoice/ Bill Print</a></li>
                        <li <?= $qtypress; ?>><a href="?action=qtypress"> Qty. For Press</a></li>
                        <li <?= $packet; ?>><a href="?action=packet">Packet</a></li>
                        <li <?= $schldmnd; ?>><a href="?action=schldmnd">School List of Demand Form (Centerwise)</a></li>
                        <li <?= $ledger; ?>><a href="?action=ledger">Ledger</a></li>
                        <li <?= $osbill; ?>><a href="?action=osbill">O/s. Receivable</a></li>
                        <li <?= $osbill; ?>><a href="?action=ossumm">O/s. Summary(Examwise)</a></li>
                        <li <?= $multenvp; ?>><a href="?action=multenvp">Multiple Envelope</a></li>
                        <li <?= $multenvp; ?>><a href="?action=multdemd">Multiple Demand Form</a></li>
                        <li <? ?>><a href="?action=unmark">Unsettled Receipt</a></li>
                        <li <?= $label; ?> class="nav-dropdown">
                            <a href="#">Labels<i></i></a>
                            <ul class="nav-sub">
                                <li <?= $rpsubject; ?> ><a href="?action=rpsubject">Subject</a></li>
                                <li <?= $rpbill; ?> ><a href="?action=rpbill">Bill</a></li>
                                <li <?= $rpschool; ?> ><a href="?action=rpschool">School</a></li>
                            </ul>
                        </li>
                    </ul>
                </li> 
                <li class="nav-dropdown">
                    <a href='#'><i class="fa fa-registered"></i>Registers</a>
                    <ul class='nav-sub'>
                        <li <?= $rgbill; ?>><a href="?action=rgbill">Bill</a></li>
                        <li <?= $rgbillpend; ?>><a href="?action=rgbillpend">Bill Pending of Demandform</a></li>
                        <li <?= $dmndreg; ?>><a href="?action=dmndreg">Demand Form</a></li>
                        <li <?= $bankbook; ?>><a href="?action=bankbook">Bank book</a></li>
                        <li <?= $cashbook; ?>><a href="?action=cashbook">Cash book</a></li>
                        <li <?= $cheqretu; ?>><a href="?action=cheqretu">Cheque Return</a></li>
                        <li <?= $paymrecd; ?> class="nav-dropdown">
                            <a href="#">Payment Received<i></i></a>
                            <ul class="nav-sub">
                                <li <?= $payrecpbank; ?> ><a href="?action=paymrecd_b">Bank</a></li>
                                <li <?= $payrecpcash; ?> ><a href="?action=paymrecd_c">Cash</a></li>
                            </ul>
                        </li>
                    </ul>
                </li>
                <li class="nav-dropdown">
                    <a href='#'><i class="fa fa-asterisk"></i>Summary</a>
                    <ul class='nav-sub'>
                        <li <?= $rpsales; ?> class="nav-dropdown">
                            <a href="#">Sales<i></i></a>
                            <ul class="nav-sub">
                                <li <?= $salesumppr; ?> ><a href="?action=salesumppr">Sales Summary Paperwise</a></li>
                                <li <?= $salesumamt; ?> ><a href="?action=salesumamt">Sales Summary Amountwise</a></li>
                            </ul>
                        </li>
                        <li <?= $packsum; ?>><a href="?action=packsum">Packet</a></li>
                        <li <?= $schlstrprnt; ?>><a href="?action=schlstrprnt">School Strength For Printers</a></li>
                    </ul>
                </li>
                <li class="nav-dropdown">
                    <a href='#'><i class="fa fa-envelope"></i>Mails</a>
                    <ul class='nav-sub'>
                        <!--<li //<?= $mailmsg; ?> ><a href="?action=mail_msga">Mail All (Message)</a></li>-->
                        <li <?= $mailmsg; ?> ><a href="?action=mail_msgm">Mail Multi. (Message)</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:100000px;"  frameBorder="0" scrolling="no"></iframe>
                </div>
            </section>
        </section>
    </div>
    <!--main content end-->
    <?php include("includes/linksfoot.php") ?>
</body>
</html>
