/**
  * Method to get select list of possible parent segments
  *
  * @access protected
  * @return array
  */
 protected function getParentList()
 {
     $parentList = array("- select -") + CRM_Contactsegment_Utils::getParentList();
     asort($parentList);
     return $parentList;
 }
 /**
  * Method to add form elements
  *
  * @access protected
  */
 protected function addFormElements()
 {
     $roleList = CRM_Contactsegment_Utils::getRoleList();
     $parentList = CRM_Contactsegment_Utils::getParentList();
     if ($this->_parentSegmentId) {
         $childList = array("- select -") + CRM_Contactsegment_Utils::getChildList($this->_parentSegmentId);
     } else {
         if (isset($this->_contactSegment['segment_id'])) {
             $childList = array("- select -") + CRM_Contactsegment_Utils::getChildList($this->_contactSegment['segment_id']);
         } else {
             $defaultParentId = CRM_Core_DAO::singleValueQuery('SELECT id FROM civicrm_segment where parent_id IS NULL ORDER BY label ASC LIMIT 1');
             $childList = array("- select -") + CRM_Contactsegment_Utils::getChildList($defaultParentId);
         }
     }
     $this->add('hidden', 'contact_id');
     $this->add('hidden', 'contact_segment_id');
     $this->add('select', 'contact_segment_role', ts('Role'), $roleList, true);
     $this->add('select', 'segment_parent', ts($this->_parentLabel), $parentList, true);
     $this->add('select', 'segment_child', ts($this->_childLabel), $childList);
     $this->addDate('start_date', ts('Start Date'), true);
     $this->addDate('end_date', ts('End Date'), false);
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
 }