function buildQuickForm() { CRM_Utils_System::setTitle('Afternoon SignIn - Extended Care'); require_once 'SFS/Utils/ExtendedCare.php'; $term = SFS_Utils_ExtendedCare::getTerm($term); $sql = "\n( \nSELECT c.id as contact_id, c.display_name as display_name, s.name as course_name, v.grade as grade,\n 0 as sout_id, 0 as signout_time, e.location as course_location\nFROM civicrm_contact c\nINNER JOIN civicrm_value_school_information v ON v.entity_id = c.id\nINNER JOIN civicrm_value_extended_care s ON ( s.entity_id = c.id AND s.has_cancelled = 0 AND s.day_of_week = '{$this->_dayOfWeek}' )\nINNER JOIN sfschool_extended_care_source e ON ( s.session = e.session AND s.name = e.name AND s.term = e.term AND s.day_of_week = e.day_of_week ) \nWHERE v.subtype = 'Student'\nAND v.grade_sis >= 1\nAND e.is_active = 1\nAND s.term = %3\n)\nUNION\n(\nSELECT c.id as contact_id, c.display_name as display_name, sout.class as course_name, v.grade as grade,\n sout.id as sout_id, sout.signout_time as signout_time, e.location as course_location\nFROM civicrm_contact c\nINNER JOIN civicrm_value_school_information v ON v.entity_id = c.id\nINNER JOIN civicrm_value_extended_care_signout sout ON sout.entity_id = c.id\nINNER JOIN sfschool_extended_care_source e ON ( sout.class = e.name )\nWHERE v.subtype = 'Student'\nAND v.grade_sis >= 1\nAND ( sout.is_morning = 0 OR sout.is_morning IS NULL )\nAND DATE( sout.signin_time ) = %1\nAND e.is_active = 1\nAND e.day_of_week = %2\n)\nUNION\n(\nSELECT c.id as contact_id, c.display_name as display_name, sout.class as course_name, v.grade as grade,\n -1 as sout_id, 0 as signout_time, e.location as course_location\nFROM civicrm_contact c\nINNER JOIN civicrm_value_school_information v ON v.entity_id = c.id\nINNER JOIN civicrm_value_extended_care_signout sout ON sout.entity_id = c.id\nINNER JOIN sfschool_extended_care_source e ON ( sout.class = e.name )\nWHERE v.subtype = 'Student'\nAND v.grade_sis >= 1\nAND ( sout.is_morning = 0 OR sout.is_morning IS NULL )\nAND DAYNAME( sout.signin_time ) = %2\nAND DATE_ADD( sout.signin_time, INTERVAL 8 DAY ) > '{$this->_date}'\nAND e.is_active = 1\nAND e.day_of_week = %2\nGROUP BY c.id\nORDER BY id DESC\n)\nORDER BY contact_id, sout_id DESC, course_name, display_name, signout_time\n"; $params = array(1 => array($this->_date, 'String'), 2 => array($this->_dayOfWeek, 'String'), 3 => array($term, 'String')); $dao = CRM_Core_DAO::executeQuery($sql, $params); $someSignedIn = false; $studentDetails = array(); while ($dao->fetch()) { if (array_key_exists($dao->contact_id, $studentDetails)) { continue; } $courseName = $dao->sout_class ? $dao->sout_class : $dao->course_name; if (empty($courseName)) { $courseName = $dao->grade <= 5 ? 'Yard Play' : 'Homework'; } $studentDetails[$dao->contact_id] = array('display_name' => $dao->display_name, 'course_name' => $courseName, 'course_location' => $dao->course_location, 'grade' => $dao->grade, 'contact_id' => $dao->contact_id, 'is_marked' => $dao->sout_id > 0 ? 1 : 0, 'signout_block' => self::signoutBlock($dao->signout_time)); if ($dao->sout_id > 0) { $someSignedIn = true; } } $this->assign('studentDetails', $studentDetails); $this->assign('someSignedIn', $someSignedIn); require_once 'SFS/Utils/Query.php'; $students = array('' => '- Select Student -') + SFS_Utils_Query::getStudentsByGrade(true, false, true, ''); $this->add('select', "student_id", ts('Student'), $students); $this->add('select', "student_id_top", ts('Student'), $students); $classes = array('' => '- Select Class -') + SFS_Utils_Query::getClasses(); $this->add('select', "course_name", ts('Course'), $classes); $this->add('select', "course_name_top", ts('Course'), $classes); $timeSlots = array('' => '- Select Time -', 1 => 'Before 3:30 pm', 2 => '3:30 - 4:30 pm', 3 => '4:30 - 5:15 pm', 4 => '5:15 - 6:00 pm', 5 => 'After 6:00 pm'); $this->add('select', "signout_time", ts('Signout Time'), $timeSlots); $this->add('select', "signout_time_top", ts('Signout Time'), $timeSlots); }
public function buildQuickForm() { if ($this->_action & CRM_Core_Action::DELETE) { $buttonLabel = ts('Delete'); } else { require_once 'SFS/Utils/Query.php'; $buttonLabel = ts('Save'); $students = SFS_Utils_Query::getStudentsByGrade(true, false, true, ''); $this->add('select', 'entity_id', ts('Student'), array('' => '--select--') + $students, true); if ($this->_action & CRM_Core_Action::UPDATE) { $this->freeze('entity_id'); } if ($this->_object == 'fee') { $sql = "SELECT cf.column_name as column_name, cf.option_group_id as option_group_id\n FROM civicrm_custom_field cf\n INNER JOIN civicrm_custom_group cg ON cf.custom_group_id = cg.id\n WHERE cg.table_name = %1"; $params = array(1 => array($this->_tableName, 'String')); $dao = CRM_Core_DAO::executeQuery($sql, $params); $options = array(); while ($dao->fetch()) { if ($dao->option_group_id) { $options[$dao->column_name] = CRM_Core_OptionGroup::valuesByID($dao->option_group_id); } } $this->add('select', 'fee_type', ts('Fee Type'), array('' => '--select--') + $options['fee_type'], true); $this->add('select', 'category', ts('Category'), array('' => '--select--') + $options['category'], true); $this->add('text', 'description', ts('Description'), null, true); $this->addDate('fee_date', ts('Fee Date'), CRM_Core_SelectValues::date('custom', 1, 1)); $this->add('text', 'total_blocks', ts('Total Blocks'), null, true); $this->addRule('total_blocks', ts('Please enter valid Total Blocks'), 'positiveInteger'); } else { $classes = SFS_Utils_Query::getClasses(); $this->add('text', 'pickup_person_name', ts('Pickup Person:')); $this->addDateTime('signin_time', ts('Signin'), CRM_Core_SelectValues::date('custom', 10, 2)); $this->addDateTime('signout_time', ts('Signout'), CRM_Core_SelectValues::date('custom', 10, 2)); $this->add('select', 'class', ts('Class'), array('' => '--select--') + $classes, true); $this->add('checkbox', 'is_morning', ts('Is morning?')); $this->add('checkbox', 'at_school_meeting', ts('At School Meeting?')); } } $this->addButtons(array(array('type' => 'next', 'name' => $buttonLabel, 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); }