Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. <select class="form-control" style="width:115px" name="schoolyearData" id="schoolyearData">
  2. <?php foreach ($schoolyearData as $schoolyear)
  3. {
  4. ?>
  5. <option value="<?php echo $schoolyear['schoolyear_id']; ?>"> <?php echo $schoolyear['schoolyear_date']; ?> </option>
  6.  
  7. <?php
  8. }
  9. ?>
  10. </select>
  11.  
  12. var manageRegistrationTable;
  13.  
  14. $(document).ready(function() {
  15.  
  16. manageRegistrationTable = $("#manageRegistrationTable").DataTable({
  17. 'ajax' : 'registration/fetchRegistrationData',
  18. 'order' : []
  19.  
  20. });
  21. });
  22.  
  23. public function fetchRegistrationData($registrationId = null)
  24. {
  25. if($registrationId) {
  26. $registrationData = $this->model_registration->fetchRegistrationData($registrationId);
  27. echo json_encode($registrationData); // USED FOR EDITING
  28. }
  29. else {
  30. $registrationData = $this->model_registration->fetchRegistrationData();
  31. $result = array('data' => array());
  32.  
  33. $x = 1;
  34. foreach ($registrationData as $key => $value) {
  35.  
  36. $button = '<!-- Single button -->
  37. <div class="btn-group">
  38. <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  39. Action <span class="caret"></span>
  40. </button>
  41. <ul class="dropdown-menu">
  42. <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>
  43. <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>
  44. <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>
  45. </ul>
  46. </div>';
  47.  
  48. $photo = ' <img src="../'.$value['student_image'].'" alt="Photo" class="img-circle candidate-photo" width="95" height="95"/>';
  49.  
  50. $result['data'][$key] = array(
  51. $x,
  52. $photo,
  53. $value['student_lastname'],
  54. $value['student_firstname'],
  55. $value['student_middlename'],
  56. $value['schoolyear_date'],
  57. $value['gradelevel_name'],
  58. $value['section_name'],
  59. $value['registration_dateadded'],
  60. $button
  61. );
  62. $x++;
  63. } // /froeach
  64.  
  65. echo json_encode($result);
  66. } // /else
  67. }
  68.  
  69. public function fetchRegistrationData($registrationId = null)
  70. {
  71. if($registrationId) {
  72. $sql = "SELECT * FROM tbl_registration
  73. INNER JOIN tbl_student ON tbl_student.student_id = tbl_registration.student_id
  74. INNER JOIN tbl_schoolyear ON tbl_schoolyear.schoolyear_id = tbl_registration.schoolyear_id
  75. INNER JOIN tbl_gradelevel ON tbl_gradelevel.gradelevel_id = tbl_registration.gradelevel_id
  76. INNER JOIN tbl_section ON tbl_section.section_id = tbl_registration.section_id WHERE registration_id = ?";
  77. $query = $this->db->query($sql, array($registrationId));
  78. return $query->row_array();
  79.  
  80. // USED FOR EDIT
  81. }
  82. else {
  83. $sql = "SELECT * FROM tbl_registration
  84. INNER JOIN tbl_student ON tbl_student.student_id = tbl_registration.student_id
  85. INNER JOIN tbl_schoolyear ON tbl_schoolyear.schoolyear_id = tbl_registration.schoolyear_id
  86. INNER JOIN tbl_gradelevel ON tbl_gradelevel.gradelevel_id = tbl_registration.gradelevel_id
  87. INNER JOIN tbl_section ON tbl_section.section_id = tbl_registration.section_id ORDER BY schoolyear_date DESC";
  88. $query = $this->db->query($sql);
  89. return $query->result_array();
  90. }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement