<?php

error_reporting(0);
	define('INCLUDE_CHECK',true);
	session_start();
	require ('classes/config.php');
	require_once('classes/session.php');

if(isset($_POST['submit'])){
		         $author=$_POST['author'];
				$title = $_POST['title'];
				$year = $_POST['year'];
				$name=$_POST['name'];
				$location=$_POST['location'];
				$dateofconference=$_POST['dateofconference'];
				$page=$_POST['page'];
				//$downloadable = $_POST['downloadable'];
				$fileid = 'OSCO' . ($_SESSION['staffno']).'_' . ($title);
				
					define ("filesplace","./journal/");

					 if (is_uploaded_file($_FILES['file']['tmp_name'])) {
					
					 if ($_FILES['file']['type'] == "application/pdf") {
						$name = $fileid;
						$u_ext = 'pdf';
					 	$result1 = move_uploaded_file($_FILES['file']['tmp_name'], filesplace."/$name.$u_ext");
					 echo "<p>Class notes must be uploaded in PDF format.</p>";
					 
					 if ($result1 == 1) echo "<p>Upload done .</p>";
					 else echo "<p>Sorry, Error happened while uploading . </p>";
					} #endIF
					 } #endIF		
					
				$filedoc = filesplace."$name.$u_ext";			 
				$query = ("INSERT INTO staff_seminar (author,year,title,name,location,dateofconference,page,staff_id,date) 
										VALUES('$author','$year','$title','$name','$location','$dateofconference','$page','{$_SESSION['id']}',NOW())");
							$res = $conn->query($query);		
			}
	
?>       
        
        <div id="page-wrapper" >
            <div id="page-inner">

                    <!-- /. ROW  -->
            



 <div class="row">
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                           Seminar and Conference
                        </div>
                        <div class="panel-body">
                            <div class="panel-group" id="accordion">
                                <div class="panel panel-primary">
                                    <div class="panel-heading">
                                        <h4 class="panel-title">
                                            <a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" class="collapsed">Seminar and Conference</a>
                                        </h4>
                                    </div>
                                    <div id="collapseTwo" class="panel-collapse collapse" style="height: 0px;">
                                        <div class="panel-body">
                                            <form action="" method="post" enctype="multipart/form-data">
                                    	<!--	<div class="form-group">
                                              <label for="title">Title/Heading/Topic</label>
                                              <input type="text" class="form-control" name="title" placeholder="Title/Heading/Topic">
                                            </div> -->
                                            
                                            <div class="form-group">
                                              <label for="author">Author(s)</label>
                                              <input type="text" class="form-control" name="author" placeholder="Author">
                                            </div> 
                                            
                                            <div class="form-group">
                                              <label for="year">Year(s) of Publication</label>
                                              <input type="text" class="form-control" name="year" placeholder="Year(s) f Publication">
                                            </div> 
                                            
                                             <div class="form-group">
                                              <label for="title">Title of the Paper</label>
                                              <input type="text" class="form-control" name="title" placeholder="Title of the paper">
                                            </div> 
                                            
                                              <div class="form-group">
                                              <label for="name">Name of Conference/Seminar</label>
                                              <input type="text" class="form-control" name="name" placeholder="Name of Conference/Seminar">
                                            </div>
                                            
                                             <div class="form-group">
                                              <label for="location">Location</label>
                                              <input type="text" class="form-control" name="location" placeholder="Location">
                                            </div>
                                            
                                             <div class="form-group">
                                              <label for="dateofconference">Date of Conference/Seminar</label>
                                              <input type="text" class="form-control" name="dateofconference" placeholder="Date of Conference / Seminar">
                                            </div>
                                            
                                            
                                             <div class="form-group">
                                              <label for="page">Pages</label>
                                              <input type="text" class="form-control" name="page" placeholder="Pages">
                                            </div>
                                            
                                          <!--  <div class="form-group">
                                                <label for="downloadable">Downloadable</label>
                                                <select class="form-control"  name="downloadable" data-placeholder="Downloadable: Yes/No">
                                                    <option value="" >-- Downloadable: Yes/No --</option> 
                                                    <option value="Yes">Yes</option>
                                                    <option value="No">No</option>
                                                </select>
                                            </div>                                             <div class="form-group">
                      								<label for="file" >Upload File <span style="color:#F00; font-size:11px;">only PDF</span></label>
                        							<input type="file" name="file" class="form-control" id="file" required>
                      							</div>-->
                    						
                                            
                                            
                                      
                                            
                                            
                                            
                                            <button type="submit" class="btn btn-primary" name="submit">Add</button>
                                            <button type="submit" class="btn btn-default">Reset</button>
                                    </form>
                                    <p>&nbsp;</p>
                                    
                                                               
                                    
                                    
                                    
                                    
                                    <div class="panel-body">
                                        <div class="form-group">
                                             <h4>List of Seminars and Conference</h4>
                                             <table class="table table-striped table-bordered">
                                                <tr>
                                                	<th>S/N</th>
                                                    <th>Author</th>
                                                    <th>Year</th>
                                                    <th>Title of the Paper</th>
                                                     <th>Name of Conference / Seminar</th>
                                                     <th>Location</th>
                                                     <th>Date of Conference/Seminar</th>
                                                     <th>Pages</th>
                                                  <!-- <th>Download</th> -->
                                                    <th>OPTION</th>
                                                </tr>
									<?php
            
                                        $key="";
                                        if(isset($_POST['searchtxt']))
                                            $key=$_POST['searchtxt'];
                                        
                                        if($key !="")
                                            $sqlf=("SElECT * FROM staff_seminar WHERE staff_id='{$_SESSION['id']}'");
                                        else
                                            $sqlf=("SElECT * FROM staff_seminar WHERE staff_id='{$_SESSION['id']}'");
                                        	$res = $conn->query($sqlf);
                                            
                                           
                                        $i=0;
                                      //  while($row=mysql_fetch_array($sqlf)){
                                      while($row = $res->fetch_assoc()) {
                                        $i++;
                                        $color=($i%2==0)?"lightblue":"white";
                                    ?>
                                                <tr>
                                                    <td><?php echo $i;?></td>
                                                    <td><?php echo $row['author'];?></td>
                                                    <td><?php echo $row['title'];?></td>
                                                    <td><?php echo $row['year'];?></td>
                                                    <td><?php echo $row['name'];?></td>
                                                    <td><?php echo $row['location'];?></td>
                                                    <td><?php echo $row['dateofconference'];?></td>
                                                    <td><?php echo $row['page'];?></td>
                                                    <td><a href="#">Edit</a> | <a href="#">Delete</a></td>
                                                </tr>
                                          <?php }?>
                                             </table>

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


                 <hr />
               
    </div>
             <!-- /. PAGE INNER  -->
            </div>
         <!-- /. PAGE WRAPPER  -->
        </div>
     <!-- /. WRAPPER  -->
