<script type="text/javascript">
    
    function importDatabase(zipfiledata,module,action)
    {
        var m=confirm('Caution! Are you sure you want to restore this database backup?');
        if (m==true)
        {
            xmlHttp = GetXmlHttpObject();
            if (xmlHttp == null)
            {
                alert ("Your browser does not support XMLHTTP!");
                return;
            }
            var url = "index.php?ajax=Y&module="+module+"&action="+action+'&zipfile='+zipfiledata;

            xmlHttp.onreadystatechange = function()
            {
                if(xmlHttp.readyState==1)
                {
                    SetBackground();
                }
                if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
                {
                   
                    var result = xmlHttp.responseText;
                  
                    if(result==0){
                        alert('Congrats! The database backup is successfullly restored.');
                    }else{
                        alert('There are some problem to restore this database.');
                    }
                    window.location='index.php?module=dbackup';
                    UnsetBackground();
                }
            };
            xmlHttp.open("GET",url,true);
            xmlHttp.send(null);
        }
        else
        {
            return false;
        }
    }    
    function delbackupzipdata(zipfiledata,module,action)
    {
        var m=confirm('Caution! Are you sure you want to delete this database backup?');
        if (m==true)
        {
            xmlHttp = GetXmlHttpObject();
            if (xmlHttp == null)
            {
                alert ("Your browser does not support XMLHTTP!");
                return;
            }
            var url = "index.php?ajax=Y&module="+module+"&action="+action+'&zipfile='+zipfiledata;

            xmlHttp.onreadystatechange = function()
            {
                if(xmlHttp.readyState==1)
                {
                    SetBackground();
                }
                if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
                {
                    var result = xmlHttp.responseText;
                    alert('The database backup file is deleted successfully.');
                    window.location='index.php?module=dbackup';
                    UnsetBackground();
                }
            };
            xmlHttp.open("GET",url,true);
            xmlHttp.send(null);
        }
        else
        {
            return false;
        }
    }

    function dbbackup()
    {
        xmlHttp = GetXmlHttpObject();
        if (xmlHttp == null)
        {
            alert ("Your browser does not support XMLHTTP!");
            return;
        }
        var url = "modules/dbackup/html/dbbackup/backup_dbs.php";
        xmlHttp.onreadystatechange = function()
        {
            if(xmlHttp.readyState==1)
            {
                SetBackground();
            }
            if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
            {
                var result = xmlHttp.responseText;
                alert('Congrats! database backup is successfully generated.');
                window.location='index.php?module=dbackup';
                UnsetBackground();
            }
        };
        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);
    }
</script>    
<div class="web-booking-main" id="gridbody">
    <div class="clear"></div>
    <?= $messagebox; ?>
    <?php echo $headerpanel; ?>
    <?php echo $pagingTop; ?>

    <br class="clear" />
    <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="1%" align="left" valign="middle" class="grid-td-left">No.</td>
                <td width="9%" align="left" valign="middle" class="grid-td-top" style="padding-left:10px;*padding-left:30px;">Database Backup Name</td>
       <td width="4%" align="center" valign="middle" class="grid-td-top" style="padding-left:15px;*padding-left:25px;">Restore
                </td>                
                <td width="4%" align="center" valign="middle" class="grid-td-top" style="padding-left:15px;*padding-left:25px;">Download
                </td>
                <td width="2%" valign="middle">&nbsp;</td>
                <td width="5%" align="left" valign="middle" class="grid-td-top">Delete Backup</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">
                <?php
                $rowzip = count($fileziparray);
                if ($rowzip > 0) {
                    $rowcount = 1;
                    for ($i = 0; $i < $rowzip; $i++) {
                        ?>
                        <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="top" class="grid-td-left">
                                <?= $rowcount ?>
                            </td>
                            <td width="13%" align="left" valign="middle" class="grid-td-top">
                                <span> <?= $fileziparray[$i] ?></span></td>
                            <td width="6%" align="left" valign="middle" class="grid-td-top">
                                <a onclick="importDatabase('<?= $fileziparray[$i] ?>','dbackup','importfile');" ><img src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>restore.png" style="vertical-align:middle;cursor:pointer;" alt="Restore" /></a>
                            </td>                            
                            <td width="6%" align="left" valign="middle" class="grid-td-top">
                                <a href="modules/dbackup/html/dbbackup/db_backups/<?= $fileziparray[$i] ?>"><img src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>download.png" style="vertical-align:middle;cursor:pointer;" alt="Download" /></a>
                            </td>
                            <td width="5%" align="left" valign="middle" class="grid-td-top">
                                <a href="javascript:;"><img alt="delete"  id="tick" height="16" width="16" alt="<?= $title ?>" title="" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>delete1.png" style="vertical-align:middle;cursor:pointer;" onclick="delbackupzipdata('<?= $fileziparray[$i] ?>','dbackup','delzipfile');"></a>
                            </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="8" class="form_titles">No Database Backup Available</td>
                    </tr>
<?php } ?>
                <input type="hidden" name="ptrecords" id="ptrecords" value="<?= $rowcount ?>">
            </table>
        </div>
    </div>
    <div class="clear"></div>
<?php echo $pagingBottom; ?>
</div>