/**
  * Build the form
  *
  * @access public
  * @return void
  */
 function buildQuickForm()
 {
     // text for sort_name
     $this->addElement('text', 'sort_name', ts('Contributor'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     CRM_Contribute_Form_Search::buildQuickFormCommon($this);
     /* 
      * add form checkboxes for each row. This is needed out here to conform to QF protocol 
      * of all elements being declared in builQuickForm 
      */
     $rows = $this->get('rows');
     if (is_array($rows)) {
         $this->addElement('checkbox', 'toggleSelect', null, null, array('onChange' => "return toggleCheckboxVals('mark_x_',this.form);"));
         $total = $cancel = 0;
         foreach ($rows as $row) {
             $this->addElement('checkbox', $row['checkbox'], null, null, array('onclick' => "return checkSelectedBox('" . $row['checkbox'] . "', '" . $this->getName() . "');"));
             if ($row['cancel_date']) {
                 $cancel += $row['total_amount'];
             } else {
                 $total += $row['total_amount'];
             }
         }
         $this->assign('total_amount', $total);
         $this->assign('cancel_amount', $cancel);
         $this->assign('num_amount', count($rows));
         $this->assign('single', $this->_single);
         // also add the action and radio boxes
         require_once 'CRM/Contribute/Task.php';
         $tasks = array('' => ts('- more actions -')) + CRM_Contribute_Task::tasks();
         $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
         $this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);"));
         $this->add('submit', $this->_printButtonName, ts('Print'), array('class' => 'form-submit', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);"));
         // need to perform tasks on all or selected items ? using radio_ts(task selection) for it
         $this->addElement('radio', 'radio_ts', null, '', 'ts_sel', array('checked' => null));
         $this->addElement('radio', 'radio_ts', null, '', 'ts_all', array('onchange' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_'," . $this->getName() . "); return false;"));
     }
     // add buttons
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => true)));
 }
 /**
  * Build the form
  *
  * @access public
  * @return void
  */
 function buildQuickForm()
 {
     // add checkboxes for contact type
     $contact_type = array();
     foreach (CRM_Core_SelectValues::contactType() as $k => $v) {
         if (!empty($k)) {
             $contact_type[] = HTML_QuickForm::createElement('checkbox', $k, null, $v);
         }
     }
     $this->addGroup($contact_type, 'contact_type', ts('Contact Type(s)'), '<br />');
     // checkboxes for groups
     $group = array();
     foreach ($this->_group as $groupID => $groupName) {
         $this->_groupElement =& $this->addElement('checkbox', "group[{$groupID}]", null, $groupName);
     }
     // checkboxes for categories
     foreach ($this->_tag as $tagID => $tagName) {
         $this->_tagElement =& $this->addElement('checkbox', "tag[{$tagID}]", null, $tagName);
     }
     // add text box for last name, first name, street name, city
     $this->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     $this->addElement('text', 'street_address', ts('Street Address'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address', 'street_address'));
     $this->addElement('text', 'city', ts('City'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address', 'city'));
     // select for state province
     $stateProvince = array('' => ts('- any state/province -')) + CRM_Core_PseudoConstant::stateProvince();
     $this->addElement('select', 'state_province', ts('State/Province'), $stateProvince);
     // select for country
     $country = array('' => ts('- any country -')) + CRM_Core_PseudoConstant::country();
     $this->addElement('select', 'country', ts('Country'), $country);
     // add text box for postal code
     $this->addElement('text', 'postal_code', ts('Postal Code'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address', 'postal_code'));
     $this->addElement('text', 'postal_code_low', ts('Range-From'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address', 'postal_code'));
     $this->addElement('text', 'postal_code_high', ts('To'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address', 'postal_code'));
     $this->addElement('text', 'location_name', ts('Location Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Location', 'name'));
     // checkboxes for DO NOT phone, email, mail
     // we take labels from SelectValues
     $t = CRM_Core_SelectValues::privacy();
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_phone', null, $t['do_not_phone']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_email', null, $t['do_not_email']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_mail', null, $t['do_not_mail']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_trade', null, $t['do_not_trade']);
     $this->addGroup($privacy, 'privacy', ts('Privacy'), '&nbsp;');
     // checkboxes for location type
     $location_type = array();
     $locationType = CRM_Core_PseudoConstant::locationType();
     foreach ($locationType as $locationTypeID => $locationTypeName) {
         $location_type[] = HTML_QuickForm::createElement('checkbox', $locationTypeID, null, $locationTypeName);
     }
     $this->addGroup($location_type, 'location_type', ts('Location Types'), '&nbsp;');
     // textbox for Activity Type
     $this->addElement('text', 'activity_type', ts('Activity Type'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_ActivityHistory', 'activity_type'));
     // Date selects for activity date
     $this->add('date', 'activity_date_from', ts('Activity Dates - From'), CRM_Core_SelectValues::date('relative'));
     $this->addRule('activity_date_from', ts('Select a valid date.'), 'qfDate');
     $this->add('date', 'activity_date_to', ts('To'), CRM_Core_SelectValues::date('relative'));
     $this->addRule('activity_date_to', ts('Select a valid date.'), 'qfDate');
     $this->assign('validCiviContribute', false);
     if (CRM_Utils_System::accessCiviContribute()) {
         $this->assign('validCiviContribute', true);
         require_once 'CRM/Contribute/Form/Search.php';
         CRM_Contribute_Form_Search::buildQuickFormCommon($this);
     }
     //Custom data Search Fields
     $this->customDataSearch();
     $this->buildQuickFormCommon();
 }