<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
class CRM_Event_Page_AJAX {
/**
- * Function for building Event combo box
- */
- function event() {
- $name = trim(CRM_Utils_Type::escape($_GET['s'], 'String'));
- if (!$name) {
- $name = '%';
- }
- $whereClause = " title LIKE '$name%' AND ( civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0 )";
- $includeOld = CRM_Utils_Request::retrieve('includeOld', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, TRUE);
- if (!$includeOld) {
- $whereClause .= " AND ( end_date IS NULL OR end_date >= NOW() )";
- }
- $query = "
- SELECT civicrm_event.title AS title,
- civicrm_event.id AS id,
- civicrm_address.city AS city,
- civicrm_event.start_date
- FROM civicrm_event
- LEFT JOIN civicrm_loc_block ON
- civicrm_event.loc_block_id = civicrm_loc_block.id
- LEFT JOIN civicrm_address ON
- civicrm_loc_block.address_id = civicrm_address.id
- WHERE
- {$whereClause}
- ORDER BY
- civicrm_event.title
-";
- $dao = CRM_Core_DAO::executeQuery($query);
- $results = array();
- while ($dao->fetch()) {
- $fields = array();
- foreach (array('title', 'city') as $field) {
- if (isset($dao->$field)) {
- array_push($fields, $dao->$field);
- }
- }
- if (isset($dao->start_date)) {
- array_push($fields, CRM_Utils_Date::customFormat($dao->start_date));
- }
- $results[$dao->id] = implode(' - ', $fields);
- }
- CRM_Core_Page_AJAX::autocompleteResults($results);
- }
-
- /**
- * Function for building Event Type combo box
- */
- function eventType() {
- $name = trim(CRM_Utils_Type::escape($_GET['s'], 'String'));
- if (!$name) {
- $name = '%';
- }
- $whereClause = " v.label LIKE '$name%' ";
-
- $query = "
-SELECT v.label ,v.value
-FROM civicrm_option_value v,
- civicrm_option_group g
-WHERE v.option_group_id = g.id
-AND g.name = 'event_type'
-AND v.is_active = 1
-AND {$whereClause}
-ORDER by v.weight";
-
- $dao = CRM_Core_DAO::executeQuery($query);
- $results = array();
- while ($dao->fetch()) {
- $results[$dao->value] = $dao->label;
- }
- CRM_Core_Page_AJAX::autocompleteResults($results);
- }
-
- /**
- * Function for building EventFee combo box
+ * Building EventFee combo box.
+ * FIXME: This ajax callback could be eliminated in favor of an entityRef field but the priceFieldValue api doesn't currently support filtering on entity_table
*/
- function eventFee() {
- $name = trim(CRM_Utils_Type::escape($_GET['s'], 'String'));
+ public function eventFee() {
+ $name = trim(CRM_Utils_Type::escape($_GET['term'], 'String'));
if (!$name) {
$name = '%';
$dao = CRM_Core_DAO::executeQuery($query);
$results = array();
while ($dao->fetch()) {
- $results[$dao->id] = $dao->label;
- }
- CRM_Core_Page_AJAX::autocompleteResults($results);
- }
-
- function eventList() {
- $listparams = CRM_Utils_Array::value('listall', $_REQUEST, 1);
- $events = CRM_Event_BAO_Event::getEvents($listparams);
-
- $elements = array(array('name' => ts('- select -'),
- 'value' => '',
- ));
- foreach ($events as $id => $name) {
- $elements[] = array(
- 'name' => $name,
- 'value' => $id,
- );
+ $results[] = array('id' => $dao->id, 'text' => $dao->label);
}
-
- echo json_encode($elements);
- CRM_Utils_System::civiExit();
+ CRM_Utils_JSON::output($results);
}
- /**
- * Function to get default participant role
- */
- function participantRole() {
- $eventID = $_GET['eventId'];
-
- $defaultRoleId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event',
- $eventID,
- 'default_role_id',
- 'id'
- );
- $participantRole = array('role' => $defaultRoleId);
- echo json_encode($participantRole);
- CRM_Utils_System::civiExit();
- }
}
-