/** * * @return Am_Form * */ public function createNewTicketForm() { $form = parent::createNewTicketForm(); $element = HTML_QuickForm2_Factory::createElement('text', 'loginOrEmail'); $element->setId('loginOrEmail')->setLabel(___('E-Mail Address or Username'))->addRule('callback', ___('Can not find user with such username or email'), array($this, 'checkUser')); //prepend element to form $formElements = $form->getElements(); $form->insertBefore($element, $formElements[0]); $from = HTML_QuickForm2_Factory::createElement('select', 'from'); $from->setLabel(___('Create ticket as')); $from->loadOptions(array('admin' => ___('Admin'), 'user' => ___('Customer'))); $form->insertBefore($from, $element); $form->addScript('script')->setScript(<<<CUT \$("input#loginOrEmail").autocomplete({ minLength: 2, source: window.rootUrl + "/admin-users/autocomplete" }); CUT ); $id = $form->getId(); $snippets = ___('Snippets'); $form->addScript('snippets')->setScript(<<<CUT \$('#{$id}').find('textarea[name=content]').after('<br /><br /><a href="javascript:;" id="snippets-link" class="local">{$snippets}</a>') \$('#snippets-link').bind('click', function(){ var \$this = \$(this); var div = \$('<div></div>'); div.load(window.rootUrl + '/helpdesk/admin/p/view/displaysnippets', {}, function(){ div.dialog({ autoOpen: true, modal : true, title : "", width : 700, position : ['center', 'center'] }); div.find('.grid-wrap').bind('load', function() { \$(this).find('a.am-helpdesk-insert-snippet').unbind().click(function(){ var \$target = \$this.closest('div.am-form').find('textarea[name=content]'); \$target.insertAtCaret(\$(this).data('snippet-content')) div.dialog('close'); }) }) }) }) CUT ); return $form; }
/** * * @return Am_Form * */ public function createNewTicketForm() { $form = parent::createNewTicketForm(); $element = HTML_QuickForm2_Factory::createElement('text', 'loginOrEmail'); $element->setId('loginOrEmail')->setLabel(___('E-Mail Address or Username'))->addRule('callback', ___('Can not find user with such username or email'), array($this, 'checkUser')); //prepend element to form $formElements = $form->getElements(); $form->insertBefore($element, $formElements[0]); $from = HTML_QuickForm2_Factory::createElement('select', 'from'); $from->setLabel(___('Create ticket as')); $from->loadOptions(array('admin' => ___('Admin'), 'user' => ___('Customer'))); $form->insertBefore($from, $element); $script = <<<CUT \$("input#loginOrEmail").autocomplete({ minLength: 2, source: window.rootUrl + "/admin-users/autocomplete" }); CUT; $form->addScript('script')->setScript($script); return $form; }
public function __construct(Am_Di $di, $user_id = null) { parent::__construct($di); $this->_identity = $user_id ? $user_id : $this->getDi()->auth->getUserId(); }