<script type="text/javascript">
    function SendGridBindRequestTrashmanager(url,targetdiv,action,chkidfordelete,view,tablename)
    {
        xmlHttp = GetXmlHttpObject();
        if(xmlHttp != null)
        {
            xmlHttp.onreadystatechange = function()
            {
                if(xmlHttp.readyState==1)
                {
                    SetBackground();
                }
                if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
                {
                    var str =  xmlHttp.responseText;
                    document.getElementById(targetdiv).innerHTML = '';
                    document.getElementById(targetdiv).innerHTML = str;
                    UnsetBackground();
                    switch(action)
                    {
                        case 'R': // to set the focus on the search text field
                            //alert('Congrats! The selected records have been successfully restored.');
                            break;
                        case 'D': // to set the focus on the go to page text field on top
                            alert('The record(s) has been succesfully deleted');
                            break;
                    }
                }
            };

            var appendurl = '';

            switch(action)
            {
                case 'D': // This is for delete

                    var chkelements = document.getElementsByName(chkidfordelete);
                    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;
                        }
                    }
                    if(countChecked == 0)
                    {
                        alert("Please select atleast one record for delete.");
                        return false;
                    }
                    if(!confirm('Caution! The selected records will be deleted. Press OK to confirm.'))
                    {
                        return false;
                    }
                    var totalpagerecords = document.getElementById('ptrecords').value;
                    appendurl = '&tablename='+tablename+'&view='+view+'&action=delete&ptotalr='+totalpagerecords+'&dids='+ids;
                    break;

                case 'R':

                    var chkelements = document.getElementsByName(chkidfordelete);
                    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;
                        }
                    }
                    if(countChecked == 0)
                    {
                        alert("Please select atleast one record for restore.");
                        return false;
                    }
                    if(!confirm('Caution! The selected records will be restored. Press OK to confirm.'))
                    {
                        return false;
                    }

                    var totalpagerecords = document.getElementById('ptrecords').value;

                    appendurl = '&tablename='+tablename+'&view='+view+'&action=restore&ptotalr='+totalpagerecords+'&rids='+ids;

                    break;

            }

            xmlHttp.open('GET', url + '&ajax=Y'+appendurl, true);
            xmlHttp.send(null);
        }
        else
        {
            alert("Your browser does not support HTTP request.");
        }
        return true;
    }

    function verify()
    {
        var tablename=document.getElementById('h_tablename').value;
        var view=document.getElementById('h_view').value;

        SendGridBindRequestTrashmanager('<?= $trashmanagerObj->urlwithpara ?>','gridbody','D','chkgrow',view,tablename);
    }
    function restore()
    {
        var tablename=document.getElementById('h_tablename').value;
        var view=document.getElementById('h_view').value;
        SendGridBindRequestTrashmanager('<?= $trashmanagerObj->urlwithpara ?>','gridbody','R','chkgrow',view,tablename);
    }
</script>
<div class="web-booking-main" id="gridbody">
    <div class="clear"></div>
    <?= $messagebox; ?>
    <?php echo $headerpanel; ?>
    <?php echo $pagingTop; ?>
    <?php echo $notemessagebox; ?>
    <?php
    if ($paramMain['Delete'] == 'Y') {
        $delete_link = "true";
    } else {
        $delete_link = "false";
    }
    if ($paramMain['Restore'] == 'Y') {
        $restore_link = "true";
    } else {
        $restore_link = "false";
    }
    ?>

    <input name="h_tablename" type="hidden" id="h_tablename" value="<?= $trashmanagerObj->tablename ?>" />
    <input name="h_view" type="hidden" id="h_view" value="<?= $trashmanagerObj->view ?>" />
    <input name="trname" type="hidden" id="trname" value="pages" />
    
    <div class="grid-list-subtitle-bg" style="margin-top:10px;">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td width="2%" align="left" valign="top" class="grid-td-left">
                    <? if ($restore_link == "true" || $delete_link == "true") { ?>
                        <input name="chkall" id="chkall" type="checkbox" onclick="checkall('chkgrow')"/> <? } ?>
                </td>


                <td width="3%" align="left" valign="top" class="grid-td-top">&nbsp;</td>

                <td width="30%" align="left" valign="top" class="grid-td-top">
                    <a href="javascript:;" onclick="SendGridBindRequest('<?= $trashmanagerObj->urlwithoutsort ?>&orderby=<?= $trashmanagerObj->displayfield1 ?>&sorting=Y&view=<?= $_REQUEST['view'] ?>','gridbody','ST')">
                        <?= $trashmanagerObj->displayfieldtitle1 ?>
                        <?= ${"setsortimg" . $trashmanagerObj->displayfield1} ?>
                    </a>
                </td>
                <?php if ($_REQUEST['view'] == 'photogallery') { ?>

                    <td width="18%" align="left" valign="top" class="grid-td-top" style="padding-left:20px;">

                        <?= $trashmanagerObj->displayfieldtitle2 ?>


                    </td>
                <?php } else { ?>

                    <td width="18%" align="left" valign="top" class="grid-td-top" style="padding-left:20px;">
                        <a href="javascript:;" onclick="SendGridBindRequest('<?= $trashmanagerObj->urlwithoutsort ?>&orderby=<?= $trashmanagerObj->displayfield2 ?>&sorting=Y&view=<?= $_REQUEST['view'] ?>','gridbody','ST')">
                            <?= $trashmanagerObj->displayfieldtitle2 ?>
                            <?= ${"setsortimg" . $trashmanagerObj->displayfield2} ?>
                        </a>
                    </td>

                <?php } ?>
                <td width="16%" align="left" valign="top" class="grid-td-top"><a href="javascript:;" onclick="SendGridBindRequest('<?= $trashmanagerObj->urlwithoutsort ?>&orderby=var_adminuser&sorting=Y&view=<?= $_REQUEST['view'] ?>','gridbody','ST')">User Name<?= $setsortimgvar_adminuser ?></a></td>
                <td width="16%" align="left" valign="top" class="grid-td-top">Ip Address</td>
                <td width="16%" align="center" valign="top" class="grid-td-top">
                    <a href="javascript:;" onclick="SendGridBindRequest('<?= $trashmanagerObj->urlwithoutsort ?>&orderby=dt_modifydate&sorting=Y&view=<?= $_REQUEST['view'] ?>','gridbody','ST')">
                        Deleted Date<?= $setsortimgdt_modifydate ?></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 ($trashmanagerObj->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

                        $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
                        ?>
                        <tr id="gtr-<?= $row['int_glcode'] ?>"  style="background-color: transparent;"  class="grid-list-inner-table-text-active" onmouseover="this.style.backgroundColor='#f6f6f6'" onmouseout="this.style.backgroundColor='transparent'" >

                            <td width="2%" align="left" valign="middle" class="grid-td-left">
                                <?php if ($restore_link == "true" || $delete_link == "true") { ?>
                                    <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-left1"><img id="star-<?= $row['int_glcode'] ?>" height="16" width="16" alt="remember me" title="<?php echo $tool; ?>" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?><?= $starimg ?>" style="vertical-align:middle;cursor:pointer;"onclick="UpdateStar('<?= $trashmanagerObj->tablename ?>','chr_star','<?= $row['int_glcode'] ?>');"></td>
                            <?php } else { ?>
                                <td width="3%" align="center" valign="middle" class="grid-left1"></td>
                            <?php } ?>
                            <td width="32%" align="left" valign="middle" class="grid-td-top">
                                <?php
                                $char = substr($row[$trashmanagerObj->displayfield1], 0, 25);
                                if (strlen($row[$trashmanagerObj->displayfield1]) > 25) {
                                    $char.='...';
                                } ?>
                                <span><?= $char; ?></span>
                            </td>

                            <td width="16%" align="left" valign="middle" class="grid-td-top">

                                <?php
                                if ($row['var_image'] != '' && $trashmanagerObj->displayfield2 == 'var_image' && $_REQUEST['view'] != 'projectsphoto') {
                                    ?>
                                    <a onClick="return hs.expand(this);" href="modules/<?= $_REQUEST['view'] ?>/html/uploads/images/thumb2_<?= $_REQUEST['view'] . trim($row['var_image']) ?>">
                                        <img border="0" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>/photo-gallery-icon.png" >
                                    </a>
                                    <?php
                                } else if ($_REQUEST['view'] == 'projectsphoto') { ?>
                                    <a onClick="return hs.expand(this);" href="modules/projects/html/uploads/images/thumb2_project<?= trim($row['var_image']) ?>">
                                        <img border="0" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>/photo-gallery-icon.png" >
                                    </a>
                                    <?php
                                } else { ?>
                                    <span><?= $row[$trashmanagerObj->displayfield2]; ?></span>
                                    <?php
                                } ?>
                            <td width="16%" align="left" valign="middle" class="grid-td-top"><?= $row['var_adminuser']; ?> </td>
                            <td width="16%" align="left" valign="middle" class="grid-td-top"><?= $row['var_ipaddress']; ?> </td>
                        <?php $date_news = DEFAULT_DATEFORMAT;

                            if ($date_news == "%d/%m/%Y") {
                                $date_news1 = "d/m/Y H:i:s";
                            }
                            if ($date_news == "%m/%d/%Y") {
                                $date_news1 = "m/d/Y H:i:s";
                            }
                            if ($date_news == "%Y/%m/%d") {
                                $date_news1 = "Y/m/d H:i:s";
                            }
                            if ($date_news == "%Y/%d/%m") {
                                $date_news1 = "Y/d/m H:i:s";
                            }
                            $deleteddate = date($date_news1, strtotime($row['modifydate']));
                            ?>
                            <td width="15%" align="center" valign="middle" class="grid-td-top"> <?= $deleteddate ?>
                            </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="5" class="form_titles">No records are available.</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) { ?>
        <div class="add-new-user-button" <?= $paramMain['Delete'] ?>>
            <?php if ($delete_link == "true") { ?>
                <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>
            <?php } ?>
        <?php } ?>
        <?php if ($numofrows > 0) { ?>
            <?php if ($restore_link == "true") { ?>
                <a href="javascript:" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image50','','<?= GLOBAL_ADMIN_IMAGES_PATH ?>restore-btn-hvr.jpg',0)"><img src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>restore-btn.jpg" alt="Restore" name="Image50" width="80" height="25" border="0" id="Image50" onclick="return restore();" /></a>
            <?php } ?></div>
        <?php } ?>
</div>