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

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

//$zdb = $_SESSION["zdbyear_" . $dbname];
//mysqli_select_db($conn,$zdb);


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

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

if (isset($_POST["submit"])) {
    $a = 1;
    $user = $_POST["user"];
    $password = $_POST["password"];
//    $ipadd = $_POST["ipadd"];
//    $ipadd2 = $_POST["ipadd2"];
    $usertype = $_POST["usertype"];
//    $email = $_POST["email"];
//    $accounts = $_POST["accounts"];
    ################## MASTERS ##################
    $customer = $_POST["customer"];
    $item = $_POST["item"];
    $designation = $_POST["designation"];
    $staff = $_POST["staff"];
    $expense = $_POST["expense"];
    $metric = $_POST["metric"];
    $nbmetric = $_POST["nbmetric"];
    $guagemetric = $_POST["guagemetric"];
    $area = $_POST["area"];
    $openbal = $_POST["openbal"];
    $bank = $_POST["bank"];
    $narration = $_POST["narration"];
    $narrmast = $_POST["narrmast"];
    $diamaster = $_POST["diamaster"];

    ################## TRANSACTION ##################
    $challan = $_POST["challan"];
    $genbill = $_POST["genbill"];
    $cashrecd = $_POST["cashrecd"];
    $expensevoch = $_POST["expensevoch"];
    $bankrecp = $_POST["bankrecp"];
    $bankpay = $_POST["bankpay"];
    $persexpense = $_POST["persexpense"];
    $discgive = $_POST["discgive"];
    $attendance = $_POST["attendance"];
    $attendedit = $_POST["attendedit"];
    $salprocess = $_POST["salprocess"];
//    $diamaster = $_POST["diamaster"];
//    $openbal = $_POST["openbal"];
    ################## REPORTS ##################
    $challprint = $_POST["challprint"];
    $gstinvrep = $_POST["gstinvrep"];
    $summparty = $_POST["summparty"];
    $ledger = $_POST["ledger"];
    $labels = $_POST["labels"];
    $query = $_POST["query"];
    $analysis = $_POST["analysis"];
    $diaprint = $_POST["diaprint"];
    $bankbook = $_POST["bankbook"];
    $partratecomp = $_POST["partratecomp"];
    $calcbonus = $_POST["calcbonus"];
    $dailycash = $_POST["dailycash"];

    ################## REGISTERS ##################
    $chalreg = $_POST["chalreg"];
    $gstinvreg = $_POST["gstinvreg"];
    $cashrecd_print = $_POST["cashrecd_print"];
    $expreg = $_POST["expreg"];
    $attendreg = $_POST["attendreg"];
    $stafattend = $_POST["stafattend"];
    $salreg = $_POST["salreg"];
    $bonusreg = $_POST["bonusreg"];
    $shopreg = $_POST["shopreg"];
    $persexpreg = $_POST["persexpreg"];
//    $balsheet = $_POST["balsheet"];
    $discgvreg = $_POST["discgvreg"];

    ################## FINALIZATION ##################
    $trbal = $_POST["trbal"];
    $profit = $_POST["profit"];
    $profshar = $_POST["profshar"];
    $balsheet = $_POST["balsheet"];


    ################## TOOLS ##################
    $tlcompany = $_POST["tlcompany"];
    $tlbackup = $_POST["tlbackup"];
    $tlprofile = $_POST["tlprofile"];
    $dstock = $_POST["dstock"];


    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;
        }

############################## MAIN  ######################################################

        if ($addflag == 1) {

            $usecode = mysqli_query($conn,"SELECT code FROM $zroot.`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`,`customer`,`item`,`designation`,`staff`,`expense`,`metric`,`nbmetric`,`guagemetric`,
                                `area`,`openbal`, `bank`, `narration`, `narrmast`, `diamaster`,`challan`,`genbill`,`cashrecd`,`expensevoch`,`bankrecp`,
                                `bankpay`,`persexpense`,`discgive`,`attendance`,`attendedit`,`salprocess`,`challprint`,
                                `gstinvrep`,`summparty`,`ledger`,`labels`,`query`,`analysis`,`diaprint`,`bankbook`,`partratecomp`,`calcbonus`,`dailycash`,
                                `chalreg`,`gstinvreg`,`cashrecd_print`,`expreg`,`attendreg`,`stafattend`,`salreg`,`bonusreg`,`shopreg`, `persexpreg`,`discgvreg`,
                                `trbal`,`profit`,`profshar`,`balsheet`)
                                
                        VALUES($qvouch, '$user', '$password', '$usertype', '$customer','$item','$designation','$staff','$expense','$metric','$nbmetric','$guagemetric',
                                '$area','$openbal', '$bank', '$narration', '$narrmast', '$diamaster','$challan','$genbill','$cashrecd','$expensevoch','$bankrecp',
                                '$bankpay','$persexpense','$discgive','$attendance','$attendedit','$salprocess','$challprint',
                                '$gstinvrep','$summparty','$ledger','$labels','$query','$analysis','$diaprint','$bankbook','$partratecomp','$calcbonus','$dailycash',
                                '$chalreg','$gstinvreg','$cashrecd_print','$expreg','$attendreg','$stafattend','$salreg','$bonusreg','$shopreg', '$persexpreg','$discgvreg',
                                '$trbal','$profit','$profshar','$balsheet')") 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 $zroot.`passmain` WHERE user='$username'")or die(mysqli_error($conn));
            $getuser = mysqli_fetch_object($usecode);
            $code = $getuser->code;

            mysqli_query($conn,"UPDATE `$maindb` SET code='$qvouch', `user`='$user', `password`='$password',`usertype`='$usertype',`customer`='$customer',
                                              `item`='$item',`designation`='$designation',`staff`='$staff',`expense`='$expense',`metric`='$metric',`nbmetric`='$nbmetric',
                                              `guagemetric`='$guagemetric',`area`='$area',`openbal`='$openbal', `bank`='$bank', `narration`='$narration', `narrmast`='$narrmast', 
                                              `diamaster`='$diamaster',`challan`='$challan',`genbill`='$genbill',`cashrecd`='$cashrecd',`expensevoch`='$expensevoch',`bankrecp`='$bankrecp',
                                              `bankpay`='$bankpay',`persexpense`='$persexpense',`discgive`='$discgive',`attendance`='$attendance',`attendedit`='$attendedit',
                                              `salprocess`='$salprocess',`challprint`='$challprint',`gstinvrep`='$gstinvrep',`summparty`='$summparty',`ledger`='$ledger',`labels`='$labels',
                                              `query`='$query',`analysis`='$analysis',`diaprint`='$diaprint',`bankbook`='$bankbook',`partratecomp`='$partratecomp',`calcbonus`='$calcbonus',`dailycash`='$dailycash',
                                              `chalreg`='$chalreg',`gstinvreg`='$gstinvreg',`cashrecd_print`='$cashrecd_print',`expreg`='$expreg',`attendreg`='$attendreg',
                                              `stafattend`='$stafattend',`salreg`='$salreg',`bonusreg`='$bonusreg',`shopreg`='$shopreg',`persexpreg`='$persexpreg',`discgvreg`='$discgvreg',
                                              `trbal`='$trbal',`profit`='$profit',`profshar`='$profshar',`balsheet`='$balsheet' 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;
    }

    $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"); ?>
<script>
    $(document).ready(function () {
        $("#branch").on('change keyup blur', GetPlace);

        function GetPlace() {
            var brch = $('#branch').val();
            $.post('getplace.php', {branch: brch}, function (data) {
                $("#place").val(data);
            });
        }

        $("#Smasters").click(function () {
            $(".masters").prop('checked', $(this).prop('checked'));
        });
        $("#Stransactions").click(function () {
            $(".transactions").prop('checked', $(this).prop('checked'));
        });
        $("#Sreports").click(function () {
            $(".reports").prop('checked', $(this).prop('checked'));
        });
        $("#Sregisters").click(function () {
            $(".registers").prop('checked', $(this).prop('checked'));
        });
        $("#Sfinalization").click(function () {
            $(".finalization").prop('checked', $(this).prop('checked'));
        });
        $("#Stools").click(function () {
            $(".tools").prop('checked', $(this).prop('checked'));
        });
        $("#Sdashboard").click(function () {
            $(".dashboard").prop('checked', $(this).prop('checked'));
        });

        $("#confpass").blur(function () {
            var pass = $("#password").val();
            var cpass = $("#confpass").val();
            if (pass !== cpass) {
                $("#alert").html("<b style='color:red;'>Password Doesn't Match</b>");
                $("#ssubmit").hide();
            } else {
                $("#alert").html("<b style='color:green;'>Password Matched</b>");
                $("#ssubmit").show();
            }
        });
    });
</script>
<body>
    <!-- Default box -->
    <form action='' method='POST'>
        <!-- Default box -->
        <div class="row">
            <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" name="user" placeholder="User Name" autocomplete="on" 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" name="password" id="password" 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 tmarg">Ip Address</label>
                                                    <div class="col-sm-6">
                                                        <input type="text" class="form-control form" name="ipadd" placeholder="Ip Address" value='<? echo ($addflag != 1) ? $get['ipadd'] : ''; ?>'>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <label class="col-sm-3 control-label tmarg">Ip Address 2</label>
                                                    <div class="col-sm-6">
                                                        <input type="text" class="form-control form" name="ipadd2" placeholder="Ip Address 2" value='<? echo ($addflag != 1) ? $get['ipadd2'] : ''; ?>'>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <label class="col-sm-3 control-label marg">Email Id</label>
                                                    <div class="col-sm-6">
                                                        <input type="email" name="email" id="email" class="form-control form"  placeholder="Email" required="" value='<? echo ($addflag != 1) ? $get['email'] : ''; ?>'>
                                                    </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="row">
                                                    <label class="col-sm-3 control-label marg">Accounts</label>
                                                    <div class="col-sm-6">
                                                        <input type="text" class="form-control form" name="accounts" placeholder="Accounts" autocomplete="on" value='<? echo ($addflag != 1) ? $get['accounts'] : ''; ?>' >
                                                    </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">Finalization</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-4" 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">Party</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="customer" name="customer" value="1" <?
                                            if ($get[customer] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Item</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="item" name="item" value="1" <?
                                            if ($get[item] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Designation</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="designation" name="designation" value="1" <?
                                            if ($get[designation] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Staff</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="staff" name="staff" value="1" <?
                                            if ($get[staff] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Expense</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="expense" name="expense" value="1" <?
                                            if ($get[expense] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Metric</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="metric" name="metric" value="1" <?
                                            if ($get[metric] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">NB Metric</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="nbmetric" name="nbmetric" value="1" <?
                                            if ($get[nbmetric] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Guage Metric</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="guagemetric" name="guagemetric" value="1" <?
                                            if ($get[guagemetric] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Area</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="area" name="area" value="1" <?
                                            if ($get[area] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Opening Balance</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="openbal" name="openbal" value="1" <?
                                            if ($get[openbal] == 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 class="row">
                                        <label class="col-sm-4 control-label marg">Pers. Expense Party</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="narrmast" name="narrmast" value="1" <?
                                            if ($get[narrmast] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Dia Master</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="diamaster" name="diamaster" value="1" <?
                                            if ($get[diamaster] == 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">Challan</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="challan" name="challan" value="1" <?
                                            if ($get[challan] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Generation GST Challan</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="genbill" name="genbill" value="1" <?
                                            if ($get[genbill] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Cash Recd.</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="cashrecd" name="cashrecd" value="1" <?
                                            if ($get[cashrecd] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Cash Payment/Expense</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="expensevoch" name="expensevoch" value="1" <?
                                            if ($get[expensevoch] == 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">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>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Personal Expense</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="persexpense" name="persexpense" value="1" <?
                                            if ($get[persexpense] == 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="discgive" name="discgive" value="1" <?
                                            if ($get[discgive] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Attendance</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="attendance" name="attendance" value="1" <?
                                            if ($get[attendance] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div><label class="col-sm-4 control-label marg">Attendance (Edit)</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="attendedit" name="attendedit" value="1" <?
                                            if ($get[attendedit] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Salary Process</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="salprocess" name="salprocess" value="1" <?
                                            if ($get[salprocess] == 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">Challan Print</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="challprint" name="challprint" value="1" <?
                                            if ($get[challprint] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">GST Invoice Print</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="gstinvrep" name="gstinvrep" value="1" <?
                                            if ($get[gstinvrep] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Summary Partywise</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="summparty" name="summparty" value="1" <?
                                            if ($get[summparty] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <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>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Labels</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="labels" name="labels" value="1" <?
                                            if ($get[labels] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Query</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="query" name="query" value="1" <?
                                            if ($get[query] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Analysis</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="analysis" name="analysis" value="1" <?
                                            if ($get[analysis] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Dia Print</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="diaprint" name="diaprint" value="1" <?
                                            if ($get[diaprint] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <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  reports" id="bankbook" name="bankbook" value="1" <?
                                            if ($get[bankbook] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Party Rate Compare</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="partratecomp" name="partratecomp" value="1" <?
                                            if ($get[partratecomp] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Calculate Bonus</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="calcbonus" name="calcbonus" value="1" <?
                                            if ($get[calcbonus] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Daily Cash Report</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="dailycash" name="dailycash" value="1" <?
                                            if ($get[dailycash] == 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">Challan Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="chalreg" name="chalreg" value="1" <?
                                            if ($get[chalreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">GST Invoice</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="gstinvreg" name="gstinvreg" value="1" <?
                                            if ($get[gstinvreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Cash Recd.</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="cashrecd_print" name="cashrecd_print" value="1" <?
                                            if ($get[cashrecd_print] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Expense</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="expreg" name="expreg" value="1" <?
                                            if ($get[expreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Attendance Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="attendreg" name="attendreg" value="1" <?
                                            if ($get[attendreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Staff Attendance</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="stafattend" name="stafattend" value="1" <?
                                            if ($get[stafattend] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Salary Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="salreg" name="salreg" value="1" <?
                                            if ($get[salreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Bonus Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="bonusreg" name="bonusreg" value="1" <?
                                            if ($get[bonusreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Shopping Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="shopreg" name="shopreg" value="1" <?
                                            if ($get[shopreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Personal Expense Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="persexpreg" name="persexpreg" value="1" <?
                                            if ($get[persexpreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <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  registers" id="discgvreg" name="discgvreg" value="1" <?
                                            if ($get[discgvreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                </div> <!-- /.tab-pane-->
                                <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-4" style="margin-top:6px">
                                            <input type="checkbox" class="form" id="Sfinalization" value="1">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Trial Balance</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  finalization" id="trbal" name="trbal" value="1" <?
                                            if ($get[trbal] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Profit/Loss</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  finalization" id="profit" name="profit" value="1" <?
                                            if ($get[profit] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Profit Sharing</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  finalization" id="profshar" name="profshar" value="1" <?
                                            if ($get[profshar] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Balance Sheet</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  finalization" id="balsheet" name="balsheet" value="1" <?
                                            if ($get[balsheet] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                </div> <!-- /.tab-pane-->
                            </div><!-- /.tab-content -->
                        </div>
                    </div>
                    <div class="panel-footer">
                        <?php include("includes/buttons.php"); ?>
                    </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 style="background-color: #64CCFC;">
                                    <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)) {
                                        echo "<tr>";
                                        echo "<td align='left'>$row[code]</td>";
                                        echo "<td align='left'>$row[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"); ?>