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

$zdir = $dbname;
$zcomp = 1;
$zdbroot = $zdir;
$focusfield = "user";
$usertype = $_SESSION["usertype"];
$user = $_SESSION["username_" . $dbname];


if (isset($_POST["submit"])) {

    $series = $_POST["series"];
    $_SESSION["series_" . $dbname] = $series;
    $spltype = $_SESSION["spltype_" . $dbname];

//    if ($spltype == "1") {
//        header("Location: mainmenu.php");
//    } else {
//        header("Location: menu.php");
//    }
    header("Location: year.php");
}
include("includes/linkshead.php");
?>
</head>

<body class="animated fadeIn">
    <section id="login-container">

        <div class="row">
            <div class="col-md-3" id="login-wrapper">
                <div class="panel panel-primary animated flipInY" style="background-color: transparent">
                    <div class="panel-heading">
                        <h3 class="panel-title" style="font-size: 30px">Select Branch/Series</h3>      
                    </div>
                    <div class="panel-body">
                        <p> Login to access your account.</p>
                        <form class="form-horizontal" action='' method="POST">
                            <div class="form-group">
                                <div class="col-md-12">
                                    <select  name="series"  class="form-control select2" style="height:33px;width: 100%">
                                        <?php

                                        if ($user == "madni"){
                                            $usercond = " AND code = 'MAD'";
                                        }elseif ($user == "taiba"){
                                            $usercond = " AND code = 'TAI'";
                                        }elseif ($user == "mumbai"){
                                            $usercond = " AND code = 'MJ'";
                                        }else{
                                            $usercond = "";
                                        }
                                        $getseries = mysqli_query($conn, "SELECT `code`,`name` FROM `series` where gdw != '1' $usercond ORDER BY `ordby`") OR die(mysqli_error($conn));
                                        while ($row = mysqli_fetch_array($getseries)) {
                                            $code = $row['code'];
                                            $name = $row['name'];
                                            echo "<option value=\"$code\">$name</option>";
                                        }
                                        ?>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-md-12">
                                    <input type='submit' name='submit' value="submit" class="btn btn-primary btn-block" autofocus>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </section>
    <?php include("includes/linksfoot.php") ?>
</body>
</html>
