 
         <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
        });
			</script>



 <div class="row">
  
   	<div class="col-md-12">
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
			Add new post
			 <a href="<?php echo base_url();?>user/viewleaves" class="btn btn-info">  Go back</a>	

													</span>

				
</span>
            	</div>
            </div>
			<div class="panel-body">

			
										
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">
					
	
				<?PHP
								
 echo $this->session->flashdata('msg'); 
 			$session_data = $this->session->userdata('logged_in');

   
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];

 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	  echo $this->session->flashdata('deletemsg'); 
				
					
$mydate=date("d-m-Y h:m a");
$transactioncode = rand(100, 9900).time();
$imgid = rand(100, 990000).time();
				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addnewpost' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
					
				    <div class="form-group">
    <label for="inputname" class="col-sm-2 control-label"> Post Name:   </label>
    <div class="col-sm-10">
		
				<input type="text" name="name" value="<?php echo set_value('name') ;?>" id="name" class="form-control" required  placeholder="Please provide  post name ">

				
		</span>
	</div>
  </div>
		
  
  
		
  	
					
					
					
  
  <div class="form-group">
    <label for="inputdescription" class="col-sm-2 control-label">Post Description</label>
    <div class="col-sm-10">

	<textarea name="description" class="form-control" placeholder="Post Descriptionhere"><?php echo set_value('description'); ?></textarea> 
			<span class="text-danger"> Description<?php echo form_error('description'); ?>
		
		</span>
	</div>
  </div>
  
  
  
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  name="btn_addpost"  value="post"  class="btn btn-primary"> Add New Post </button>

    </div>
  </div>
			</div>							   
									<?php echo form_close();?>
								
							</div>
						</div>
						
						
						
						
						
						
  <table cellpadding="0" cellspacing="0" border="0" class="table  table-striped" id="example" style="border-color:#CCCCCC; width:100%;"  >
<thead>
 
  <tr>
   <th>No#</th>

   

    <th>Post Name</th>    
    <th>Total Leaves</th>   
    <th> Description</th>    

    <th>Date</th>    
    <th>More</th>    

  </tr>
</thead>

<?php 
		 
$Posts = $this->usermodel->populatealldata('post','id','ASC');

if(is_array($Posts)) {

   foreach($Posts as $row){

  echo "<tr>";

     echo "<td>". $row->id ."</td>";

   

    echo "<td>". $row->name ."</td>";
  echo "<td>". $row->total ."</td>";
    echo "<td>". $row->description ."</td>";
    echo "<td>". $row->createdat ."</td>";

?>


 <td> 

 
 
					<div class="btn-group">
                                    <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown">
                                        More <span class="caret"></span>
                                    </button>
									<?php
										if($usertype=="admin"){
											
											?>
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
                                        
                                        <!-- teacher EDITING LINK -->
                                      
										
											  <li> 
										 <a class="btn btn-danger managebtn" id="managebtndelete"		 data-id='<?php echo  $row->id;?>'    data-toggle='modal' data-target='#myModal2<?php  $row->id; ?>'>	 


                                                <i class="glyphicon glyphicon-pencil"></i>
																Delete
                                                </a>
                                                        </li>
									
								
                                        
                                    </ul>
											<?php
										}
										?>
                                </div>
</td>
		 
		 
			</tr>
 <?php

}} else {
    echo 'There is no any Leave data available.... try again.';
}






?>



</table>
		
						
						
						
						
						
						
						
						
						
						
						
						
					</div>

								
			
					<div id="myModal2" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Delete</h4>
      </div>
      <div class="modal-body">
        <h3>Are you sure you want to delete this item? </h3>
      </div>
      <div class="modal-footer">
	  	

     
		<?PHP
				$session_data = $this->session->userdata('adminlogged_in');

		
                 echo form_open('user/deletebyid' , array('class' => 'form-horizontal ', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
 <input type="hidden" id="table"name="table" class="table" placeholder="view" value="post">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/addpost">
 <input type="hidden" id="itemid1"name="itemid" class="itemid" placeholder="itemid" value=""><br>
 <button type="button" class="btn btn-success" data-dismiss="modal">No</button>
 		  	         <button type="submit" name="btn_delete" value="deletebyid" class="btn btn-danger"> Delete  </button>

	<?php echo form_close();?>
      </div>
    </div>

  </div>

  </div>
			
			
			
			
			
		
		</div>
  
  </div>

</div>
















