<?php
ob_start();
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include('includes/function.php');
header("Content-Type: text/html;charset=UTF-8");

$formname = 'CRM';
$maindb = 'crm';
$file = 'crm.php';
$printfile = 'crmlist.php';
$keyfld = "myvouch";
$myyear = $_SESSION["tit_" . $dbname];

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$username = $_SESSION["username_" . $dbname];
$zroot = $_SESSION["zdir"];
//$modet = $_GET["mode"];
mysqli_select_db($conn, $zdb);
include("includes/vouchno_generate.php");
include("includes/prev&next.php");

mysqli_query($conn, "Create temporary table `crm` SELECT Date_Format(`vouchdt`, '%d/%m/%Y') as mydt, myvouch,
                       remark, emailid, name, mobile,passport, category, edu FROM `$maindb` WHERE myvouch != ''  ")or die(mysqli_error($conn));

$srchresult = "SELECT *  FROM `crm` WHERE myvouch != ''"or die(mysqli_error($conn));

$result = mysqli_query($conn, $srchresult)or die(mysqli_error($conn));
include("includes/linkshead.php");
?>
<div class="panel panel-default">

    <div class="panel-heading" style="height: 0.6vh">
        <div class="row col-lg-12">

            <div class="col-lg-7"> 
                <h3 class="panel-title" style="color:inherit"><?php Echo $formname; ?></h3>
            </div>

            <div class="col-lg-1"></div>
            <div class="col-lg-5 " style="padding-left: 2%">
                <!--<input id="addnew" value="Add new Entry" type="button" class="btn btn-primary" onclick="window.locatoin.href = "'<?= $file . "?mode=last" ?>'>-->
                <input id='addnew' value="Add New Entry" type="button"  class="btn btn-primary" style="" onclick="window.location.href = '<?= $file . "?mode=true" ?>'" class="btn btn-labeled btn-success">
            </div>
            <div class="actions pull-right">
                <!--<i class="fa fa-chevron-down"></i>-->
                <!--<i class="fa fa-times"></i>-->
            </div>
        </div>
    </div>
    <!--<h1 class="panel-title">
    <?php Echo $formname; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <span style="color: #5D96E4;font-size: 11px">
    </h1>-->

    <script src="MyScript/crm_search.js"  type="text/javascript"></script>   
    <div class="panel-body">

        <div class="col-lg-11 table responsive ssload" style="overflow-y: scroll;height: 480px;">
            <table id="example1" class="table table-striped table-condensed table-bordered" width="100%" >
                <thead>
                    <tr class="mySearchTr">
                        <th style="width:5%;">Date</th>
                        <th style="width:20%;">Name</th>
                        <th style="width:3%;">Email Id</th>
                        <th style="width:10%;">Mobile No.</th>
                        <th style="width:10%;">Passport No.</th>
                        <th style="width:10%;">Job Category</th>
                        <th style="width:7%;">Education</th>
                        <th style="width:8%;">Remarks</th> 
                        <th align="center"  style="width:1%;">Action</th>
                    </tr>
                </thead>
                <tbody class="sTbody">
                    <?php
                    while ($row = mysqli_fetch_array($result)) {
                        echo "<tr class='' data-href='$file?mode=edit&$keyfld=$row[$keyfld]'>";
                        echo "<td align='left'>$row[mydt]</td>";
                        echo "<td align='left'>$row[name]</td>";
                        echo "<td align='left'>$row[emailid]</td>";
                        echo "<td align='left'>$row[mobile]</td>";
                        echo "<td align='left'>$row[passport]</td>";
                        echo "<td align='left'>$row[category]</td>";
                        echo "<td align='left'>$row[edu]</td>";
                        echo "<td align='left'>$row[remark]</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>
        <br>
    </div><!-- comment -->
</div>
<div class="panel-footer">

    <div class="row">
        <div id="example1" class="col-xs-11 text-right search-action-bar">
            <input type="button"  class="btn btn-primary sprev" value="Previous">
            <input type="button"  class="btn btn-primary snext" value="Next">
        </div>
    </div>
</div>

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