<?php include("links/top.php");
$action=$_GET['action'];
?>
<?php
if($action=='delete'){
$id=$_GET['id'];

$del="delete from abstract_traking where id='$id'";
$DB->executeQuery($del);

header('Location:abstract_traking.php?action=list');
}
?>
	<?php
	if($action=='addnew' || $action== 'edit'){
	if($action=='edit'){
	$id=$_GET['id'];
	}
	if(isset($_POST['submit']) || isset($_POST['update'])){

	extract($_POST);
	
	$vlc  =  new validator();	  



	    $pattern = "/^([a-zA-Z0-9._-]+)$/";	



		$regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/';



		 $no = "/^[0-9]+$/";	  



		
		if ($aid!='') {



		 $co= "select * from abstract_traking where aid='$aid'";



						   $cou=executeQuery($co);



						   $count=totalRecords($cou);



	     			 if($count>=1){ $errormessage[2]="AbstractId Already Exists"; }



		}

if(!isset($errormessage)){

	if($action=='addnew'){
		$arr=array('aid' => mysql_real_escape_string($aid),'name' => mysql_real_escape_string($name),'email' => mysql_real_escape_string($email),'phone'	=> mysql_real_escape_string($phone),'country'	=> mysql_real_escape_string($country),'university' => mysql_real_escape_string($university),'title' => mysql_real_escape_string($title),'category' => mysql_real_escape_string($category),'status' => mysql_real_escape_string($status),'message' => mysql_real_escape_string($message),'link' => mysql_real_escape_string($link));
		$DB->insert('abstract_traking',$arr);
		$id=getRecordId();
	}
	}
	if($action=='edit'){
		$arr=array('aid' => mysql_real_escape_string($aid),'name' => mysql_real_escape_string($name),'email' => mysql_real_escape_string($email),'phone'	=> mysql_real_escape_string($phone),'country'	=> mysql_real_escape_string($country),'university' => mysql_real_escape_string($university),'title' => mysql_real_escape_string($title),'category' => mysql_real_escape_string($category),'status' => mysql_real_escape_string($status),'message' => mysql_real_escape_string($message),'link' => mysql_real_escape_string($link));
		$DB->update('abstract_traking',$arr,"id='$id'");
	}
	if($_FILES['file']['name']!='')

		{

		//$code=time();

		$filepath="uploads/images/";

		$extension = strtolower(strrchr($_FILES['file']['name'], '.'));

		if($extension=='.jpg' || $extension=='.jpeg' || $extension=='.png' || $extension=='.gif' || $extension=='.JPG' || $extension=='.JPEG' || $extension=='.PNG' || $extension=='.GIF' || $extension=='.bmp' || $extension=='.BMP'){

		$image = $filepath.$_FILES['file']['name'];

		move_uploaded_file($_FILES['file']['tmp_name'],'../'.$image);

		$arr=array( 'image' 	=> $image);

		$DB->update('abstract_traking',$arr,"id='$id'");

		}}
		
		if($_FILES['file1']['name']!='')
		{
		//$code=time();
		$filepath="uploads/images/";			
		$extension = strtolower(strrchr($_FILES['file1']['name'], '.'));	
		if($extension=='.pdf' || $extension=='.docx' || $extension=='.doc'){		
		$pdf = $filepath.$_FILES['file1']['name'].$extension;	
		move_uploaded_file($_FILES['file1']['tmp_name'],'../'.$pdf);        
		$arr=array( 'pdf' 	=> $pdf);
		$DB->update('abstract_traking',$arr,"id='$id'");
		}}
header('Location: abstract_traking.php?action=list');
	}
	}
	
	?>
		<div id="content">
			<div class="container">
				<div class="page-header">
					<div class="page-title">
						<h3>Abstract Traking Management</h3>
					</div>
				</div>
				<div class="row">

					<div class="col-md-12">
                     <?php if($action=='list'){?> <a href="abstract_traking.php?action=addnew"><button class="btn btn-sm btn-info">Add Abstract Traking</button></a> <?php } ?>
						<div class="widget box">
                        <div class="widget-header">
                           <?php if($action=='list'){?>
                            <h4>Abstract Traking List</h4>
                            <?php }else if($action=='addnew'){ ?>
                            <h4>Add Abstract Traking</h4>
                            <?php }?>
							</div>
                        <div class="widget-content">
                             <?php if($action=='list'){
								 $sno=1;
								$sel=mysql_query("select * from abstract_traking");
								?>

								<table class="table table-striped table-bordered table-hover table-checkable datatable">
									<thead>
										<tr>
											<!-- <th class="checkbox-column"><input type="checkbox" class="uniform"></th> -->
                                 <th>S.No</th>
                                 <th>Abstract ID</th>
								 <th>Name</th>
                                 <th>Image</th>
                                 <th>Phone</th>
                                 <th>Email</th>
											<th>Action</th>
										</tr>
									</thead>
									<tbody>
                                    <?php
								  $sno=1;
								 while($rec=getAssoc($sel)){?>
										<tr>
											<!--<td class="checkbox-column"><input type="checkbox" class="uniform"></td>-->
                                 <td><?php echo $sno;?></td>
                                 <td><?php echo $rec['aid'];?></td>
											<td><?php echo $rec['name'];?></td>
                                 <td><img src="<?php if($rec['image']!=''){echo '../'.$rec['image'];}else{echo 'assets/img/no-image.gif';}?>" style="height:40px;" /></td>
                                 <td><?php echo $rec['phone'];?></td>
                                 <td><?php echo $rec['email'];?></td>
											<td><a href="abstract_traking.php?action=edit&id=<?php echo $rec['id'];?>" title="Edit"><i class="icol-pencil"></i></a>&nbsp;&nbsp;

										 <a href="abstract_traking.php?action=delete&id=<?php echo $rec['id'];?>" onClick="return confirm('Are you sure you want to delete ?')" title="Delete"><i class="icol-cross"></i></a>&nbsp;&nbsp;
                             <a href="mail.php?id=<?php echo $rec['id'];?>" title="Send Mail"><img src="assets/img/envelope.png" style="width:22px;" alt="" /></a>

</td>
										</tr>
                                        <?php $sno++;}?>
									</tbody>
								</table>
<p>Abstrack Trakig Tool URL :<a href="https://agingcongress.com/login.php" target="_blank">https://agingcongress.com/login.php</a>
                            <?php }else if($action=='addnew' || $action=='edit'){?>

							<?php if($action=='edit'){
                            $id=$_GET['id'];
                            $e="select * from abstract_traking where id='$id'";
                            $ed=$DB->executeQuery($e);
                            $edi=$DB->getAssoc($ed);
                            }?>

								<form class="form-horizontal" id="validate-1" method="post" novalidate="novalidate" enctype="multipart/form-data">
                                <div class="form-group">
										<label class="col-md-2 control-label">Abstract ID<span class="required">*</span></label>
										<div class="col-md-4">
											<input type="text" name="aid" class="form-control required" value="<?php if($action=='edit'){echo $edi['aid'];}?>">
                                            <p style="color:#f00;"><?php if(isset($errormessage['2'])){echo $errormessage[2]; }?></p> 
										</div>
										<label class="col-md-2 control-label">Name<span class="required">*</span></label>
										<div class="col-md-4">
											<input type="text" name="name" class="form-control required" value="<?php if($action=='edit'){echo $edi['name'];}?>">
										</div>
									</div>
                                    <div class="form-group">
										<label class="col-md-2 control-label">Phone <span class="required">*</span></label>
										<div class="col-md-4">
											<input type="text" name="phone" class="form-control required" value="<?php if($action=='edit'){echo $edi['phone'];}?>">
										</div>
										<label class="col-md-2 control-label">Email Id <span class="required">*</span></label>
										<div class="col-md-4">
											<input type="text" name="email" class="form-control required" value="<?php if($action=='edit'){echo $edi['email'];}?>">
										</div>
									</div>
                                     <div class="form-group">
										<label class="col-md-2 control-label">Country <span class="required">*</span></label>
										<div class="col-md-4">
											<input type="text" name="country" class="form-control required" value="<?php if($action=='edit'){echo $edi['country'];}?>">
										</div>
										<label class="col-md-2 control-label">University <span class="required">*</span></label>
										<div class="col-md-4">
											<input type="text" name="university" class="form-control required" value="<?php if($action=='edit'){echo $edi['university'];}?>">
										</div>
									</div>
									<div class="form-group">
										<label class="col-md-2 control-label">Abstract Title<span class="required">*</span></label>
										<div class="col-md-4">
											 <textarea name="title" class="form-control"><?php if($action=='edit'){echo $edi['title'];}?></textarea>
										</div>
                                    <label class="col-md-2 control-label">Image <span class="required">*</span></label>
                                    <div class="col-md-2 fileupload fileupload-new" data-provides="fileupload">
                                            <div class="fileupload-new thumbnail" style="width: 180px;">
                                            <img src="<?php if($edi['image']!=''){ echo '../'.$edi['image'];}else{echo 'assets/img/no-image.gif';}?>" style="width:170px;" />
                                            </div>
                                            <div class="fileupload-preview fileupload-exists thumbnail"></div>
                                            <div>
                                                <span class="btn btn-file"><span class="fileupload-new">Select image</span><span class="fileupload-exists" style="padding:6px;">Change</span><input type="file" name='file' accept="image/*"  /></span>
                                                <a href="#" class="btn fileupload-exists" style="padding:4px 7px!important;" data-dismiss="fileupload">Remove</a>
                                            </div>
                                        </div>
                                        </div>
                                        
                              <div class="form-group">
										<label class="col-md-2 control-label">Participation Category<span class="required">*</span></label>
										<div class="col-md-4">
											<select name="category" class="form-control required">
                                            <option value="">Select Participation Category</option>
                                            <option <?php if($action=='edit'){if($edi['category']=='Oral Presentation'){echo 'selected="selected"';}}?> value="Oral Presentation">Oral Presentation</option>
                                             <option <?php if($action=='edit'){if($edi['category']=='Poster Presentation'){echo 'selected="selected"';}}?> value="Poster Presentation">Poster Presentation</option>
                                             <option <?php if($action=='edit'){if($edi['category']=='Keynote Presentation'){echo 'selected="selected"';}}?> value="Keynote Presentation">Keynote Presentation</option>
                                             <option <?php if($action=='edit'){if($edi['category']=='WorkShop'){echo 'selected="selected"';}}?> value="WorkShop">WorkShop</option>
											</select>
										</div>
										<label class="col-md-2 control-label">status<span class="required">*</span></label>
										<div class="col-md-4">
											<select name="status" class="form-control required">
                                            <option value="">Select Status</option>
                                            <option <?php if($action=='edit'){if($edi['status']=='Received and accepted for review'){echo 'selected="selected"';}}?> value="Received and accepted for review">Received and accepted for review</option>
                                             <option <?php if($action=='edit'){if($edi['status']=='Under Peer Review Process'){echo 'selected="selected"';}}?> value="Under Peer Review Process">Under Peer Review Process</option>
                                             <option <?php if($action=='edit'){if($edi['status']=='Reviewed and decision pending'){echo 'selected="selected"';}}?> value="Reviewed and decision pending">Reviewed and decision pending</option>
                                             <option <?php if($action=='edit'){if($edi['status']=='Accepted'){echo 'selected="selected"';}}?> value="Accepted">Accepted</option>
                                             <option <?php if($action=='edit'){if($edi['status']=='Rejected'){echo 'selected="selected"';}}?> value="Rejected">Rejected</option>
											</select>
										</div>
									</div>
                                    <div class="form-group">
										<label class="col-md-2 control-label">Comment <span class="required">*</span></label>
										<div class="col-md-4 clearfix">
                                       <textarea name="message" class="form-control"><?php if($action=='edit'){echo $edi['message'];}?></textarea>
                                       </div>
									</div>
                                    
                                    <div class="form-group">
										<label class="col-md-2 control-label">Registration Link</label>
										<div class="col-md-4">
										<input type="text" name="link" class="form-control " value="<?php if($action=='edit'){echo $edi['link'];}?>">
										</div>
                                    <label class="col-md-2 control-label">Pdf </label>
                                    <div class="col-md-4">
                                            
                                        <input class="text-input small-input form-control" type="file"  name="file1"  />   
                                            
                                        </div>
                                        </div>
									
									<div class="form-actions">
                                    <label class="col-md-2">&nbsp;</label>
                                    <?php if($action=='addnew'){?>
									<input class="btn btn-info pull-left" type="submit" name="submit" value="Submit" />
									<?php }else if($action=='edit'){?>
									<input class="btn btn-info pull-left" type="submit" name="update" value="Update" />
									<?php }?>
									</div>
								</form>
						<?php }?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
	<?php include("links/bottom.php");?>