Ejemplo n.º 1
0
 public function init()
 {
     $this->setName('f3')->setMethod('post');
     $mauOptions = array("multiOptions" => Default_Model_Constraints::report());
     $mau = new Zend_Form_Element_Select('mau', $mauOptions);
     $mau->setRequired(true)->setLabel('Mẫu báo cáo (*)')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width : 85%')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttribs(array('id' => 'mau'));
     $namOptions = array("multiOptions" => Default_Model_Constraints::nam());
     $nam = new Zend_Form_Element_Select('nam', $namOptions);
     $nam->setRequired(true)->setLabel('Năm (*)')->setValue(date('Y'))->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttribs(array('id' => 'nam'));
     $quyet_dinh = new Zend_Form_Element_Text('quyet_dinh');
     $quyet_dinh->setLabel('Quyết định')->addFilter('StripTags')->addFilter('StringTrim')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input medium-input');
     $loai_lv = new Default_Model_LoaiLinhVuc();
     $llvOptions = array("multiOptions" => $loai_lv->getMultiOptions());
     $ma_loai = new Zend_Form_Element_Select('ma_loai', $llvOptions);
     $ma_loai->setLabel('Loại')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr', 'id' => 'ma_loai-wrapper'))));
     $options = array("multiOptions" => array('1' => 'Có', '0' => 'Không'));
     $thong_bao = new Zend_Form_Element_Radio('thong_bao', $options);
     $thong_bao->setRequired(true)->setLabel('Tạo thông báo mới')->setValue('0')->setSeparator('')->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'thong_bao')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr', 'id' => 'thong_bao-wrapper'))))->setAttribs(array('id' => 'thong_bao'));
     $fileTypeOptions = array("multiOptions" => array('excel' => 'Excel', 'pdf' => 'Pdf'));
     $file_type = new Zend_Form_Element_Select('file_type', $fileTypeOptions);
     $file_type->setRequired(true)->setLabel('Xuất Thành File')->setSeparator('')->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'file_type')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr', 'id' => 'file_type-wrapper'))))->setAttribs(array('id' => 'file_type'));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel('Xuất')->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span', 'class' => 'filter_btn_l'))))->setAttribs(array('class' => 'button', 'id' => 'submit'));
     $this->addElements(array($mau, $nam, $quyet_dinh, $ma_loai, $thong_bao, $file_type, $submit));
     $this->addDisplayGroup(array('submit'), 'report', array('decorators' => array('FormElements', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'td')), array('HtmlTag', array('tag' => 'tr', 'id' => 'report')))));
     $this->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'table', 'class' => 'report_dt')), 'Form'));
 }
Ejemplo n.º 2
0
 public function init()
 {
     $this->setName('f2')->setMethod('post');
     $id = new Zend_Form_Element_Hidden('id');
     $id->addFilter('Int');
     $ma = new Zend_Form_Element_Text('ma');
     $ma->setLabel('Mã (*)')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->addValidator(new Zend_Validate_StringLength(0, 10))->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width: 85%')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input');
     $ten = new Zend_Form_Element_Text('ten');
     $ten->setLabel('Tên (*)')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input medium-input');
     $mo_ta = new Zend_Form_Element_Textarea('mo_ta');
     $mo_ta->setLabel('Mô tả')->addFilter('StripTags')->addFilter('StringTrim')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttribs(array('id' => 'mo_ta', 'class' => 'textarea', 'rows' => '4'));
     $loai_lv = new Default_Model_LoaiLinhVuc();
     $llvOptions = array("multiOptions" => $loai_lv->getMultiOptions());
     $ma_loai = new Zend_Form_Element_Select('ma_loai', $llvOptions);
     $ma_loai->setLabel('Loại lĩnh vực')->setDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))));
     $submitCon = new Zend_Form_Element_Submit('submitCon');
     $submitCon->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span'))))->setAttribs(array('class' => 'button'));
     $submitExit = new Zend_Form_Element_Submit('submitExit');
     $submitExit->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span'))))->setAttribs(array('class' => 'button'));
     $url = new Zend_View_Helper_Url();
     $link = $url->url(array('module' => 'admin', 'controller' => 'linh-vuc', 'action' => 'index'), null, true);
     $cancel = new Zend_Form_Element_Button('cancel');
     $cancel->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'span')), array(array('row' => 'HtmlTag'), array('tag' => 'span'))))->setAttribs(array('class' => 'button', 'onclick' => 'window.location.href="' . $link . '"'));
     $this->addElements(array($id, $ma, $ten, $mo_ta, $ma_loai, $submitCon, $submitExit, $cancel));
     $this->addDisplayGroup(array('submitCon', 'submitExit', 'cancel'), 'submit', array('decorators' => array('FormElements', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'colspan' => 2)), array(array('row' => 'HtmlTag'), array('tag' => 'td')))));
     $this->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'table', 'class' => 'linh_vuc')), 'Form'));
 }
Ejemplo n.º 3
0
 public function themAction()
 {
     // TODO Auto-generated {0}::indexAction() default action
     $form = new Admin_Form_LoaiLV();
     $form->submitCon->setLabel('Lưu và tiếp tục');
     $form->submitExit->setLabel('Lưu và thoát');
     $form->cancel->setLabel('Không lưu');
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             $loai_lv = new Default_Model_LoaiLinhVuc();
             $loai_lv->setMa($form->getValue('ma'))->setTen($form->getValue('ten'));
             $kq = $loai_lv->them();
             if (!$kq) {
                 $_SESSION['msg'] = 'Lỗi !. Đã có lỗi trong quá trình xử lý, vui lòng thử lại .';
                 $_SESSION['type_msg'] = 'error';
                 $this->_redirect('/admin/loai-lv/index');
             }
             $_SESSION['msg'] = 'Thành công !. Dữ liệu đã được lưu trữ .';
             $_SESSION['type_msg'] = 'success';
             if ($form->submitCon->isChecked()) {
                 $this->_redirect('/admin/loai-lv/them');
             } else {
                 $this->_redirect('/admin/loai-lv/index');
             }
         } else {
             $form->populate($formData);
         }
     }
 }
Ejemplo n.º 4
0
 public function getAll()
 {
     $loai_lv = new Default_Model_LoaiLinhVuc();
     $linhVucs = $this->linh_vuc->fetchAll();
     $dsLinhVucs = array();
     $loais = $loai_lv->getMultiOptions();
     foreach ($linhVucs as $linh_vuc) {
         $dsLinhVucs[] = array('id' => $linh_vuc['id'], 'ma' => $linh_vuc['ma'], 'ten' => $linh_vuc['ten'], 'mo_ta' => $linh_vuc['mo_ta'], 'loai' => $loais[$linh_vuc['ma_loai']]);
     }
     return $dsLinhVucs;
 }