Mini Shell

Direktori : /home/mhcadmin/public_html/
Upload File :
Current File : /home/mhcadmin/public_html/ManageAppUploads.php

<?php
session_start();
require_once 'config/config.php';
require_once 'include/auth_validate.php';

/////// Code for new access control on header menu /////////////////////////
$User = $_SESSION['id'];
$UserAccessName= $sql = "";

$result = mysqli_query( $connection,"SELECT * FROM admin_accounts WHERE id = '$User' ");
        $num = mysqli_num_rows($result);

	        if ($num >0){
				
				$rows = mysqli_fetch_array($result);
                $UserAccessName = $rows['UserAccessName'];
				
						}



//Only super admin is allowed to access this page
if ($_SESSION['admin_type'] !== 'super') {
    // show permission denied message
    header('HTTP/1.1 401 Unauthorized', true, 401);
    
    exit("401 Unauthorized");
}
$db = getDbInstance();


//Get data from query string
$search_string = filter_input(INPUT_GET, 'search_string');
$del_id = filter_input(INPUT_GET, 'del_id');

$filter_col = filter_input(INPUT_GET, 'filter_col');
$order_by = filter_input(INPUT_GET, 'order_by');
$page = filter_input(INPUT_GET, 'page');
$pagelimit = 20;
if ($page == "") {
    $page = 1;
}
// If filter types are not selected we show latest added data first
if ($filter_col == "") {
    $filter_col = "AppUploadID";
}
if ($order_by == "") {
    $order_by = "desc";
}
// select the columns



//$db->where('Full_Name', 'Administrator');
$select = array('AppUploadID', 'FullName', 'Region', 'Fname2','Application_Date');


// If user searches 
if ($search_string) {
    $db->where('FullName', '%' . $search_string . '%', 'like');
}



if ($order_by) {
    $db->orderBy($filter_col, $order_by);
}

$db->pageLimit = $pagelimit;
$result = $db->arraybuilder()->paginate("applicationuploads", $page, $select);
$total_pages = $db->totalPages;


// get columns for order filter
foreach ($result as $value) {
    foreach ($value as $col_name => $col_value) {
        $filter_options[$col_name] = $col_name;
    }
    //execute only once
    break;
}



include_once 'include/AdminHeader.php';
?>

<div id="page-wrapper">
<div class="row">
     <div class="col-lg-6">
            <h4 class="page-header">Manage Uploaded Applications</h4>
        </div>
        <div class="col-lg-6" style="">
            <div class="page-action-links text-right">
			 
			<a href="ManageAppUploads.php??operation=Form Uploads"> <button class="btn btn-success"><span class="glyphicon glyphicon-refresh"></span> Refresh</button></a>
            </div>
        </div>
</div>
 <?php include('include/flash_messages.php') ?>

    <?php
    if (isset($del_stat) && $del_stat == 1) {
        echo '<div class="alert alert-info">Successfully deleted</div>';
    }
    ?>
    
    <!--    Begin filter section-->
    <div class="well text-center filter-form">
        <form class="form form-inline" action="">
            <label for="input_search" >Search</label>
            <input type="text" class="form-control" id="input_search" placeholder = "By Applicant Name" name="search_string" value="<?php echo $search_string; ?>">
            <label for ="input_order">Order By</label>
            <select name="filter_col" class="form-control">

                <?php
                foreach ($filter_options as $option) {
                    ($filter_col === $option) ? $selected = "selected" : $selected = "";
                    echo ' <option value="' . $option . '" ' . $selected . '>' . $option . '</option>';
                }
                ?>

            </select>

            <select name="order_by" class="form-control" id="input_order">

                <option value="Asc" <?php
                if ($order_by == 'Asc') {
                    echo "selected";
                }
                ?> >Asc</option>
                <option value="Desc" <?php
                if ($order_by == 'Desc') {
                    echo "selected";
                }
                ?>>Desc</option>
            </select>
            <input type="submit" value="Go" class="btn btn-primary">

        </form>
    </div>
    <!--   Filter section end-->
    <hr>
    <table class="table table-striped table-bordered table-condensed">
        <thead>
            <tr style= "background-color:#BAC4CC;">
   
				
                <th>FullName</th>
                <th>Region</th>
				<th>Application Date</th>
				<th>Action</th>
            </tr>
        </thead>
        <tbody>
 
            <?php foreach ($result as $row) : ?>
                
            <tr>
                <td><h5><?php echo htmlspecialchars($row['FullName']) ?></h5></td>
				<td><h5><?php echo htmlspecialchars($row['Region']) ?></h5></td>
				<td><h5><?php echo htmlspecialchars($row['Application_Date']) ?></h5></td>
				
				<td>
					  <ul class="nav navbar-top-links navbar-right">
                        <!-- /.dropdown -->

                        <!-- /.dropdown -->
						
                        <li class="dropdown">
                            <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                                <i class="fa fa-folder-open"></i> 
                            </a>
                            <ul class="dropdown-menu dropdown-user">
							
                                <li class="divider"></li>
								 <li><h6><a href="ApplicationUploads/<?php echo($row['Fname2']) ?> "><span class="btn btn-primary" > Download<span class="glyphicon glyphicon-download-alt"></span></a>
								</h6></li>
																
                                <li class="divider"></li>
								<li><h6><a href=""  data-toggle="modal" data-target="#confirm-delete-<?php echo $row['AppUploadID'] ?>" ><span class="btn btn-danger delete_btn"> Delete Record</span></a>
				                </h6></li>
                                
                            </ul>
							
                      </div>
                            <!-- /.dropdown-user -->
                       
                        <!-- /.dropdown -->
                    </ul>
					  </td>	

            </tr>
			
			
			
			
			
                <!-- Delete Confirmation Modal-->
                     <div class="modal fade" id="confirm-delete-<?php echo $row['AppUploadID'] ?>" role="dialog">
                        <div class="modal-dialog">
                          <form action="DeleteUPloadedApp.php" method="POST">
                          <!-- Modal content-->
                              <div class="modal-content">
                                <div class="modal-header" style="text-align:center; background-color:#BAC4CC;">
                                  <button type="button" class="close" data-dismiss="modal">&times;</button>
                                  <h4 class="modal-title">Confirm</h4>
                                </div>
                                <div class="modal-body">
                                    <input type="hidden" name="del_id" id = "del_id" value="<?php echo $row['AppUploadID'] ?>">
                                    <p>Are you sure you want to delete this Record?</p>
                                </div>
                                <div class="modal-footer">
                                    
									<button type="submit" name="submit" id="submit" class="btn btn-danger delete_btn pull-left" value = "Submit" > Delete <span class="glyphicon glyphicon-trash"></button>
									
                                    <button type="button" class="btn btn-primary" data-dismiss="modal">Cancel <span class="glyphicon glyphicon-remove"></button>
						            </div>
                              </div>
                          </form>
                          
                        </div>
                    </div>
					
					
					
					
					
					
            <?php endforeach; ?>   
        </tbody>
    </table>
	
	
	
	
    <!--    Pagination links-->
    <div class="text-center">

        <?php
        if (!empty($_GET)) {
            //we must unset $_GET[page] if built by http_build_query function
            unset($_GET['page']);
            $http_query = "?" . http_build_query($_GET);
        } else {
            $http_query = "?";
        }
        if ($total_pages > 1) {
            echo '<ul class="pagination text-center">';
            for ($i = 1; $i <= $total_pages; $i++) {
                ($page == $i) ? $li_class = ' class="active"' : $li_class = "";
                echo '<li' . $li_class . '><a href="ManageAppUploads.php' . $http_query . '&page=' . $i . '">' . $i . '</a></li>';
            }
            echo '</ul></div>';
        }
        ?>
    </div>
</div>


<?php include_once 'include/footer.php'; ?>