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

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

<div id="page-wrapper">

    <div class="container-fluid">

		<br/>

         <div class="row">

             <div class="col-lg-12">
				<div class="panel panel-default dash">
					<div class="panel panel-primary">
						<div class="panel-heading">
							<h2 class="sub-header">
								<i class="fa fa-picture-o" aria-hidden="true"></i> Photos
							</h2>
						</div>
						<!-- /.panel-heading -->
						<div class="panel-body">
							<div class="table-responsive">
							
								<div class="col-md-12">

									 <form id="editPublication" method="post" enctype="multipart/form-data" class="form-horizontal" name="editPublication">
									 	<?php echo editPublication($_GET['id']); 
									 	$id=$_GET['id'];
										 $consulta = mysqli_query($conection,"select * from publication WHERE id='".$id."'");    
										 $row = mysqli_fetch_assoc($consulta);   
										 ?>

										<?php $csrf->echoInputField(); ?>
										
										<fieldset>

											<?php $csrf->echoInputField(); ?> 
                                            <!-- Text input -->
											<div class="form-group">
												<label class="col-md-2 control-label" for="category">Select faculty name  </label>
												<div class='col-md-6'> 
													<select class="form-control input-md" name="authors[]" multiple> 
													<?php  
													  $qry=mysqli_query($conection, "select * from team");
													  while ($res=mysqli_fetch_array($qry)) {  $title=$res['name']; 							
													?>
													  <option value="<?php  echo $title; ?>">  <?php  echo $title; ?> </option> 
													<?php } ?>  
													</select> 
												</div>
											</div>
											 
											<div class="form-group">
												<label class="col-md-2 control-label" for="category"> Year of Publication</label>
												<div class='col-md-6'> 
							 	<input type="text" class="form-control input-md" name="yearpub" id="year" value="<?php echo $row['yearpub']; ?>">   
												</div>
											</div>
											
											<!-- Text input-->
											<div class="form-group">
												<label class="col-md-2 control-label" for="name"> Select </label>
												<div class="col-md-6">
												<?php     
												    $article =  $row['article'];											
												    if( $article == 'bookchapter') 
													   { 
													   	?>
													   	<input type="radio" id="bookchapter" name="article" value="bookchapter" checked> Book Chapter
												<input type="radio" id="reviewarticle" name="article" value="reviewarticle"> Review Article
												<input type="radio" id="originalarticle" name="article" value="originalarticle"> Original Article <?php 
													   } elseif ($article == 'reviewarticle') {  		
													?> 
												<input type="radio" id="bookchapter" name="article" value="bookchapter"> Book Chapter
												<input type="radio" id="reviewarticle" name="article" value="reviewarticle" checked> Review Article
												<input type="radio" id="originalarticle" name="article" value="originalarticle"> Original Article
												<?php } else { ?>
												<input type="radio" id="bookchapter" name="article" value="bookchapter"> Book Chapter
												<input type="radio" id="reviewarticle" name="article" value="reviewarticle" > Review Article
												<input type="radio" id="originalarticle" name="article" value="originalarticle" checked> Original Article 
											   <?php } ?>
												</div>
											</div>
											
																	
											<!-- Text input-->
											<div class="form-group">
												<label class="col-md-2 control-label" for="name"> Select </label>
												<div class="col-md-6">
												<?php  
													   $pub =  $row['pub'];											
													    if( $pub == 'PubMed') 
													   { 
													   	?>
													   	   <input type="radio" id="pubmed" name="pub" value="PubMed" checked> [Pub Med]
												           <input type="radio" id="doi" name="pub" value="DOI"> [DOI] 
												   <?php 
													   } elseif ($pub == 'DOI') {  		
													?>	
												<input type="radio" id="pubmed" name="pub" value="PubMed"> [Pub Med]
												<input type="radio" id="doi" name="pub" value="DOI" checked> [DOI] 
												<?php } else { ?>
												<input type="radio" id="pubmed" name="pub" value="PubMed"> [Pub Med]
												<input type="radio" id="doi" name="pub" value="DOI"> [DOI] 
											    <?php } ?>
												<input id="name" name="publink" type="text" class="form-control input-md" value="<?php echo $row['publink']; ?>">
												</div>
											</div>					
											
								        	<!-- Text input-->
											<div class="form-group">
												<label class="col-md-2 control-label" for="name"> Book Title </label>
												<div class="col-md-6">  
												<textarea rows ='5' cols='10' id='sub_title' name='booktitle' type='text' class='form-control input-md'><?php echo $row['booktitle']; ?></textarea>
												</div>
											</div>	 

											<!-- Button -->
											<div class="form-group">
												<label class="col-md-10 control-label" for="singlebutton"></label>
												<div class="col-md-2">
													<input type="submit" name="editPublication" class="btn btn-primary" value="Save" />
												</div>
											</div>

										</fieldset>
									</form>
									<?php
	
									  if(isset($_POST['editPublication']))
									  {
										updatePublication($_GET['id'],$_POST['authors'],$_POST['yearpub'],$_POST['article'],$_POST['pub'],
											$_POST['publink'],$_POST['booktitle']);
									  }

									?>    
								</div>    
							</div>
						</div>
					</div>
				</div>
			</div>
        </div>
        <!-- /.row -->


    </div>
    <!-- /.container-fluid -->

</div>
<!-- /#page-wrapper -->

</div>
<!-- /#wrapper -->

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