<style>
/* 
Max width before this PARTICULAR table gets nasty
This query will take effect for any screen smaller than 760px
and also iPads specifically.
*/
@media only screen and (max-width: 560px), (min-device-width: 568px) and (max-device-width: 1024px) {
/* Force table to not be like tables anymore */
table, thead, tbody, th, td, tr {
	display: block;
}
/* Hide table headers (but not display: none;, for accessibility) */
thead tr {
	position: absolute;
	top: -9999px;
	left: -9999px;
}
tr {
	border: 0px solid #ccc;
}
td {
	/* Behave  like a "row" */
	border: none;
	/*border-bottom: 1px solid #eee; */
	position: relative;
	padding-left: 50%;
}
td:before {
	/* Now like a table header */
	position: unset; /*absolute causing issues*/
	/* Top/left values mimic padding */
	top: 6px;
	left: 6px;
	width: 45%;
	padding-right: 10px;
	white-space: nowrap;
}
/*
Label the data
*/
td:nth-of-type(1):before {content: "S.No";}
td:nth-of-type(2):before {content: "Mobile No.";}
td:nth-of-type(3):before {content: "Name";}
td:nth-of-type(4):before {content: "Department";}
td:nth-of-type(5):before {content: "Status";}
td:nth-of-type(6):before {content: "Actions";}
.table-checkable tr > td:first-child, .table-checkable tr > th:first-child {
  max-width: 20%;  
}
}
@media only screen and (max-width: 480px), (min-device-width: 300px) and (max-device-width: 480px) {
	.table-checkable tr > td:first-child, .table-checkable tr > th:first-child {
	  max-width: 100%;  
	}
	td:nth-of-type(1)::before {
	  content: "";
	}
}
</style>
<div class="page-content-wrapper">
                <div class="page-content">
                    <div class="page-bar">
                        <div class="page-title-breadcrumb">                            
                            <ol class="breadcrumb page-breadcrumb pull-right">
                                <li><i class="fa fa-home"></i>&nbsp;<a class="parent-item" href="index.php?page=home">Home</a>&nbsp;<i class="fa fa-angle-right"></i>
                                </li><li class="active">Manage IVRS</li>
                            </ol>
                        </div>
                    </div>
                    
	 <div class="row">
                        <div class="col-md-12">
                            <div class="card card-topline-red">
                                <div class="card-head">
                                    <header>Manage IVRS</header>
                                    <div class="tools">                                        
	                                    <a class="t-collapse btn-color fa fa-chevron-down" href="javascript:;"></a>
	                                    <a class="t-close btn-color fa fa-times" href="javascript:;"></a>
                                    </div>
                                </div>
                                <div style="margin: 10px;">
	                                <form name="form_search" id="form_search1" action="" method="post">  
										<select name="department" id="department" >
                                             <option value="">--Select Department--</option>
										              <?php if(mysqli_num_rows($departmentRs)>0){
										              	while($departmentRec = mysqli_fetch_array($departmentRs)){ ?>
										             		<option value="<?php echo $departmentRec['department']; ?>" <?php if(isset($_REQUEST['department']) && $_REQUEST['department']==$departmentRec['department']) { echo 'selected="selected"'; } ?> ><?php echo $departmentRec['department']; ?></option>
                                      	              <?php } } ?>
									  </select>
										    <button class="btn" type="submit" id="search1" name="submit">Search</button>&nbsp;
											<button class="btn" name="clear">Clear</button>
															
									</form>
								</div>
                                <div class="card-body ">                                    
                                    <?php if(isset($_REQUEST['success'])){ ?><div class="alert alert-success"><?php echo urldecode($_REQUEST['success']); ?></div></div><?php } ?>
                                    <?php if(isset($execDetails) && mysqli_num_rows($execDetails)>0) { ?>
                                    <table class="table table-striped table-bordered table-hover table-checkable order-column" style="width: 100%" id="example4">
                                        <thead>
                                            <tr>                                                
                                                <th> S.No. </th>
                                                <th> Mobile No. </th>
                                                <th> Name </th>
                                                <th> Department </th>     
                                                <th> Time </th>                                           
                                                <th> Status </th>
                                                <th> Actions </th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        	<?php
                                        	if(isset($_GET['p']) && is_numeric($_GET['p']) && ($_GET['p'] > 1)) {
												$slNo = ($_GET['p']*30-29);
											} else {
												$slNo = 1;
											}
												while($resDetails = mysqli_fetch_array($execDetails)) {														
													$callTime = $resDetails['time']+19800;  ?>
                                            <tr class="odd gradeX">                                                
                                                <td><?php echo $slNo; ?></td>
                                                <td><?php echo $resDetails['mobile']; ?></td>
                                                <td>
                                                	<?php if($resDetails['user_type']=='U'){ ?>
                                                		<?php echo getUserName($resDetails['user_id']).' (U)'; ?>
                                                	<?php } else if($resDetails['user_type']=='P'){ ?>
                                                		<?php echo getPartnerName($resDetails['user_id']).' (P)'; ?>
                                                	<?php } else if($resDetails['user_type']=='T'){ ?>
                                                		<?php echo getTechnicianName($resDetails['user_id']).' (T)'; ?>
                                                	<?php } else { echo 'Unknown'; } ?>
                                                </td>
                                                <td><?php echo $resDetails['department']; ?></td>
                                                <td><?php echo gmdate("F j, Y, g:i a", $callTime); ?></td>                                                
                                                <td>
                                                	<?php if($resDetails['status']=='Processed'){?>
                                                    	<span class="label label-sm label-success"> <?php echo $resDetails['status'];?> </span>
                                                    <?php } else if($resDetails['status']=='Pending'){ ?>
                                                    	<span class="label label-sm label-warning"> <?php echo $resDetails['status'];?> </span>
                                                    <?php }?>
                                                </td>                                                
                                                <td class="valigntop">
                                                    <div class="btn-group">
                                                        <button class="btn btn-xs deepPink-bgcolor dropdown-toggle no-margin" type="button" data-toggle="dropdown" aria-expanded="false"> Actions
                                                            <i class="fa fa-angle-down"></i>
                                                        </button>
                                                        <ul class="dropdown-menu pull-left" role="menu">     
                                                        	<?php if($resDetails['status']=='Pending'){?>
                                                        	<li>
                                                                <a href="index.php?page=manage_ivrs&action=processed&id=<?php echo $resDetails['id']; ?>&p=<?php echo $p; ?>">
                                                                    <i class="icon-user"></i> Processed </a>
                                                            </li>
                                                            <?php }?>
                                                            <li>
                                                                <a  onclick="return confirm('Are you sure to delete?');" href="index.php?page=manage_ivrs&action=delete&del_id=<?php echo $resDetails['id']; ?>&p=<?php echo $p; ?>">
                                                                    <i class="icon-docs"></i> Delete </a>
                                                            </li>                                                           
                                                        </ul>
                                                    </div>
                                                </td>
                                            </tr>
                                            <?php ++$slNo; } ?>                                            
                                        </tbody>
                                    </table>
                                    <div style="float: left; width: auto;"> <?php echo $pageNums; ?> </div>
                                    <?php } else { ?>
                                    	<div class="alert alert-danger">Sorry! No Results Found.</div>					        		
					        		<?php }	?> 
                                </div>
                            </div>
                        </div>
                    </div>
                    

</div>
</div>
<script type="text/javascript">
    window.onload=function(){    	
        var auto = setTimeout(function(){ autoRefresh(); }, 60000);
        function submitform(){          
          document.getElementById('search1').click();
          //document.getElementById("form_search1").submit();
        }
        function autoRefresh(){
           clearTimeout(auto);
           auto = setTimeout(function(){ submitform(); autoRefresh(); }, 60000);
        }
    }
</script>