<?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_kacha.php';
$trandbexist = 0;
$grid = '';
$keyfld = "code";

$admin = $_SESSION["admin_" . $dbname];
$username = $_SESSION["username_" . $dbname];
$password = $_SESSION["password_" . $dbname];
$spectype = $_SESSION["spltype_" . $dbname];

// browse($spectype);
if ($spectype == "1") {
    $speccond = "and `compchng`='1'";
} else {
    $speccond = "and `compchng`=''";
}

$keycond = "and `spltype`='$spectype'";
//browse($spectype);

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"];
    $spltype  = $_POST["spltype"];

    ################## MASTERS ##################
    $customer  = $_POST["customer"];
    $maker     = $_POST["maker"];
    $supplier  = $_POST["supplier"];
    $openbal   = $_POST["openbal"];
    $transport = $_POST["transport"];
    $color     = $_POST["color"];
    $bank      = $_POST["bank"];
    $cash      = $_POST["cash"];
    $expense   = $_POST["expense"];
    $group     = $_POST["group"];
    $otherac   = $_POST["otherac"];

    ################## RAW MASTERS ##################
    $rawmatgrp   = $_POST["rawmatgrp"];
    $rawmat      = $_POST["rawmat"];
    $rawchrateop = $_POST["rawchrateop"];

    ################## Raw Material ###############
    $purchmat       = $_POST["purchmat"];
    $debnoteraw     = $_POST["debnoteraw"];
    $debothgst_raw  = $_POST["debothgst_raw"];
    $salemat        = $_POST["salemat"];
    $crednoteraw    = $_POST["crednoteraw"];
    $inwardraw      = $_POST["inwardraw"];
    $outwardraw     = $_POST["outwardraw"];
    $damagedraw     = $_POST["damagedraw"];
    $purchrawreg    = $_POST["purchrawreg"];
    $debnoterawreg  = $_POST["debnoterawreg"];
    $slmatmultireg  = $_POST["slmatmultireg"];
    $crednoterawreg = $_POST["crednoterawreg"];
    $inwregraw      = $_POST["inwregraw"];
    $outregraw      = $_POST["outregraw"];
    $damregraw      = $_POST["damregraw"];
    $rawstock       = $_POST["rawstock"];
    $rawinwout      = $_POST["rawinwout"];
    $rawmatwise     = $_POST["rawmatwise"];
    $rawmatwisesale = $_POST["rawmatwisesale"];
    $rawgrpwisesale = $_POST["rawgrpwisesale"];

    ################## PRODUCT MASTERS ##################
    $itemgrp  = $_POST["itemgrp"];
    $item     = $_POST["item"];
    $chrateop = $_POST["chrateop"];

    ################## Product ##################
    $saleamt            = $_POST["saleamt"];
    $purchase           = $_POST["purchase"];
    $sale               = $_POST["sale"];
    $debnote            = $_POST["debnote"];
    $debothgst          = $_POST["debothgst"];
    $crednote           = $_POST["crednote"];
    $inwardgst          = $_POST["inwardgst"];
    $outwardgst         = $_POST["outwardgst"];
    $damagedgst         = $_POST["damagedgst"];
    $saleamtreg         = $_POST["saleamtreg"];
    $purchreg           = $_POST["purchreg"];
    $salereg            = $_POST["salereg"];
    $debreg             = $_POST["debreg"];
    $crdntreg           = $_POST["crdntreg"];
    $inwreg             = $_POST["inwreg"];
    $damreg             = $_POST["damreg"];
    $jobrecdreg         = $_POST["jobrecdreg"];
    $stock              = $_POST["stock"];
    $inwout             = $_POST["inwout"];
    $itemwise           = $_POST["itemwise"];
    $itemwisesale       = $_POST["itemwisesale"];
    $itemgrpwisesale    = $_POST["itemgrpwisesale"];
    $partygrpwisesale   = $_POST["partygrpwisesale"];
    $credreg            = $_POST["credreg"];
    $outreg             = $_POST["outreg"];
    $partygrpwisesalepr = $_POST["partygrpwisesalepr"];

    ################## Accounts ##################
    $bankrecp       = $_POST["bankrecp"];
    $bankpay        = $_POST["bankpay"];
    $cashrecp       = $_POST["cashrecp"];
    $cashpay        = $_POST["cashpay"];
    $contra         = $_POST["contra"];
    $journal        = $_POST["journal"];
    $discgvn        = $_POST["discgvn"];
    $discrecd       = $_POST["discrecd"];
    $bankrecon      = $_POST["bankrecon"];
    $ledger         = $_POST["ledger"];
    $receivable     = $_POST["receivable"];
    $payable        = $_POST["payable"];
    $leadparty      = $_POST["leadparty"];
    $dailyreport    = $_POST["dailyreport"];
    $dailycashrp    = $_POST["dailycashrp"];
    $dailyrawreport = $_POST["dailyrawreport"];
    $bankbook       = $_POST["bankbook"];
    $cashbook       = $_POST["cashbook"];
    $jvbook         = $_POST["jvbook"];
    $bankrecorep    = $_POST["bankrecorep"];

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

    ################################# MAIN PART #################################
    if (isset($_POST["name"])) {
        $result = mysqli_query($conn, "SELECT * FROM `$maindb` WHERE `user`= '$user' AND code != '$qvouch' and `spltype`='$spectype'") 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));

        $count = $_POST["items"];

        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`, `spltype`) 
                    VALUES ('$qvouch', '$cono', '$cname', '$finyear', '$yearname', '$startdate', '$lastdate', '$spltype')") or die(mysqli_error($conn));
            }
        }

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

        if ($addflag == 1) {

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



            mysqli_query($conn, "INSERT INTO `$maindb`(`code`, `user`, `password`, `spltype`, `usertype`,`customer`,  `maker`,`supplier`,
                                                        `openbal`, `transport`, `color`, `bank`, `cash`, `expense`, `group`,`otherac`, `rawmatgrp`, 
                                                        `rawmat`,`rawchrateop`,`itemgrp`, `item`,`chrateop`,
                                                        `purchmat`, `debnoteraw`, `debothgst_raw`,`salemat`, `crednoteraw`, `inwardraw`,`outwardraw`,
                                                        `damagedraw`, `purchrawreg`, `debnoterawreg`, `slmatmultireg`, `crednoterawreg`,`inwregraw`,
                                                        `outregraw`, `damregraw`, `rawstock`, `rawinwout`, `rawmatwise`,`rawmatwisesale`, `rawgrpwisesale`,
                                                        `saleamt`, `purchase`, `sale`, `debnote`, `debothgst`,`crednote`,`inwardgst`, `outwardgst`,`damagedgst`,
                                                        `saleamtreg`, `purchreg`, `salereg`, `debreg`,`crdntreg`, `inwreg`,`damreg`, `jobrecdreg`, `stock`,
                                                        `inwout`, `itemwise`, `itemwisesale`, `itemgrpwisesale`,`partygrpwisesale`,`credreg`, `outreg`, `partygrpwisesalepr`,
                                                        `bankrecp`, `bankpay`, `cashrecp`, `cashpay`, `contra`, `journal`, `discgvn`, `discrecd`, `bankrecon`, 
                                                        `ledger`,`receivable`, `payable`, `leadparty`, `dailyreport`, `dailycashrp`, `bankbook`, `cashbook`, 
                                                        `jvbook`, `bankrecorep`,`dailyrawreport`, `trbal`, `profit`, `profshar`, `balsheet`)

                                    VALUES('$qvouch', '$user', '$password', '$spectype', '$usertype', '$customer','$maker','$supplier',
                                                    '$openbal','$transport','$color','$bank','$cash','$expense','$group','$otherac', '$rawmatgrp',
                                                    '$rawmat','$rawchrateop','$itemgrp','$item','$chrateop',
                                                    '$purchmat','$debnoteraw','$debothgst_raw','$salemat','$crednoteraw', '$inwardraw','$outwardraw',
                                                    '$damagedraw','$purchrawreg','$debnoterawreg','$slmatmultireg','$crednoterawreg','$inwregraw',
                                                    '$outregraw', '$damregraw','$rawstock','$rawinwout','$rawmatwise', '$rawmatwisesale','$rawgrpwisesale',
                                                    '$saleamt','$purchase','$sale','$debnote','$debothgst','$crednote','$inwardgst', '$outwardgst','$damagedgst',
                                                    '$saleamtreg','$purchreg','$salereg','$debreg','$crdntreg','$inwreg','$damreg','$jobrecdreg','$stock',
                                                    '$inwout','$itemwise','$itemwisesale','$itemgrpwisesale','$partygrpwisesale','$credreg', '$outreg','$partygrpwisesalepr',
                                                    '$bankrecp','$bankpay','$cashrecp','$cashpay','$contra','$journal','$discgvn','$discrecd','$bankrecon',
                                                    '$ledger','$receivable','$payable','$leadparty','$dailyreport','$dailycashrp','$bankbook','$cashbook',
                                                    '$jvbook','$bankrecorep','$dailyrawreport','$trbal','$profit','$profshar','$balsheet')") or die(mysqli_error($conn));
            insmess();
            $mvouch = $qvouch;
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit&spltype=$spectype");
        } else {
            $mvouch = $qvouch;

            $usecode = mysqli_query($conn, "SELECT code FROM `passmain` WHERE user='$username' and `password`='$password' and `spltype`='$spltype'") 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', `spltype`='$spectype',                                               
                                               `customer`='$customer',`maker`='$maker',`supplier`='$supplier', `openbal`='$openbal',
                                               `transport`='$transport', `color`='$color', `bank`='$bank',`cash`='$cash',`expense`='$expense',
                                               `group`='$group', `otherac`='$otherac',`rawmatgrp`='$rawmatgrp',`rawmat`='$rawmat',
                                               `rawchrateop`='$rawchrateop',`itemgrp`='$itemgrp',`item`='$item',`chrateop`='$chrateop', 
                                               `purchmat`='$purchmat', `debnoteraw`='$debnoteraw',`debothgst_raw`='$debothgst_raw', 
                                               `salemat`='$salemat',`crednoteraw`='$crednoteraw', `inwardraw`='$inwardraw',`outwardraw`='$outwardraw',
                                               `damagedraw`='$damagedraw', `purchrawreg`='$purchrawreg',`debnoterawreg`='$debnoterawreg',
                                               `slmatmultireg`='$slmatmultireg',`crednoterawreg`='$crednoterawreg', `inwregraw`='$inwregraw',
                                               `outregraw`='$outregraw',`damregraw`='$damregraw',`rawstock`='$rawstock',`rawinwout`='$rawinwout',
                                               `rawmatwise`='$rawmatwise',`rawmatwisesale`='$rawmatwisesale', `rawgrpwisesale`='$rawgrpwisesale',
                                               `saleamt`='$saleamt',`purchase`='$purchase', `sale`='$sale',`debnote`='$debnote', `debothgst`='$debothgst',
                                               `crednote`='$crednote',`inwardgst`='$inwardgst',`outwardgst`='$outwardgst',`damagedgst`='$damagedgst',
                                               `saleamtreg`='$saleamtreg', `purchreg`='$purchreg',`salereg`='$salereg',`debreg`='$debreg',
                                               `crdntreg`='$crdntreg',`inwreg`='$inwreg',`damreg`='$damreg',`jobrecdreg`='$jobrecdreg', `stock`='$stock',
                                               `inwout`='$inwout', `itemwise`='$itemwise',`itemwisesale`='$itemwisesale',`itemgrpwisesale`='$itemgrpwisesale',
                                               `partygrpwisesale`='$partygrpwisesale', `credreg`='$credreg',`outreg`='$outreg',`partygrpwisesalepr`='$partygrpwisesalepr',
                                               `bankrecp`='$bankrecp',`bankpay`='$bankpay',`cashrecp`='$cashrecp',`cashpay`='$cashpay',`contra`='$contra',`journal`='$journal',
                                               `discgvn`='$discgvn',`discrecd`='$discrecd',`bankrecon`='$bankrecon',`ledger`='$ledger',`receivable`='$receivable',
                                               `payable`='$payable',`leadparty`='$leadparty',`dailyreport`='$dailyreport',`dailycashrp`='$dailycashrp',
                                               `bankbook`='$bankbook',`cashbook`='$cashbook', `jvbook`='$jvbook',`bankrecorep`='$bankrecorep', `dailyrawreport`='$dailyrawreport',
                                               `trbal`='$trbal',`profit`='$profit',`profshar`='$profshar',`balsheet`='$balsheet'
                                                WHERE code = '$mvouch'") or die(mysqli_error($conn));
            updmess();
            //            browse($spectype);
            header("refresh: 1; $file?$keyfld=$mvouch&spltype=$spectype&mode=edit");
        }
    }
}

if ($addflag != 1) {

    $getvouch = '';
    if ($addflag == 0) {
        $getvouch = $_GET[$keyfld];
    } else {
        $getvouch = $qvouch;
    }
    //    browse($speccond);
    $result = mysqli_query($conn, "SELECT * FROM `$maindb` WHERE $keyfld='$getvouch' $keycond") 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&spltype=$spectype");
}
?>
<?php include("includes/linkshead.php"); ?>
<style>
    input[type=checkbox] {
        width: 20px;
        height: 20px;
    }
</style>
<script src="MyScript/user_obd.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" 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" 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>
                        <?php
                        if ($spectype == "1") {
                        ?>
                            <!-- <div class="row">
                                <label class="col-sm-4 control-label marg">Special</label>
                                <div class="col-sm-2" style="margin-top:6px">
                                    <input type="checkbox" class="form  spltype" id="spltype" name="spltype" value="1" <?
                                                                                                                        // if ($get['spltype'] == 1) {
                                                                                                                        //     Echo "checked";
                                                                                                                        // }
                                                                                                                        ?> required>
                                </div>
                            </div> -->
                        <?php } ?>
                        <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">Raw Material</a></li>
                                <li class=""><a href="#tab_3" data-toggle="tab" aria-expanded="false">Product</a></li>
                                <li class=""><a href="#tab_4" data-toggle="tab" aria-expanded="false">Accounts</a></li>
                                <li class=""><a href="#tab_5" data-toggle="tab" aria-expanded="false">Finalization</a></li>
                            </ul>
                            <div class="tab-content">
                                <!-- TAB_1 STARTS FROM HERE -->
                                <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">Customer</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form ip masters" id="customer" name="customer" value="1" <?
                                                if ($get['customer'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Maker / Karigar</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form ip masters" id="maker" name="maker" value="1" <?
                                                if ($get['maker'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Supplier</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form ip masters" id="supplier" name="supplier" value="1" <?
                                                if ($get['supplier'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label ip marg">Opening Balance</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form ip 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">Transporter</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form ip masters" id="transport" name="transport" value="1" <?
                                                if ($get['transport'] == 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 ip masters" id="expense" name="expense" value="1" <?
                                                if ($get['expense'] == 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 ip  masters" id="bank" name="bank" value="1" <?
                                                if ($get['bank'] == 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 ip 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">Group</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form ip masters" id="group" name="group" value="1" <?
                                                if ($get['group'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Other A/C</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form ip masters" id="otherac" name="otherac" value="1" <?
                                                if ($get['otherac'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                </div>

                                <!-- RAW MATERIAL TAB_2 STARTS FROM HERE -->

                                <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-1" style="margin-top:6px">
                                            <input type="checkbox" class="form " id="Srawmaterial" value="1">

                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Raw Material Group</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="rawmatgrp" name="rawmatgrp" value="1" <?
                                                if ($get['rawmatgrp'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Raw Material</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="rawmat" name="rawmat" value="1" <?
                                                if ($get['rawmat'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Change of Rates</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="rawchrateop" name="rawchrateop" value="1" <?
                                                if ($get['rawchrateop'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Color</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="color" name="color" value="1" <?
                                                if ($get['color'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        
                                    </div>

                                    <div class="row">
                                    <label class="col-sm-4 control-label marg">Purchase Raw Material</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="purchmat" name="purchmat" value="1" <?
                                                if ($get['purchmat'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Purchase Return</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="debnoteraw" name="debnoteraw" value="1" <?
                                                if ($get['debnoteraw'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                    <label class="col-sm-4 control-label marg">Purchase Return - Others</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="debothgst_raw" name="debothgst_raw" value="1" <?
                                                if ($get['debothgst_raw'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Sale Raw Material</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="salemat" name="salemat" value="1" <?
                                                if ($get['salemat'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                    <label class="col-sm-4 control-label marg">Sale Return</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="crednoteraw" name="crednoteraw" value="1" <?
                                                if ($get['crednoteraw'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Inward Raw Material</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="inwardraw" name="inwardraw" value="1" <?
                                                if ($get['inwardraw'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                    <label class="col-sm-4 control-label marg">Outward Raw Material</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="outwardraw" name="outwardraw" value="1" <?
                                                if ($get['outwardraw'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Damaged Raw Material</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="damagedraw" name="damagedraw" value="1" <?
                                                if ($get['damagedraw'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Purchase Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="purchrawreg" name="purchrawreg" value="1" <?
                                                if ($get['purchrawreg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>

                                        </div>
                                        <label class="col-sm-4 control-label marg">Purchase Return Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="debnoterawreg" name="debnoterawreg" value="1" <?
                                                if ($get['debnoterawreg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Sale Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="slmatmultireg" name="slmatmultireg" value="1" <?
                                                if ($get['slmatmultireg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>

                                        </div>
                                        <label class="col-sm-4 control-label marg">Sale Return Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="crednoterawreg" name="crednoterawreg" value="1" <?
                                                if ($get['crednoterawreg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Inward Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="inwregraw" name="inwregraw" value="1" <?
                                                if ($get['inwregraw'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>

                                        </div>
                                        <label class="col-sm-4 control-label marg">Outward Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="outregraw" name="outregraw" value="1" <?
                                                if ($get['outregraw'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Damaged Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="damregraw" name="damregraw" value="1" <?
                                                if ($get['damregraw'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>

                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Stock</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="rawstock" name="rawstock" value="1" <?
                                                if ($get['rawstock'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>

                                        </div>
                                        <label class="col-sm-4 control-label marg">Inward/Outward History</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="rawinwout" name="rawinwout" value="1" <?
                                                if ($get['rawinwout'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>

                                        </div>
                                    </div>

                                    <div class="row">

                                        <label class="col-sm-4 control-label marg">Raw Material Wise P/L</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="rawmatwise" name="rawmatwise" value="1" <?
                                                if ($get['rawmatwise'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Raw Material Wise Sale</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="rawmatwisesale" name="rawmatwisesale" value="1" <?
                                                if ($get['rawmatwisesale'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>

                                        </div>
                                    </div>

                                    <div class="row">

                                        <label class="col-sm-4 control-label marg">Raw Material Groupwise Sale</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="rawgrpwisesale" name="rawgrpwisesale" value="1" <?
                                                if ($get['rawgrpwisesale'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Partywise Raw Material Group Sale</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  rawmaterial" id="partygrpwisesale" name="partygrpwisesale" value="1" <?
                                                if ($get['partygrpwisesale'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>

                                        </div>
                                    </div>

                                </div>

                                <!-- PRODUCT TAB_3 STARTS FROM HERE -->

                                <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="Sproduct" value="1">
                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Product Group</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="itemgrp" name="itemgrp" value="1" <?
                                                if ($get['itemgrp'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Product</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" 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">Change of Rates</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="chrateop" name="chrateop" value="1" <?
                                                if ($get['chrateop'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Sale (Only Amt.)</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="saleamt" name="saleamt" value="1" <?
                                                if ($get['saleamt'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Purchase</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="purchase" name="purchase" value="1" <?
                                                if ($get['purchase'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Purchase Return</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="debnote" name="debnote" value="1" <?
                                                if ($get['debnote'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>


                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Purchase Return - Others</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="debothgst" name="debothgst" value="1" <?
                                                if ($get['debothgst'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Sale</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="sale" name="sale" value="1" <?
                                                if ($get['sale'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Sale Return/Credit Note - Goods Return</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="crednote" name="crednote" value="1" <?
                                                if ($get['crednote'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Inward</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="inwardgst" name="inwardgst" value="1" <?
                                                if ($get['inwardgst'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Outward</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="outwardgst" name="outwardgst" value="1" <?
                                                if ($get['outwardgst'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Damaged</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="damagedgst" name="damagedgst" value="1" <?
                                                if ($get['damagedgst'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Only Sale Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="saleamtreg" name="saleamtreg" value="1" <?
                                                if ($get['saleamtreg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Purchase Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="purchreg" name="purchreg" value="1" <?
                                                if ($get['purchreg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Purchase Return Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="debreg" name="debreg" value="1" <?
                                                if ($get['debreg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Sale Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="salereg" name="salereg" value="1" <?
                                                if ($get['salereg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Sale Return / Credit Note Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="credreg" name="credreg" value="1" <?
                                                if ($get['credreg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Inward Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="inwreg" name="inwreg" value="1" <?
                                                if ($get['inwreg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Outward Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="outreg" name="outreg" value="1" <?
                                                if ($get['outreg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Damaged Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="damreg" name="damreg" value="1" <?
                                                if ($get['damreg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <!-- <label class="col-sm-4 control-label marg">Job Received Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="jobrecdreg" name="jobrecdreg" value="1" <?
                                                if ($get['jobrecdreg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div> -->
                                        <label class="col-sm-4 control-label marg">Stock</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="stock" name="stock" value="1" <?
                                                if ($get['stock'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Inward/Outward History</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="inwout" name="inwout" value="1" <?
                                                if ($get['inwout'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Itemwise P/L</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="itemwise" name="itemwise" value="1" <?
                                                if ($get['itemwise'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Itemwise Sale</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="itemwisesale" name="itemwisesale" value="1" <?
                                                if ($get['itemwisesale'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Item Groupwise Sale</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="itemgrpwisesale" name="itemgrpwisesale" value="1" <?
                                                if ($get['itemgrpwisesale'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>


                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Partywise Item Group Sale</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  product" id="partygrpwisesalepr" name="partygrpwisesalepr" value="1" <?
                                                if ($get['partygrpwisesalepr'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                </div>

                                <!-- Accounts TAB_4 STARTS FROM HERE -->
                                <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="Saccounts" value="1">
                                        </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  accounts" 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  accounts" 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">Cash Receipt</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  accounts" id="cashrecp" name="cashrecp" value="1" <?
                                                if ($get['cashrecp'] == 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  accounts" 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">Contra</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  accounts" id="contra" name="contra" value="1" <?
                                                if ($get['contra'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Journal</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  accounts" id="journal" name="journal" value="1" <?
                                                if ($get['journal'] == 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  accounts" id="discgvn" name="discgvn" value="1" <?
                                                if ($get['discgvn'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <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  accounts" id="discrecd" name="discrecd" value="1" <?
                                                if ($get['discrecd'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Bank Reconcilation</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  accounts" id="bankrecon" name="bankrecon" value="1" <?
                                                if ($get['bankrecon'] == 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  accounts" 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">O/s Receivable</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  accounts" id="receivable" name="receivable" value="1" <?
                                                if ($get['receivable'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">O/s Payable</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  accounts" id="payable" name="payable" value="1" <?
                                                if ($get['payable'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Leading Parties</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  accounts" id="leadparty" name="leadparty" value="1" <?
                                                if ($get['leadparty'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Daily Report</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  accounts" id="dailyreport" name="dailyreport" value="1" <?
                                                if ($get['dailyreport'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Daily Raw Report</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  accounts" id="dailyrawreport" name="dailyrawreport" value="1" <?
                                                if ($get['dailyrawreport'] == 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  accounts" id="dailycashrp" name="dailycashrp" value="1" <?
                                                if ($get['dailycashrp'] == 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  accounts" id="bankbook" name="bankbook" value="1" <?
                                                if ($get['bankbook'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <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  accounts" id="cashbook" name="cashbook" value="1" <?
                                                if ($get['cashbook'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <div class="row">

                                        <label class="col-sm-4 control-label marg">Journal Book</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  accounts" id="jvbook" name="jvbook" value="1" <?
                                                if ($get['jvbook'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Reconcilation Report</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  accounts" id="bankrecorep" name="bankrecorep" value="1" <?
                                                if ($get['bankrecorep'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                </div>

                                <!-- Finalization TAB_5 STARTS FROM HERE -->
                                <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>
                            </div>
                        </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 `code`,`name` 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[code]'>$fcomp[name]</option>";
                                            $gcomp = mysqli_query($conn, "SELECT `code`,`name` FROM `company` where code !='' $speccond") or die(mysqli_error($conn));
                                            while ($comp = mysqli_fetch_array($gcomp)) {
                                                echo "<option value='$comp[code]'>$comp[name]</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` where finyear != '' group by finyear") 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 `code`,`name` FROM `company` where code !='' $speccond") or die(mysqli_error($conn));

                                                    while ($comp = mysqli_fetch_array($gcomp)) {
                                                        echo "<option value='$comp[code]'>$comp[name]</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` group by finyear") 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` where code!='' $keycond") 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"); ?>