<?php
if(basename($_SERVER['PHP_SELF']) == 'postm.php') 
  $cm=" class='current'";
include'header.php';
include'connection.php';
$cond='LIMIT 20';
$conde='';
$perpagevalue=20;

if(isset($_POST['delete_id']))
		{
			$rowid=$_POST['rowid'];
			$then=mysqli_query($conn, "UPDATE `department` SET `Status`='1' WHERE `Depid`='$rowid' LIMIT 1");
		}
if(isset($_POST['perpage']))
		{
			$perpagevalue=$_POST['perpagevalue'];
			$cond="LIMIT $perpagevalue";
		}
if(isset($_POST['search']))
		{
			$column_name=$_POST['column_name'];
			$searchkeyword=$_POST['searchkeyword'];
		if($searchkeyword)
			$conde="AND (`Depname` LIKE '%$searchkeyword%')";
		elseif($column_name)
			$conde="AND `Depname`='$column_name'";
		else
			$conde='';
		}


$do=mysqli_query($conn, "SELECT *FROM `department` WHERE `Status`='0' $conde ORDER BY `Depid` ASC $cond");
$fo=mysqli_num_rows($do);
?>
<div class="container-fluid main-content">
        <div class="page-title">
          <h1 style='margin-top:-20px; margin-bottom: 5px;'>
         Department List
          </h1>
                 </div>
     
        <div class="row">
  <div class="col-lg-2">
   
   <ul class="list-group">
      
   <li class="list-group-item">
              <a href="postm.php">
                <p>
                <i class="lnr lnr-menu-circle"></i>&nbsp;Post List
                </p>
              </a></li>   
           <li class="list-group-item ">
           <a href="npost.php">
           <p>
           <i class="lnr lnr-plus-circle"></i>&nbsp;Create New
           </p></a>
           </li>

	   <li class="list-group-item active">
              <a href="depam.php">
                <p>
                <i class="lnr lnr-menu-circle"></i>&nbsp;Department
                </p>
              </a></li>   
           <li class="list-group-item ">
           <a href="ndepa.php">
           <p>
           <i class="lnr lnr-plus-circle"></i>&nbsp;Create New
           </p></a>
           </li>
                         
            </ul>
  </div>
                    
           
           
       
        <div class="col-lg-10">
                  <div class="row">
           <div class="col-lg-6 "> 
           <form action="" method="POST" class="form-horizontal ">
        <input name="searchkeyword" value="" type="hidden">
        <input name="column_name" value="" type="hidden">
    
            <div class="col-lg-4 "> 
           <select name="perpagevalue" class="form-control">
                              <option selected="selected" value="20">20 per page</option>
                              <option value="50">50 per page</option>
                              <option value="100">100 per page</option>
                              <option value="200">200 per page</option>
                              <option value="1000">1000 per page</option>
                            
               </select>
          
         </div>    
          
                    <div class="col-lg-2 "> 
      
                 <button class="btn  btn-primary  btn-block" type="submit" name="perpage"><i class="lnr lnr-chevron-right-circle"></i>Show</button>
          </div> 
    
        </form>
           
           
              </div>
          
          
           <div class="col-lg-6 ">
           

        <form action="" method="post" class="form-horizontal ">
                  
                       <div class="col-lg-6"> 
                        <select name="column_name" class="form-control">
                <option selected="selected" value="">-------All-------</option>
				<?php
				$de=mysqli_query($conn, "SELECT *FROM `position` WHERE `Status` = '0' GROUP BY `Postname` ORDER BY `Postname` ASC");
			  while($re=mysqli_fetch_assoc($de)){
					$ne=$re['Number'];
					$dep=$re['Postname'];
					$tit=$re['Owner'];
			echo"<option value='$dep' $sed title='$tit'>$dep</option>";
			  }
			  ?>
</select>
                        </div> 
                       
                       <div class="col-lg-6 input-group">
                       
                      <input class="form-control" name="searchkeyword" placeholder="search" type="text">
                      <span class="input-group-btn">
                        <button class="btn  btn-primary" type="submit" name="search"><i class="lnr lnr-magnifier"></i> Search</button>
                      </span>
                      
                      
                      </div>
                  
            </form> 
            </div>
             
               
            </div>
             <div class="row">
            <div class="col-lg-12">
             <span>Total Records Found : <b><?php echo" $fo / $perpagevalue " ?></b></span>
            <div class="widget-container fluid-height clearfix">
            <div class="widget-content padded clearfix">
               
                                 <table class="table table-striped">     
                                      <thead>
                    <tr role="row">
                     <th class="hidden-xs"> S.NO</th>
					  <th class="hidden-xs"> CODE</th>
                       <th> Department&nbsp;Name</th> 
						 <th class="hidden-xs"> Starting&nbsp;Date </th>
                        <th> Created&nbsp;By </th>
                        <th class="hidden-xs"> Created&nbsp;On </th>
                        <th colspan='2' style="width: 80px;text-align:center;">Actions</th>
                     </tr>
                    </thead>
                                        <tbody>
					<?php
					$n=1;
						while($ro=mysqli_fetch_assoc($do)){
$code=$ro['Depid'];
$pna=$ro['Depname'];
$done=$ro['Done'];
$stat=$ro['Starting'];
$dte=$ro['Date'];


/*
if($file1)
	$dfile="<a href='down_contra.php?link=$file1'>Download&nbsp;File</a>";
else
	$dfile="";
*/
           
		print("<tr>
                        <td class=hidden-xs>$n</td>
                        <td class=hidden-xs>$code</td>
                        <td class=hidden-xs> $pna </td>
                        <td class=hidden-xs> $stat </td>
                        <td> $done </td>
                        <td> $dte </td>

                     <form method=post action='depam.php'><td align='right' style='width:40px;padding:0px;'>
                        <input type='hidden' name='rowid' value='$code'>
                           <button style='background-color:transparent;border:0px solid black; width:40px; margin:0px;' type='submit' name='edit_id'>
						   <span style=color:blue;>Edit</span></button></td></form>
						   
						   <form method=post action='depam.php'><td align='right' style='width:40px; padding:0px;'>
                              <input type='hidden' name='rowid' value='$code'>
                          <button style='background-color:transparent;border:0px solid black; width:50px; margin:0px;' type='submit' name='delete_id'>
						  <span style=color:red;>Delete</span></button>
                                                    <input name=id value=29 type=hidden>
                          </td></form></tr>");
						  $n++;
						}
						?>
						
                    </tbody>   
                  </table>
                    <div class="row">
                  <div class="col-lg-12">
                  <div class="pull-right">
                  <ul class="pagination">
				   <li>
                                 <a class="icon" href="#">
           <i class="lnr lnr-chevron-left"></i></a>
                                            </li>
                      <li>
                                            </li>
                      <li class="active">
                        <a href="#">
                        1                        </a>
                      </li>
                            <li>
                                              <a class="icon" href="#">
                        <i class="lnr lnr-chevron-right"></i></a>
                                           </li>
                    </ul>
              </div></div></div>                     
                
              </div>
            </div></div>
                  </div>

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