<?php 
class Application_Model_Form_UserSearch extends MyWeb_Form
{

    public function init()
    {
    	ZendX_JQuery::enableForm($this);	// zapnuti jQuery
    	
        $request = Zend_Controller_Front::getInstance()->getRequest();
        $getValue = $request->getParams();
        $translate = Zend_Registry::get('Zend_Translate');
        
        // nastaví atributy formuláře
        $this->setAction("search");
        $this->setMethod("post");
        $this->setAttrib("id", "form_user_search");
        
        
        //nacteni config souboru s definovan7mi fomularovymi prvky
        $config = new Zend_Config_Ini(APPLICATION_PATH . "/forms/userSearch.ini");
        $this->setConfig($config);
        
        $article = $this->_model->fetchEntry(NULL);
        
        //***************************************************************************
         $element = $this->getElement('user_userName');
         $element->setLabel($translate->translate('Username'));
        //***************************************************************************
         $element = $this->getElement('user_name');
         $element->setLabel($translate->translate('Name'));
        //***************************************************************************
        $user_registrationDateTime = new ZendX_JQuery_Form_Element_DatePicker("user_registrationDateTime",'');
        $user_registrationDateTime->setLabel($translate->translate('Date'));
        //***************************************************************************
        $url = new Zend_View_Helper_Url();
        
        $link = '<a href = "'."javascript:load0()".'">'.$translate->translate('State').'</a>';
        $element = $this->getElement('State_id_stateValue');
        $element->setLabel($translate->translate('State'));
        $element->setDescription( $link );
        $element->setDecorators(	array('ViewHelper',array('Description', array('escape' => false, 'tag' => false)),
        array('HtmlTag', array('tag' => 'dd')),
        array('Label', array('tag' => 'dt')),
        'Errors')); 
        
        //*** vytvoreni hidden poli pro jmeno hodnoty a hodnotu
        $State_id_stateInputName = new Zend_Form_Element_Hidden('State_id_stateInputName');
        $State_id_stateInputName->setValue(NULL);
        $State_id_stateInputValue = new Zend_Form_Element_Hidden('State_id_stateInputValue');
        $State_id_stateInputValue->setValue(NULL);
        
        $nameState_nameInputName = new Zend_Form_Element_Hidden('nameState_nameInputName');
        $nameState_nameInputName->setValue(NULL);
        $nameState_nameInputValue = new Zend_Form_Element_Hidden('nameState_nameInputValue');
        $nameState_nameInputValue->setValue(NULL);
        //***************************************************************************
        $url = new Zend_View_Helper_Url();
        
        $link = '<a href = "'."javascript:load1()".'">'.$translate->translate('Role').'</a>';
        $element = $this->getElement('Role_id_roleValue');
        $element->setLabel($translate->translate('Role'));
        $element->setDescription( $link );
        $element->setDecorators(	array('ViewHelper',array('Description', array('escape' => false, 'tag' => false)),
        array('HtmlTag', array('tag' => 'dd')),
        array('Label', array('tag' => 'dt')),
        'Errors')); 
        
        //*** vytvoreni hidden poli pro jmeno hodnoty a hodnotu
        $Role_id_roleInputName = new Zend_Form_Element_Hidden('Role_id_roleInputName');
        $Role_id_roleInputName->setValue(NULL);
        $Role_id_roleInputValue = new Zend_Form_Element_Hidden('Role_id_roleInputValue');
        $Role_id_roleInputValue->setValue(NULL);
        
        $Role_roleInputName = new Zend_Form_Element_Hidden('Role_roleInputName');
        $Role_roleInputName->setValue(NULL);
        $Role_roleInputValue = new Zend_Form_Element_Hidden('Role_roleInputValue');
        $Role_roleInputValue->setValue(NULL);
        
        // vytvoří formulářový prvek odesílací tlačítko
        $submitInsert = new Zend_Form_Element_Submit("send", array("label" => $translate->translate('Search')));
        // pred pridanim do DisplayGroups je nutne pridat vsechny prvky do formulare (addElements)
        $this->addElements(array(
        							$State_id_stateInputName,
        							$State_id_stateInputValue,
        							$user_registrationDateTime,
        							$Role_id_roleInputName,
        							$Role_id_roleInputValue,
        							
        							$Role_roleInputName,
        							$Role_roleInputValue,
        							$nameState_nameInputName,
        							$nameState_nameInputValue
        							)
        						);
        // přidá formulářové prvky do formuláře
        $this->addDisplayGroup(array(
        								'user_userName',
        								'user_name',
        								'user_registrationDateTime',
        								'State_id_stateValue',
        								'Role_id_roleValue',
        								
        								
        
        								'Role_id_roleInputName',
        								'Role_id_roleInputValue',
        								'Role_roleInputName',
        								'Role_roleInputValue',
        
        								'State_id_stateInputName',
        								'State_id_stateInputValue',
        								'nameState_nameInputName',
        								'nameState_nameInputValue'
        								
        							),'formRoleEdit',array('legend' => $translate->translate('SearchUser')));
        $this->addElements(array($submitInsert));
    }


}
