<?php include("links/top.php");
$action=$_GET['action'];
?>
<?php 
if($action=='delete'){
$id=$_GET['id'];
$del="delete from pastconference where id='$id'";
$DB->executeQuery($del);
header('Location:pastconference.php?action=list');
}
?>
	<?php 
	if($action=='addnew' || $action== 'edit'){
	if($action=='edit'){
	$id=$_GET['id'];
	}
	if(isset($_POST['submit']) || isset($_POST['update'])){
	
	extract($_POST);
	
	if($action=='addnew'){
		$arr=array('title' 		=> addslashes($title),'title1' 		=> addslashes($title1),'title2' 		=> addslashes($title2),'title3' 		=> addslashes($title3),'title4' 		=> addslashes($title4),'date' 		=> addslashes($date),'description' 		=> addslashes($description),'link' 		=> addslashes($link),'link2' 		=> addslashes($link2)); 
		$DB->insert('pastconference',$arr);
		$id=getRecordId();							
	}
	if($action=='edit'){
		$arr=array( 'title' 		=> addslashes($title),'title1' 		=> addslashes($title1),'title2' 		=> addslashes($title2),'title3' 		=> addslashes($title3),'title4' 		=> addslashes($title4),'date' 		=> addslashes($date),'description' 		=> addslashes($description),'link' 		=> addslashes($link),'link2' 		=> addslashes($link2));
		$DB->update('pastconference',$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.$code.$_FILES['file']['name'];	
		move_uploaded_file($_FILES['file']['tmp_name'],'../'.$image);        
		$arr=array( 'image' 	=> $image);
		$DB->update('pastconference',$arr,"id='$id'");
		}}
		
		if($_FILES['file1']['name']!='')
		{
		//$code=time();
		$filepath="uploads/images/";			
		$extension = strtolower(strrchr($_FILES['file1']['name'], '.'));	
		if($extension=='.jpg' || $extension=='.jpeg' || $extension=='.png' || $extension=='.gif' || $extension=='.JPG' || $extension=='.JPEG' || $extension=='.PNG' || $extension=='.GIF' || $extension=='.bmp' || $extension=='.BMP'){		
		$image1 = $filepath.$id.$_FILES['file1']['name'];	
		move_uploaded_file($_FILES['file1']['tmp_name'],'../'.$image1);        
		$arr=array( 'image1' 	=> $image1);
		$DB->update('pastconference',$arr,"id='$id'");
		}}
		
		if($_FILES['file2']['name']!='')
		{
		//$code=time();
		$filepath="uploads/images/";			
		$extension = strtolower(strrchr($_FILES['file2']['name'], '.'));	
		if($extension=='.pdf' || $extension=='.docx' || $extension=='.doc'){		
		$pdf = $_FILES['file2']['name'];	
		move_uploaded_file($_FILES['file2']['tmp_name'],'../uploads/images/'.$pdf);        
		$arr=array( 'pdf' 	=> $pdf);
		$DB->update('pastconference',$arr,"id='$id'");
		}}
		
		if($_FILES['file3']['name']!='')
		{
		//$code=time();
		$filepath="uploads/images/";			
		$extension = strtolower(strrchr($_FILES['file3']['name'], '.'));	
		if($extension=='.pdf' || $extension=='.docx' || $extension=='.doc'){		
		$pdf1 = $_FILES['file3']['name'];	
		move_uploaded_file($_FILES['file3']['tmp_name'],'../uploads/images/'.$pdf1);        
		$arr=array( 'pdf1' 	=> $pdf1);
		$DB->update('pastconference',$arr,"id='$id'");
		}}
		
		if($_FILES['file4']['name']!='')
		{
		//$code=time();
		$filepath="uploads/images/";			
		$extension = strtolower(strrchr($_FILES['file4']['name'], '.'));	
		if($extension=='.jpg' || $extension=='.jpeg' || $extension=='.png' || $extension=='.gif' || $extension=='.JPG' || $extension=='.JPEG' || $extension=='.PNG' || $extension=='.GIF' || $extension=='.bmp' || $extension=='.BMP'){		
		$image2 = $filepath.$id.$_FILES['file4']['name'];	
		move_uploaded_file($_FILES['file4']['tmp_name'],'../'.$image2);        
		$arr=array( 'image2' 	=> $image2);
		$DB->update('pastconference',$arr,"id='$id'");
		}}
		
		if($_FILES['file5']['name']!='')
		{
		//$code=time();
		$filepath="uploads/images/";			
		$extension = strtolower(strrchr($_FILES['file5']['name'], '.'));	
		if($extension=='.jpg' || $extension=='.jpeg' || $extension=='.png' || $extension=='.gif' || $extension=='.JPG' || $extension=='.JPEG' || $extension=='.PNG' || $extension=='.GIF' || $extension=='.bmp' || $extension=='.BMP'){		
		$image3 = $filepath.$id.$_FILES['file5']['name'];	
		move_uploaded_file($_FILES['file5']['tmp_name'],'../'.$image3);        
		$arr=array( 'image3' 	=> $image3);
		$DB->update('pastconference',$arr,"id='$id'");
		}}
		
header('Location: pastconference.php?action=list');
	}
	}
	?>	
		<div id="content">
			<div class="container">
				<div class="page-header">
					<div class="page-title">
						<h3>Pastconference Management</h3>
					</div>
				</div>
				<div class="row">
               
					<div class="col-md-12">
                    <?php if($action=='list'){?> <a href="pastconference.php?action=addnew"><button class="btn btn-sm btn-info">Add Pastconference</button></a> <?php } ?>                   
						<div class="widget box">
                        <div class="widget-header">
						<?php if($action=='list'){?>
                            <h4>Pastconference List</h4>
                            <?php }else if($action=='addnew'){ ?>
                            <h4>Add Pastconference</h4>
                            <?php }?>					
							</div>
                        <div class="widget-content">
                             <?php if($action=='list'){
								 $sno=1;
								$sel=executeQuery("select * from pastconference");
								?>							
							
								<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>Title</th>
                                 <th>Image</th>
                                 <th>Status</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['title'];?></td>
                                 <td><img src="<?php if($rec['image']!=''){echo '../'.$rec['image'];}else{echo 'assets/img/no-image.gif';}?>" style="height:40px;" /></td>
                                
                                 <td><a href="javascript:void(0)" id="status<?php echo $rec['id'];?>" onclick="return status(<?php echo $rec['id'];?>,'pastconference')"><?php if($rec['status']==1){echo 'Active';}else{echo 'Inactive';}?></a></td>
											<td>
                                             <a href="pastconference.php?action=edit&id=<?php echo $rec['id'];?>" title="Edit"><i class="icol-pencil"></i></a> &nbsp; &nbsp; &nbsp;
										 <a href="pastconference.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; ;&nbsp;

                                       <?php /*  <a href="pastconference_img.php?action=list&pid=<?php echo $rec['id'];?>" title="Images"><img src="assets/img/add.png" style="width:25px;" alt="" /></a>
                                            </td> */ ?>
										</tr>
                                        <?php $sno++;}?>
									</tbody>
								</table>
							
                            <?php }else if($action=='addnew' || $action=='edit'){?>
					
							<?php if($action=='edit'){
                            $id=$_GET['id'];
                            $e="select * from pastconference 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">Conference Name <span class="required">*</span></label>
										<div class="col-md-4">
											<input type="text" name="title" class="form-control required" value="<?php if($action=='edit'){echo $edi['title'];}?>">
										</div>
									</div>
                                    <div class="form-group">
                                     <label class="col-md-2 control-label">Book Title<span class="required">*</span></label>
										<div class="col-md-4">
											<input type="text" name="title1" class="form-control required" value="<?php if($action=='edit'){echo $edi['title1'];}?>">
										</div>
                                       
                                        </div>
                                       <div class="form-group">
                                        
                                        <label class="col-md-2 control-label">Program Title <span class="required">*</span></label>
										<div class="col-md-4">
											<input type="text" name="title2" class="form-control required" value="<?php if($action=='edit'){echo $edi['title2'];}?>">
										</div>
                                        <label class="col-md-2 control-label">Conference Date <span class="required">*</span></label>
										<div class="col-md-4">
											<input type="text" name="date" class="form-control required" value="<?php if($action=='edit'){echo $edi['date'];}?>">
										</div>
                                        </div>
									<div class="form-group">
                                   
                                    <label class="col-md-2 control-label">Book 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($action=='edit'){if($edi['image']!=''){ echo '../'.$edi['image'];}else{echo 'assets/img/no-image.gif';}}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' <?php if($action=='edit'){if($edi['image']==''){echo 'class="required"';}}else{echo 'class="required"';}?> accept="image/*"  /></span><br />
                                                 <span style="color:#F00;"> Image Size[370 X 409];</span>
                                                <a href="#" class="btn fileupload-exists" style="padding:4px 7px!important;" data-dismiss="fileupload">Remove</a>
                                            </div>
                                            
                                        </div>
                                       <label class="col-md-3 control-label">Abstract Book Upload PDF File</label>
                                             <div class="col-md-4">
                                                 
											<div class="form-group">
                                   
                                    <div class=" fileupload fileupload-new" data-provides="fileupload">
                                            <div class="fileupload-new thumbnail" style="width: 180px;">
                                           <img src="<?php if($action=='edit'){if($edi['pdf']!=''){ echo '../'.$edi['pdf'];}else{echo 'assets/img/no-image.gif';}}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 File</span><span class="fileupload-exists" style="padding:6px;">Change</span><input type="file" name='file2' /></span>
                                                <a href="#" class="btn fileupload-exists" style="padding:4px 7px!important;" data-dismiss="fileupload">Remove</a>
                                            </div>
                                        </div>
                                        </div>
										
										
                                      </div>
                                       
                                        </div>
                                        	<div class="form-group">
                                         <label class="col-md-2 control-label">Program 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($action=='edit'){if($edi['image1']!=''){ echo '../'.$edi['image1'];}else{echo 'assets/img/no-image.gif';}}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='file1' <?php if($action=='edit'){if($edi['image1']==''){echo 'class="required"';}}else{echo 'class="required"';}?> accept="image/*"  /></span><br />
                                                 <span style="color:#F00;"> Image Size[370 X 409];</span>
                                                <a href="#" class="btn fileupload-exists" style="padding:4px 7px!important;" data-dismiss="fileupload">Remove</a>
                                            </div>
                                        </div>
                                           <label class="col-md-3 control-label">Program Book Upload PDF File</label>
                                 <div class="col-md-4">
									
										
										<div class="form-group">
                                   
                                    <div class=" fileupload fileupload-new" data-provides="fileupload">
                                            <div class="fileupload-new thumbnail" style="width: 180px;">
                                           <img src="<?php if($action=='edit'){if($edi['pdf1']!=''){ echo '../'.$edi['pdf1'];}else{echo 'assets/img/no-image.gif';}}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 File</span><span class="fileupload-exists" style="padding:6px;">Change</span><input type="file" name='file3' /></span>
                                                <a href="#" class="btn fileupload-exists" style="padding:4px 7px!important;" data-dismiss="fileupload">Remove</a>
                                            </div>
                                        </div>
                                        </div>
										
										
                                      </div>
                                        </div>
                                        
                                        
                                        	<div class="form-group">
                                         <label class="col-md-2 control-label">Gallery 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($action=='edit'){if($edi['image2']!=''){ echo '../'.$edi['image2'];}else{echo 'assets/img/no-image.gif';}}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='file4' <?php if($action=='edit'){if($edi['image2']==''){echo 'class="required"';}}else{echo 'class="required"';}?> accept="image/*"  /></span><br />
                                                 <span style="color:#F00;"> Image Size[370 X 409];</span>
                                                <a href="#" class="btn fileupload-exists" style="padding:4px 7px!important;" data-dismiss="fileupload">Remove</a>
                                            </div>
                                        </div>
                                        <label class="col-md-2 control-label">Gallery Title</label>
                                 <div class="col-md-4">
										<input type="text" name="title3" class="form-control required" value="<?php if($action=='edit'){echo $edi['title3'];}?>">
                                      </div>
                                        </div>
                                        
                                        	<div class="form-group">
                                         <label class="col-md-2 control-label">Speaker 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($action=='edit'){if($edi['image3']!=''){ echo '../'.$edi['image3'];}else{echo 'assets/img/no-image.gif';}}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='file5' <?php if($action=='edit'){if($edi['image3']==''){echo 'class="required"';}}else{echo 'class="required"';}?> accept="image/*"  /></span><br />
                                                 <span style="color:#F00;"> Image Size[370 X 409];</span>
                                                <a href="#" class="btn fileupload-exists" style="padding:4px 7px!important;" data-dismiss="fileupload">Remove</a>
                                            </div>
                                        </div>
                                        <label class="col-md-2 control-label">Gallery Title</label>
                                 <div class="col-md-4">
										<input type="text" name="title4" class="form-control required" value="<?php if($action=='edit'){echo $edi['title4'];}?>">
                                      </div>
                                        </div>
                                        
                                         <div class="form-group">
                                    
                                        <label class="col-md-2 control-label">Speakers 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">Gallery Link </label>
										<div class="col-md-4">
											<input type="text" name="link2" class="form-control" value="<?php if($action=='edit'){echo $edi['link2'];}?>">
										</div>
                                        </div>
                                        
                                        <div class="form-group">

										<label class="col-md-2 control-label">Description</label>

										<div class="col-md-12 clearfix" style="clear:both; margin-top:40px;">

											<textarea id="description" name="description" class="ckeditor"><?php if($action=='edit'){echo $edi['description'];}?></textarea>

										</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");?>