Esempio n. 1
0
 public function loadTableData($netId, $yearTerm = null)
 {
     require_once "BYU/Common/Registration/Enrollment.php";
     require_once "BYU/Common/RestClient/RestClient.php";
     $connection = $this->getDataSource()->config;
     //get the information from the database config
     $api_key = $connection['apiKey'];
     $shared_secret = $connection['sharedSecret'];
     $rest = new BYU\Common\RestClient('json', null, null, false);
     //rest client for control dates
     $user = new BYU\Common\Enrollment($api_key, $shared_secret, $rest);
     //This if statement determines if a yearTerm has been specified. If not, it gets the current yearTerm from a method
     if ($yearTerm == null) {
         $yearTerm = $this->ControlDate->currentYearTerm();
     }
     $schedule = $user->getInstructorScheduleByNetID($netId, $yearTerm, true);
     //this is formatted according to the specifications for DataTables
     $table_data = array("sEcho" => 0, "iTotalRecords" => count($schedule['class_list']), "iTotalDisplayRecords" => count($schedule['class_list']), "aaData" => array());
     //get data out from instructor data
     //$reportUrl = $this->Html->url(array('action' => 'stats_page')); //update with real URL info
     foreach ($schedule['class_list'] as $course) {
         $courseName = $course['subject_area'] + (string) $course['catalog_number'];
         $row = array($course['subject_area'] . " " . strval($course['catalog_number']), $course['section_number'], $schedule["sort_name"], array(24, 111), 1, true, rand());
         $table_data['aaData'][] = $row;
     }
     return json_encode($table_data);
 }
 public function loadTableData($netId, $yearTerm = null, $dataSet)
 {
     require_once "BYU/Common/Registration/Enrollment.php";
     require_once "BYU/Common/RestClient/RestClient.php";
     $connection = $this->getDataSource()->config;
     //get the information from the database config
     $api_key = $connection['apiKey'];
     $shared_secret = $connection['sharedSecret'];
     $rest = new BYU\Common\RestClient('json', null, null, false);
     //rest client for control dates
     $user = new BYU\Common\Enrollment($api_key, $shared_secret, $rest);
     //This if statement determines if a yearTerm has been specified. If not, it gets the current yearTerm from a method
     if ($yearTerm == null) {
         $currentDate = date('Ymd');
         $url = "https://ws.byu.edu/rest/v1/academic/controls/controldatesws/asofdate/" . $currentDate . "/current_yyt";
         $dateInfo = $rest->makeRequest('GET', $url);
         $yearTerm = $dateInfo['ControldateswsService']['response']['date_list'][0]['year_term'];
     }
     $schedule = $user->getInstructorScheduleByNetID($netId, $yearTerm, true);
     //Everything below formats the data according to the specifications for DataTables. It must go in this way.
     $table_data = array("sEcho" => 0, "iTotalRecords" => count($schedule['class_list']), "iTotalDisplayRecords" => count($schedule['class_list']), "aaData" => array());
     //get data out from instructor data
     $testData = array("Iglesias, Enrique", "Montoya, Inigo", "Quixote, Don");
     $administrators = "";
     for ($i = 0; $i < count($testData); $i++) {
         if ($i < count($testData) - 1) {
             $administrators = $administrators . $testData[$i] . "; ";
         } elseif ($i == count($testData) - 1) {
             $administrators = $administrators . $testData[$i];
         }
     }
     foreach ($schedule['class_list'] as $course) {
         $courseName = $course['subject_area'] + (string) $course['catalog_number'];
         $row = array("", "Spanish", $administrators, array("tthomas8", "gds2", "devingd"), array("tthomas8", "gds2", "devingd"), array("Alvarez Zavala, Maria de las Fuentes ", "Potter, Harry", "Bourne, Jason"), array("Norris, Chuck", "Solo, Han", "Parker, Peter"), rand());
         $table_data['aaData'][] = $row;
     }
     return json_encode($table_data);
 }