示例#1
0
 function _register_fields_dynamic()
 {
     $options = $this->getOptions();
     $schedule = new Schedule($this->dbcon, $options['schedule_id']);
     $open_appts = $schedule->describeOpenItems();
     $header_prefix = 'AMP_SCHEDULE_APPOINTMENT_FORM_TEXT_';
     $header_descriptor = 'AVAILABLE';
     $choose_default = null;
     if (isset($_GET['action_id']) && ($item_id = $_GET['action_id'])) {
         if (!isset($open_appts[$item_id])) {
             $header_prefix .= 'REQUESTED_';
             $open_appts = array();
         } else {
             $single_appt = array();
             $single_appt[$item_id] = $open_appts[$item_id];
             $open_appts = $single_appt;
             $choose_default = $item_id;
         }
     }
     if (empty($open_appts) || !$open_appts) {
         $header_descriptor = 'UNAVAILABLE';
     }
     $this->fields = array('Appointments' => array('type' => 'header', 'label' => sprintf(constant($header_prefix . $header_descriptor), $schedule->getName()), 'enabled' => true, 'public' => true));
     if (empty($open_appts) || !$open_appts) {
         return;
     }
     $this->fields['action_id'] = array('type' => 'radiogroup', 'public' => true, 'enabled' => true, 'default' => $choose_default, 'label' => 'Available Times', 'required' => true, 'values' => $open_appts);
 }
示例#2
0
 function setDynamicValues()
 {
     $form_set = AMPSystem_Lookup::instance('userDataFormalNames');
     $schedule_set = AMPSystem_Lookup::instance('scheduleNames');
     $this->setFieldValueSet('schedule_id', $schedule_set);
     $this->setFieldValueSet('userdata_id', $form_set);
     $schedule = new Schedule(AMP_Registry::getDbcon());
     $this->swapper->addSwapper('schedule_id');
     $this->swapper->setForm($this->formname, 'schedule_id');
     foreach ($schedule_set as $schedule_id => $schedule_name) {
         $schedule->readData($schedule_id);
         $open_items = $schedule->describeOpenItems();
         $this->addAppointmentSet($open_items, $schedule);
     }
     $this->addFieldAttr('schedule_id', array('onChange' => $this->swapper->js_swapAction('schedule_id')));
 }