<script type="text/javascript" src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>jquery/ui/minified/jquery.ui.mouse.min.js"></script>
<script type="text/javascript" src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>jquery/ui/minified/jquery.ui.draggable.min.js"></script>
<script type="text/javascript" src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>jquery/ui/minified/jquery.ui.resizable.min.js"></script>
<script type="text/javascript" src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>jquery/ui/minified/jquery.ui.dialog.min.js"></script>
<script type="text/javascript" src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>highslide/highslide-with-html.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo GLOBAL_ADMIN_JS_PATH; ?>highslide/highslide.css" />
<link type="text/css" href="<?php echo GLOBAL_ADMIN_JS_PATH; ?>jquery/themes/base/jquery.ui.dialog.css" rel="stylesheet" />
<link type="text/css" href="<?php echo GLOBAL_ADMIN_JS_PATH; ?>jquery/themes/base/jquery.ui.resizable.css" rel="stylesheet" />
<script type="text/javascript">
    hs.graphicsDir = '<?php echo GLOBAL_ADMIN_JS_PATH; ?>highslide/graphics/';
    hs.outlineType = 'rounded-white';
    hs.showCredits = false;
    hs.wrapperClassName = 'draggable-header';
</script>

<script type="text/javascript">
    function verify()
    {	
        SendGridBindRequest('<?= $inquiryObj->urlwithpara ?>','gridbody','D','chkgrow');
    }

    function popreply(id)
    {
        var response;
        $.ajax({
            type: "GET",
            url:"index.php" ,
            data: "module=contactusmsg&action=email&ajax=Y&id="+id,
            async: false,
            success: function(data){
                //alert(data);
                response=data;
            }
        });

        ////////////ajax end
        $('#dialog-modal').html(response);
        $('#dialog-modal').dialog({
            autoOpen: false,
            height: 295,
            width: 615,
            modal: true
        });
        $('#dialog-modal').dialog('open');
    }

    function excelreport()
    {
        var chkelements = document.getElementsByName('chkgrow');
        var ids = "";
        var countChecked = 0;

        for(var i = 0; i < chkelements.length; i++)
        {
            if(chkelements.item(i).checked == true)
            {
                countChecked++;
                if(ids != "")
                    ids += ",";
                ids += chkelements.item(i).value;
            }
        }
        var totalpagerecords = document.getElementById('ptrecords').value;
        document.getElementById('totalrecords').value = totalpagerecords;
        document.getElementById('chkids').value = ids;

        document.forms["exportform"].submit();
    }
    function updateread(id)
    {
        var p='';
        $.ajax({
            type: "GET",
            url:"index.php" ,
            data: "module=contactusmsg&action=updatereaddata&ajax=Y&id="+id,
            async: false,
            success: function(data){
                p=data;

                document.getElementById('gtr-'+p).className = 'grid-list-inner-table-text';
                if(document.getElementById('star1-'+p).style.display=='inline')
                {
                    document.getElementById('star1-'+p).style.display='none';
                }
            }
        });
    }
</script>
<div id="dialog-modal" title="Reply Form"></div>
<div class="web-booking-main" id="gridbody" style="padding-right:2px;">
    <div class="breadcrumbs"><a href="index.php">Home </a>&nbsp;>&nbsp; <span class="current"> Manage Contact Us Leads</span></div>
    <div class="clear"></div>
    <input type="hidden" value='contactusmsg' name="hdnmodule" id="hdnmodule" />
    <?php echo $messagebox; ?><?php echo $sendmailstatus; ?>
    <?php echo $headerpanel; ?>        
    <?php echo $pagingTop; ?>
    <div class="grid-list-subtitle-bg" style="margin-top:10px;margin-right: 2px;">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td width="2%" align="left" valign="top" class="grid-td-left"><input name="chkall" id="chkall" type="checkbox" onclick="checkall('chkgrow')"  /></td>                     
                <td width="3%" valign="left" class="grid-td-left">&nbsp;</td>
                <td width="20%" align="left" valign="middle" class="grid-td-top"><a href="javascript:;" onclick="SendGridBindRequest('<?= $inquiryObj->urlwithoutsort ?>&orderby=var_name&sorting=Y','gridbody','ST')">Name
                        <?= $setsortimgvar_name ?>
                    </a></td>
                <td width="15%" align="center" valign="middle" class="grid-td-top"><a href="javascript:;" onclick="SendGridBindRequest('<?= $inquiryObj->urlwithoutsort ?>&orderby=var_phone&sorting=Y','gridbody','ST')">Phone<?= $setsortimgvar_phone ?></a></td>
                <td width="18%" align="center" valign="middle" class="grid-td-top"><a href="javascript:;" onclick="SendGridBindRequest('<?= $inquiryObj->urlwithoutsort ?>&orderby=var_email&sorting=Y','gridbody','ST')">Email Id<?= $setsortimgvar_email ?></a></td>
                <td width="7%" align="center" valign="middle" class="grid-td-top">Message</td>
               
                <td width="12%" align="center" valign="middle" class="grid-td-top"><a href="javascript:;" onclick="SendGridBindRequest('<?= $inquiryObj->urlwithoutsort ?>&orderby=dt_createddate&sorting=Y','gridbody','ST')">Date<?= $setsortimgdt_createddate ?></a></td>
            </tr>
        </table>
    </div>
    <div class="information-white-bg" id="dvpersonalinformation" style="margin-right: 2px;">
        <div class="clear"></div>
        <div class="grid-list-inner-table-text">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
            </table> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <?php
                if ($numofrows > 0) {
                    $rowcount = 0;
                    while ($row = $configObj->glDbObj->fetch_array($result)) {
                        $clsname = ($row['chr_read'] == 'N') ? "grid-list-inner-table-text-active" : "grid-list-inner-table-text"; // For read unread class
                        
//                        echo $clsname;exit;
                        $starimg = ($row['chr_star'] == 'Y') ? "gstar.png" : "gstar-disable.png"; // Displaying the stat and unstart image
                        $tool = ($row['chr_star'] == 'Y') ? "Starred" : "Not starred";
                        $tickimg = ($row['chr_publish'] == 'Y') ? "tick.png" : "tick_cross.png"; // Displaying the stat and unstart image
                        $sql_con_rep = "SELECT fk_contactdetail,GROUP_CONCAT(var_adminreply,'<br/>$$$$$') as add_rep,GROUP_CONCAT(DATE_FORMAT(dtcreateddate, '" . DEFAULT_DATEFORMAT . "'),'$$$$$') as add_rep_date,GROUP_CONCAT(time(dtcreateddate),'<br/>$$$$$') as add_rep_time FROM " . DB_PREFIX . "contactusmsg_reply where fk_contactdetail='" . $row['int_glcode'] . "' group by fk_contactdetail order by dtcreateddate desc";
                        $row_add_rep = $configObj->glDbObj->get_sql_row($sql_con_rep);
                        $arr_admin = explode('<br/>$$$$$,', $row_add_rep['add_rep']);
                        $arr_admin_date = explode('$$$$$,', $row_add_rep['add_rep_date']);
                        $arr_admin_time = explode('<br/>$$$$$,', $row_add_rep['add_rep_time']);

                        if ($row['chr_read'] == 'N') {
                            $style = 'display:inline;';
                        } else {
                            $style = 'display:none;';
                        }

                        $starClass = "<span id='star1-" . $row['int_glcode'] . "' style='" . $style . "'><img width='10px' id='imgStar-" . $row['int_glcode'] . "' style='padding-bottom:5px;' height='10px' title='New Inquiry Added'  src='html/images/star_red.png'></span>";
                        ?>
                        <tr id="gtr-<?= $row['int_glcode'] ?>"  style="background-color: transparent;"  class="<?= $clsname ?>" onmouseover="this.style.backgroundColor='#f6f6f6'" onmouseout="this.style.backgroundColor='transparent'" >

                            <td width="2%" align="left" valign="middle" class="grid-td-left"><input name="chkgrow" id="chkgrow" type="checkbox" value="<?php echo $row['int_glcode'] ?>" /></td>
                            <?php if ($configObj->glSessionObj->value('admin_id') == '1') { ?>
                                <td width="3%" align="center" valign="middle" class="grid-td-top">
                                    <img id="star-<?= $row['int_glcode'] ?>" height="16" width="16" alt="remember me" title="<?= $tool ?>" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?><?= $starimg ?>" style="vertical-align:middle;cursor:pointer;"onclick="UpdateStar('<?= DB_PREFIX ?>contactdetails','chr_star','<?= $row['int_glcode'] ?>');">
                                </td>
                            <?php } else { ?>
                                <td width="3%" align="center" valign="middle" class="grid-td-top">&nbsp;</td>
                            <?php } ?>

                            <td width="20%" align="left" valign="middle" class="grid-td-top"> <?php echo $row['var_name']; ?>&nbsp;<?php echo $starClass; ?></td>
                                      <?php if($row['var_phone']!='') { ?>
                            <td width="15%" align="center" valign="middle" class="grid-td-top"><?php echo $row['var_phone']; ?></td>
                           <?php } else {?>
                            <td width="15%" align="center" valign="middle" class="grid-td-top">N/A</td>
                            <?php } ?>
                            <td width="18%" align="center" valign="middle" class="grid-td-top"><?php echo $row['var_email']; ?></td>
                            <td width="7%" align="center" valign="middle" class="grid-td-top">
                                <?php if ($row['var_message'] != '') { ?>
                                <a href="index.php?module=contactusmsg" onclick="return hs.htmlExpand(this, { headingText: 'Message' })"><span  onclick="javascript : return updateread('<?= $row['int_glcode'] ?>');">View </span>
                                    </a>
                                <?php } ?>
                                <div class="highslide-maincontent">
                                    <table cellspacing="0" cellpadding="0" border="0" align="center" width="98%">
                                        <tbody>

                                            <tr>
                                                <td align="left" valign="top"><?php echo $row['var_message']; ?></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </td>

                            <td width="12%" align="center" valign="middle" class="grid-td-top" >
                                <?= $row['Date']; ?>
                            </td>
                        </tr>
                        <?php
                        $rowcount++;
                    }
                } else {
                    ?>

                    <tr style="background-color: transparent;"  class="<?= $clsname ?>" onmouseover="this.style.backgroundColor='#f6f6f6'" onmouseout="this.style.backgroundColor='transparent'">
                        <td height="25" align="center" valign="middle" colspan="6" class="form_titles">

                            No new leads, Please <a href="http://www.netclues.ky/seo-search-engine-optimization-cayman-islands.php" target="_blank"> <strong>Click Here</strong> </a> to find out how to get more leads.

                        </td>
                    </tr>
                    <?php
                }
                ?>
                <input type="hidden" name="ptrecords" id="ptrecords" value="<?= $rowcount ?>">             
            </table>
        </div>
    </div>            
    <div class="clear"></div>

    <?php echo $pagingBottom; ?>
    <?php if ($paramMain['Delete'] == 'Y' && $numofrows > 0) { ?>

        <div style="width:90px; float: left;" class="add-new-user-button"><a href="javascript:" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image47','','<?= GLOBAL_ADMIN_IMAGES_PATH ?>delete-button-hover.jpg',0)"><img src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>delete-button.jpg" alt="Delete" name="Image47" width="80" height="25" border="0" id="Image47" onclick="return verify();" /></a>
        </div>
    <?php } ?>
    <form name="exportform" id="exportform" action="index.php?module=contactusmsg&action=export"  method="post">
        <input type="hidden" name="totalrecords" id="totalrecords" value="">
        <input type="hidden" name="chkids" id="chkids" value="">
        <? if ($numofrows > 0) { ?>
            <div class="add-new-user-button"><a href="javascript:" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image48','','<?= GLOBAL_ADMIN_IMAGES_PATH ?>export-button-hover.gif',0)"><img src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>export-button.gif" alt="Delete" name="Image48" width="81" height="25" border="0" id="Image48" onclick="return excelreport();" /></a></div>
                <?php } ?>
    </form>
</div>