<? include ("../settings.php"); ?>
<? include ("session.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Abstract Details</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script>
        function frmsubmit(){
            $.ajax({
                type:"POST",
                url:"abstract_edit_ajax.php",
                data:$("#abstract").serialize(),//only input
                success: function(response){
                    if (response != "1"){
                        alert(response);
                    }else{
                        alert("Changes saved.");
                        $('#myModal').modal('hide');
                    }
                }
            });
        }
        
        function deleteabstract(){
            var ans = confirm("Are you sure you want to delete?");
            if (ans == true) {
                $.ajax({
                    type:"POST",
                    url:"abstract_delete_ajax.php",
                    data:$("#abstract").serialize(),//only input
                    success: function(response){
                        if (response != "1"){
                            alert(response);
                        }else{
                            alert("Abstract Deleted.");
                            $('#myModal').modal('hide');
                        }
                    }
                });
            }
        }
    </script>
   </head>
<body>
<div class="well">
<div class="content" bgcolor="#FFFFD0">
<div class="col-12 feature">
<div class="panelCheck">
    <div class="panel-heading">
        <h3 class "panel-title"><strong>Abstract Submission</strong></h3>
    </div>

    <form name="abstract" id="abstract" method='POST' action="" enctype="multipart/form-data" class="form-horizontal" role="form">
    <center>
       
<?
    $bind = array(
        ":search1" => $_REQUEST['abstract_id']
    );
    $results = $db->select("tbl_abstract as a, tbl_abstract_status as b, tbl_topic as c", "a.abstract_id = :search1 AND a.abstract_status=b.status_id AND a.topic_id=c.topic_id", $bind);
    $result = $results[0];
    if ($_SESSION['user_admin']!=1)
    	$disabled = "disabled";
    else
    	$disabled = "";
    //<input type='text' class='form-control' id='datevisit' name='datevisit' value="=date("d-m-Y",strtotime ($row['datevisit']));">
?>        
<div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title">Author's Particulars</h3>
      </div>
      <div class="panel-body">
		<div class='form-group'>
            <label for='registrant_salutation' class='col-lg-4 control-label'>Salutation</label>
            <div class='col-lg-4 text-left'>
                <input type="text" <?=$disabled;?> name="registrant_salutation" id="registrant_salutation" value="<?=$result['registrant_salutation'];?>" class="form-control">
            </div>
        </div>
        <div class='form-group'>
            <label for='registrant_lastname' class='col-lg-4 control-label'>Last Name</label>
            <div class='col-lg-4 text-left'>
                <input type="text" <?=$disabled;?> name="registrant_lastname" id="registrant_lastname" value="<?=$result['registrant_lastname'];?>" class="form-control">
            </div>
        </div>
        <div class='form-group'>
            <label for='registrant_firstname' class='col-lg-4 control-label'>First Name</label>
            <div class='col-lg-4 text-left'>
                <input type="text" <?=$disabled;?> name="registrant_firstname" id="registrant_firstname" value="<?=$result['registrant_firstname'];?>" class="form-control">
            </div>
        </div>
        <div class='form-group'>
            <label for='registrant_organisation' class='col-lg-4 control-label'>Organisation</label>
            <div class='col-lg-4 text-left'>
                <input type="text" <?=$disabled;?> name="registrant_organisation" id="registrant_organisation" value="<?=$result['registrant_organisation'];?>" class="form-control">
            </div>
        </div>
		<div class='form-group'>
            <label for='registrant_designation' class='col-lg-4 control-label'>Designation</label>
            <div class='col-lg-4 text-left'>
                <input type="text" <?=$disabled;?> name="registrant_designation" id="registrant_designation" value="<?=$result['registrant_designation'];?>" class="form-control">
            </div>
        </div>
        <div class='form-group'>
            <label for='registrant_email' class='col-lg-4 control-label'>Email</label>
            <div class='col-lg-4 text-left'>
                <input type="text" <?=$disabled;?> name="registrant_email" id="registrant_email" value="<?=$result['registrant_email'];?>" class="form-control">
            </div>
        </div>
        <div class='form-group'>
            <label for='registrant_mailing1' class='col-lg-4 control-label'>Mailing 1</label>
            <div class='col-lg-4 text-left'>
                <input type="text" <?=$disabled;?> name="registrant_mailing1" id="registrant_mailing1" value="<?=$result['registrant_mailing1'];?>" class="form-control">
            </div>
        </div>
		<div class='form-group'>
            <label for='registrant_mailing2' class='col-lg-4 control-label'>Mailing 2</label>
            <div class='col-lg-4 text-left'>
                <input type="text" <?=$disabled;?> name="registrant_mailing2" id="registrant_mailing2" value="<?=$result['registrant_mailing2'];?>" class="form-control">
            </div>
        </div>
		<div class='form-group'>
            <label for='registrant_city' class='col-lg-4 control-label'>City</label>
            <div class='col-lg-4 text-left'>
                <input type="text" <?=$disabled;?> name="registrant_city" id="registrant_city" value="<?=$result['registrant_city'];?>" class="form-control">
            </div>
        </div>
		<div class='form-group'>
            <label for='registrant_state' class='col-lg-4 control-label'>State</label>
            <div class='col-lg-4 text-left'>
                <input type="text" <?=$disabled;?> name="registrant_state" id="registrant_state" value="<?=$result['registrant_state'];?>" class="form-control">
            </div>
        </div>
        <div class='form-group'>
            <label for='registrant_postal' class='col-lg-4 control-label'>Postal</label>
            <div class='col-lg-4 text-left'>
                <input type="text" <?=$disabled;?> name="registrant_postal" id="registrant_postal" value="<?=$result['registrant_postal'];?>" class="form-control">
            </div>
        </div>
		
        <div class='form-group'>
            <label for='registrant_city' class='col-lg-4 control-label'>City</label>
            <div class='col-lg-4 text-left'>
                <input type="text"  <?=$disabled;?> name="registrant_city" id="registrant_city" value="<?=$result['registrant_city'];?>" class="form-control">
            </div>
        </div>

        <div class='form-group'>
            <label for='registrant_country' class='col-lg-4 control-label'>Country</label>
            <div class='col-lg-4 text-left'>
                <select name="registrant_country" id="registrant_country" <?=$disabled;?> class='form-control'>
            	<?
            		$options = $db->select("tbl_country");
            		foreach($options as $option){
            			if ($result['registrant_country']==$option['country_name'])
            				echo "<option value='".$option['country_name']."' selected>".$option['country_name']."</option>";
            			else
            				echo "<option value='".$option['country_name']."'>".$option['country_name']."</option>";
            		}
            	?>
            	</select>
            </div>
        </div>

        <div class='form-group'>
            <label for='registrant_officecc' class='col-lg-4 control-label'>Office CC</label>
            <div class='col-lg-4 text-left'>
            	<input type="text" name="registrant_officecc" id="registrant_officecc" value="<?=$result['registrant_officecc'];?>" <?=$disabled;?> class='form-control'>
            </div>
        </div>
		<div class='form-group'>
            <label for='registrant_office' class='col-lg-4 control-label'>Office</label>
            <div class='col-lg-4 text-left'>
            	<input type="text" name="registrant_office" id="registrant_office" value="<?=$result['registrant_office'];?>" <?=$disabled;?> class='form-control'>
            </div>
        </div>
        <div class='form-group'>
            <label for='registrant_mobilecc' class='col-lg-4 control-label'>Mobile CC</label>
            <div class='col-lg-4 text-left'>
            	<input type="text" name="registrant_mobilecc" id="registrant_mobilecc" value="<?=$result['registrant_mobilecc'];?>" <?=$disabled;?> class='form-control'>
            </div>
        </div>  
        <div class='form-group'>
            <label for='registrant_mobile' class='col-lg-4 control-label'>Mobile</label>
            <div class='col-lg-4 text-left'>
            	<input type="text" name="registrant_mobile" id="registrant_mobile" value="<?=$result['registrant_mobile'];?>" <?=$disabled;?> class='form-control'>
            </div>
        </div> 
    </div>       
    
 
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title">Abstract Details</h3>
      </div>
      <div class="panel-body">
        <div class='form-group'>
            <label for='parent_name' class='col-lg-4 control-label'>Abstract Number</label>
            <div class='col-lg-4 text-left'>
               <?=$result['abstract_number'];?>
            </div>
        </div>   

        <div class='form-group'>
            <label for='abstract_title' class='col-lg-4 control-label'>Abstract Title</label>
            <div class='col-lg-4 text-left'>
            	<input type="text" <?=$disabled;?> name="abstract_title" id="abstract_title" value="<?=$result['abstract_title'];?>" class="form-control">
            </div>
        </div>   
 
        <div class='form-group'>
            <label for='parent_name' class='col-lg-4 control-label'>Abstract Category</label>
            <div class='col-lg-4 text-left'>
               <?=$result['topic'];?>
            </div>
        </div>   

        <div class='form-group'>
            <label for='parent_name' class='col-lg-4 control-label'>Abstract Submission Date/Time</label>
            <div class='col-lg-4 text-left'>
               <?=date("d-m-Y H:i",strtotime ($result['abstract_datetime']));?>
            </div>
        </div>   
        <div class='form-group'>
            <label for='parent_name' class='col-lg-4 control-label'>Student Competition</label>
            <div class='col-lg-4 text-left'>
               <?=$result['registrant_studentcom'];?>
            </div>
        </div>   
        <div class='form-group'>
            <label for='parent_name' class='col-lg-4 control-label'>Abstract Download</label>
            <div class='col-lg-4 text-left'>
               <a href="../abstract_documents/<?=$result['abstract_path'];?>">Click to download</a><br/>
			   <?
					if ($result['abstract_revision'])
						echo "<a href='../abstract_documents/".$result['abstract_revision_path']."'>Click to download revision abstract</a><br/>";
					if ($result['abstract_full'])
						echo "<a href='../abstract_documents/".$result['abstract_full_path']."'>Click to download full paper</a><br/>";
			   ?>
            </div>
        </div>            
    </div>       
    <?
        if ($result['abstract_submit_by']=="SPEAKER"){
        
    ?>
            <div class="panel panel-default">
              <div class="panel-heading">
                <h3 class="panel-title">Speaker Details</h3>
              </div>
              <div class="panel-body">

                 <div class='form-group'>
                    <label for='optional_name' class='col-lg-4 control-label'>Bio Data</label>
                    <div class='col-lg-4 text-left'>
                        <?=$result['biodata'];?>
                    </div>
                </div>   

                <div class='form-group'>
                    <label for='optional_contact' class='col-lg-4 control-label'>Bio Picture</label>
                    <div class='col-lg-4 text-left'>
                        <img src="../abstract_biodatapic/<?=$result['biopicpath'];?>" width="200">
                    </div>
                </div>   

                <div class='form-group'>
                    <label for='abstract_mode' class='col-lg-4 control-label'>Abstract Mode</label>
                    <div class='col-lg-4 text-left'>
                        <select class='form-control' id='abstract_mode' name='abstract_mode' <?=$disabled;?>>
                            <?
                                $options = array("Invited","Plenary","Keynote");
                                foreach ($options as $option){
                                    if ($result['abstract_mode']==$option)
                                        echo "<option value='$option' selected>$option</option>";
                                    else
                                        echo "<option value='$option'>$option</option>";
                                }
                            ?>
                        </select>
                    </div>
                </div> 
                  
                  
              </div>
            </div>       
    <?
        }
    ?>
        
     <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title">OFFICIAL USE</h3>
      </div>
      <div class="panel-body">
          
        <div class='form-group'>
            <label for='abstract_status_id' class='col-lg-4 control-label'>Abstract Status</label>
            <div class='col-lg-4'>
                <select class='form-control' id='abstract_status_id' name='abstract_status_id' <?=$disabled;?>>
                 <?
                    $output = "";
                    $statuses = $db->select("tbl_abstract_status");
                    foreach ($statuses as $status){
                        if ($status['status_id']==$result['abstract_status'])
                            echo "<option value='".$status['status_id']."' selected>".$status['status_name']."</option>";
                        else
                            echo "<option value='".$status['status_id']."'>".$status['status_name']."</option>";
                    }
                    echo $output;
                ?>            
                </select>
            </div>
        </div>
		<?
			if ($_SESSION['user_admin']==1){
				$bind = array(
					":search1" => $_REQUEST['abstract_id']
				);
				$remarks = $db->select("tbl_abstract_remarks","abstract_id = :search1",$bind);
				$comments = "Reviewer 1 :".$remarks[0]['remarks'];
				$comments .= "\nReviewer 2 :".$remarks[1]['remarks'];
			}else{
				$bind = array(
					":search1" => $_REQUEST['abstract_id'],
					":search2" => $_SESSION['user_id']
				);
				$remarks = $db->select("tbl_abstract_remarks","abstract_id = :search1 AND user_id = :search2",$bind);
				$comments = $remarks[0]['remarks'];
			}
		?>
        <div class='form-group'>
            <label for='house_id' class='col-lg-4 control-label'>Abstract Comments</label><br/>
            <div class='col-lg-4'>
                <textarea class='form-control' name='abstract_comments' id='abstract_comments'><?=$comments;?></textarea>
            </div>
        </div>          
          
        <?
            
                echo "<div class='form-group'>";
                echo "<label for='house_id' class='col-lg-4 control-label'>Abstract Submission</label>";
                echo "<div class='col-lg-4'>";
                echo "<select class='form-control' id='abstract_op' name='abstract_op'  $disabled>";
                if ($result['abstract_op']=="OR")
                    echo "<option value='OR' selected>Oral</option>";
                else
                    echo "<option value='OR'>Oral</option>";
                
                if ($result['abstract_op']=="P")
                    echo "<option value='P' selected>Poster</option>";
                else
                    echo "<option value='P'>Poster</option>";
                echo "</select></div></div>";
                
                echo "<div class='form-group'>";
                echo "<label for='catid' class='col-lg-4 control-label'>Abstract Category</label>";
                echo "<div class='col-lg-4'>";
                echo "<select class='form-control' id='topic_id' name='topic_id' $disabled>";
                
                $cats = $db->select("tbl_topic");
                foreach ($cats as $cat){
                    if ($cat['topic_id']==$result['topic_id'])
                        echo "<option value='".$cat['topic_id']."' selected>".$cat['topic']."</option>";
                    else
                        echo "<option value='".$cat['topic_id']."'>".$cat['topic']."</option>";
                }
                echo "</select></div></div>";      
                
                echo "<div class='form-group'>";
                echo "<label for='abstract_mode' class='col-lg-4 control-label'>Abstract Mode</label>";
                echo "<div class='col-lg-4'>";
                echo "<select class='form-control' id='abstract_mode' name='abstract_mode'  $disabled>";
                
                
                $abstract_type = array("NORMAL","SPEAKERS","INVITED");
                foreach ($abstract_type as $type){
                    if ($type==$result['abstract_mode'])
                        echo "<option value='".$type."' selected>".$type."</option>";
                    else
                        echo "<option value='".$type."'>".$type."</option>";
                }
                echo "</select></div></div>";                      
                
            
        ?>
           
    </div>
     </div>       
    <input type="hidden" name="abstract_id" value="<?php echo $_REQUEST['abstract_id']; ?>">
        <?
        if ($_SESSION['user_admin']=="1"){ 
            echo "<input type='button' class='btn btn-danger' name='remove' value='Delete Abstract' onclick='deleteabstract();'><br/><br/>";
        }
        ?>
    <input type="button" name="confirm" value="Update" class="btn btn-default" onclick="frmsubmit();">
    <input type="button" value="Close" class="btn btn-default" onclick="$('#myModal').modal('hide')">
    <br><br>        
        
    </center>
    <span>
    </span>
    </form>
</div>
</div>
</div>
</div>
</body>
</html>
    
    

<?

	function cleandata(&$inputarray){
		foreach ($inputarray as $key => $value) {
			if (!is_array($inputarray[$key]))
				$inputarray[$key]=htmlentities($value,ENT_QUOTES);
		}
	}

?>