Ejemplo n.º 1
0
 public function execute()
 {
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     // Select all cancelled apps for the given term
     $db = new PHPWS_DB('hms_new_application');
     $db->addWhere('cancelled', 1);
     $db->addWhere('term', $this->term);
     $results = $db->select();
     // Initialize storage for processed rows
     $this->rows = array();
     // Get friendly cancellation reasons from HousingApplication
     $reasons = HousingApplication::getCancellationReasons();
     // Process and store each result
     foreach ($results as $app) {
         $row = array();
         $row['bannerId'] = $app['banner_id'];
         $row['username'] = $app['username'];
         $row['gender'] = HMS_Util::formatGender($app['gender']);
         $row['application_term'] = $app['application_term'];
         $row['student_type'] = $app['student_type'];
         $row['cancelled_reason'] = $reasons[$app['cancelled_reason']];
         $row['cancelled_on'] = HMS_Util::get_long_date($app['cancelled_on']);
         $row['cancelled_by'] = $app['cancelled_by'];
         $this->rows[] = $row;
     }
 }
Ejemplo n.º 2
0
 public function getRowTags()
 {
     // Get the damage types, if we don't already have them
     if (!isset(self::$damageTypes)) {
         self::$damageTypes = DamageTypeFactory::getDamageTypeAssoc();
     }
     $row = array();
     $row['CATEGORY'] = $row['DAMAGE_TYPE'] = self::$damageTypes[$this->getDamageType()]['category'];
     $row['DESCRIPTION'] = self::$damageTypes[$this->getDamageType()]['description'];
     $row['SIDE'] = $this->getSide();
     $row['TERM'] = Term::toString($this->getTerm());
     $row['REPORTED_ON'] = HMS_Util::get_long_date($this->getReportedOn());
     return $row;
 }
Ejemplo n.º 3
0
 public function applicantsReport()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     $term = Term::getSelectedTerm();
     $rlc_list = HMS_Learning_Community::getRlcList();
     $student = StudentFactory::getStudentByUsername($this->username, $this->term);
     $application_date = isset($this->date_submitted) ? HMS_Util::get_long_date($this->date_submitted) : 'Error with the submission date';
     $roomie = null;
     if (HMS_Roommate::has_confirmed_roommate($this->username, $term)) {
         $roomie = HMS_Roommate::get_Confirmed_roommate($this->username, $term);
     } elseif (HMS_Roommate::has_roommate_request($this->username, $term)) {
         $roomie = HMS_Roommate::get_unconfirmed_roommate($this->username, $term) . ' *pending* ';
     }
     $row = array();
     $row['last_name'] = $student->getLastName();
     $row['first_name'] = $student->getFirstName();
     $row['middle_name'] = $student->getMiddleName();
     $row['gender'] = $student->getPrintableGender();
     if ($roomie instanceof Student) {
         $row['roommate'] = $roomie->getUsername();
     } else {
         $row['roommate'] = '';
     }
     $row['email'] = $student->getUsername() . '@appstate.edu';
     $row['first_chocie'] = $rlc_list[$this->getFirstChoice()];
     $row['second_choice'] = $rlc_list[$this->getSecondChoice()];
     $row['third_choice'] = $rlc_list[$this->getThirdChoice()];
     $row['application_date'] = $application_date;
     $row['denied'] = isset($this->denied) && $this->denied == 0 ? 'no' : 'yes';
     return $row;
 }
Ejemplo n.º 4
0
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'view_rlc_applications')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to view rlc applications');
     }
     $term = Term::getSelectedTerm();
     $db = new PHPWS_DB('hms_learning_communities');
     $db->addColumn('community_name');
     $db->addWhere('id', $_REQUEST['rlc_list']);
     $title = $db->select('one');
     $filename = $title . '-applications-' . date('Ymd') . ".csv";
     // setup the title and headings
     $buffer = $title . "\n";
     $buffer .= '"last_name","first_name","middle_name","gender","roommate","email","second_choice","third_choice","major","application_date","denied"' . "\n";
     // get the userlist
     $db = new PHPWS_DB('hms_learning_community_applications');
     $db->addColumn('username');
     $db->addColumn('rlc_second_choice_id');
     $db->addColumn('rlc_third_choice_id');
     $db->addColumn('date_submitted');
     $db->addWhere('rlc_first_choice_id', $_REQUEST['rlc_list']);
     $db->addWhere('term', Term::getSelectedTerm());
     $db->addOrder('denied asc');
     //$db->addWhere('denied', 0); // Only show non-denied applications
     $users = $db->select();
     foreach ($users as $user) {
         PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
         $roomie = NULL;
         $roomie = HMS_Roommate::has_confirmed_roommate($user['username'], $term) ? HMS_Roommate::get_Confirmed_roommate($user['username'], $term) : NULL;
         if ($roomie == NULL) {
             $roomie = HMS_Roommate::has_roommate_request($user['username'], $term) ? HMS_Roommate::get_unconfirmed_roommate($user['username'], $term) . ' *pending* ' : NULL;
         }
         $student = StudentFactory::getStudentByUsername($user['username'], Term::getSelectedTerm());
         $buffer .= '"' . $student->getLastName() . '",';
         $buffer .= '"' . $student->getFirstName() . '",';
         $buffer .= '"' . $student->getMiddleName() . '",';
         $buffer .= '"' . $student->getPrintableGender() . '",';
         if ($roomie != NULL) {
             $buffer .= '"' . $roomie->getFullName() . '",';
         } else {
             $buffer .= '"",';
         }
         $buffer .= '"' . $student->getUsername() . '@appstate.edu' . '",';
         if (isset($user['rlc_second_choice_id'])) {
             $db = new PHPWS_DB('hms_learning_communities');
             $db->addColumn('community_name');
             $db->addWhere('id', $user['rlc_second_choice_id']);
             $result = $db->select('one');
             if (!PHPWS_Error::logIfError($result)) {
                 $buffer .= '"' . $result . '",';
             }
         } else {
             $buffer .= '"",';
         }
         if (isset($user['rlc_third_choice_id'])) {
             $db = new PHPWS_DB('hms_learning_communities');
             $db->addColumn('community_name');
             $db->addWhere('id', $user['rlc_third_choice_id']);
             $result = $db->select('one');
             if (!PHPWS_Error::logIfError($result)) {
                 $buffer .= '"' . $result . '",';
             }
         } else {
             $buffer .= '"",';
         }
         //Major for this user, N/A for now
         $buffer .= '"N/A",';
         //Application Date
         if (isset($user['date_submitted'])) {
             PHPWS_Core::initModClass('hms', 'HMS_Util.php');
             $buffer .= '"' . HMS_Util::get_long_date($user['date_submitted']) . '",';
         } else {
             $buffer .= '"Error with the submission Date",';
         }
         //Denied
         $buffer .= isset($user['denied']) && $user['denied'] == 1 ? '"yes"' : '"no"';
         $buffer .= "\n";
     }
     //HERES THE QUERY:
     //select hms_learning_community_applications.user_id, date_submitted, rlc_first_choice.abbreviation as first_choice, rlc_second_choice.abbreviation as second_choice, rlc_third_choice.abbreviation as third_choice FROM (SELECT hms_learning_community_applications.user_id, hms_learning_communities.abbreviation FROM hms_learning_communities,hms_learning_community_applications WHERE hms_learning_communities.id = hms_learning_community_applications.rlc_first_choice_id) as rlc_first_choice, (SELECT hms_learning_community_applications.user_id, hms_learning_communities.abbreviation FROM hms_learning_communities,hms_learning_community_applications WHERE hms_learning_communities.id = hms_learning_community_applications.rlc_second_choice_id) as rlc_second_choice, (SELECT hms_learning_community_applications.user_id, hms_learning_communities.abbreviation FROM hms_learning_communities,hms_learning_community_applications WHERE hms_learning_communities.id = hms_learning_community_applications.rlc_third_choice_id) as rlc_third_choice, hms_learning_community_applications WHERE rlc_first_choice.user_id = hms_learning_community_applications.user_id AND rlc_second_choice.user_id = hms_learning_community_applications.user_id AND rlc_third_choice.user_id = hms_learning_community_applications.user_id;
     //Download file
     if (ob_get_contents()) {
         print 'Some data has already been output, can\'t send file';
     }
     if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
         header('Content-Type: application/force-download');
     } else {
         header('Content-Type: application/octet-stream');
     }
     if (headers_sent()) {
         print 'Some data has already been output to browser, can\'t send file';
     }
     header('Content-Length: ' . strlen($buffer));
     header('Content-disposition: attachment; filename="' . $filename . '"');
     echo $buffer;
     die;
 }
Ejemplo n.º 5
0
 /**
  * Returns the fields for this HousingApplication parent class. Usually called by overriding methods in subclasses (e.g. SummerApplication).
  *
  * @return Array Array of fields for this HousingApplication.
  */
 protected function unassignedStudentsFields()
 {
     $fields = array();
     $fields['banner_id'] = $this->getBannerId();
     $fields['username'] = $this->getUsername();
     $fields['gender'] = HMS_Util::formatGender($this->getGender());
     $fields['application_term'] = Term::toString($this->getApplicationTerm(), true);
     $fields['student_type'] = HMS_Util::formatType($this->getStudentType());
     $fields['meal_plan'] = HMS_Util::formatMealOption($this->getMealPlan());
     $fields['created_on'] = HMS_Util::get_long_date($this->getCreatedOn());
     $roommate = HMS_Roommate::get_confirmed_roommate($this->getUsername(), $this->getTerm());
     if (!is_null($roommate)) {
         $fields['roommate'] = $roommate->getFullName();
         $fields['roommate_id'] = $roommate->getBannerId();
     } else {
         $fields['roommate'] = '';
         $fields['roommate_id'] = '';
     }
     return $fields;
 }