コード例 #1
0
ファイル: Search.php プロジェクト: nielosz/civicrm-core
 /**
  * Build the form object.
  *
  *
  * @return void
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->addSortNameField();
     if (CRM_Core_Permission::check('access deleted contacts') and Civi::settings()->get('contact_undelete')) {
         $this->addElement('checkbox', 'deleted_contacts', ts('Search in Trash') . '<br />' . ts('(deleted contacts)'));
     }
     CRM_Event_BAO_Query::buildSearchForm($this);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         $lineItems = $eventIds = array();
         if (!$this->_single) {
             $this->addRowSelectors($rows);
         }
         foreach ($rows as $row) {
             $eventIds[$row['event_id']] = $row['event_id'];
             if (CRM_Event_BAO_Event::usesPriceSet($row['event_id'])) {
                 // add line item details if applicable
                 $lineItems[$row['participant_id']] = CRM_Price_BAO_LineItem::getLineItems($row['participant_id']);
             }
         }
         //get actual count only when we are dealing w/ single event.
         $participantCount = 0;
         if (count($eventIds) == 1) {
             //convert form values to clause.
             $seatClause = array();
             if (CRM_Utils_Array::value('participant_test', $this->_formValues) == '1' || CRM_Utils_Array::value('participant_test', $this->_formValues) == '0') {
                 $seatClause[] = "( participant.is_test = {$this->_formValues['participant_test']} )";
             }
             if (!empty($this->_formValues['participant_status_id'])) {
                 $seatClause[] = CRM_Contact_BAO_Query::buildClause("participant.status_id", '=', $this->_formValues['participant_status_id'], 'Int');
                 if ($status = CRM_Utils_Array::value('IN', $this->_formValues['participant_status_id'])) {
                     $this->_formValues['participant_status_id'] = $status;
                 }
             }
             if (!empty($this->_formValues['participant_role_id'])) {
                 $escapedRoles = array();
                 foreach ((array) $this->_formValues['participant_role_id'] as $participantRole) {
                     $escapedRoles[] = CRM_Utils_Type::escape($participantRole, 'String');
                 }
                 $seatClause[] = "( participant.role_id IN ( '" . implode("' , '", $escapedRoles) . "' ) )";
             }
             // CRM-15379
             if (!empty($this->_formValues['participant_fee_id'])) {
                 $participant_fee_id = $this->_formValues['participant_fee_id'];
                 foreach ($participant_fee_id as $k => &$val) {
                     $val = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $val, 'label');
                     $val = CRM_Core_DAO::escapeString(trim($val));
                 }
                 $feeLabel = implode('|', $participant_fee_id);
                 $seatClause[] = "( participant.fee_level REGEXP '{$feeLabel}' )";
             }
             $seatClause = implode(' AND ', $seatClause);
             $participantCount = CRM_Event_BAO_Event::eventTotalSeats(array_pop($eventIds), $seatClause);
         }
         $this->assign('participantCount', $participantCount);
         $this->assign('lineItems', $lineItems);
         $permission = CRM_Core_Permission::getPermission();
         $tasks = CRM_Event_Task::permissionedTaskTitles($permission);
         if (isset($this->_ssID)) {
             if ($permission == CRM_Core_Permission::EDIT) {
                 $tasks = $tasks + CRM_Event_Task::optionalTaskTitle();
             }
             $savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'));
             $this->assign_by_ref('savedSearch', $savedSearchValues);
             $this->assign('ssID', $this->_ssID);
         }
         $this->addTaskMenu($tasks);
     }
 }
コード例 #2
0
ファイル: Search.php プロジェクト: hguru/224Civi
 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     $this->addElement('text', 'sort_name', ts('Participant Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     CRM_Event_BAO_Query::buildSearchForm($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)) {
         $lineItems = $eventIds = array();
         if (!$this->_single) {
             $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true ); return toggleCheckboxVals('mark_x_',this);"));
         }
         foreach ($rows as $row) {
             $eventIds[$row['event_id']] = $row['event_id'];
             if (!$this->_single) {
                 $this->addElement('checkbox', $row['checkbox'], NULL, NULL, array('onclick' => "toggleTaskAction( true ); return checkSelectedBox('" . $row['checkbox'] . "');"));
             }
             if (CRM_Event_BAO_Event::usesPriceSet($row['event_id'])) {
                 // add line item details if applicable
                 $lineItems[$row['participant_id']] = CRM_Price_BAO_LineItem::getLineItems($row['participant_id']);
             }
         }
         //get actual count only when we are dealing w/ single event.
         $participantCount = 0;
         if (count($eventIds) == 1) {
             //convert form values to clause.
             $seatClause = array();
             // Filter on is_test if specified in search form
             if (CRM_Utils_Array::value('participant_test', $this->_formValues) == '1' || CRM_Utils_Array::value('participant_test', $this->_formValues) == '0') {
                 $seatClause[] = "( participant.is_test = {$this->_formValues['participant_test']} )";
             }
             if (CRM_Utils_Array::value('participant_status_id', $this->_formValues)) {
                 $statuses = array_keys($this->_formValues['participant_status_id']);
                 $seatClause[] = '( participant.status_id IN ( ' . implode(' , ', $statuses) . ' ) )';
             }
             if (CRM_Utils_Array::value('participant_role_id', $this->_formValues)) {
                 $roles = array_keys($this->_formValues['participant_role_id']);
                 $seatClause[] = '( participant.role_id IN ( ' . implode(' , ', $roles) . ' ) )';
             }
             $clause = NULL;
             if (!empty($seatClause)) {
                 $clause = implode(' AND ', $seatClause);
             }
             $participantCount = CRM_Event_BAO_Event::eventTotalSeats(array_pop($eventIds), $clause);
         }
         $this->assign('participantCount', $participantCount);
         $this->assign('lineItems', $lineItems);
         $total = $cancel = 0;
         $permission = CRM_Core_Permission::getPermission();
         $tasks = array('' => ts('- actions -')) + CRM_Event_Task::permissionedTaskTitles($permission);
         if (isset($this->_ssID)) {
             if ($permission == CRM_Core_Permission::EDIT) {
                 $tasks = $tasks + CRM_Event_Task::optionalTaskTitle();
             }
             $savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'));
             $this->assign_by_ref('savedSearch', $savedSearchValues);
             $this->assign('ssID', $this->_ssID);
         }
         $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
         $this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'id' => 'Go', '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' => 'checked'));
         $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('onclick' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_',this); toggleTaskAction( true );"));
     }
     // add buttons
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE)));
 }
コード例 #3
0
ファイル: Search.php プロジェクト: nganivet/civicrm-core
 /**
  * Build the form object.
  *
  *
  * @return void
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->addElement('text', 'sort_name', ts('Participant Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     CRM_Event_BAO_Query::buildSearchForm($this);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         $lineItems = $eventIds = array();
         if (!$this->_single) {
             $this->addRowSelectors($rows);
         }
         foreach ($rows as $row) {
             $eventIds[$row['event_id']] = $row['event_id'];
             if (CRM_Event_BAO_Event::usesPriceSet($row['event_id'])) {
                 // add line item details if applicable
                 $lineItems[$row['participant_id']] = CRM_Price_BAO_LineItem::getLineItems($row['participant_id']);
             }
         }
         //get actual count only when we are dealing w/ single event.
         $participantCount = 0;
         if (count($eventIds) == 1) {
             //convert form values to clause.
             $seatClause = array();
             if (CRM_Utils_Array::value('participant_test', $this->_formValues) == '1' || CRM_Utils_Array::value('participant_test', $this->_formValues) == '0') {
                 $seatClause[] = "( participant.is_test = {$this->_formValues['participant_test']} )";
             }
             if (!empty($this->_formValues['participant_status_id'])) {
                 $seatClause[] = CRM_Contact_BAO_Query::buildClause("participant.status_id", '=', $this->_formValues['participant_status_id'], 'Int');
                 if ($status = CRM_Utils_Array::value('IN', $this->_formValues['participant_status_id'])) {
                     $this->_formValues['participant_status_id'] = $status;
                 }
             }
             if (!empty($this->_formValues['participant_role_id'])) {
                 $seatClause[] = '( participant.role_id IN ( ' . implode(' , ', (array) $this->_formValues['participant_role_id']) . ' ) )';
             }
             // CRM-15379
             if (!empty($this->_formValues['participant_fee_id'])) {
                 $participant_fee_id = $this->_formValues['participant_fee_id'];
                 $feeLabel = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $participant_fee_id, 'label');
                 $feeLabel = CRM_Core_DAO::escapeString(trim($feeLabel));
                 $seatClause[] = "( participant.fee_level LIKE '%{$feeLabel}%' )";
             }
             $seatClause = implode(' AND ', $seatClause);
             $participantCount = CRM_Event_BAO_Event::eventTotalSeats(array_pop($eventIds), $seatClause);
         }
         $this->assign('participantCount', $participantCount);
         $this->assign('lineItems', $lineItems);
         $permission = CRM_Core_Permission::getPermission();
         $tasks = CRM_Event_Task::permissionedTaskTitles($permission);
         if (isset($this->_ssID)) {
             if ($permission == CRM_Core_Permission::EDIT) {
                 $tasks = $tasks + CRM_Event_Task::optionalTaskTitle();
             }
             $savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'));
             $this->assign_by_ref('savedSearch', $savedSearchValues);
             $this->assign('ssID', $this->_ssID);
         }
         $this->addTaskMenu($tasks);
     }
 }
コード例 #4
0
ファイル: Search.php プロジェクト: bhirsch/voipdev
 /**
  * Build the form
  *
  * @access public
  * @return void
  */
 function buildQuickForm()
 {
     $this->addElement('text', 'sort_name', ts('Participant Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     require_once 'CRM/Event/BAO/Query.php';
     CRM_Event_BAO_Query::buildSearchForm($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)) {
         $lineItems = array();
         require_once 'CRM/Event/BAO/Event.php';
         if (!$this->_single) {
             $this->addElement('checkbox', 'toggleSelect', null, null, array('onclick' => "toggleTaskAction( true ); return toggleCheckboxVals('mark_x_',this);"));
         }
         foreach ($rows as $row) {
             if (!$this->_single) {
                 $this->addElement('checkbox', $row['checkbox'], null, null, array('onclick' => "toggleTaskAction( true ); return checkSelectedBox('" . $row['checkbox'] . "', '" . $this->getName() . "');"));
             }
             if (CRM_Event_BAO_Event::usesPriceSet($row['event_id'])) {
                 // add line item details if applicable
                 require_once 'CRM/Price/BAO/LineItem.php';
                 $lineItems[$row['participant_id']] = CRM_Price_BAO_LineItem::getLineItems($row['participant_id']);
             }
         }
         $this->assign('lineItems', $lineItems);
         $total = $cancel = 0;
         require_once "CRM/Core/Permission.php";
         $permission = CRM_Core_Permission::getPermission();
         require_once 'CRM/Event/Task.php';
         $tasks = array('' => ts('- more actions -')) + CRM_Event_Task::permissionedTaskTitles($permission);
         if (isset($this->_ssID)) {
             if ($permission == CRM_Core_Permission::EDIT) {
                 require_once "CRM/Contact/Task.php";
                 $tasks = $tasks + CRM_Event_Task::optionalTaskTitle();
             }
             $savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'));
             $this->assign_by_ref('savedSearch', $savedSearchValues);
             $this->assign('ssID', $this->_ssID);
         }
         $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
         $this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'id' => 'Go', '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' => 'checked'));
         $this->addElement('radio', 'radio_ts', null, '', 'ts_all', array('onclick' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_',this); toggleTaskAction( true );"));
     }
     // add buttons
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => true)));
 }