/** * Cria a toolbar. * @param Boolean $save define se irá aparecer o botão padrão Salvar. * @param Boolean $saveClose Botão para salvar e fechar * @param Boolean $printForm Botão para imprimir * @param Boolean $deleteForm Botão para deletar * @param Boolean $clearForm Botão limpar dados de um formulário * @param Boolean $includeForm Botão para incluir * @param Boolean $editForm Botão para editar * @param Boolean $backForm Botão para voltar * @param Boolean $execute Botão para executar processo [GAMBI] * @param Boolean $returnPendency Botão para processar dados [GAMBI] * @param Boolean $processData Botão para processar dados [GAMBI] * @param Boolean $block Botão para bloquear recursos [GAMBI] * @param Boolean $disable Botão para desativar recursos [GAMBI] */ public function createToolbar($save = false, $saveClose = false, $printForm = false, $deleteForm = false, $clearForm = false, $includeForm = false, $editForm = false, $backForm = false, $execute = false, $returnPendency = false, $processData = false, $block = false, $disable = false, array $params = null) { $elementsList = array(); $elementsNameList = array(); if ($save) { $saveForm = new Zend_Form_Element_Submit('saveForm'); $saveForm->setLabel('Salvar'); $saveForm->setAttrib('class', 'save'); $saveForm->setDecorators(array(array('ViewHelper'), array('description'), array('HtmlTag', array('tag' => 'li')))); $elementsList[] = $saveForm; $elementsNameList[] = "saveForm"; } if ($saveClose) { $saveCloseForm = new Zend_Form_Element_Submit('saveCloseForm'); // $saveCloseForm = new Zend_Form_Element_Hidden('saveCloseForm'); $saveCloseForm->setLabel('Salvar/Fechar'); $saveCloseForm->setAttrib('class', 'save_close'); // $saveCloseForm->setDescription('<a href="" class="save_close" id="save_close">Salvar/Fechar</a>'); $saveCloseForm->setDecorators(array(array('ViewHelper'), array('description'), array('HtmlTag', array('tag' => 'li')))); $saveCloseForm->getDecorator('description')->setOption('escape', false); $elementsList[] = $saveCloseForm; $elementsNameList[] = "saveCloseForm"; } if ($execute) { $execute = new Zend_Form_Element_Hidden('execute'); $execute->setDescription('<a href="" id="execute" class="execute">Executar</a>'); $execute->setDecorators(array(array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'execute')))); $execute->getDecorator('description')->setOption('escape', false); $elementsList[] = $execute; $elementsNameList[] = "execute"; } if ($returnPendency) { $returnPendency = new Zend_Form_Element_Hidden('returnPendency'); $returnPendency->setDescription('<a href="" id="rtPendency" class="back">Retornar pendência</a>'); $returnPendency->setDecorators(array(array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'back')))); $returnPendency->getDecorator('description')->setOption('escape', false); $elementsList[] = $returnPendency; $elementsNameList[] = "returnPendency"; } if ($processData) { $processData = new Zend_Form_Element_Hidden('processData'); $processData->setDescription('<a href="" id="processData" class="process">Dados do processo</a>'); $processData->setDecorators(array(array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'process')))); $processData->getDecorator('description')->setOption('escape', false); $elementsList[] = $processData; $elementsNameList[] = "processData"; } if ($clearForm) { $clearForm = new Zend_Form_Element_Hidden('clearForm'); $clearForm->setDescription('<a href="" id="clear_btn" class="clean">Limpar</a>'); $clearForm->setDecorators(array(array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'clear')))); $clearForm->getDecorator('description')->setOption('escape', false); $elementsList[] = $clearForm; $elementsNameList[] = "clearForm"; } if ($includeForm) { $includeForm = new Zend_Form_Element_Hidden('includeForm'); $includeForm->setDescription('<a href="#" id="include_btn" class="include">Incluir</a>'); $includeForm->setDecorators(array(array('ViewHelper'), array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'include')))); $includeForm->getDecorator('description')->setOption('escape', false); $elementsList[] = $includeForm; $elementsNameList[] = "includeForm"; } if ($editForm) { $editForm = new Zend_Form_Element_Hidden('editForm'); $editForm->setDescription('<a href="#" id="edit_btn" class="edit">Editar</a>'); $editForm->setDecorators(array(array('ViewHelper'), array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'edit')))); $editForm->getDecorator('description')->setOption('escape', false); $elementsList[] = $editForm; $elementsNameList[] = "editForm"; } if ($deleteForm) { $deleteForm = new Zend_Form_Element_Hidden('deleteForm'); $deleteForm->setDescription('<a href="" id="delete_btn" class="delete">Excluir</a>'); $deleteForm->setDecorators(array(array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'delete')))); $deleteForm->getDecorator('description')->setOption('escape', false); $elementsList[] = $deleteForm; $elementsNameList[] = "deleteForm"; } if ($block) { $block = new Zend_Form_Element_Hidden('blockForm'); $block->setDescription('<a href="" id="block_btn" class="block">Bloquear/Desbloquear</a>'); $block->setDecorators(array(array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'block')))); $block->getDecorator('description')->setOption('escape', false); $elementsList[] = $block; $elementsNameList[] = "blockForm"; } if ($disable) { $disable = new Zend_Form_Element_Hidden('disableForm'); $disable->setDescription('<a href="" id="disable_btn" class="disable">Ativar/Desativar</a>'); $disable->setDecorators(array(array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'disable')))); $disable->getDecorator('description')->setOption('escape', false); $elementsList[] = $disable; $elementsNameList[] = "disableForm"; } if ($printForm) { $printForm = new Zend_Form_Element_Hidden('printForm'); $printForm->setDescription('<a href="" id="print_btn" class="prints">Impressões</a>'); $printForm->setDecorators(array(array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'prints')))); $printForm->getDecorator('description')->setOption('escape', false); $elementsList[] = $printForm; $elementsNameList[] = "printForm"; } if ($backForm) { $backForm = new Zend_Form_Element_Hidden('backForm'); $backForm->setDescription('<a href="' . $_SERVER['HTTP_REFERER'] . '" id="back_btn" class="back">Voltar</a>'); $backForm->setDecorators(array(array('ViewHelper'), array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'back')))); $backForm->getDecorator('description')->setOption('escape', false); $elementsList[] = $backForm; $elementsNameList[] = "backForm"; } if (isset($params)) { foreach ($params as $idParam => $valueParam) { $objectZendForm = "Zend_Form_Element_" . $valueParam["typeButton"]; $idParam = new $objectZendForm($valueParam["name"]); if ($valueParam["typeButton"] == "Hidden") { $idParam->setDescription('<a href="' . $valueParam["href"] . '" id="' . $valueParam["name"] . '" class="' . $valueParam["class"] . '">' . $valueParam["label"] . '</a>'); $idParam->setDecorators(array(array('description'), array('HtmlTag', array('tag' => 'li')))); $idParam->getDecorator('description')->setOption('escape', false); } else { if ($valueParam["typeButton"] == "Submit") { $idParam->setLabel($valueParam["label"]); $idParam->setAttrib('class', $valueParam["class"]); $idParam->setDecorators(array(array('ViewHelper'), array('description'), array('HtmlTag', array('tag' => 'li')))); } } $elementsList[] = $idParam; $elementsNameList[] = $valueParam["name"]; } } $this->clearDecorators(); $this->addDecorator('FormElements')->addDecorator('HtmlTag', array('tag' => '<ul>'))->addDecorator('Form'); $this->addElements($elementsList); $this->addDisplayGroup($elementsNameList, 'toolbar', array('legend' => '')); $toolbar = $this->getDisplayGroup('toolbar'); $toolbar->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'ul', 'id' => 'toolbar')))); }
/** * @author code generate * @return mixed */ public function __construct($option = array()) { $userId = new Zend_Form_Element_Hidden('TutorId'); $userId->setDecorators(array('ViewHelper')); $this->addElement($userId); $birthDay = new Zend_Form_Element_Text('Birthday'); $birthDay->setLabel('Ngày sinh *'); $birthDay->addFilter('StringTrim'); $birthDay->setRequired(true); $birthDay->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'col-lg-2 control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $birthDay->addValidator('stringLength', false, array(2, 50, "messages" => "Ngày sinh dài tối đa 50 ký tự")); $this->addElement($birthDay); $gender = new Zend_Form_Element_Select('Gender'); $gender->setLabel('Giới tính *'); $gender->addFilter('StringTrim'); $gender->setRequired(true); $gender->setMultiOptions(array('1' => 'Nam', '0' => 'Nữ')); $gender->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $gender->setSeparator(''); $gender->setValue("1"); $this->addElement($gender); $email = new Zend_Form_Element_Text('Email'); $email->setLabel('Email *'); $email->addFilter('StringTrim'); $email->setRequired(true); $email->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'col-lg-2 control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $email->addValidator(new Zend_Validate_Db_NoRecordExists("Tutors", "Email")); $email->addValidator('EmailAddress', true); $email->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Email không phù hợp"))); $this->addElement($email); $userName = new Zend_Form_Element_Text('UserName'); $userName->setLabel('Họ tên *'); $userName->addFilter('StringTrim'); $userName->setRequired(true); $userName->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'col-lg-2 control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $userName->addValidator('stringLength', false, array(2, 50, "messages" => "Họ tên dài tối đa 2-50 ký tự")); $this->addElement($userName); $address = new Zend_Form_Element_Text('Address'); $address->setLabel('Địa chỉ *'); $address->addFilter('StringTrim'); $address->setRequired(true); $address->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'col-lg-2 control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $userName->addValidator('stringLength', false, array(1, 100, "messages" => "Địa chỉ dài tối đa 100 ký tự")); $this->addElement($address); $phone = new Zend_Form_Element_Text('Phone'); $phone->setLabel('Điện thoại *'); $phone->addFilter('StringTrim'); $phone->setRequired(true); $phone->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'col-lg-2 control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $phone->addValidator('stringLength', false, array(6, 50, "messages" => "Điện thoại dài tối đa 6-50 ký tự")); $this->addElement($phone); $required = new Zend_Validate_NotEmpty(); $required->setType($required->getType() | Zend_Validate_NotEmpty::INTEGER | Zend_Validate_NotEmpty::ZERO); $level = new Zend_Form_Element_Select('Level'); $level->setLabel('Trình độ *'); $level->addFilter('StringTrim'); $level->addValidator('Int'); $level->setRequired(true); $level->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $level->addValidators(array($required)); $level->setMultiOptions(unserialize(TUTOR_LEVELS)); $this->addElement($level); $university = new Zend_Form_Element_Text('University'); $university->setLabel('Trường tốt nghiệp *'); $university->addFilter('StringTrim'); $university->setRequired(true); $university->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $university->addValidator('stringLength', false, array(1, 100, "messages" => "Trường tố nghiệp dài tối đa 100 ký tự")); $this->addElement($university); $subject = new Zend_Form_Element_Text('Subject'); $subject->setLabel('Chuyên ngành *'); $subject->addFilter('StringTrim'); $subject->setRequired(true); $subject->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $subject->addValidator('stringLength', false, array(1, 100, "messages" => "Chuyên ngành dài tối đa 100 ký tự")); $this->addElement($subject); $experienceYears = new Zend_Form_Element_Select('ExperienceYears'); $experienceYears->setLabel('Số Năm Kinh Nghiệm *'); $experienceYears->addFilter('StringTrim'); $experienceYears->setRequired(false); $experienceYears->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $options = unserialize(EXPERIENCE_YEAR); //$experienceYears->addMultiOptions(array_combine($options, $options)); $experienceYears->setMultiOptions(unserialize(EXPERIENCE_YEAR)); $this->addElement($experienceYears); $career = new Zend_Form_Element_Select('Career'); $career->setLabel('Hiện tại là *'); $career->addFilter('StringTrim'); $career->addValidator('Int'); $career->setRequired(true); $career->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $career->setMultiOptions(unserialize(TUTOR_CAREERS)); $this->addElement($career); $careerLocation = new Zend_Form_Element_Text('CareerLocation'); $careerLocation->setLabel('Nơi Công Tác ( Giáo hoặc Giảng Viên ) *'); $careerLocation->addFilter('StringTrim'); $careerLocation->setRequired(false); $careerLocation->setAttrib('style', 'min-height: 30px;'); $careerLocation->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $careerLocation->addValidator('stringLength', false, array(1, 100, "messages" => "Nơi Công Tác dài tối đa 100 ký tự")); $this->addElement($careerLocation); $teachableInClass = new Zend_Form_Element_Text('TeachableInClass'); $teachableInClass->setLabel('Lớp Có Thể Dạy'); $teachableInClass->addFilter('StringTrim'); $teachableInClass->setRequired(false); $teachableInClass->setAttrib('disabled', true); $teachableInClass->setDescription('<a id="grades-modal" class="btn btn-info" title="Chọn lớp">...</a>'); $teachableInClass->setDecorators(array('ViewHelper', array('Description', array('escape' => false)), array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control col-lg-6')), array('Label', array('class' => 'control-label col-lg-2')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $this->addElement($teachableInClass); $teachableSubjects = new Zend_Form_Element_Text('TeachableSubjects'); $teachableSubjects->setLabel('Môn Có Thể Dạy'); $teachableSubjects->addFilter('StringTrim'); $teachableSubjects->setRequired(false); $teachableSubjects->setAttrib('disabled', true); $teachableSubjects->setDescription('<a id="subjects-modal" class="btn btn-info" title="Chọn môn">...</a>'); $teachableSubjects->setDecorators(array('ViewHelper', array('Description', array('escape' => false)), array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control col-lg-6')), array('Label', array('class' => 'control-label col-lg-2')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $this->addElement($teachableSubjects); $teachableDistricts = new Zend_Form_Element_Text('TeachableDistricts'); $teachableDistricts->setLabel('Khu Vực Có Thể Dạy'); $teachableDistricts->addFilter('StringTrim'); $teachableDistricts->setRequired(false); $teachableDistricts->setAttrib('disabled', true); $teachableDistricts->setDescription('<span id="districts-modal" class="btn btn-info" title="Chọn quận">...</span>'); $teachableDistricts->setDecorators(array('ViewHelper', array('Description', array('escape' => false)), array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control col-lg-6')), array('Label', array('class' => 'control-label col-lg-2')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $this->addElement($teachableDistricts); $avatar = new Zend_Form_Element_Hidden('Upload'); $avatar->setLabel('Hình đại diện'); $avatar->setRequired(false); $avatar->setDescription('fieldlabel'); $avatar->setDecorators(array('ViewHelper', array(array('Description' => 'HtmlTag'), array('tag' => 'div', 'id' => "file-uploader")), array(array('Errors' => 'HtmlTag'), array('placement' => 'append', 'tag' => 'img', 'id' => 'progress-img', 'src' => "/scripts/upload/loading.gif")), array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control', 'style' => "position: relative;float: left;margin-left: 20px;")), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $this->addElement($avatar); $avatarNote = new Zend_Form_Element_Hidden('Avatar'); $avatarNote->setLabel('Chú ý'); $avatarNote->setRequired(false); $avatarNote->setDescription("Kích thước khoảng: 240 x 120 (px)<br>Kích cỡ cho phép: " . IMAGE_SIZE_LIMIT . " kB"); $avatarNote->setDecorators(array('ViewHelper', array('Description', array('escape' => false, 'tag' => 'div')), array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group', 'style' => "float: left;")))); $this->addElement($avatarNote); $introduction = new Zend_Form_Element_Textarea('Introduction'); $introduction->setLabel('Giới thiệu bản thân'); $introduction->addFilter('StringTrim'); $introduction->setRequired(false); $introduction->setOptions(array('cols' => '10', 'rows' => '4')); /* $introduction->setDecorators(array('ViewHelper')); */ $introduction->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $subject->addValidator('stringLength', false, array(1, 2000, "messages" => "Giới thiệu bản thân dài tối đa 2000 ký tự")); $this->addElement($introduction); $isDisabled = new Zend_Form_Element_Text('IsDisabled'); $isDisabled->setLabel('IsDisabled'); $isDisabled->addFilter('StringTrim'); $isDisabled->addValidator('Int'); $isDisabled->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $this->addElement($isDisabled); $submit = new Zend_Form_Element_Submit('Save'); $submit->setLabel('Đăng ký'); $submit->setAttrib('class', 'btn btn-primary'); $submit->setDecorators(array('ViewHelper')); $this->addElement($submit); $reset = new Zend_Form_Element_Reset('Reset'); $reset->setLabel('Làm lại'); $reset->setAttrib('class', 'btn btn-primary'); $reset->setDecorators(array('ViewHelper')); $this->addElement($reset); $this->addDisplayGroup(array('UserName', 'Gender', 'Birthday', 'Email', 'Address', 'Phone'), 'contact', array('disableLoadDefaultDecorators' => false, 'legend' => 'Thông tin cá nhân')); $contact = $this->getDisplayGroup('contact'); $contact->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'fieldset', 'class' => 'well the-fieldset')))); $this->addDisplayGroup(array('Level', 'University', 'Subject', 'Career', 'CareerLocation', 'ExperienceYears'), 'level', array('disableLoadDefaultDecorators' => false, 'legend' => 'Thông tin học vấn')); $level = $this->getDisplayGroup('level'); $level->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'fieldset', 'class' => 'well the-fieldset')))); $this->addDisplayGroup(array('TeachableInClass', 'TeachableSubjects', 'TeachableDistricts', 'Upload', 'Avatar', 'Introduction'), 'extra', array('disableLoadDefaultDecorators' => false, 'legend' => 'Thông tin thêm')); $extra = $this->getDisplayGroup('extra'); $extra->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'fieldset', 'class' => 'well the-fieldset')))); $this->addDisplayGroup(array('Save', 'Reset'), 'submit', array('disableLoadDefaultDecorators' => false, 'legend' => 'Thông tin học vấn')); $submit = $this->getDisplayGroup('submit'); $submit->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'fieldset', 'class' => 'well the-fieldset')))); }