ok
Direktori : /home2/selectio/public_html/tnpsctestbatch.com/admin/old/ |
Current File : /home2/selectio/public_html/tnpsctestbatch.com/admin/old/event-edit.php |
<?php include "header.php"; if(isset($_POST['update_event'])){ try{ $events_name=""; $role=""; $image=""; $achiver_name=""; $achiver_department=""; $achiver_rank=""; if(isset($_POST['event_name'])){ $events_name = $_POST['event_name']; } if(isset($_POST['status'])){ $role= $_POST['status']; } if(isset($_POST['achiver_name'])){ $achiver_name= $_POST['achiver_name']; } if(isset($_POST['department_name'])){ $achiver_department= $_POST['department_name']; } if(isset($_POST['achiver_rank'])){ $achiver_rank= $_POST['achiver_rank']; } $date = date('Y-m-d h:i:s', time()); // $month =date('m',strtotime($_POST['holiday_date'])); // $year =date('Y',strtotime($_POST['holiday_date'])); if(isset($_FILES['achiver_images'])){ if(isset($_FILES['achiver_images']) && $_FILES["achiver_images"]["name"]!=""){ $extension = end(explode(".", $_FILES["achiver_images"]["name"])); $image = rand(10,1000000000)."-".$date."-image." . $extension; $upload = move_uploaded_file($_FILES['achiver_images']['tmp_name'], '../upload/achivers/' . $image); $upload_image = 'upload/achivers/' . $image; } else{ $upload_image=$_POST['old_photo']; } } if(isset($_FILES['placement_image'])){ if(isset($_FILES['placement_image']) && $_FILES["placement_image"]["name"]!=""){ unlink($_POST['old_images']); $extension = end(explode(".", $_FILES["placement_image"]["name"])); $image = rand(10,1000000000)."-".$date."-image." . $extension; $upload = move_uploaded_file($_FILES['placement_image']['tmp_name'], '../upload/placement/' . $image); $upload_image = 'upload/placement/' . $image; } else{ $upload_image=$_POST['old_images']; } } $statement = $pdo->prepare("UPDATE tbl_event SET event_name=?,achiver_name=?,image=?,achiver_department=?,achiver_rank=?,status=? WHERE id=?"); $result=$statement->execute(array($events_name,$achiver_name,$upload_image,$achiver_department,$achiver_rank,$_POST['status'],$_POST['ids'])); if($result){ echo '<script type="text/javascript"> alert("Event Updated successfully"); window.location.href = "event-details.php"; </script>'; unset($_POST); }else{ echo '<script type="text/javascript"> alert("Something went wrong try again..."); </script>'; } }catch(Exception $e){ $error=$e; } } $ids=$_GET['id']; $statement = $pdo->prepare("SELECT * FROM tbl_event WHERE id=".$ids); $statement->execute(); $events_data = $statement->fetchAll(PDO::FETCH_ASSOC); ?> <div class="content-wrapper" style="background:white;"> <section class="content-header"> <h4><b>Update Events Image</b></h4> <ol class="breadcrumb"> <li><a href="index.php"><i class="fa fa-dashboard"></i> Home</a></li> <li class="active">Update Events Image</li></ol> </section> <section class="content"> <div class="row"> <div class="col-xs-12"> <div> <div class="box-body"> <div class="col-lg-12"> <div class="col-lg-12" style="display: flex;justify-content: center;"> <label><?php if($events_data[0]['role']==3){echo "Achiver's Photo";}else{ echo 'Placement Photo';} ?></label> <br> </div> <div class="col-lg-12" style="display: flex;justify-content: center;"> <?php if($events_data[0]['image']==""){}else{?> <img src="../<?=$events_data[0]['image']?>" style="width: 200px;height: 110px;"> <?php } ?> </div> <form action="" enctype="multipart/form-data" method="post" accept-charset="utf-8"> <div class="row"> <div class="col-md-4"> <input type="hidden" name="ids" value="<?=$_GET['id'] ?>"> <div class="form-group"> <label class="required" for="status">Select Events</label> <select name="status" id="status" class="form-control tip select2"> <?php if($events_data[0]['role']==1){ echo '<option value="1">Announcement</option>'; }elseif($events_data[0]['role']==2){ echo '<option value="2">News And Events</option>'; }elseif($events_data[0]['role']==3){ echo '<option value="3">Achivers</option>'; }else{ echo '<option value="4">Placement News</option>'; }?> </select> </div> </div> <div id="special_trip_date"> </div> <div class="col-md-4"> <div class="form-group"> <label class="required" for="status">Status</label> <select name="status" id="status" class="form-control tip select2"> <option value="1" <?php if($events_data[0]['status']==1){echo 'selected';}?>>Active</option> <option value="0" <?php if($events_data[0]['status']==0){echo 'selected';}?>>In-Active</option> </select> </div> </div> <div class="col-md-4"> <div class="form-group"> <label class="required" for="file">Action</label><br> <input type="submit" id="add_category" name="update_event" value="Update" class="btn btn-success" /> </div> </div> </div> </form> </div> </div> <div class="form-group" style="text-align:center;"> <?php echo "<a href=gallery-edit.php?id=".$ids."> <button class='btn btn-primary' > <i class='fa fa-refresh'></i> Reset Form</button></a>"; ?> <a href="gallery.php"><button class="btn btn-warning" ><i class="fa fa-chevron-left"></i> Back to List</button></a> </div> <div class="clearfix"></div> </div> </div> </div> </div> </section> <script> var photo = document.getElementById("photo"); photo.onchange = function() { console.log(photo); $('#photospan').text(''); if(this.files[0].size > 5500000){ $('#photospan').text('Photo Image Maximum 5 mb Allowed'); alert("File is too big!"); this.value = ""; }; }; </script> <script> $(document).ready(function(){ trip_status(); }); $("#status").change(function () { trip_status(); }); function trip_status(){ var trip_status = $("#status").val(); $("#special_trip_date").empty(); /* Trip Status ( 1=Always ON, 2=Special Trip ON, 3=Trip Off )*/ var anouncement ='<div class="col-md-4"><div class="form-group"><label class="required" for="file">Announcement</label><input type="text" name="event_name" id="photo" value="<?=$events_data[0]['event_name']?>" placeholder="Enter Anouncement Content" class="form-control tip" required="required" /><span style="color: red;" id="photospan"></span></div></div>'; var news ='<div class="col-md-4"><div class="form-group"><label class="required" for="file">News & Events</label><input type="text" name="event_name" id="photo" value="<?=$events_data[0]['event_name']?>" placeholder="Enter News & events Content" class="form-control tip" required="required" /><span style="color: red;" id="photospan"></span></div></div>'; var achiver ='<div class="col-md-4"><div class="form-group"><label class="required" for="file">Achivers name</label><input type="text" name="achiver_name" id="photo" value="<?=$events_data[0]['achiver_name']?>" placeholder="Enter Achivers name" class="form-control tip" required="required" /><span style="color: red;" id="photospan"></span></div></div><div class="col-md-4"><div class="form-group"><label class="required" for="files">Achivers Photo</label><input name="old_photo" type="hidden" value="<?=$events_data[0]['image']?>"><input type="file" name="achiver_images" id="photos" value="" placeholder="Enter Achivers image" class="form-control tip" /><span style="color: red;" id="photospan"></span></div></div><div class="col-md-4"><div class="form-group"><label class="required" for="file">Achivers Department Name</label><input type="text" name="department_name" id="photo" value="<?=$events_data[0]['achiver_department']?>" placeholder="Enter Achivers Department Name" class="form-control tip" required="required" /><span style="color: red;" id="photospan"></span></div></div><div class="col-md-4"><div class="form-group"><label class="required" for="file">Achivers Rank</label><input type="text" name="achiver_rank" id="photo" value="<?=$events_data[0]['achiver_rank']?>" placeholder="Enter Achivers Rank" class="form-control tip" required="required" /><span style="color: red;" id="photospan"></span></div></div>'; var placement ='<div class="col-md-4"><div class="form-group"><label class="required" for="file">Placements Photo</label><input name="old_images" type="hidden" value="<?=$events_data[0]['image']?>"><input type="file" name="placement_image" id="photo" value="" placeholder="Enter News & events Content" class="form-control tip" " /><span style="color: red;" id="photospan"></span></div></div>'; if(trip_status==1){ $("#special_trip_date").append(anouncement); }else if(trip_status==2){ $("#special_trip_date").append(news); }else if(trip_status==3){ $("#special_trip_date").append(achiver); }else if(trip_status==4){ $("#special_trip_date").append(placement); } else{ } } </script> <?php include "footer.php";?>