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

$formname = 'Purchase Return/ Debit Note';
$maindb = 'debmain';
$trandb = 'debtran';
$stkdb = 'transacn';
//$accdb = 'actran';
$printfile = "debnote_print.php";
$file = 'debnote.php';
$trandbexist = 1;
$keyfld = "vouchno";
$source = "PU";

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$myyear = $_SESSION[$myyear];
mysqli_select_db($conn, $zdb);
include("includes/vouchno_generate.php");
include("includes/prev&next.php");

if (isset($_POST["submit"])) {
    $a = 1;
    $vouchno = $_POST["vouchno"];
    $invno = $_POST["invno"];
    $vouchdt = $_POST["vouchdt"];
    $party = $_POST["party"];
    $type = $_POST["type"];
    $subtotal = $_POST["subtotal"];
    $litemdisc = $_POST["litemdisc"];
    $cdiscperc = $_POST["cdiscperc"];
    $cdiscamt = $_POST["cdiscamt"];
    $lesother = $_POST["lesother"];
    $vatperc = $_POST["vatperc"];
    $vatamt = $_POST["vatamt"];
    $packing = $_POST["packing"];
    $netamt = $_POST["netamt"];
    $remark1 = $_POST["remark1"];
    $remark2 = $_POST["remark2"];

    $count = $_POST["items"];

    $mvouch = $qvouch;

    $salecode = 11;

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


    if ($a == 1) {

        #################################TRAN PART #################################

        mysqli_query($conn, "DELETE FROM `$trandb` WHERE `$keyfld`='$mvouch'") or die(mysqli_error($conn));
        mysqli_query($conn, "DELETE FROM `$stkdb` WHERE `$keyfld`='$mvouch' AND `source`='$source'")or die(mysqli_error($conn));
        $group = $source . $mvouch;

        $srl = 0;
        for ($i = 0; $i < $count; $i++) {
            $msrno = $_POST["srno_$i"];
            $mbarcode = $_POST["barcode_$i"];
            $mitem = $_POST["itemcode_$i"];
            $mqty = $_POST["qty_$i"];
            $munit = $_POST["unit_$i"];
            $mmrp = $_POST["mrp_$i"];
            $mrate = $_POST["rate_$i"];
            $mamount = $_POST["amount_$i"];
            $mdiscperc = $_POST["discperc_$i"];
            $mdiscount = $_POST["discount_$i"];
            $mtotal = $_POST["total_$i"];
            $mmsp = $_POST["msp_$i"];
            $mactbatch = $source . $mvouch . $mbatch;

            if (!empty($mitem)) {
                $getmitemname = mysqli_query($conn, "SELECT * FROM `item` WHERE `code`='$mitem'")or die(mysqli_error($conn));
                $gmitemname = mysqli_fetch_array($getmitemname);
                $getmunit = mysqli_query($conn, "SELECT * FROM `unit` WHERE `code`='$munit'")or die(mysqli_error($conn));
                $gmunit = mysqli_fetch_array($getmunit);
                $mitemname = $gmitemname['name'];
//                $mshade       = $gmitemname['shade'];
                $srl = $srl + 1;

                mysqli_query($conn, "INSERT INTO `$trandb`(`vouchno`, `vouchdt`, `srno`, `itemcode`, `qty`, `unit`, `mrp`,
                                                            `rate`, `amount`, `discperc`, `discount`, `total`, `msp`)
                                            VALUES('$mvouch', '$vouchdt', '$srl', '$mitem', '$mqty', '$munit', '$mmrp',
                                           '$mrate', '$mamount', '$mdiscperc', '$mdiscount', '$mtotal', '$mmsp')") or die(mysqli_error($conn));


                #################################STOCK PART #################################

                mysqli_query($conn, "INSERT INTO `$stkdb`(`srno`, `vouchno`, `vouchdt`, `source`, `barcode`, `itemcode`,  `qty`, `unit`, `mrp`, `rate`, `amount`)
                                        VALUES( '$srl', '$qvouch', '$vouchdt', '$source', '$barcode', '$item', '$trqty', '$unit', '$mrp', '$rate', '$amount')") or die(mysqli_error($conn));
            }
        }

        ############################### Accounts Part ######################################################
        mysqli_query($conn, "DELETE FROM `$accdb` WHERE `vouchno` = '$mvouch' AND `source`='$source'") OR die(mysqli_error($conn));

        if ($netamt > 0) {
            $minus_amt = ($netamt * -1);

// purchase part
            mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, trnno, accode, grpcode, amount)
                    VALUES ('$vouchdt','$mvouch', '$source', '001', '$salecode','004', '$minus_amt')") OR die(mysqli_error($conn));
// party part
            mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, trnno, accode, grpcode, amount)
                     VALUES ('$vouchdt','$mvouch', '$source', '002', '$party','009', '$netamt')") or die(mysqli_error($conn));
        }



        ############################## MAIN ######################################################
        if ($addflag == 1) {
            mysqli_query($conn, "INSERT INTO `$maindb`(`vouchno`, `invno`, `vouchdt`, `party`, `type`, `subtotal`, `litemdisc`, `cdiscperc`, 
                                            `cdiscamt`, `discount`, `lesother`, `vatperc`, `vatamt`, `packing`, `netamt`)
                                     VALUES($qvouch, '$invno', '$vouchdt', '$party', '$type', '$subtotal', '$litemdisc', '$cdiscperc',
                                            '$cdiscamt', '$discount', '$lesother', '$vatperc', '$vatamt', '$packing', '$netamt')")
                    or die(mysqli_error($conn));

            browse('4');

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

            mysqli_query($conn, "UPDATE `$maindb` SET `vouchno`='$mvouch',`vouchdt`='$vouchdt', `branch`='$branch', `invno`='$invno', `party`='$party',
                                `netamt`='$netamt' WHERE `vouchno`= '$mvouch' ") or die(mysqli_error($conn));
            updmess();
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
        }
    }
}

if ($addflag != 1) {

    $getvouch = '';
    if ($addflag == 0) {
        $getvouch = $_GET[$keyfld];
    } else {
        $getvouch = $qvouch;
    }

    $result = mysqli_query($conn, "SELECT * FROM `$maindb` WHERE $keyfld='$getvouch'") or die(mysqli_error($conn));
    $get = mysqli_fetch_array($result);

//    $findtype = mysqli_query($conn, "SELECT * FROM `cepheisy_gujtran_root`.`branch` WHERE `code`='$get[name]'") or die(mysqli_error($conn));
//    $ltype = mysqli_fetch_array($findtype);

    $findparty = mysqli_query($conn, "SELECT * FROM `accmast` WHERE `grpcode`= '009' ") or die(mysqli_error($conn));
    $lparty = mysqli_fetch_array($findparty);
}

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

if (isset($_GET["delete"])) {
    delete($zdb, "$maindb", "$keyfld", $_GET[$keyfld], "$file?mode=last");
    delete($zdb, "$trandb", "$keyfld", $_GET[$keyfld], "$file?mode=last");
    $delcond = " source = '$source' and vouchno = '$_GET[vouchno]' ";
    delnew($zdb, "$stkdb", "$delcond", "$file?mode=last");
    delnew($zdb, "$accdb", "$delcond", "$file?mode=last");
}

include("includes/linkshead.php");
?>
<script src="MyScript/purchase.js" type="text/javascript"></script>
</head>
<body>
    <!--    <div id="preloader" class="col-lg-12 text-center">
            <h3 class="text-center">Loading</h3>
            <div id="status">&nbsp;</div>
        </div>-->
    <form action='' method='POST'>
        <!-- Default box -->
        <div>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12  pad">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title" style="color:#78909C"><?php Echo $formname; ?></h3>
                        <div class="actions pull-right">
                            <i class="fa fa-chevron-down"></i>
                            <i class="fa fa-times"></i>
                        </div>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Voucher</label>
                            </div>
                            <div class="col-lg-1 col-md-8 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control form" name="vouchno" value="<?php Echo ($addflag != 1) ? $get["vouchno"] : " $qvouch"; ?>" required readonly>
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Date</label>
                            </div>
                            <div class="col-lg-2 col-md-8 col-sm-8 col-xs-8 pad">
                                <input type="date" class="form-control form" name="vouchdt" value="<?php Echo ($addflag != 1) ? $get["vouchdt"] : date("Y-m-d"); ?>">
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Invoice No.</label>
                            </div>
                            <div class="col-lg-1 col-md-8 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control form focusfield" name="invno" value="<?php Echo ($addflag != 1) ? $get["invno"] : ""; ?>"  autofocus>
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Type</label>
                            </div>
                            <div class="col-lg-1 col-md-8 col-sm-8 col-xs-8 pad">
                                <select class="form-control form  select2" name="type" style="width: 100%" required>
                                    <option value="<?php Echo ($addflag != 1) ? $get["type"] : ""; ?>"><?php
                                        if ($get["type"] == "R") {
                                            Echo "CREDIT";
                                        } elseif ($get["type"] == "C") {
                                            Echo "CASH";
                                        }
                                        ?></option>
                                    <option value="C">CASH</option>
                                    <option value="R">CREDIT</option>
                                </select>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Party</label>
                            </div>
                            <div class="col-lg-4 col-md-8 col-sm-8 col-xs-8 pad">
                                <select class="form-control form  select2" name="party" style="width: 100%" required>
                                    <option value="<?php Echo ($addflag != 1) ? $get["party"] : ""; ?>"><?php Echo ($addflag != 1) ? $lparty["name"] : ""; ?></option>
                                    <?php
                                    $gparty = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` WHERE `grpcode`='010'")or die(mysqli_error($conn));
                                    while ($party = mysqli_fetch_array($gparty)) {
                                        Echo "<option value='$party[accode]'>$party[name]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 pad">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <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 table-padd" width="100%">
                                <thead  class="mySearchTr">
                                    <tr>
                                        <th width="2%"></th>
                                        <th width="3%" class='text-right'>Sr.</th>
                                        <th width="7%">Barcode</th>
                                        <th width="12%">Itemname</th>
                                        <th width="6%" class='text-right'>Qty.</th>
                                        <th width="9%">Unit</th>
                                        <th width="8%" class='text-right'>MRP.</th>
                                        <th width="8%" class='text-right'>Rate</th>
                                        <th width="8%" class='text-right'>Amount</th>
                                        <th width="8%" class='text-right'>Discperc</th>
                                        <th width="8%" class='text-right'>Discount</th>
                                        <th width="8%" class='text-right'>Total</th>
                                        <th width="8%" class='text-right'>MSP</th>
                                    </tr>
                                </thead>
                                <tbody class="tbody">
                                    <?php
                                    if ($addflag != 1) {
                                        $ctr = 0;
                                        $gettran = mysqli_query($conn, "SELECT * FROM `$trandb` WHERE `vouchno`='$get[vouchno]' ORDER BY `srno`")or die(mysqli_error($conn));
                                        while ($tran = mysqli_fetch_array($gettran)) {
                                            $finditem = mysqli_query($conn, "SELECT * FROM `item` WHERE `code`='$tran[itemcode]'") or die(mysqli_error($conn));
                                            $fitem = mysqli_fetch_array($finditem);
                                            $findunit = mysqli_query($conn, "SELECT * FROM `unit` WHERE `code`='$tran[unit]'") or die(mysqli_error($conn));
                                            $funit = mysqli_fetch_array($findunit);

                                            Echo "<tr>";
                                            Echo "<td><i class='fa fa-close remove' style='display:none;'></i></td>";
                                            Echo "<td><input type='text' class='form-control form text-right srno' name='srno_$ctr' value='$tran[srno]'></td>";
                                            Echo "<td><input type='text' class='form-control form text-left barcode' name='barcode_$ctr' value='$tran[barcode]'></td>";
                                            Echo "<td>";
                                            Echo "<select class='form-control form fetchpart_$ctr item' name='item_$ctr' style='width:100%'>";
                                            Echo "<option value='$fitem[code]'>$fitem[name]</option>";
                                            $gitem = mysqli_query($conn, 'SELECT * FROM `item` order by name')or die(mysqli_error($conn));
                                            while ($item = mysqli_fetch_array($gitem)) {
                                                Echo "<option value='$item[code]'>$item[name]</option>";
                                            }
                                            Echo "</select>";
                                            Echo "</td>";
                                            Echo "<td><input type='text' class='form-control form text-right qty'       name='qty_$ctr'         value='$tran[qty]'></td>";
                                            Echo "<td>";
                                            Echo "<select class='form-control form fetchpart_$ctr unit' name='unit_$ctr' style='width:100%'>";
                                            Echo "<option value='$funit[code]'>$funit[name]</option>";
                                            $gunit = mysqli_query($conn, 'SELECT * FROM `unit` order by name')or die(mysqli_error($conn));
                                            while ($unit = mysqli_fetch_array($gunit)) {
                                                Echo "<option value='$unit[code]'>$unit[name]</option>";
                                            }
                                            Echo "</select>";
                                            Echo "</td>";
                                            Echo "<td><input type='text' class='form-control form text-right mrp'       name='mrp_$ctr'        value='$tran[mrp]' readonly></td>";
                                            Echo "<td><input type='text' class='form-control form text-right rate'      name='rate_$ctr'        value='$tran[rate]'></td>";
                                            Echo "<td><input type='text' class='form-control form text-right amount'    name='amount_$ctr'      value='$tran[amount]' readonly></td>";
                                            Echo "<td><input type='text' class='form-control form text-right discperc'  name='discperc_$ctr'      value='$tran[discperc]'></td>";
                                            Echo "<td><input type='text' class='form-control form text-right discount'  name='discount_$ctr'      value='$tran[discount]'></td>";
                                            Echo "<td><input type='text' class='form-control form text-right total'     name='total_$ctr'      value='$tran[total]'></td>";
                                            Echo "<td><input type='text' class='form-control form text-right msp'       name='msp_$ctr'      value='$tran[msp]'></td>";
                                            Echo "</tr >";
                                            $ctr++;
                                        }
                                    } else {
                                        $pctr = 0;
                                        ?>
                                        <tr>
                                            <td><i class="fa fa-close remove"></i></td>
                                            <td><input type="text" class="form-control form text-right srno" name="srno_<?= $pctr ?>" value="1"></td>
                                            <td><input type="text" class="form-control form text-right barcode" name="barcode_<?= $pctr ?>" value="" ></td>
                                            <td>
                                                <select class="form-control form select2 item" name="item_<?= $pctr ?>" style='width:100%'>
                                                    <option value=""></option>
                                                    <?php
                                                    $gitem = mysqli_query($conn, "SELECT * FROM `item`")or die(mysqli_error($conn));
                                                    while ($item = mysqli_fetch_array($gitem)) {
                                                        Echo "<option value='$item[code]'>$item[name]</option>";
                                                    }
                                                    ?>
                                                </select>
                                            </td>
                                            <td><input type="text" class="form-control form text-right qty"     name="qty_<?= $pctr ?>"        value="0"></td>
                                            <td>
                                                <select class='form-control form select2 unit' name="unit_<?= $pctr ?>" style='width:100%'>
                                                    <option value=""></option>
                                                    <?php
                                                    $gunit = mysqli_query($conn, 'SELECT * FROM `unit` order by name')or die(mysqli_error($conn));
                                                    while ($unit = mysqli_fetch_array($gunit)) {
                                                        Echo "<option value='$unit[code]'>$unit[name]</option>";
                                                    }
                                                    ?>
                                                </select>
                                            </td>
                                            <td><input type="text" class="form-control form text-right mrp"         name="mrp_<?= $pctr ?>"       value="0"></td>
                                            <td><input type="text" class="form-control form text-right rate"        name="rate_<?= $pctr ?>"       value="0"></td>
                                            <td><input type="text" class="form-control form text-right amount"      name="amount_<?= $pctr ?>"     value="0"></td>
                                            <td><input type="text" class="form-control form text-right discperc"    name="discperc_<?= $pctr ?>"     value="0"></td>
                                            <td><input type="text" class="form-control form text-right discount"    name="discount_<?= $pctr ?>"     value="0"></td>
                                            <td><input type="text" class="form-control form text-right total"       name="total_<?= $pctr ?>"     value="0"></td>
                                            <td><input type="text" class="form-control form text-right msp"       name="msp_<?= $pctr ?>"     value="0"></td>
                                        </tr>  
                                        <?
                                        $pctr++;
                                    }
                                    ?>
                                </tbody>
                            </table>
                        </div>


                        <div class="col-lg-12 pad">
<!--                            <input type="button" style="height: 30px; width: 30px; padding: 0px" id="addnew" class="btn btn-success btn-lg form" accode="addnew2" value="+" />-->
                            <button type="button" class="btn btn-success btn-square form"  id="addnew">
                                <i class="fa fa-plus" style="color:#ffffff" data-toggle='tooltip' title='Add Row'></i>    
                            </button>
                            <input type="hidden" id="items" name="items" value="<?php echo ($addflag != 1) ? $ctr : $pctr; ?>" />  
                        </div>
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12  pad">
                            <div class="panel panel-default">

                                <div class="panel-body">
                                    <div class="col-lg-12 col-xs-12 pad">
                                        <div class="col-lg-6 col-xs-12 pad">
                                        </div>

                                        <div class="col-lg-6 col-xs-12 pad">
                                            <div class="col-lg-12 col-xs-12 pad">
                                                <div class="col-lg-3 pad"></div>
                                                <div class="col-lg-2 pad">
                                                    <label class="label-control marg" style="color: red">SubTotal</label>
                                                </div>
                                                <div class="col-lg-3 pad text-center">
                                                </div>
                                                <div class="col-lg-4 pad">
                                                    <input type="text" class="form-control form subtotal text-right" value="<? Echo ($addflag != 1) ? $get[subtotal] : "0"; ?>" name="subtotal" readonly>
                                                </div>
                                            </div>
                                            <div class="col-lg-12 col-xs-12 pad">
                                                <div class="col-lg-3 pad"></div>
                                                <div class="col-lg-3 pad">
                                                    <label class="label-control marg">Less Item Discount</label>
                                                </div>
                                                <div class="col-lg-3 pad text-center">
                                                </div>
                                                <div class="col-lg-3 pad">
                                                    <input type="text" class="form-control form litemdisc text-right" value="<? Echo ($addflag != 1) ? $get[litemdisc] : "0"; ?>" name="litemdisc">
                                                </div>
                                            </div>
                                            <div class="col-lg-12 col-xs-12 pad">
                                                <div class="col-lg-3 pad"></div>
                                                <div class="col-lg-4 pad">
                                                    <label class="label-control marg">Less Cash Discount</label>
                                                </div>
                                                <div class="col-lg-1 pad">
                                                    <input type="text" class="form-control form cdiscperc text-right" value="<? Echo ($addflag != 1) ? $get[cdiscperc] : "0"; ?> "  name="cdiscperc">
                                                </div>
                                                <div class="col-lg-1 pad text-center">
                                                    <label class="label-control marg ">%</label>
                                                </div>
                                                <div class="col-lg-3 pad">
                                                    <input type="text" class="form-control form cdiscamt text-right" value="<? Echo ($addflag != 1) ? $get[cdiscamt] : "0"; ?>" name="cdiscamt" readonly>
                                                </div>
                                            </div>
                                            <div class="col-lg-12 col-xs-12 pad">
                                                <div class="col-lg-3 pad"></div>
                                                <div class="col-lg-3 pad">
                                                    <label class="label-control marg">Less Other</label>
                                                </div>
                                                <div class="col-lg-3 pad"></div>
                                                <div class="col-lg-3 pad">
                                                    <input type="text" class="form-control form lesother text-right" value="<? Echo ($addflag != 1) ? $get[lesother] : "0"; ?>" name="lesother">
                                                </div>
                                            </div>
                                            <div class="col-lg-12 col-xs-12 pad">
                                                <div class="col-lg-3 pad"></div>
                                                <div class="col-lg-4 pad">
                                                    <label class="label-control marg">Add VAT</label>
                                                </div>
                                                <div class="col-lg-1 pad">
                                                    <input type="text" class="form-control form vatperc text-right" value="<? Echo ($addflag != 1) ? $get[vatperc] : "0"; ?> "  name="vatperc">
                                                </div>
                                                <div class="col-lg-1 pad text-center">
                                                    <label class="label-control marg ">%</label>
                                                </div>
                                                <div class="col-lg-3 pad">
                                                    <input type="text" class="form-control form vatamt text-right" value="<? Echo ($addflag != 1) ? $get[vatamt] : "0"; ?>" name="vatamt" readonly>
                                                </div>
                                            </div>
                                            <div class="col-lg-12 col-xs-12 pad">
                                                <div class="col-lg-3 pad"></div>
                                                <div class="col-lg-4 pad">
                                                    <label class="label-control marg">Add Transport/Packing</label>
                                                </div>
                                                <div class="col-lg-2 pad"></div>
                                                <div class="col-lg-3 pad">
                                                    <input type="text" class="form-control form packing text-right" value="<? Echo ($addflag != 1) ? $get[packing] : "0"; ?>" name="packing" >
                                                </div>
                                            </div>
                                            <div class="col-lg-12 col-xs-12 pad">
                                                <div class="col-lg-3 pad"></div>
                                                <div class="col-lg-2 pad">
                                                    <label class="label-control marg" style="color: blue">Netamt (Rs.)</label>
                                                </div>
                                                <div class="col-lg-3 pad"></div>
                                                <div class="col-lg-4 pad">
                                                    <input type="text" class="form-control form netamt text-right" readonly value="<? Echo ($addflag != 1) ? $get[netamt] : "0"; ?>" name="netamt">
                                                </div>
                                            </div>

                                        </div>
                                    </div>
                                    <div class="col-lg-12 col-xs-12 pad">
                                        <div class="col-lg-3 pad text-right">
                                            <label class="label-control marg">Remarks</label>
                                        </div>
                                        <div class="col-lg-7 pad">
                                            <input type="text" name="remark1" class="form-control form remark1" value="<? Echo ($addflag != 1) ? $get["remark1"] : ""; ?>">
                                        </div>
                                    </div>
                                    <div class="col-lg-12 col-xs-12 pad">
                                        <div class="col-lg-3 pad text-right"></div>
                                        <div class="col-lg-7 pad">
                                            <input type="text" name="remark2" class="form-control form remark2" value="<? Echo ($addflag != 1) ? $get["remark2"] : ""; ?>">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12  pad">
        <div class="panel panel-default">
            <div class="panel-heading">
                <div class="actions pull-right">
                    <i class="fa fa-chevron-down"></i>
                </div>
            </div>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 pad">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <?php include("includes/buttons.php"); ?>
                    </div>
                </div>
            </div>
        </div>
</form>

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