Guest User

Untitled

a guest
Oct 20th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. //////////////////////////////////////////// JS method ///////////////////////////////////
  2. setDetails:function(id){
  3. var view = M.ViewManager.getViewById(id);
  4. var courseName = M.ViewManager.getView(view,'courseNameLabel').value;
  5. var searchString = this.get('searchString');
  6.  
  7. M.Request.init({
  8. url:"/mysql/database.php",
  9. isJSON: YES,
  10. data:{
  11. functionID:3,
  12. course: courseName,
  13. byDate: searchString
  14. },
  15. onSuccess:function(data){
  16. console.log(data);
  17. },
  18.  
  19. }).send();
  20. //this.showDetails();
  21. },
  22.  
  23.  
  24. ///////////////////////////////////////////////////// php method ////////////////////////////////////////
  25.  
  26. function getCoursesDetails($course,$date)
  27. {
  28. $query = "SELECT course.courseID, course.courseName, course_room.roomID,course_room.day_date, course_room.start_time, course_room.end_time, prof.firstName, prof.lastName, prof.profID FROM course, course_room, prof
  29. WHERE course_room.courseID = course.courseID AND course.courseName = $course AND course_room.day_date = $date AND prof.profID = course.profID";
  30. $result = mysql_query($query);
  31. $arr = array();
  32. while($record = mysql_fetch_assoc($result))
  33. {
  34. $arr[] = array ('courseID' => $record['courseID'],
  35. 'courseName' => $record['courseName'],
  36. 'roomID' => $record['roomID'],
  37. 'date' => $record['day_date'],
  38. 'starting' => $record ['start_time'],
  39. 'ending' => $record['end_time'],
  40. 'firstName' => $record['firstName'],
  41. 'lastName' => $record['lastName']);
  42. }
  43. echo json_encode($arr);
  44. }
  45.  
  46. ////////////////////////////////////////////// Model //////////////////////////////////////////////
  47. roject.courseDetails = M.Model.create({
  48.  
  49. __name__: 'courseDetails',
  50.  
  51. usesValidation:NO,
  52.  
  53. courseID: M.Model.attr('String', {
  54. isRequired: YES,
  55. defaultValue: ''
  56. }),
  57.  
  58. courseName: M.Model.attr('String', {
  59. isRequired: YES,
  60. defaultValue: ''
  61. }),
  62.  
  63. roomID: M.Model.attr('String', {
  64. isRequired: YES,
  65. defaultValue: ''
  66. }),
  67.  
  68. date: M.Model.attr('String',{
  69. isRequired: YES,
  70. defaultValue:''
  71. }),
  72.  
  73. starting: M.Model.attr('String',{
  74. isRequired: YES,
  75. defaultValue:''
  76. }),
  77.  
  78. ending: M.Model.attr('String',{
  79. isRequired: YES,
  80. defaultValue:''
  81. }),
  82.  
  83. firstName: M.Model.attr('String',{
  84. isRequired: YES,
  85. defaultValue:''
  86. }),
  87.  
  88. lastName: M.Model.attr('String',{
  89. isRequired:YES,
  90. defaultValue:''
  91. })
  92.  
  93. }, M.DataProviderLocalStorage);
  94.  
  95.  
  96. ////////////////////////////////////////// result returned from the database ///////////////////////
  97.  
  98. {"courseID":"WWI10SCC","courseName":"Programming","roomID":"003 A","date":"2011-03-01","starting":"10:00:00","ending":"12:30:00","firstName":"Ralf","lastName":"Mark"}
Add Comment
Please, Sign In to add comment