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

$formname = 'User Creation';
$maindb = 'passmain';
$trandb = 'usercomp';
$printfile = "";
$file = 'user.php';
$trandbexist = 0;
$grid = '';
$keyfld = "code";

$admin = $_SESSION["admin_" . $dbname];
$username = $_SESSION["username_" . $dbname];

include("includes/vouchno_generate.php");
include("includes/prev&next.php");


if (isset($_POST["submit"])) {
    $a = 1;
    $user = $_POST["user"];
    $password = $_POST["password"];
    $usertype = $_POST["usertype"];
    ################## MASTERS ##################
    $school = $_POST["school"];
    $center = $_POST["center"];
    $medium = $_POST["medium"];
    $subject = $_POST["subject"];
    $district = $_POST["district"];
    $exam = $_POST["exam"];
    $courier = $_POST["courier"];
    $stdepot = $_POST["stdepot"];
    $bank = $_POST["bank"];
    $cash = $_POST["cash"];
    $narration = $_POST["narration"];
    $prprimary = $_POST["prprimary"];
    $prsecondry = $_POST["prsecondry"];
    $prprelium = $_POST["prprelium"];

    ################## TRANSACTION ##################
    $dmndfrm = $_POST["dmndfrm"];
    $gendemd = $_POST["gendemd"];
    $geninvs = $_POST["geninvs"];
    $geninvm = $_POST["geninvm"];
    $invoice = $_POST["invoice"];
    $bankpay = $_POST["bankpay"];
    $bankrecp = $_POST["bankrecp"];
    $cashpay = $_POST["cashpay"];
    $cashrecp = $_POST["cashrecp"];
    $prevbill = $_POST["prevbill"];
    $discgvn = $_POST["discgvn"];
    $discrecd = $_POST["discrecd"];

    ################## REPORTS ##################
    $invprin = $_POST["invprin"];
    $qtypress = $_POST["qtypress"];
    $packet = $_POST["packet"];
    $schldmnd = $_POST["schldmnd"];
    $ledger = $_POST["ledger"];
    $osbill = $_POST["osbill"];
    $multenvp = $_POST["multenvp"];
    $unmark = $_POST["unmark"];
    $rpsubject = $_POST["rpsubject"];
    $rpbill = $_POST["rpbill"];
    $rpschool = $_POST["rpschool"];
    $rpunmark = $_POST["rpunmark"];

    ################## REGISTERS ##################
    $rgbill = $_POST["rgbill"];
    $rgbillpend = $_POST["rgbillpend"];
    $cheqretu = $_POST["cheqretu"];
    $dmndreg = $_POST["dmndreg"];
    $bankbook = $_POST["bankbook"];
    $cashbook = $_POST["cashbook"];
    $payrecpbank = $_POST["payrecpbank"];
    $payrecpcash = $_POST["payrecpcash"];

    ################## SUMMARY ##################
    $salesumppr = $_POST["salesumppr"];
    $salesumamt = $_POST["salesumamt"];
    $packsum = $_POST["packsum"];
    $schlstrprnt = $_POST["schlstrprnt"];

    $count = $_POST["items"];

    if (isset($_POST["name"])) {
        $result = mysqli_query($conn, "SELECT * FROM `$maindb` WHERE `name`= '$name' AND code != '$qvouch'") or die(mysqli_error($conn));
        if (mysqli_num_rows($result) > 0) {
            $a = 0;
            browse("Name Already Exist");
            header("refresh: 1; $file?code=$qvouch&mode=last");
        }
    }

    if ($a == 1) {
        if ($addflag == 1) {
            $gen1 = mysqli_query($conn, "SELECT MAX($keyfld) AS maxcode FROM `$maindb` LIMIT 0,1 ") or die(mysqli_error($conn));

            if (mysqli_num_rows($gen1) > 0) {
                $vvouch = mysqli_fetch_assoc($gen1);
                $qvouch = $vvouch["maxcode"] + 1;
            } else {
                $qvouch = '1';
            }
            $mvouch = $qvouch;
        }

#################################TRAN PART #################################
//        mysqli_query($conn, "DELETE FROM `$trandb` WHERE `username`='$qvouch'") or die(mysqli_error($conn));
//
//        for ($i = 0; $i < $count; $i++) {
//            $cono = $_POST["cono_$i"];
//            $finyear = $_POST["finyear_$i"];
//            $yearname = $_POST["yearname_$i"];
//            $startdate = $_POST["startdate_$i"];
//            $lastdate = $_POST["lastdate_$i"];
//
//            if (!empty($cono)) {
//                $company = mysqli_query($conn, "SELECT `name` FROM `company` WHERE `code`='$cono'")or die(mysqli_error($conn));
//                $co = mysqli_fetch_array($company);
//                $cname = $co[name];
//
//                mysqli_query($conn, "INSERT INTO `$trandb`(`username`,`cono`,`cname`, `finyear`, `yearname`, `startdate`, `lastdate`) 
//                    VALUES ('$qvouch', '$cono', '$cname', '$finyear', '$yearname', '$startdate', '$lastdate')") or die(mysqli_error($conn));
//            }
//        }
############################## MAIN  ######################################################

        if ($addflag == 1) {

            $usecode = mysqli_query($conn, "SELECT code FROM `passmain` WHERE user='$username'")or die(mysqli_error($conn));
            $getuser = mysqli_fetch_object($usecode);
            $code = $getuser->code;

            mysqli_query($conn, "INSERT INTO `$maindb`(`code`, `user`, `password`,`usertype`, `school`, `center`, `medium`, `subject`, `district`, `exam`,
                         `courier`, `stdepot`, `bank`, `cash`, `narration`, `prprimary`, `prsecondry`, `prprelium`, 
                         `dmndfrm`, `gendemd`,`geninvs`,`geninvm`, `invoice`, `bankrecp`, `bankpay`, `cashpay`, `cashrecp`, `prevbill`, `discgvn`, `discrecd`,
                         `invprin`, `qtypress`,`packet`,`schldmnd`,`ledger`, `osbill`, `multenvp`, `unmark`,  `rpsubject`,`rpbill`,`rpschool`, `rpunmark`,
                         `rgbill`, `rgbillpend`, `cheqretu`,`dmndreg`,`bankbook`,`cashbook`, `payrecpbank`, `payrecpcash` 
                         `salesumppr`,`salesumamt`,`packsum`,`schlstrprnt`)
                 VALUES ('$qvouch','$user', '$password','$usertype' ,'$school', '$center', '$medium', '$subject', '$district', '$exam',
                         '$courier', '$stdepot', '$bank', '$cash', '$narration', '$prprimary', '$prsecondry', '$prprelium',
                         '$dmndfrm', '$gendemd', '$geninvs', '$geninvm', '$invoice', '$bankrecp', '$bankpay', '$cashpay', '$cashrecp', '$prevbill', '$discgvn', '$discrecd',
                         '$invprin', '$qtypress', '$packet', '$schldmnd','$ledger','$osbill', '$multenvp', '$unmark','$rpsubject','$rpbill','$rpschool', '$rpunmark',
                         '$rgbill','$rgbillpend', '$cheqretu','$dmndreg','$bankbook','$cashbook', '$payrecpbank', '$payrecpcash',
                         '$salesumppr','$salesumamt','$packsum','$schlstrprnt')") or die(mysqli_error($conn));


            insmess();
            $mvouch = $qvouch;
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
        } else {
            $mvouch = $qvouch;

            $usecode = mysqli_query($conn, "SELECT code FROM `passmain` WHERE user='$username'")or die(mysqli_error($conn));
            $getuser = mysqli_fetch_object($usecode);
            $code = $getuser->code;

            mysqli_query($conn, "UPDATE `$maindb` SET `user`='$user', `password`='$password',`usertype`='$usertype', `school`='$school',
                                              `center`='$center',`medium`='$medium', `subject`='$subject', `district`='$district',
                                              `exam`='$exam', `courier`='$courier', `stdepot`='$stdepot',`bank`='$bank', `cash`='$cash',
                                              `narration`='$narration', `prprimary`='$prprimary', `prsecondry`='$prsecondry',
                                              `prprelium`='$prprelium',`dmndfrm`='$dmndfrm', `gendemd`='$gendemd', `geninvs`='$geninvs', 
                                              `geninvm`='$geninvm', `invoice`='$invoice', `bankrecp`='$bankrecp', `bankpay`='$bankpay',
                                              `cashpay`='$cashpay', `cashrecp`='$cashrecp', `prevbill`='$prevbill', `discgvn`='$discgvn',
                                              `discrecd`='$discrecd', `invprin`='$invprin', `qtypress`='$qtypress', `packet`='$packet',
                                              `schldmnd`='$schldmnd',`ledger`='$ledger',`osbill`='$osbill', `multenvp`='$multenvp', `unmark`='$unmark', `rpsubject`='$rpsubject',
                                              `rpbill`='$rpbill', `rpschool`='$rpschool', `rpunmark`='$rpunmark', `packet`='$packet', `rgbill`='$rgbill', 
                                              `rgbillpend`='$rgbillpend', `cheqretu`='$cheqretu',`dmndreg`='$dmndreg', `bankbook`='$bankbook',`cashbook`='$cashbook',
                                              `payrecpbank`='$payrecpbank', `payrecpcash`='$payrecpcash', `salesumppr`='$salesumppr',`salesumamt`='$salesumamt', `packsum`='$packsum', 
                                              `schlstrprnt`='$schlstrprnt' WHERE code = '$mvouch' ") or die(mysqli_error($conn));
            updmess();
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
        }
    }
}

if ($addflag != 1) {

    $getvouch = '';
    if ($addflag == 0) {
        $getvouch = $_GET[$keyfld];
    } else {
        $getvouch = $qvouch;
    }
//browse($getvouch);
    $result = mysqli_query($conn, "SELECT * FROM `$maindb` WHERE $keyfld='$getvouch'") or die(mysqli_error($conn));
    $get = mysqli_fetch_array($result);
}

$senable = "";
$cenable = "";

/* DELETE */
if (isset($_GET["delete"])) {
    delete($zdb, "$maindb", "$keyfld", $_GET[$keyfld], "$file?mode=last");
}
?>
<?php include("includes/linkshead.php"); ?>
<style>
    input[type = checkbox]{
        width: 20px;
        height: 20px;
    }
</style>
<script src="MyScript/user.js" type="text/javascript"></script>
<body>
    <!-- Default box -->
    <form action='' method='POST'>
        <!-- Default box -->
        <div class="">
            <div class="col-lg-6">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><?php Echo $formname; ?></h3>
                        <div class="actions pull-right">
                            <i class="fa fa-chevron-down"></i>
                        </div>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <label class="col-sm-3 control-label marg">User Name</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control form user" name="user" placeholder="User Name" autocomplete="off" value='<? echo ($addflag != 1) ? $get['user'] : ''; ?>' required="" autofocus>
                            </div>
                        </div>
                        <div class="row">
                            <label class="col-sm-3 control-label marg">Password</label>
                            <div class="col-sm-6">
                                <input type="password" class="form-control form password" name="password" id="pass" autocomplete="off" placeholder="Password" value='<? echo ($addflag != 1) ? $get['password'] : ''; ?>' required="">
                            </div>
                        </div>
                        <div class="row">
                            <label class="col-sm-3 control-label marg">Confirm Pass</label>
                            <div class="col-sm-6">
                                <input type="password" name="confpass" id="confpass" class="form-control form"  placeholder="Cofirm Password" required="" value='<? echo ($addflag != 1) ? $get['password'] : ''; ?>'>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-6">
                                <p id="alert"></p>
                            </div>
                        </div>
                        <div class="row">
                            <label class="col-sm-3 control-label marg">User Type</label>
                            <div class="col-sm-6">

                                <select class='form-control select2 form' name="usertype" id="usertype">                                    
                                    <?php
                                    if ($addflag != 1) {
                                        $usertyp = "";
                                        if ($get[usertype] == 1) {
                                            $ucode = "1";
                                            $usertyp = "Admin";
                                        }
                                        if ($get[usertype] == 2) {
                                            $ucode = "2";
                                            $usertyp = "Supervisor";
                                        }
                                        if ($get[usertype] == 3) {
                                            $ucode = "3";
                                            $usertyp = "Staff";
                                        }
                                        echo "<option value='$ucode'>$usertyp</option>";
                                    }
                                    ?>
                                    <option value=""></option>
                                    <option value="3">Staff</option>
                                    <option value="2">Supervisor</option>
                                    <option value="1">Admin</option>
                                </select>
                            </div>
                        </div>
                        <div class="nav-tabs-custom">
                            <ul class="nav nav-tabs">
                                <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true">Masters</a></li>
                                <li class=""><a href="#tab_2" data-toggle="tab" aria-expanded="false">Transaction</a></li>
                                <li class=""><a href="#tab_3" data-toggle="tab" aria-expanded="false">Reports</a></li>
                                <li class=""><a href="#tab_4" data-toggle="tab" aria-expanded="false">Registers</a></li>
                                <li class=""><a href="#tab_5" data-toggle="tab" aria-expanded="false">Summary</a></li>
                            </ul>
                            <div class="tab-content">
                                <div class="tab-pane active" id="tab_1">
                                    <div class="row">
                                        <label class="col-sm-6 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-1" style="margin-top:6px">
                                            <input type="checkbox" class="form " id="Smasters" value="1">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">School</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="school" name="school" value="1" <?
                                            if ($get['school'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Center</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="center" name="center" value="1" <?
                                            if ($get['center'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Medium</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="medium" name="medium" value="1" <?
                                            if ($get['medium'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Subject</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="subject" name="subject" value="1" <?
                                            if ($get['subject'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">District</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="district" name="district" value="1" <?
                                            if ($get['district'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Exam</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="exam" name="exam" value="1" <?
                                            if ($get['exam'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Courier</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="courier" name="courier" value="1" <?
                                            if ($get['courier'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">St.Depot</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="stdepot" name="stdepot" value="1" <?
                                            if ($get['stdepot'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Paper Rate - Primary </label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="prprimary" name="prprimary" value="1" <?
                                            if ($get['prprimary'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Paper Rate - Secondry</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="prsecondry" name="prsecondry" value="1" <?
                                            if ($get['prsecondry'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Paper Rate - Prelium</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="prprelium" name="prprelium" value="1" <?
                                            if ($get['prprelium'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>> 
                                        </div>
                                        <label class="col-sm-4 control-label marg">Cash</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="cash" name="cash" value="1" <?
                                            if ($get['cash'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Bank</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="bank" name="bank" value="1" <?
                                            if ($get['bank'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Narration</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="narration" name="narration" value="1" <?
                                            if ($get['narration'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                </div><!-- /.tab-pane -->
                                <div class="tab-pane" id="tab_2">
                                    <div class="row">
                                        <label class="col-sm-6 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form " id="Stransactions" value="1">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Demand Form</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="dmndfrm" name="dmndfrm" value="1" <?
                                            if ($get['dmndfrm'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Generate Demand Form</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="gendemd" name="gendemd" value="1" <?
                                            if ($get['gendemd'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Generate Bill Single</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="geninvs" name="geninvs" value="1" <?
                                            if ($get['geninvs'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Invoice</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="invoice" name="invoice" value="1" <?
                                            if ($get['invoice'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Bank Payment</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="bankpay" name="bankpay" value="1" <?
                                            if ($get['bankpay'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Cash Payment</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="cashpay" name="cashpay" value="1" <?
                                            if ($get['cashpay'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Bank Receipt</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="bankrecp" name="bankrecp" value="1" <?
                                            if ($get['bankrecp'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Cash Receipt</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="cashrecp" name="cashrecp" value="1" <?
                                            if ($get['cashrecp'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Previous Bill</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="prevbill" name="prevbill" value="1" <?
                                            if ($get['prevbill'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Discount Given</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="discgvn" name="discgvn" value="1" <?
                                            if ($get['discgvn'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Discount Received</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="discrecd" name="discrecd" value="1" <?
                                            if ($get['discrecd'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Generate Bill  Multiple</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="geninvm" name="geninvm" value="1" <?
                                            if ($get['geninvm'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                </div><!-- /.tab-pane -->
                                <div class="tab-pane" id="tab_3">
                                    <div class="row">
                                        <label class="col-sm-6 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form " id="Sreports" value="1">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Invoice /Bill Print</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="invprin" name="invprin" value="1" <?
                                            if ($get['invprin'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Qty. For Press</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="qtypress" name="qtypress" value="1" <?
                                            if ($get['qtypress'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Packet</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="packet" name="packet" value="1" <?
                                            if ($get['packet'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">School List of Demand Form(Centerwise)</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="schldmnd" name="schldmnd" value="1" <?
                                            if ($get['schldmnd'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Ledger</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="ledger" name="ledger" value="1" <?
                                            if ($get['ledger'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Subject Label</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="rpsubject" name="rpsubject" value="1" <?
                                            if ($get['rpsubject'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Bill Label</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="rpbill" name="rpbill" value="1" <?
                                            if ($get['rpbill'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">School Label</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="rpschool" name="rpschool" value="1" <?
                                            if ($get['rpschool'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Outstanding Receivable</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="osbill" name="osbill" value="1" <?
                                            if ($get['osbill'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Unmarked</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="unmark" name="unmark" value="1" <?
                                            if ($get['unmark'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Multiple Envelope</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="multenvp" name="multenvp" value="1" <?
                                            if ($get['multenvp'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Unsettled Reciept</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="multenvp" name="multenvp" value="1" <?
                                            if ($get['multenvp'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    
                                </div>
                                <!-- /.tab-pane -->
                                <div class="tab-pane" id="tab_4">
                                    <div class="row">
                                        <label class="col-sm-6 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form " id="Sregisters" value="1">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Bill</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="rgbill" name="rgbill" value="1" <?
                                            if ($get['rgbill'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Bill Pending</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="rgbillpend" name="rgbillpend" value="1" <?
                                            if ($get['rgbillpend'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Demand Form</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="dmndreg" name="dmndreg" value="1" <?
                                            if ($get['dmndreg'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Bank Book</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="bankbook" name="bankbook" value="1" <?
                                            if ($get['bankbook'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Cash Book</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="cashbook" name="cashbook" value="1" <?
                                            if ($get['cashbook'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Cheque Return</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  cheqretu" id="cheqretu" name="cheqretu" value="1" <?
                                            if ($get['cheqretu'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Payment Received-Bank</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="payrecpbank" name="payrecpbank" value="1" <?
                                            if ($get['payrecpbank'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Payment Recieved-Cash</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  payrecpcash" id="payrecpcash" name="payrecpcash" value="1" <?
                                            if ($get['payrecpcash'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                </div> 
                                <div class="tab-pane" id="tab_5">
                                    <div class="row">
                                        <label class="col-sm-6 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-1" style="margin-top:6px">
                                            <input type="checkbox" class="form " id="Ssummary" value="1">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Sales Summary - Paperwise</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  summary" id="salesumppr" name="salesumppr" value="1" <?
                                            if ($get['salesumppr'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Sales Summary - Amountwise</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  summary" id="salesumamt" name="salesumamt" value="1" <?
                                            if ($get['salesumamt'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Packet</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  summary" id="packsum" name="packsum" value="1" <?
                                            if ($get['packsum'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">School Strenght For Printers</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  summary" id="schlstrprnt" name="schlstrprnt" value="1" <?
                                            if ($get['schlstrprnt'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                </div>
                                <!-- /.tab-content -->
                            </div>
                        </div>
                        <div class="panel-footer">
                            <?php include("includes/buttons.php"); ?>
                        </div>
                    </div>
                </div>
                <!--            <div class="col-lg-6 col-md-12 col-sm-12 col-xs-12 pad">
                                <div class="panel panel-default">
                                    <div class="panel-heading">
                                        <h3 class="panel-title">Year Details</h3>
                                        <div class="actions pull-right">
                                            <i class="fa fa-chevron-down"></i>
                                        </div>
                                    </div>
                                    <div class="panel-body">
                                        <div class="table-responsive">
                                            <table class="table table-striped table-condensed table-bordered" width="100%">
                                                <thead  class="mySearchTr">
                                                    <tr>
                                                        <th width="3%"></th>
                                                        <th width="17%">Company</th>
                                                        <th width="10%">Year</th>
                                                        <th width="10%">Name</th>
                                                        <th width="10%">From</th>
                                                        <th width="10%">To</th>
                                                    </tr>
                                                </thead>
                                                <tbody class="tbody">
                <?php
//                                    if ($addflag != 1) {
//                                        $ctr = 0;
//                                        $gettran = mysqli_query($conn, "SELECT `cono`,`cname`,`finyear`,`startdate`,`lastdate`,`yearname` FROM `usercomp` WHERE `username`='$get[code]' ORDER BY `cono`")or die(mysqli_error($conn));
//                                        while ($tran = mysqli_fetch_array($gettran)) {
//                                            $fetcomp = mysqli_query($conn, "SELECT `cono`,`compname` FROM `company` WHERE `code`='$tran[cono]'")or die(mysqli_error($conn));
//                                            $fcomp = mysqli_fetch_array($fetcomp);
//
//                                            $fetyear = mysqli_query($conn, "SELECT `finyear` FROM `compyear` WHERE `finyear`='$tran[finyear]'")or die(mysqli_error($conn));
//                                            $fyear = mysqli_fetch_array($fetyear);
//
//                                            Echo "<tr>";
//                                            Echo "<td><i class='fa fa-close remove' style='display:none;'></i></td>";
//                                            Echo "<td>";
//                                            Echo "<select class='form-control form cono select2' name='cono_$ctr' style='width:100%'>";
//                                            Echo "<option value='$fcomp[cono]'>$fcomp[compname]</option>";
//                                            $gcomp = mysqli_query($conn, "SELECT `cono`,`compname` FROM `company`")or die(mysqli_error($conn));
//                                            while ($comp = mysqli_fetch_array($gcomp)) {
//                                                Echo "<option value='$comp[cono]'>$comp[compname]</option>";
//                                            }
//                                            Echo "</select>";
//                                            Echo "</td>";
//                                            Echo "<td>";
//                                            Echo "<select class='form-control form finyear select2' name='finyear_$ctr' style='width:100%'>";
//                                            Echo "<option value='$fyear[finyear]'>$fyear[finyear]</option>";
//                                            $gyear = mysqli_query($conn, "SELECT `finyear` FROM `compyear`")or die(mysqli_error($conn));
//                                            while ($year = mysqli_fetch_array($gyear)) {
//                                                Echo "<option value='$year[finyear]'>$year[finyear]</option>";
//                                            }
//                                            Echo "</select>";
//                                            Echo "</td>";
//                                            Echo "<td><input type='text' class='form-control form yearname' name='yearname_$ctr' value='$tran[yearname]' readonly></td>";
//                                            Echo "<td><input type='text' class='form-control form startdate' name='startdate_$ctr' value='$tran[startdate]' readonly></td>";
//                                            Echo "<td><input type='text' class='form-control form lastdate' name='lastdate_$ctr' value='$tran[lastdate]' readonly></td>";
//                                            Echo "</tr >";
//                                            $ctr++;
//                                        }
//                                    } else {
                ?>
                                                        <tr>
                                                            <td><i class='fa fa-close remove'></i></td>
                                                            <td>
                                                                <select class="form-control form cono select2" name="cono_0" style='width:100%' required>
                                                                    <option value=""></option>
                <?php
//                                                    $gcomp = mysqli_query($conn, "SELECT `cono`,`compname` FROM `company`")or die(mysqli_error($conn));
//                                                    while ($comp = mysqli_fetch_array($gcomp)) {
//                                                        Echo "<option value='$comp[cono]'>$comp[compname]</option>";
//                                                    }
                ?>
                                                                </select>
                                                            </td>
                                                            <td>
                                                                <select class="form-control form finyear select2" name="finyear_0" style='width:100%' required>
                                                                    <option value=""></option>
                <?php
//                                                    $gyear = mysqli_query($conn, "SELECT `finyear` FROM `compyear`")or die(mysqli_error($conn));
//                                                    while ($year = mysqli_fetch_array($gyear)) {
//                                                        Echo "<option value='$year[finyear]'>$year[finyear]</option>";
//                                                    }
                ?>
                                                                </select>
                                                            </td>
                                                            <td><input type="text" class="form-control form yearname" name="yearname_0" value="" readonly></td>
                                                            <td><input type="text" class="form-control form startdate" name="startdate_0" value="" readonly></td>
                                                            <td><input type="text" class="form-control form lastdate" name="lastdate_0" value="" readonly></td>
                                                        </tr>  
                <?
//                                    }
                ?>
                                                </tbody>
                                            </table>
                                        </div>
                                        <div class="col-lg-12 pad">
                                            <button type="button" class="btn btn-primary btn-square form"  id="addnew">
                                                <i class="fa fa-plus" data-toggle='tooltip' title='Add Row'></i>    
                                            </button>
                                            <input type="hidden" id="items" name="items" value="<?php // echo ($addflag != 1) ? $ctr : 1;      ?>" />  
                                        </div>
                                    </div>
                                </div>
                            </div>-->
            </div>
    </form>
    <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span>&times;</span></button>
                    <h4 class="modal-title" id="myLargeModalLabel">Search <? Echo $formname; ?></h4>
                </div>
                <div class="modal-body">
                    <div class=" table-responsive">
                        <table id="example1" class="table table-striped">
                            <thead>
                                <tr class="mySearchTr">
                                    <th>code</th>
                                    <th>Name</th>
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                if ($addflag != 1) {
                                    $srchresult = mysqli_query($conn, "SELECT * FROM `$maindb`")or die(mysqli_error($conn));
                                    while ($row = mysqli_fetch_array($srchresult)) {

                                        $code = $row['code'];
                                        $user = $row['user'];

                                        echo "<tr>";
                                        echo "<td align='left'>$code</td>";
                                        echo "<td align='left'>$user</td>";
                                        echo "<td align='left'><a href=\"$file?mode=edit&$keyfld=$row[$keyfld]\"><i class='fa fa-pencil' style='font-size:1.3em;color:#00C0EF;cursor:pointer;'></i></a></td>";
                                        echo "</tr>";
                                    }
                                }
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="modal-footer"></div>
            </div>
        </div>
    </div>
</body>
</html>
<?php include("includes/linksfoot.php"); ?>