ok
Direktori : /proc/self/root/home2/selectio/www/thedentalpark.com/admin/ |
Current File : //proc/self/root/home2/selectio/www/thedentalpark.com/admin/specialization-add.php |
<?php include("header.php"); error_reporting(0); if(isset($_POST['specialization_name'])) { try { $specialization_name = $_POST['specialization_name'] ? $_POST['specialization_name'] : ''; $college_id = $_POST['college_id'] ? $_POST['college_id'] : ''; $course_id = $_POST['course_id'] ? $_POST['course_id'] : ''; $status = $_POST['status'] ? $_POST['status'] : ''; $update_id = $_POST['update_id'] ? $_POST['update_id'] : ''; $date = date("Y-m-d H:i:s"); if($update_id){ $statement = $pdo->prepare("UPDATE tbl_course_specialization SET specialization_name=?, college_id=?, course_id=?, status=?, created_at=? WHERE id=?"); $statement->execute(array($specialization_name, $college_id, $course_id, $status, $date, $update_id)); // Check result of database operation if($statement) { $_SESSION['special_success_message'] = 'Course Specialization Details Updated Successfully' ; header("Location: specialization-list.php"); exit; } else { $_SESSION['special_error_message'] = 'Error Occured Not Added'; header("Location: specialization-add.php"); exit; } }else{ // Inserting the slider details into the database $statement = $pdo->prepare("INSERT INTO tbl_course_specialization (specialization_name, college_id, course_id, status, created_at) VALUES (?,?,?,?,?)"); $statement->execute(array($specialization_name, $college_id, $course_id, $status, $date)); // Check result of database operation if($statement) { $_SESSION['special_success_message'] = 'Course Specialization Details Added Successfully' ; header("Location: specialization-list.php"); exit; } else { $_SESSION['special_error_message'] = 'Error Occured Not Added'; header("Location: specialization-add.php"); exit; } } } catch(Exception $e) { $_SESSION['special_error_message'] = $e->getMessage(); header("Location: specialization-add.php"); exit; } } if(isset($_GET['id']) && $_GET['id']!=''){ $id = isset($_GET['id']) ? $_GET['id'] : ''; $statement = $pdo->prepare("SELECT * FROM tbl_course_specialization WHERE id=?"); $statement->execute(array($id)); $edit_result = $statement->fetchAll(PDO::FETCH_ASSOC); $edit_count = $statement->rowCount(); $specialization_name = $edit_result[0]['specialization_name']; $college_id = $edit_result[0]['college_id']; $course_id = $edit_result[0]['course_id']; $status = $edit_result[0]['status']; } ?> <div class="content-wrapper" style="background-color: white;"> <div class="clearfix"></div> <section class="content"> <div class="row"> <div class="col-xs-12"> <?php if(!empty($_SESSION['special_error_message'])) { ?> <div class="callout callout-danger"> <p><?php echo $_SESSION['special_error_message']; ?></p> </div> <?php unset($_SESSION['special_error_message']); }?> <?php if(!empty($_SESSION['special_success_message'])){ ?> <div class="callout callout-success"> <p><?php echo $_SESSION['special_success_message']; ?></p> </div> <?php unset($_SESSION['special_success_message']); } ?> </div> </div> <div class="row"> <div class="col-xs-12"> <div> <div class="box-header"> <h3 class="box-title"><b><?php if(isset($_GET['id']) && $_GET['id']!=''){ echo 'Update';}else { echo 'Add';} ?> Course Specialization : </b></h3> </div> <div class="box box-info"> <div class="box-body" style="box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px;"> <div class="col-lg-12"> <div id="content-div"> <form action="" enctype="multipart/form-data" method="post" id="course_special_form" accept-charset="utf-8"> <div class="row"> <input type="hidden" name="update_id" id="update_id" value="<?php echo (isset($_GET['id']) ? $_GET['id'] : '') ?>"> <div class="col-md-6"> <div class="form-group"> <label class="required" for="college_id">College Name</label> <select name="college_id" class="form-control select2" style="width:100%" id="college_id"> <option value="">Select College Name</option> <?php $statement = $pdo->prepare("SELECT * FROM `tbl_college` where status=1"); $statement->execute(); $location_result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($location_result as $result) { ?> <option value="<?=$result['id']?>" <?php if(!empty($college_id) && $college_id==$result['id']){ echo "selected";} ?>><?=$result['college_name']?></option> <?php } ?> </select> </div> </div> <div class="col-md-6"> <div class="form-group"> <label class="required" for="course_id">Course Name</label> <select name="course_id" class="form-control select2" style="width:100%" id="course_id"> </select> </div> </div> <div class="col-md-6"> <div class="form-group"> <label class="required" for="specialization_name">Specialization Name</label> <input type="text" name="specialization_name" id="specialization_name" value="<?php echo (isset($specialization_name) ? $specialization_name : '') ?>" placeholder="Enter Specialization Name" class="form-control" /> </div> </div> <div class="col-sm-6"> <div class="form-group"> <label class="required" for="status">Status</label> <select name="status" class="form-control select2" style="width:100%" id="status"> <option value="1" <?php if(!empty($status) && $status==1){ echo "selected";} ?>>Active</option> <option value="0" <?php if(!empty($status) && $status==0){ echo "selected";} ?>>In-Active</option> </select> </div> </div> </div> <div class="row"> <div class="form-group" style="text-align:center;margin-top:10px"> <button type="submit" id="submit_specialization" name="submit_specialization" class="btn btn-success"><?php if(isset($_GET['id']) && $_GET['id']!=''){ echo 'Update';}else { echo 'Add';} ?> Specialization</button> </div> </div> </form> <div class="form-group" style="text-align:center;"> <a href="specialization-add.php"><button class="btn btn-primary" ><i class="fa fa-refresh"></i> Reset Form</button></a> <a href="specialization-list.php"><button class="btn btn-warning" ><i class="fa fa-chevron-left"></i> Back to List</button></a> </div> </div> <div class="clearfix"></div> </div> </div> </div> </div> </div> </div> </section> <?php include "footer.php";?> <script type="text/javascript"> $(document).ready(function() { function GetCourse(collegeId, courseId=null){ $.ajax({ url: 'api/get-value.php', type: 'POST', data: { field_type:'get_course',college_id: collegeId }, success: function(response) { var response = JSON.parse(response); $('#course_id').empty(); $('#course_id').append('<option value="">Select Course Name</option>'); if(response.status == 'success'){ $.each(response.courses, function(index, course) { $('#course_id').append('<option value="' + course.id + '" '+(courseId==course.id ? "selected" : "")+' >' + course.course_name + '</option>'); }); }else{ alert(response.message); } $('#course_id').select2(); // This re-initializes the select2 dropdown }, error: function(xhr, status, error) { console.error('Error fetching courses:', error); } }); } var collegeId = '<?php echo $college_id ?>'; var courseId = '<?php echo $course_id ?>'; if(collegeId != '' && courseId != ''){ GetCourse(collegeId, courseId); } $('#college_id').change(function() { var collegeId = $(this).val(); if (collegeId) { GetCourse(collegeId); } else { $('#course_id').empty(); $('#course_id').append('<option value="">Select Course Name</option>'); } }); $.validator.addMethod("large_text_field",function(value,element){ if(value){ return this.optional(element) || (/[\=\<\>]+/.test(value))? false : true; }else{ return true; } },"Don't Use '=' Symbol and Tag '<>' Symbol "); $('#course_special_form').validate({ rules:{ 'specialization_name': { required: true, large_text_field:true, maxlength: 300 }, 'college_id': { required: true }, 'course_id': { required: true }, 'status':{ required: true } }, errorPlacement: function(error, element) { var ername = element.attr('name'); error.css('color', 'red'); element.parents('.form-group').append(error); }, messages:{ }, submitHandler: function(form){ $('#submit_specialization').attr('disabled',true).text("Processing..."); form.submit(); } }); }); </script>