Mini Shell

Direktori : /home2/aravindar/public_html/admin/
Upload File :
Current File : /home2/aravindar/public_html/admin/edit_subcourse.php

<?php
/* Database connection */
include("config.php");
$conn = dbconnect();
session_start();

// login or not
if ($_SESSION['name'] == '' || $_SESSION['admin_id'] == '') {
  header('location:logout.php');
  die();
}

$name = $_SESSION['name'];
$admin_id = $_SESSION['admin_id'];
$query  = "SELECT * FROM tb1_admin WHERE name='" . $name . "' AND admin_id='" . $admin_id . "'";
$res_query = mysqli_query($conn, $query);
$fetch = mysqli_fetch_object($res_query);
$username = $fetch->user_name;
$phone = $fetch->phone;
$adminposition = $fetch->position;
if ($adminposition == 1) {
  $type = 'Main Admin';
} elseif ($adminposition == 2) {
  $type = 'Accounts';
} elseif ($adminposition == 3) {
  $type = 'Marketing';
} else {
  $type = 'Others';
}

$id = base64_decode($_GET['id']);

$url_query  = "SELECT * FROM tb1_url WHERE url_title='course'";
$res_url = mysqli_query($conn, $url_query);
$fetch_url = mysqli_fetch_object($res_url);
$url_path = $fetch_url->url_path;

$content_query = "SELECT * FROM tb1_subcourse WHERE subcourse_id = '$id'";
//echo $content_query;
$content_res = mysqli_query($conn, $content_query);
$content_row = mysqli_fetch_object($content_res);
$subcourse_id = $content_row->subcourse_id;
$subcourse_name = $content_row->subcourse_name;
$course_id = $content_row->course_id;
$course_img = $content_row->course_img;
$course_code = $content_row->course_code;
$course_fee = $content_row->course_fee;
$duration = $content_row->duration;
$certificate = $content_row->certificate;
$language = $content_row->language;
$practical = $content_row->practical;
$validity = $content_row->validity;
$subject_content = $content_row->subject_content;
$aims = $content_row->aims;
$objective = $content_row->objective;
$target_audience = $content_row->target_audience;
$delegate = $content_row->delegate;
$course_form = $content_row->course_form;
$status = $content_row->status;
?>
<!DOCTYPE html>
<html lang="en">
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>Admin - Sri Aravindar Arts & Science College </title>
<!-- Meta -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<!-- Favicon icon -->
<link rel="icon" href="assets/images/favicon.png" type="image/x-icon">
<!-- Google font-->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,800" rel="stylesheet">
<!-- Required Fremwork -->
<link rel="stylesheet" type="text/css" href="plugin/bootstrap/dist/css/bootstrap.min.css">
<!-- feather Awesome -->
<link rel="stylesheet" type="text/css" href="assets/icon/feather/css/feather.css">
<!-- Font Awesome -->
<link rel="stylesheet" type="text/css" href="assets/icon/font-awesome/css/font-awesome.min.css">
<!-- Style.css -->
<link rel="stylesheet" type="text/css" href="assets/css/style.css">
<link rel="stylesheet" type="text/css" href="assets/css/jquery.mCustomScrollbar.css">
<!-- jquery file upload Frame work -->
<link href="assets/pages/jquery.filer/css/jquery.filer.css" type="text/css" rel="stylesheet" />
<link href="assets/pages/jquery.filer/css/themes/jquery.filer-dragdropbox-theme.css" type="text/css" rel="stylesheet" />
<!-- animation nifty modal window effects css -->
<link rel="stylesheet" type="text/css" href="assets/css/component.css">
<link rel="stylesheet" type="text/css" href="assets/css/validation/tooltip-style.css">
<style type="text/css">
  .des {
    text-align: justify;
    font-size: 13px;
    line-height: 1.4;
    height: 190px;
  }
</style>
</head>
<!-- Menu sidebar static layout -->

<body>
  <div id="loaderid" class="spinner-container hideloader">
    <div class="loader"></div>
  </div>
  <!-- Pre-loader start -->
  <div class="theme-loader">
    <div class="ball-scale">
      <div class='contain'>
        <div class="ring">
          <div class="frame"></div>
        </div>
        <div class="ring">
          <div class="frame"></div>
        </div>
        <div class="ring">
          <div class="frame"></div>
        </div>
        <div class="ring">
          <div class="frame"></div>
        </div>
        <div class="ring">
          <div class="frame"></div>
        </div>
        <div class="ring">
          <div class="frame"></div>
        </div>
        <div class="ring">
          <div class="frame"></div>
        </div>
        <div class="ring">
          <div class="frame"></div>
        </div>
        <div class="ring">
          <div class="frame"></div>
        </div>
        <div class="ring">
          <div class="frame"></div>
        </div>
      </div>
    </div>
  </div>
  <!-- Pre-loader end -->
  <div id="pcoded" class="pcoded">
    <div class="pcoded-overlay-box"></div>
    <div class="pcoded-container navbar-wrapper">

      <?php include('static-header.php') ?>

      <div class="pcoded-main-container">
        <div class="pcoded-wrapper">

          <?php include('static-sidebar.php') ?>

          <div class="pcoded-content">
            <div class="pcoded-inner-content">
              <div class="main-body">
                <div class="page-wrapper">
                  <!-- Page-header start -->
                  <div class="page-header">
                    <div class="row align-items-end">
                      <div class="col-lg-8">
                        <div class="page-header-title">
                          <div class="d-inline">
                            <h4>Edit Sub Course</h4>
                            <span>You can edit The sub courses here!</span>
                          </div>
                        </div>
                      </div>
                      <div class="col-lg-4">
                        <div class="page-header-breadcrumb">
                          <ul class="breadcrumb-title">
                            <li class="breadcrumb-item" style="float: left;">
                              <a href="dashboard"> <i class="feather icon-home"></i> </a>
                            </li>
                            <li class="breadcrumb-item" style="float: left;"><a href="#!">Home Page</a>
                            </li>
                            <li class="breadcrumb-item" style="float: left;"><a href="#!">Sub Courses</a>
                            </li>
                          </ul>
                        </div>
                      </div>
                    </div>
                  </div>
                  <!-- Page-header end -->
                  <!-- Page body start -->
                  <div class="page-body">
                    <div class="card">
                      <form class="edit-form" id="editForm" enctype="multipart/form-data">
                        <div class="col-md-12">
                          <div class="card-block">
                            <input type="hidden" name="type" value="update">
                            <input type="hidden" name="subcourse_id" value="<?php echo $subcourse_id; ?>">
                            <div class="row">
                              <div class="col-md-6 form-group">
                                <label class=" col-form-label">Course Name </label>
                                <input type="text" class="form-control" id="course_name" name="course_name" value="<?php echo $subcourse_name ?>" required>
                              </div>
                              <div class="form-group col-md-6 ">
                                <label class="col-form-label">Main Course </label>
                                <select type="text" class="form-control" id="course_id" name="course_id" required>

                                </select>
                              </div>


                              <div class="col-md-6 form-group">
                                <label class=" col-form-label">Course Code </label>
                                <input type="text" class="form-control" id="course_code" name="course_code" value="<?php echo $course_code ?>" required>
                              </div>

                              <div class="col-md-6 form-group">
                                <label class=" col-form-label">Course Fee </label>
                                <input type="text" class="form-control" id="course_fee" name="course_fee" value="<?php echo $course_fee ?>" required>
                              </div>

                              <div class="col-md-6 form-group">
                                <label class=" col-form-label">Course Duration </label>
                                <input type="text" class="form-control" id="duration" name="duration" value="<?php echo $duration ?>" required>
                              </div>
                              <div class="col-md-6 form-group">
                                <label class=" col-form-label">Course Certificate </label>
                                <input type="text" class="form-control" id="certificate" name="certificate" value="<?php echo $certificate ?>" required>
                              </div>

                              <div class="col-md-6 form-group">
                                <label class=" col-form-label">Language </label>
                                <input type="text" class="form-control" id="language" name="language" value="<?php echo $language ?>" required>
                              </div>

                              <div class="col-md-6 form-group">
                                <label class=" col-form-label">Practical</label>
                                <input type="text" class="form-control" id="practical" name="practical" value="<?php echo $practical ?>" required>
                              </div>
                              <div class="col-md-6 form-group">
                                <label class=" col-form-label">Validity</label>
                                <input type="text" class="form-control" id="validity" name="validity" value="<?php echo $validity ?>" required>
                              </div>
                              <div class="col-md-6 form-group">
                                <label class=" col-form-label">Subject Content</label>
                                <input type="text" class="form-control" id="subject_content" name="subject_content" value="<?php echo $subject_content ?>" required>
                              </div>
                              <div class="col-md-6 form-group">
                                <label class=" col-form-label">Aims Content</label>
                                <textarea type="text" class="form-control" rows="5" id="aims" name="aims" required><?php echo $aims; ?></textarea>
                              </div>
                              <div class="col-md-6 form-group">
                                <label class=" col-form-label">Objective Content</label>
                                <textarea type="text" class="form-control" rows="5" id="objective" name="objective" required><?php echo $objective; ?></textarea>
                              </div>
                              <div class="col-md-6 form-group">
                                <label class=" col-form-label">Target Audience Content</label>
                                <textarea type="text" class="form-control" rows="5" id="target_audience" name="target_audience" required><?php echo $target_audience; ?></textarea>
                              </div>
                              <div class="col-md-6 form-group">
                                <label class=" col-form-label">Delegate Content</label>
                                <textarea type="text" class="form-control" id="delegate" rows="5" name="delegate" required><?php echo $delegate; ?></textarea>
                              </div>
                              <div class="form-group col-md-4 ">
                                <label class="col-form-label">Status</label>
                                <select class="form-control news_status" id="status" name="status">
                                  <option value="1" <?php if ($status == 1) echo 'selected'; ?>>Active</option>
                                  <option value="0" <?php if ($status == 0) echo 'selected'; ?>>Inactive</option>
                                </select>
                              </div>
                              <div class="col-md-4  form-group">
                                <label class="col-form-label">Change Image</label>
                                <input type="file" class="form-control" name="files">
                              </div>
                              <div class="col-md-4  form-group">
                                <label class="col-form-label">Change Course Booking Form</label>
                                <input type="file" class="form-control" name="cbf">
                              </div>
                              <div class="col-md-12">
                                <div class="form-group col-md-12">
                                  <label for="add_details">Edit Course Date</label>
                                  <div class="row">
                                    <?php
                                    $query2  = "SELECT * FROM tb1_coursedate WHERE course_subid='" . $subcourse_id . "' AND status=1 ORDER BY course_date ASC";
                                    $res_query2 = mysqli_query($conn, $query2);
                                    while ($query_row = mysqli_fetch_object($res_query2)) {
                                      $coursedate_id = $query_row->coursedate_id;
                                      $course_date = $query_row->course_date;
                                      $total_seats = $query_row->total_seats;
                                      $available_seats = $query_row->available_seats;
                                    ?>
                                      <div class="col-md-5 mt-2"><input type="date" class="form-control" name="course_date1" id="course_date<?php echo $coursedate_id ?>" value="<?php echo $course_date ?>"> </div>
                                      <div class="col-md-2 mt-2">
                                        <input type="text" class="form-control" name="total_seats1" id="total_seats<?php echo $coursedate_id ?>" value="<?php echo $total_seats ?>">
                                      </div>
                                      <div class="col-md-2  mt-2">
                                        <input type="text" class="form-control" name="avail_seats1" id="avail_seats<?php echo $coursedate_id ?>" value="<?php echo $available_seats ?>">
                                      </div>
                                      <div class="col-md-3  mt-2 text-right">
                                        <button type="button" class="btn btn-success c_edit" data-id="<?php echo $coursedate_id; ?>" id="c_edit"><i class="fa fa-check pl-1"></i>Update</button>
                                        <button type="button" class="btn btn-danger c_delete" id="c_delete" data-id="<?php echo $coursedate_id; ?>"><i class="fa fa-trash pl-1"></i> Detete</button>
                                      </div>
                                    <?php
                                    }
                                    ?>
                                  </div>
                                </div>
                              </div>
                              <div class="col-md-12">
                                <div class="form-group col-md-12" id="TextBoxesGroup1">
                                  <label for="add_details">Add Course Date</label>
                                  <div class="row" id="additionalTextBoxDiv">
                                    <div class="col-md-5"><input type="date" class="form-control" placeholder="Enter the title. Eg: color" name="course_date[]" id="course_date"> </div>
                                    <div class="col-md-3">
                                      <input type="text" class="form-control" placeholder="Enter Total Seats" name="total_seats[]" id="total_seats">
                                    </div>
                                    <div class="col-md-3">
                                      <input type="text" class="form-control" placeholder="Enter Available Seats " name="avail_seats[]" id="avail_seats">
                                    </div>
                                    <div class="col-md-1">
                                      <button type="button" class="btn btn-primary" id="addButton1" value="Add Button"><i class="fa fa-plus pl-1"></i></button>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                        <div class="col-md-12 text-center mb-5">
                          <button type="submit" class="btn btn-success text-bold" id="sub-btn" style="width: -webkit-fill-available;">Submit</button>
                        </div>
                      </form>
                      <div class="md-overlay"></div>
                    </div>
                  </div>
                  <!-- Page body end -->
                </div>
                <div id="styleSelector">

                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>


  <!-- Required Jquery -->
  <script type="text/javascript" src="plugin/jquery/dist/jquery.min.js"></script>
  <script type="text/javascript" src="plugin/jquery-ui/jquery-ui.min.js"></script>
  <script type="text/javascript" src="plugin/popper.js/dist/umd/popper.min.js"></script>
  <script type="text/javascript" src="plugin/bootstrap/dist/js/bootstrap.min.js"></script>
  <!-- jquery slimscroll js -->
  <script type="text/javascript" src="plugin/jquery-slimscroll/jquery.slimscroll.js"></script>
  <!-- modernizr js -->
  <script type="text/javascript" src="plugin/modernizr/modernizr.js"></script>
  <script type="text/javascript" src="plugin/modernizr/feature-detects/css-scrollbars.js"></script>
  <!-- <script type="text/javascript" src="assets/js/modal.js"></script> 
 -->
  <!-- modalEffects js nifty modal window effects -->
  <script type="text/javascript" src="assets/js/modalEffects.js"></script>
  <script type="text/javascript" src="assets/js/classie.js"></script>
  <!-- jquery file upload js -->
  <script src="assets/pages/jquery.filer/js/jquery.filer.min.js"></script>
  <script src="assets/pages/filer/custom-filer.js" type="text/javascript"></script>
  <script src="assets/pages/filer/jquery.fileuploads.init.js" type="text/javascript"></script>
  <!-- Custom js -->
  <script src="assets/js/pcoded.min.js"></script>
  <script src="assets/js/vartical-layout.min.js"></script>
  <script src="assets/js/sweetalert.min.js"></script>
  <script src="assets/js/jquery.mCustomScrollbar.concat.min.js"></script>
  <script type="text/javascript" src="assets/js/script.js"></script>
  <script src="assets/validation/jquery-validation/jquery.validate.min.js"></script>
  <script src="assets/css/validation/form-validation.js"></script>

  <script type="text/javascript">
    // initialize validate plugin on the form
    $("#editForm").validate({
      errorPlacement: function(error, element) {
        var ele = $(element),
          err = $(error),
          msg = err.text();
        if (msg != null && msg !== "") {
          ele.tooltipster('content', msg);
          ele.tooltipster('open'); //open only if the error message is not blank. By default jquery-validate will return a label with no actual text in it so we have to check the innerHTML.
        }
      },
      unhighlight: function(element, errorClass, validClass) {
        $(element).removeClass(errorClass).addClass(validClass).tooltipster('close');
      },

      submitHandler: function(form) { // for demo
        var form = $('#editForm')[0];
        var formData = new FormData(form);
        event.preventDefault();
        $("#sub-btn").attr("disabled", true);
        $.ajax({
          type: 'POST',
          url: 'ajax/subcourse_action',
          processData: false,
          contentType: false,
          dataType: "json",
          data: formData,
          success: function(data) {
            if (data == 'done') {
              swal({
                title: 'Updated Successfully!',
                text: "Course has been successfully Updated",
                icon: 'success',
                confirmButtonColor: '#3f51b5',
                closeOnEsc: false,
                closeOnClickOutside: false,
                buttons: {
                  confirm: {
                    text: "Okay",
                    value: true,
                    visible: true,
                    className: "btn btn-primary",
                    closeModal: true
                  }
                }
              }).then((value) => {
                if (value == true) {
                  location.reload();
                }
              });
            }
          },
          error: function(data) {
            swal({
              title: 'Internal Sever Error!',
              text: "Try again",
              icon: 'warning',
              closeOnEsc: false,
              closeOnClickOutside: false,
            })
          },
        });
      }
    });
  </script>

  <script type="text/javascript">
    $(document).ready(function() {
      var course_id = '<?php echo $course_id; ?>';
      $('#course_id').empty();
      $.ajax({
        url: "ajax/get_editmaincourse.php",
        type: "POST",
        data: {
          "course_id": course_id
        },
        success: function(data) {
          $('#course_id').append(data);
        }
      })
    });
  </script>

  <script type="text/javascript">
    $(".c_edit").click(function(e) {
      var coursedate_id = $(this).attr('data-id');
      var course_date1 = $('#course_date' + coursedate_id).val();
      var avail_seats1 = $('#avail_seats' + coursedate_id).val();
      var total_seats1 = $('#total_seats' + coursedate_id).val();
      var type = "coursedate_update";
      swal({
        title: 'Are you sure?',
        text: "You want to update this course date?",
        icon: 'warning',
        showCancelButton: true,
        confirmButtonColor: '#3f51b5',
        cancelButtonColor: '#ff4081',
        confirmButtonText: 'Great ',
        closeOnEsc: false,
        closeOnClickOutside: false,
        buttons: {
          cancel: {
            text: "No",
            value: null,
            visible: true,
            className: "btn btn-danger",
            closeModal: true,
          },
          confirm: {
            text: "Yes",
            value: true,
            visible: true,
            className: "btn btn-primary",
            closeModal: true
          }
        }
      }).then((value) => {
        if (value == true) {
          $.ajax({
            url: "ajax/subcourse_action.php",
            type: "POST",
            data: {
              "coursedate_id": coursedate_id,
              "type": type,
              "course_date1": course_date1,
              "avail_seats1": avail_seats1,
              "total_seats1": total_seats1
            },
            dataType: "json",
            success: function(data) {
              if (data == 'done') {
                swal({
                  title: "Successfully Updated!",
                  text: "The course date has been successfully updated.",
                  type: "success",
                  icon: 'success',
                  confirmButtonColor: '#3f51b5',
                  confirmButtonText: 'OK ',
                  closeOnEsc: false,
                  closeOnClickOutside: false,
                  buttons: {
                    confirm: {
                      text: "Okay",
                      value: true,
                      visible: true,
                      className: "btn btn-primary",
                      closeModal: true
                    }
                  }
                }).then((value) => {
                  if (value == true) {
                    location.reload();
                  }
                })
              } else {
                swal("Internal Server Error!", "Please try again", "error");
              }
            },
            error: function(xhr, ajaxOptions, thrownError) {
              swal("Internal Server Error!", "Please try again", "error");
            }
          });

        } else {
          // swal(`The returned value is: ${value}`);
        }
      });
    });
  </script>

  <script type="text/javascript">
    $(document).ready(function() {
      var counter1 = 1;
      $("#addButton1").click(function() {

        var newTextBoxDiv1 = $(document.createElement('div'))
          .attr("id", 'TextBoxDiv1' + counter1).attr("class", 'TextBoxDiv1');
        if (counter1 > 15) {
          swal({
            title: 'Additional fields Exceed!',
            text: "15 additional fields only allowed",
            icon: 'warning',
            confirmButtonColor: '#3f51b5',
            closeOnEsc: false,
            closeOnClickOutside: false,
          })
        } else {
          newTextBoxDiv1.after().html('<div class="row pt-3"><div class="col-md-3"><input type="date" class="form-control" placeholder="Enter the title. Eg: color" name="course_date[]" id="course_date' + counter1 + '"> </div><div class="col-md-3"><input type="text" class="form-control" placeholder="Enter Total Seats" name="total_seats[]" id="total_seats' + counter1 + '"> </div><div class="col-md-3"><input type="text" class="form-control" placeholder="Enter Available Seats " name="avail_seats[]" id="avail_seats' + counter1 + '"></div><div class="col-md-3"><button class="btn btn-danger removeButton1" name="button" type="button"><i class="fa fa-trash"></i>Delete</button></div></div>');
          newTextBoxDiv1.appendTo("#TextBoxesGroup1");
          counter1++;
        }
      });
      $("body").on("click", ".removeButton1", function() {
        $(this).closest('.TextBoxDiv1').remove();
        counter1--;
      });
    });
  </script>
  <script type="text/javascript">
    $(".c_delete").click(function(e) {
      var coursedate_id = $(this).attr('data-id');
      var type = "coursedate_delete";
      swal({
        title: 'Are you sure?',
        text: "You want to delete this course date?",
        icon: 'warning',
        showCancelButton: true,
        confirmButtonColor: '#3f51b5',
        cancelButtonColor: '#ff4081',
        confirmButtonText: 'Great ',
        closeOnEsc: false,
        closeOnClickOutside: false,
        buttons: {
          cancel: {
            text: "No",
            value: null,
            visible: true,
            className: "btn btn-danger",
            closeModal: true,
          },
          confirm: {
            text: "Yes",
            value: true,
            visible: true,
            className: "btn btn-primary",
            closeModal: true
          }
        }
      }).then((value) => {
        if (value == true) {
          $.ajax({
            url: "ajax/subcourse_action.php",
            type: "POST",
            data: {
              "coursedate_id": coursedate_id,
              "type": type
            },
            dataType: "json",
            success: function(data) {
              if (data == 'done') {
                swal({
                  title: "Successfully Deleted!",
                  text: "The course date has been successfully deleted.",
                  type: "success",
                  icon: 'success',
                  confirmButtonColor: '#3f51b5',
                  confirmButtonText: 'OK ',
                  closeOnEsc: false,
                  closeOnClickOutside: false,
                  buttons: {
                    confirm: {
                      text: "Okay",
                      value: true,
                      visible: true,
                      className: "btn btn-primary",
                      closeModal: true
                    }
                  }
                }).then((value) => {
                  if (value == true) {
                    location.reload();
                  }
                })
              } else {
                swal("Internal Server Error!", "Please try again", "error");
              }
            },
            error: function(xhr, ajaxOptions, thrownError) {
              swal("Internal Server Error!", "Please try again", "error");
            }
          });

        } else {
          // swal(`The returned value is: ${value}`);
        }
      });
    });
  </script>
</body>

</html>

Zerion Mini Shell 1.0