<script type="text/javascript">
    function verify()
    {
        SendGridBindRequest('<?= $newsletterObj->urlwithpara ?>','gridbody','D','chkgrow');
    }
    
    function updateread(id)
    {
        var p='';
        $.ajax({
            type: "GET",
            url:"index.php" ,
            data: "module=newsletter&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';
                }
            }
        });
    }
    
    function yes_no(intglcode)
    {
        var path=document.getElementById('reply'+intglcode).src;
        var file_a= path.substring(path.lastIndexOf("/")+1,path.length);
        var value;
        if(file_a == 'cross.png'){
            value = 'Y';
        }else if(file_a == 'tick-icon.jpg'){
            value = 'N';
        }
        SetBackground();
        $.ajax({
            type: "GET",
            url:"index.php" ,
            data: "module=newsletter&action=approvenewslatterleads&ajax=Y&value="+value+"&id="+intglcode,
            async: false,
            success: function(result){
                if(value == 'Y'){
                    document.getElementById('reply'+intglcode).src = 'html/images/tick-icon.jpg';
                } else {
                    document.getElementById('reply'+intglcode).src = 'html/images/cross.png';
                }
                UnsetBackground();
            }
        });
    }
    
    function popreply1(id)
    {
        var response;
        $.ajax({
            type: "GET",
            url:"index.php" ,
            data: "module=newsletter&action=email&ajax=Y&id="+id,
                         
            async: false,
            success: function(data){
                //alert(data);
                response=data;
            }
        });

    
        $('#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();
    }
</script>
<div id="dialog-modal" title="Reply Form"></div>
<div class="web-booking-main" id="gridbody">
    <div class="breadcrumbs"><a href="index.php">Home </a>&nbsp;>&nbsp; <span class="current">Manage Newsletter Leads</span></div>
    <div class="clear"></div>
    <?= $messagebox; ?><?= $sendmailstatus; ?>
    <?php echo $headerpanel; ?>
    <?php echo $pagingTop; ?>

    <div class="grid-list-subtitle-bg" style="margin-top:10px;">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <?php if ($paramMain['Delete'] == 'Y') { ?>
                    <td width="3%" align="left" valign="top" class="grid-td-left"><input name="chkall" id="chkall" type="checkbox" onclick="checkall('chkgrow')"  /></td>                      
                <?php } else { ?>
                    <td width="3%" align="left" valign="top" class="grid-td-left">&nbsp;</td>
                <?php } ?>
                <td width="15%" align="left" valign="middle" class="grid-td-top"><a href="javascript:;" onclick="SendGridBindRequest('<?= $newsletterObj->urlwithoutsort ?>&orderby=var_email&sorting=Y','gridbody','ST')">Email ID<?= $setsortimgvar_email ?></a></td>
               
                <td width="15%" align="center" valign="top" class="grid-td-top" ><a href="javascript:;" onclick="SendGridBindRequest('<?= $newsletterObj->urlwithoutsort ?>&orderby=dt_createdate&sorting=Y','gridbody','ST')">Date/Time<?= $setsortimgdt_createdate ?></a></td>
            </tr>
        </table>
    </div>
    <div class="information-white-bg" id="dvpersonalinformation" >
        <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)) {
                       
                        $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 . "newsletter_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']);

                        $star = "<span id='star1-" . $row['int_glcode'] . "' style='" . $style . "'><img width='10px' id='imgStar-" . $row['int_glcode'] . "' style='padding-bottom:5px;' height='10px' title='New Newsletter added' alt='*' src='html/images/star_red.png'></span>";
                        ?>
                        <tr id="gtr-<?= $row['int_glcode'] ?>"  style="background-color: transparent;"  class="grid-list-inner-table-text" onmouseover="this.style.backgroundColor='#f6f6f6'" onmouseout="this.style.backgroundColor='transparent'" >
                            <?php if ($paramMain['Delete'] == 'Y') { ?>
                                <td width="3%" align="left" valign="middle" class="grid-td-left"><input name="chkgrow" id="chkgrow" type="checkbox" value="<?php echo $row['int_glcode'] ?>" /></td>
                            <?php } else { ?>
                                <td width="3%" align="left" valign="middle" class="grid-td-left"></td>
                            <?php } ?>

                            <td width="15%" align="left" valign="middle" class="grid-td-top"><?php echo $row['var_email']; ?>&nbsp;<?php // echo $star ?></td>

                            <td width="15%" align="center" valign="top" class="grid-td-top" >

                                <?
                                $date_news = DEFAULT_DATEFORMAT;

                                if ($date_news == "%d/%m/%Y") {
                                    $date_news1 = "d/m/Y H:i";
                                }
                                if ($date_news == "%m/%d/%Y") {
                                    $date_news1 = "m/d/Y H:i";
                                }
                                if ($date_news == "%Y/%m/%d") {
                                    $date_news1 = "Y/m/d H:i";
                                }
                                if ($date_news == "%Y/%d/%m") {
                                    $date_news1 = "Y/d/m H:i";
                                }
                           $date = date($date_news1, strtotime($row['dt_createdate'])); 
                                ?>


                                <?php echo $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 target="_blank" href="http://www.netclues.ky/seo-search-engine-optimization-cayman-islands.php"> <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 ($numofrows > 0) { ?>
        <?php if ($paramMain['Delete'] == 'Y') { ?>
            <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 } ?>
    <?php } ?>
    <form name="exportform" id="exportform" action="index.php?module=newsletter&action=export"  method="post">
        <input type="hidden" name="totalrecords" id="totalrecords" value="">
        <input type="hidden" name="chkids" id="chkids" value="">
        <?php 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>