Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <select class="form-control" style="width:115px" name="schoolyearData" id="schoolyearData">
- <?php foreach ($schoolyearData as $schoolyear)
- {
- ?>
- <option value="<?php echo $schoolyear['schoolyear_id']; ?>"> <?php echo $schoolyear['schoolyear_date']; ?> </option>
- <?php
- }
- ?>
- </select>
- var manageRegistrationTable;
- $(document).ready(function() {
- manageRegistrationTable = $("#manageRegistrationTable").DataTable({
- 'ajax' : 'registration/fetchRegistrationData',
- 'order' : []
- });
- });
- public function fetchRegistrationData($registrationId = null)
- {
- if($registrationId) {
- $registrationData = $this->model_registration->fetchRegistrationData($registrationId);
- echo json_encode($registrationData); // USED FOR EDITING
- }
- else {
- $registrationData = $this->model_registration->fetchRegistrationData();
- $result = array('data' => array());
- $x = 1;
- foreach ($registrationData as $key => $value) {
- $button = '<!-- Single button -->
- <div class="btn-group">
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
- Action <span class="caret"></span>
- </button>
- <ul class="dropdown-menu">
- <li><a type="button" class="btn btn-default" style="text-align:left;" data-toggle="modal" data-target="#viewRegistraionModal" onclick="viewRegistration('.$value['registration_id'].')"> <i class="glyphicon glyphicon-user"></i> View</a></li>
- <li><a type="button" class="btn btn-default" style="text-align:left;" data-toggle="modal" data-target="#updateRegistrationModal" onclick="editRegistration('.$value['registration_id'].')"> <i class="glyphicon glyphicon-edit"></i> Edit</a></li>
- <li><a type="button" class="btn btn-default" style="text-align:left;" data-toggle="modal" data-target="#removeRegistrationModal" onclick="removeRegistration('.$value['registration_id'].')"> <i class="glyphicon glyphicon-trash"></i> Remove</a></li>
- </ul>
- </div>';
- $photo = ' <img src="../'.$value['student_image'].'" alt="Photo" class="img-circle candidate-photo" width="95" height="95"/>';
- $result['data'][$key] = array(
- $x,
- $photo,
- $value['student_lastname'],
- $value['student_firstname'],
- $value['student_middlename'],
- $value['schoolyear_date'],
- $value['gradelevel_name'],
- $value['section_name'],
- $value['registration_dateadded'],
- $button
- );
- $x++;
- } // /froeach
- echo json_encode($result);
- } // /else
- }
- public function fetchRegistrationData($registrationId = null)
- {
- if($registrationId) {
- $sql = "SELECT * FROM tbl_registration
- INNER JOIN tbl_student ON tbl_student.student_id = tbl_registration.student_id
- INNER JOIN tbl_schoolyear ON tbl_schoolyear.schoolyear_id = tbl_registration.schoolyear_id
- INNER JOIN tbl_gradelevel ON tbl_gradelevel.gradelevel_id = tbl_registration.gradelevel_id
- INNER JOIN tbl_section ON tbl_section.section_id = tbl_registration.section_id WHERE registration_id = ?";
- $query = $this->db->query($sql, array($registrationId));
- return $query->row_array();
- // USED FOR EDIT
- }
- else {
- $sql = "SELECT * FROM tbl_registration
- INNER JOIN tbl_student ON tbl_student.student_id = tbl_registration.student_id
- INNER JOIN tbl_schoolyear ON tbl_schoolyear.schoolyear_id = tbl_registration.schoolyear_id
- INNER JOIN tbl_gradelevel ON tbl_gradelevel.gradelevel_id = tbl_registration.gradelevel_id
- INNER JOIN tbl_section ON tbl_section.section_id = tbl_registration.section_id ORDER BY schoolyear_date DESC";
- $query = $this->db->query($sql);
- return $query->result_array();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement