Beispiel #1
0
 /**
  * Report lists rooms in each residence hall that are still available, along with
  * the available beds in the room.  Also, show the number of beds allocated to the
  * lotter for each residence hall.
  *
  */
 public static function reappAvailability()
 {
     $term = Term::getSelectedTerm();
     // Available rooms in each residence hall.
     $db = new PHPWS_DB('hms_bed');
     $db->addJoin('LEFT', 'hms_bed', 'hms_room', 'room_id', 'id');
     $db->addJoin('LEFT', 'hms_room', 'hms_floor', 'floor_id', 'id');
     $db->addJoin('LEFT', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id');
     //$db->addWhere('hms_bed.ra_bed', 0);
     $db->addWhere('hms_room.private', 0);
     $db->addWhere('hms_room.overflow', 0);
     $db->addWhere('hms_room.reserved', 0);
     $db->addWhere('hms_room.offline', 0);
     $db->addWhere('hms_bed.term', $term);
     $db->addColumn('hms_room.room_number');
     $db->addColumn('hms_bed.bed_letter', null, null, True);
     $db->addColumn('hms_residence_hall.hall_name');
     $db->addGroupBy('hms_residence_hall.hall_name');
     $db->addGroupBy('hms_room.room_number');
     $db->addOrder('hms_residence_hall.hall_name');
     $availRooms = $db->select();
     // Allocated beds for lottery.
     $db = new PHPWS_DB('hms_bed');
     $db->addJoin('LEFT', 'hms_bed', 'hms_room', 'room_id', 'id');
     $db->addJoin('LEFT', 'hms_room', 'hms_floor', 'floor_id', 'id');
     $db->addJoin('LEFT', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id');
     $db->addJoin('RIGHT', 'hms_bed', 'hms_lottery_reservation', 'id', 'bed_id');
     $db->addWhere('hms_lottery_reservation.term', $term);
     $db->addColumn('hms_residence_hall.hall_name');
     $db->addColumn('hms_bed.id', null, null, True);
     $db->addGroupBy('hms_residence_hall.hall_name');
     $db->setIndexBy('hall_name');
     $lotteryBeds = $db->select();
     $tpl = new PHPWS_Template('hms');
     $tpl->setFile('admin/reports/reapp_availability.tpl');
     //
     // "The parent row must be parsed after the child rows."
     // Preload currHall with first residence hall name
     $currHall = $availRooms[0]['hall_name'];
     foreach ($availRooms as $row) {
         // Change halls, create new block.
         if ($currHall != $row['hall_name'] || $currHall == null) {
             $tpl->setCurrentBlock('halls');
             // Get allocated beds for the residence hall.
             $lottCount = isset($lotteryBeds[$currHall]['count']) ? $lotteryBeds[$currHall]['count'] : 0;
             $tpl->setData(array('HALL_NAME' => $currHall, 'LOTTERY_BEDS' => $lottCount));
             $tpl->parseCurrentBlock();
             $currHall = $row['hall_name'];
         }
         // Add room to residence hall template block.
         $tpl->setCurrentBlock('rooms');
         $tpl->setData(array('ROOM_NUM' => $row['room_number'], 'BED_COUNT' => $row['count']));
         $tpl->parseCurrentBlock();
     }
     // Get last residence hall. Can't parse parent before child with template class.
     $tpl->setCurrentBlock('halls');
     $tpl->setData(array('HALL_NAME' => $currHall));
     $tpl->parseCurrentBlock();
     return $tpl->get();
 }
 public function execute()
 {
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     $this->reasons = HousingApplication::getCancellationReasons();
     // All students
     $db = new PHPWS_DB('hms_new_application');
     $db->addColumn('cancelled_reason');
     $db->addColumn('id', null, 'ount', true);
     $db->addWhere('term', $this->getTerm());
     $db->addWhere('cancelled', 1);
     $db->addGroupBy('cancelled_reason');
     $this->reasonCounts = $db->select('assoc');
     // Freshmen
     $db = new PHPWS_DB('hms_new_application');
     $db->addColumn('cancelled_reason');
     $db->addColumn('id', null, 'count', true);
     $db->addWhere('term', $this->getTerm());
     $db->addWhere('cancelled', 1);
     $db->addWhere('student_type', TYPE_FRESHMEN);
     $db->addGroupBy('cancelled_reason');
     $this->freshmenReasonCounts = $db->select('assoc');
     // Continuing
     $db = new PHPWS_DB('hms_new_application');
     $db->addColumn('cancelled_reason');
     $db->addColumn('id', null, 'count', true);
     $db->addWhere('term', $this->getTerm());
     $db->addWhere('cancelled', 1);
     $db->addWhere('student_type', TYPE_CONTINUING);
     $db->addGroupBy('cancelled_reason');
     $this->continuingReasonCounts = $db->select('assoc');
 }
 public function execute()
 {
     $db = new PHPWS_DB('hms_new_application');
     $db->addColumn('student_type');
     $db->addColumn('id', null, 'count', true);
     $db->addWhere('term', $this->getTerm());
     $db->addWhere('cancelled', 1);
     $db->addGroupBy('student_type');
     $this->typeCounts = $db->select('assoc');
 }
Beispiel #4
0
 public static function getModList()
 {
     $db = new PHPWS_DB('search');
     $db->addColumn('module', null, null, false, true);
     $db->addColumn('modules.proper_name');
     $db->addGroupBy('modules.proper_name');
     $db->addWhere('search.module', 'modules.title');
     $db->setIndexBy('module');
     $result = $db->select('col');
     if (PHPWS_Error::isError($result)) {
         PHPWS_Error::log($result);
         $result = NULL;
     }
     $mod_list = array('all' => dgettext('search', 'All modules'));
     if (!empty($result)) {
         $mod_list = array_merge($mod_list, $result);
     }
     return $mod_list;
 }