Select ticket action
@return HTMLText
558822
public function index() {
		$exclude  = null;
		if (!$this->event->canRegister()) {
			$data = array(
				'Content' => '<p>This event cannot be registered for.</p>'
			);
		} elseif (!$this->event->getRemainingCapacity($exclude)) {
			$data = array(
				'Title'   => $this->event->Title . ' Is Full',
				'SoldOut' => true,
				'Content' => '<p>There are no more places available at this event.</p>'
			);
		} else {
			$tickets = $this->event->getAvailableTickets();
			$data = new ArrayData(array(
				'Tickets' => $tickets
			));
			$registration = $this->getCurrentRegistration();
			if($registration->Attendees()->exists()){
				$data->NextURL = $this->Link("review");
				$data->NextLink = AnchorField::create("review",
					_t("EventRegisterController.BACKTOREVIEW", "Back to Review"),
					$data->NextURL
				)->Field();
			}
			$template = self::config()->ticket_select_template;
			$content = $this->renderWith($template, $data);
			$data = array(
				'Title' => 'Register For ' . $this->event->Title,
				'Form'  => '',
				'Content' => $content
			);
		}
		$data['Event'] = $this->event;

		return $this->getViewer('index')->process($this->customise($data));
	}
1044193
public function getDescription() {
		$parts = array();
		foreach($this->getTicketQuantities() as $ticketid => $quantity){
			if($ticket = EventTicket::get()->byID($ticketid)){
				$parts[] = $quantity."x".$ticket->Title;
			}
		}
		return $this->Event()->Title.": ".implode(",", $parts);
	}
402081
protected function getScriptText()
    {
        $actionName = Builder::escapeText($this->actionName);
        $key        = null;
        $value      = null;
        if ($this->keyName !== null) {
            $key   = "KeyName";
            $value = $this->keyName;
        } else if ($this->keyCode !== null) {
            $key   = "KeyCode";
            $value = $this->keyCode;
        } else if ($this->charPressed !== null) {
            $key   = "CharPressed";
            $value = $this->charPressed;
        }
        $value = Builder::escapeText($value);
        return "
if (Event.{$key} == {$value}) {
	TriggerPageAction({$actionName});
}";
    }
467056
public function getTicket()
    {
        if ($this->ticket) {
            return $this->ticket;
        }

        $key = 'gibson.wechat.card.api_ticket';

        // for php 5.3
        $http = $this->http;
        $apiTicket = self::API_TICKET;

        return $this->ticket = Cache::get($key, function () use ($key, $http, $apiTicket) {
            $result = $http->get($apiTicket);

            Cache::put($key, $result['ticket'], $result['expires_in']);

            return $result['ticket'];
        });
    }
955944
public function selectPage()
    {
        if ($this->pageTotal <= 1) {
            return '';
        }

        $page = (int)$this->getOption('page', 1);
        $select = ' <select class="page-num-input" style="max-height: 400px"
        onchange="javascript:location.href=\'' . $this->getUrl() . '\'+this.value;">';

        for ($i = 1; $i <= $this->pageTotal; $i++) {
            $select .= ($page === $i) ?
                '<option value="' . $i . '" selected="selected"">' . $i . '</option>' :
                '<option value="' . $i . '" >' . $i . '</option>';
        }

        $select .= '</select> ';

        $this->html['select'] = $select;

        return $this;
    }
386466
public function autoSelectAgent()
    {
        $cat_id = $this->category_id;
        $agents = Category::find($cat_id)->agents()->with(['agentOpenTickets' => function ($query) {
            $query->addSelect(['id', 'agent_id']);
        }])->get();
        $count = 0;
        $lowest_tickets = 1000000;
        // If no agent selected, select the admin
        $first_admin = Agent::admins()->first();
        $selected_agent_id = $first_admin->id;
        foreach ($agents as $agent) {
            if ($count == 0) {
                $lowest_tickets = $agent->agentOpenTickets->count();
                $selected_agent_id = $agent->id;
            } else {
                $tickets_count = $agent->agentOpenTickets->count();
                if ($tickets_count < $lowest_tickets) {
                    $lowest_tickets = $tickets_count;
                    $selected_agent_id = $agent->id;
                }
            }
            $count++;
        }
        $this->agent_id = $selected_agent_id;

        return $this;
    }
266541
public function listAction()
    {
        $params     = $this->params();
        $request    = $this->getRequest();
        $bodyOnly   = $request->isXmlHttpRequest();
        $page       = $params->fromRoute( 'page',
            $request->getPost( 'page',
                $request->getQuery( 'page', 1 )
            )
        );

        $view = new ViewModel( array(
            'paginator' => $this->getPaginator(),
            'page'      => ( (int) $page ) ?: 1,
            'format'    => $bodyOnly,
        ) );

        if ( $bodyOnly )
        {
            $view->setTerminal( true );
        }

        return $view;
    }
377281
public function getHtmlHeadEntrySet()
    {
        $set = parent::getHtmlHeadEntrySet();

        foreach ($this->action_items as $child_widget) {
            $set->addEntrySet($child_widget->getHtmlHeadEntrySet());
        }

        return $set;
    }
797350
public function getDispatchAction()
    {
        $args = $this->request->getAsArray('args');
        $arg = array_shift($args);
        if (preg_match('/^(\w+\.\w+)$/', $arg, $matches)) {
            $action = $matches[1];
            return $action;
        }
    }
1014196
protected function _getAppointmentSelect()
    {
        $select = $this->db->select();

        $select->from('gems__appointments')
                ->joinLeft( 'gems__agenda_activities', 'gap_id_activity = gaa_id_activity')
                ->joinLeft('gems__agenda_procedures',  'gap_id_procedure = gapr_id_procedure')
                ->joinLeft('gems__locations',          'gap_id_location = glo_id_location')
                ->order('gap_admission_time DESC');

        return $select;
    }
82737
public function indexAction()
    {
        $navigation = $this->getServiceLocator()
                           ->get( 'Grid\Menu\Model\Menu\Model' )
                           ->findNavigation();

        $view = new ViewModel( array(
            'navigation' => $navigation,
        ) );

        $this->getResponse()
             ->getHeaders()
             ->addHeaderLine( 'Content-Type', 'application/xml' );

        return $view->setTerminal( true );
    }
185472
public function getActionName()
    {
        if (is_array($this->actionName)) {
            return $this->actionName;
        }
        if (empty($this->pages)) {
            throw new HTML_QuickForm2_NotFoundException('No pages added to the form');
        }
        $names = array_map('preg_quote', array_keys($this->pages));
        $regex = '/^_qf_(' . implode('|', $names) . ')_(.+?)(_x)?$/';
        foreach (array_keys($_REQUEST) as $key) {
            if (preg_match($regex, $key, $matches)) {
                $this->actionName = array($matches[1], $matches[2]);
                break;
            }
        }
        if (!is_array($this->actionName)) {
            reset($this->pages);
            $this->actionName = array(key($this->pages), 'display');
        }
        return $this->actionName;
    }
703278
public function getBetterButtonsActions()
    {
        /** @var FieldList $fields */
        $fields = parent::getBetterButtonsActions();
        $fields->push(BetterButtonCustomAction::create('send', _t('Reservation.RESEND', 'Resend the reservation')));

        return $fields;
    }
469339
protected function renderSelect()
    {
        $options = $this->getOptions();

        $selectedExtensionStyle = '';

        $renderedOptionTags = [];
        foreach ($options as $option) {
            if (isset($option['selected']) && $option['selected'] === 'selected') {
                $selectedExtensionStyle = $option['style'];
            }
            if ($option['value'] === \Tx_Phpunit_Testable::ALL_EXTENSIONS) {
                $optionValue = $this->translate('all_extensions');
            } else {
                $optionValue = $option['value'];
            }
            $renderedOptionTags[] = $this->renderTag('option', $option, $optionValue);
        }

        return $this->renderTag(
            'select',
            [
                'name' => \Tx_Phpunit_Interface_Request::PARAMETER_NAMESPACE .
                    '[' . \Tx_Phpunit_Interface_Request::PARAMETER_KEY_TESTABLE . ']',
                'onchange' => 'document.location = \'' . $this->action . '&' .
                    \Tx_Phpunit_Interface_Request::PARAMETER_NAMESPACE .
                    '[' . \Tx_Phpunit_Interface_Request::PARAMETER_KEY_TESTABLE . ']=' .
                    '\'+this.options[this.selectedIndex].value;',
                'style' => $selectedExtensionStyle,
            ],
            implode(LF, $renderedOptionTags)
        );
    }
1160969
public function getTicket()
    {
        $cacheKey = sprintf($this->cacheKey, $this->appId);

        return Cache::get($cacheKey, function () use ($cacheKey) {
            $response = $this->http->get(self::API_TICKET);

            // 设置token
            $ticket = $response['ticket'];

            // 把token缓存起来
            $expiresAt = Carbon::now()->addSeconds($response['expires_in']);
            Cache::put($cacheKey, $ticket, $expiresAt);

            return $ticket;
        });
    }
1284612
public function get_jsapi_ticket()
    {
        $ticket = false;
        if ($this->get_jsapi_ticket_diy !== false) {
            // 调用用户自定义获取jsapi_ticket方法
            $ticket = call_user_func($this->get_jsapi_ticket_diy);
            if ($ticket) {
                $ticket = json_decode($ticket);
            }
        } else {
            // 异常处理: 获取jsapi_ticket方法未定义
            @error_log('Not set getTicketDiy method, jsapi_ticket will be refreshed each time.', 0);
        }

        // 验证jsapi_ticket是否有效
        if (!$this->valid_jsapi_ticket($ticket)) {

            // 生成新的jsapi_ticket
            $ticket = $this->new_jsapi_ticket();
            if ($ticket === false) {
                return false;
            }

            // 保存新生成的AccessToken
            if ($this->save_jsapi_ticket_diy !== false) {
                // 用户自定义保存AccessToken方法
                call_user_func($this->save_jsapi_ticket_diy, json_encode($ticket));
            } else {
                // 异常处理: 保存access_token方法未定义
                @error_log('Not set saveTokenDiy method, jsapi_ticket will be refreshed each time.', 0);
            }
        }
        return $ticket->ticket;
    }
364252
private function getEditableAttendees()
    {
        $attendees = ArrayList::create();
        /** @var Attendee $attendee */
        foreach ($this->getReservation()->Attendees() as $key => $attendee) {
            $fieldName = $this->name . "[{$attendee->ID}][TicketReceiver]";
            $attendee->TicketReceiverField = CheckboxField::create($fieldName)
                ->setAttribute('Title', _t('SummaryField.TICKET_RECEIVER_HELP', 'Send tickets to this person'))
                ->setDisabled(empty($attendee->Email));
            // Select the first by default
            if ($this->getReservation()->MainContact()->ID === $attendee->ID) {
                $attendee->TicketReceiverField->setValue(1);
            }
            $attendees->push($attendee);
        }
        return $attendees;
    }