<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
      <div class="main my-0">
        <div class="row mt-3 mx-0">
          <div class="col-md-9">
            <h3>Manage Batabase Backup</h3>
          </div>
          <div class="col-md-3 text-right">
            <a href="account/createbackup" class="btn btn-success">Create Backup</a>
          </div>
        </div>
        
        <div class="container_fluid mt-4 px-3">
	
         <?php
			if($this->session->flashdata("message")!="" && $this->session->flashdata("alerttype")!="")
			{
         ?>
         <div class="text-center my-4">
			 <span class="alert <?php echo $this->session->flashdata("alerttype");?>"><?php echo $this->session->flashdata("message");?></span>
         </div>
         <?php
			}
         ?>
        <table class="table-striped table-bordered table-hover mt-2" id="">
		 
													<thead>
														<tr>
															<th class="table-checkbox">S. No.</th>
															<th> Backup File</th>				
                                                            <th class="text-center"> Backup Date</th>											
															<th class="text-center"> Action </th>
														</tr>
													</thead>
													<tbody>
														<?php
														$this->load->helper('file');
														$listing = get_dir_file_info('dbbackup/', $top_level_only = TRUE);
														$i=0;
														if(count($listing) > 0)
														{
															//preTagdata($listing);
															
															$sortcolname = 'date';
															usort($listing, function ($a, $b) use(&$sortcolname) { return $b[$sortcolname] - $a[$sortcolname];});
															
															foreach ($listing as $key => $value) 
															{
																$i++;
																$file =  $value['name'];
																$server_path =  $value['server_path'];
																$size =  $value['size'];
																$date =  $value['date'];
																$unixtime = $date;
																$dates = date("d-M-Y h:i:s A T",$unixtime);
															?>
                                                                <tr class="odd gradeX">
                                                                    <td data-label="S. No.">
                                                                        <?php echo $i;?>
                                                                        <!--<label class="mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                                                            <input type="checkbox" class="checkboxes" value="1" />
                                                                            <span></span>
                                                                        </label>-->
                                                                    </td>
                                                                    <td data-label="Backup File"> <?php echo $file;?> </td>
                                                                    
                                                                    <td data-label="Backup Date" class="text-center">
                                                                        <?php echo $dates;?>
                                                                    </td>
                                                                    <td data-label="Action" class="text-center"> 
                                                                        <a href="<?php echo base_url()."dbbackup/".$file; ?>" class="btn btn-outline green-sharp  uppercase"><i class="fa fa-download fa-lg"></i> </a>
                                                                        <a href="<?php echo base_url();?>account/del_backup/<?php echo $file; ?>" class="btn btn-outline green-sharp  uppercase" data-toggle="confirmation" data-placement="left"><i class="fa fa-trash-o" aria-hidden="true"></i> </a>
                                                                    </td>
                                                                </tr>
                                                       		<?php 
															}														
															
														}
														else
														{
														?>
														<tr><td colspan="8" style="text-align:center">Record not found!</td></tr>
														<?php
														}
														?>
													</tbody>
												</table> 
         
                 
	         <div class="clearfix"></div>
          
        </div>
        <div id="paginate" class="row">
			<?php echo $this->ajax_pagination->create_links(); ?>
        </div>
            
        </div>


