

         <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
        });
		
				
		 $(document).on("click", "#editbtn", function()
        {
          var mycategoryid = $(this).data('id');
		  $("#mycategoryid").val(mycategoryid); 
		     var host = $(this).data('host');
		   $("#host").val(host); 
		     var fromdate = $(this).data('fromdate');
		   $("#fromdate").val(fromdate); 
		     var todate = $(this).data('todate');
		   $("#todate").val(todate); 
		     var comments = $(this).data('comments');
		   $("#comments").val(comments); 
		   
		     var participants = $(this).data('participants');
		   $("#participants").val(participants); 
		     var repeated = $(this).data('repeated');
		   $("#repeated").val(repeated); 
		   
		     var status = $(this).data('status');
		   $("#status").val(status); 
		   
		   
		    var location = $(this).data('location');
		   $("#location").val(location); 
		   
		     var title = $(this).data('title');
		   $("#title").val(title); 
		 
		  
		  
		   
        });
		
		
    </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>
				 <span class="pull-right"> View events</span>
				 

<?php 
			 				echo $this->session->flashdata('deletemsg'); 

		// echo $this->session->flashdata('msg'); 
        $attr = array("class" => "form-horizontal", "role" => "form", "id" => "search", "name" => "search");
        echo form_open("user/searchallmyevents", $attr);?>
	

            <div class="form-group">
			 <div class="col-md-1">
	  <a data-toggle='modal' data-target='#addModal' class="btn btn-primary">Add New Event </a>
                </div>
                <div class="col-md-6">
                    <input class="form-control" id="searchterm" name="searchterm" placeholder="Search for events, by title, name,conatct,host etc.." type="text" value="<?php echo set_value('searchterm'); ?>" />
                </div>
                 <div class="col-md-3">
                    <input id="btn_search" name="btn_search" type="submit" class="btn btn-success" value="Search" />
                    <a href="<?php echo base_url(). "user/viewevents"; ?>" class="btn btn-primary">Refresh</a>
                </div>
				 
            </div>
        <?php echo form_close(); ?>
            	</div>
            </div>
			<div class="panel-body">

			
	<div class="widget-content nopadding table_holder table-responsive" >				
				<?PHP
 echo $this->session->flashdata('deletemsg'); 


				echo $this->session->flashdata('msg'); 
								?>	
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">
	
									
				<table class="tablesorter table table-bordered  table-hover" id="sortable_table">			

             <thead>
         <tr>
     <th>Event Title</th>
     <th>From Date</th>
	  <th>To date</th>
	     <th>Location</th>
<th>Host</th>	
 
		   <th>Partisipants</th>
<th>Repeated?</th> 		   
		   <th>Status</th> 
		
  <th>More</th> 

                 </tr>
             </thead>
<?php

 if(!is_array($viewevents)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='1'>";
    
       echo '<div class="alert alert-warning text-center">There no records found..</div>';
    echo "</td>";
   echo "</tr>";
    }else {
?>
    
             <?php 
  
  	foreach ($viewevents as $c): 

		 

             ?>



             <tr>
                
            <?php 
$id=$c->id;


?>

              
  <td><?php echo $c->title ; ?></td>
  <td><?php echo $c->fromdate ; ?></td>
    <td><?php echo $c->todate ; ?></td>
   <td><?php echo $c->location ; ?></td>
	  <td><?php echo $c->host ; ?></td>
	  <td><?php echo $c->participants ; ?></td>
<td><?php echo $c->repeated ; ?></td>
  <td><?php echo $c->status ; ?></td>
                  <td> 

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


                                                <i class="glyphicon glyphicon-pencil"></i>
																Delete
                                                </a>
                                                        </li>
									
									
                                        <li class="divider"></li>
										
											<?php
										}
										?>
												 
 	 		
 
				  
                                     	  <li> 

	 <a class="btn btn-primary editbtn" id="editbtn"    data-status='<?php echo  $c->status;?>' data-repeated='<?php echo  $c->repeated;?>'  data-comments='<?php echo  $c->comments;?>'data-participants='<?php echo  $c->participants;?>' data-host='<?php echo  $c->host;?>' data-todate='<?php echo  $c->todate;?>' data-fromdate='<?php echo  $c->fromdate;?>' data-location='<?php echo  $c->location;?>' data-title='<?php echo  $c->title;?>'  data-id='<?php echo  $c->id;?>' data-toggle='modal' data-target='#editProductModel'> 	 

                                                <i class="glyphicon glyphicon-pencil"></i>
																Update
                                                </a>
                                                        </li>
                                        
                                        <! teacher DELETION LINK >
                                        
                                    </ul>
										
                                </div>
</td> 
             </tr>

	<?php endforeach;} ?>

        </table>
		<div class="col-md-12 text-center">    <?php echo $links; ?>
					   		<span style="color:red; font-size:20px"><?php  echo $total_rows. "   Events (s) in the system. " ;?>    </span>

        
        </div>
	</div>
	
	
	
	
	
	
	
	

<div id="editProductModel" 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">Update event</h4>
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addevents' , 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;?>

		  		<input type="hidden" name="action" value="update" class="form-control"  placeholder="ction">
	<input type="hidden" name="mycategoryid" value=""id="mycategoryid" class="form-control" required placeholder="Enter mycategoryid">

	<div class="form-group">
    <label for="inputlocation" class="col-sm-2 control-label">	Event Location </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="location" id="location" value="<?php echo set_value('location'); ?>" class="form-control"  placeholder="Enter Event's location">
		 
				
		<span class="text-danger"> <?php echo form_error('location'); ?>
		
		</span>
	</div>
  </div>
	<div class="form-group">
    <label for="inputtitle" class="col-sm-2 control-label">Event title </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="title"  id="title" value="<?php echo set_value('title'); ?>" class="form-control" required placeholder="Enter title">
		 
				
		<span class="text-danger"> <?php echo form_error('title'); ?>
		
		</span>
	</div>
  </div>
  <div class="form-group">
    <label for="inputfromdate" class="col-sm-2 control-label">Start Date </label>
    <div class="col-sm-10">
	
		  		<input type="date" id="fromdate"  name="fromdate" value="<?php echo set_value('fromdate'); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('fromdate'); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group">
    <label for="inputtodate" class="col-sm-2 control-label">	Due Date </label>
    <div class="col-sm-10">
	
		  		<input type="date" id="todate" name="todate" value="<?php echo set_value('todate'); ?>" class="form-control" required placeholder="Enter End date">
		 
				
		<span class="text-danger"> <?php echo form_error('todate'); ?>
		
		</span>
	</div>
  </div>
  
    	<div class="form-group">
    <label for="inputhost" class="col-sm-2 control-label">	Event Host / In charge </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="host" id="host" value="<?php echo set_value('host'); ?>" class="form-control" required placeholder="Enter Your host or Controller">
		 
				
		<span class="text-danger"> <?php echo form_error('host'); ?>
		
		</span>
	</div>
  </div>
     <div class="form-group">
    <label for="inputstatus" class="col-sm-2 control-label">Status?</label>
    <div class="col-sm-10">
	<select class="form-control" name="status"  id="status"required>
		<option value=""  selected="selected" ></option>

	<option value="new"  >new</option>
	<option value="old"  >old</option>
		<option value="attended"  >attended</option>
		<option value="pending"  >pending</option>
		<option value="ongoing"  >ongoing</option>
				<option value="closed"  >closed</option>

		<option value="other">other</option>
</select>
		
						<span class="text-danger"><?php echo form_error('status'); ?>

	</div>
  </div>
   
  
    <div class="form-group">
    <label for="inputrepeated" class="col-sm-2 control-label">Event repeated?	?</label>
    <div class="col-sm-10">
	<select class="form-control" name="repeated" id="repeated" required>
			<option value=""  selected="selected" ></option>

	<option value="Yes"  >Yes</option>
	<option value="No"  >No</option>
</select>
		
						<span class="text-danger"><?php echo form_error('repeated'); ?>

	</div>
  </div>
  
   	<div class="form-group">
    <label for="inputparticipants" class="col-sm-2 control-label">	Participants</label>
    <div class="col-sm-10">

				<textarea name="participants"  id="participants" value="<?php echo set_value('participants'); ?>"  class="form-control"  placeholder="Enter participants"></textarea>
			
		<span class="text-danger"> <?php echo form_error('participants'); ?>
		
		</span>
	</div>
  </div>
  
	<div class="form-group">
    <label for="inputcomments" class="col-sm-2 control-label">	Comments</label>
    <div class="col-sm-10">

				<textarea name="comments" id="comments" value="<?php echo set_value('comments'); ?>"  class="form-control"  placeholder="Enter comments"></textarea>
			
		<span class="text-danger"> <?php echo form_error('comments'); ?>
		
		</span>
	</div>
  </div>
		

	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="event" name="btn_addevent" class="btn btn-primary"> Update Events   </button>

    </div>
  </div>

	
	
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

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



	
	
	
	
	
	
	
	
	
	
<div id="deleteModel" 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('logged_in');
 echo $this->session->flashdata('deletemsg'); 

		
                 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="events">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/viewevents">
 <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 id="addModal" 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">Add new Event</h4>
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addevents' , 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;?>

		  		<input type="hidden" name="action" value="insert" class="form-control"  placeholder="ction">
	<input type="hidden" name="mycategoryid" value="" class="form-control" required placeholder="Enter mycategoryid">

	<div class="form-group">
    <label for="inputlocation" class="col-sm-2 control-label">	Event Location </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="location" value="<?php echo set_value('location'); ?>" class="form-control"  placeholder="Enter Event's location">
		 
				
		<span class="text-danger"> <?php echo form_error('location'); ?>
		
		</span>
	</div>
  </div>
	<div class="form-group">
    <label for="inputtitle" class="col-sm-2 control-label">Event title </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="title" value="<?php echo set_value('title'); ?>" class="form-control" required placeholder="Enter title">
		 
				
		<span class="text-danger"> <?php echo form_error('title'); ?>
		
		</span>
	</div>
  </div>
  <div class="form-group">
    <label for="inputfromdate" class="col-sm-2 control-label">Start Date </label>
    <div class="col-sm-10">
	
		  		<input type="date" name="fromdate" value="<?php echo set_value('fromdate'); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('fromdate'); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group">
    <label for="inputtodate" class="col-sm-2 control-label">	Due Date </label>
    <div class="col-sm-10">
	
		  		<input type="date" name="todate" value="<?php echo set_value('todate'); ?>" class="form-control" required placeholder="Enter End date">
		 
				
		<span class="text-danger"> <?php echo form_error('todate'); ?>
		
		</span>
	</div>
  </div>
  
    	<div class="form-group">
    <label for="inputhost" class="col-sm-2 control-label">	Event Host </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="host" value="<?php echo set_value('host'); ?>" class="form-control" required placeholder="Enter Your host or Controller">
		 
				
		<span class="text-danger"> <?php echo form_error('host'); ?>
		
		</span>
	</div>
  </div>
     <div class="form-group">
    <label for="inputstatus" class="col-sm-2 control-label">Status?</label>
    <div class="col-sm-10">
	<select class="form-control" name="status" required>
	<option value="new"  >new</option>
	<option value="old"  >old</option>
		<option value="attended"  >attended</option>
		<option value="pending"  >pending</option>
		<option value="ongoing"  >ongoing</option>
				<option value="closed"  >closed</option>

		<option value="other">other</option>
</select>
		
						<span class="text-danger"><?php echo form_error('status'); ?>

	</div>
  </div>
   
  
    <div class="form-group">
    <label for="inputrepeated" class="col-sm-2 control-label">Event repeated?	?</label>
    <div class="col-sm-10">
	<select class="form-control" name="repeated" required>
	
	<option value="Yes"  >Yes</option>
	<option value="No"  >No</option>
</select>
		
						<span class="text-danger"><?php echo form_error('repeated'); ?>

	</div>
  </div>
  
   	<div class="form-group">
    <label for="inputparticipants" class="col-sm-2 control-label">	Participants</label>
    <div class="col-sm-10">

				<textarea name="participants" value="<?php echo set_value('participants'); ?>"  class="form-control"  placeholder="Enter participants"></textarea>
			
		<span class="text-danger"> <?php echo form_error('participants'); ?>
		
		</span>
	</div>
  </div>
  
	<div class="form-group">
    <label for="inputcomments" class="col-sm-2 control-label">	Comments</label>
    <div class="col-sm-10">

				<textarea name="comments" value="<?php echo set_value('comments'); ?>"  class="form-control"  placeholder="Enter comments"></textarea>
			
		<span class="text-danger"> <?php echo form_error('comments'); ?>
		
		</span>
	</div>
  </div>
		

	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="event" name="btn_addevent" class="btn btn-primary"> Add Events   </button>

    </div>
  </div>
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

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

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

 
</div>


















