public function danhSachAction() { // TODO Auto-generated {0}::indexAction() default action $loai = $this->getRequest()->getParam('loai'); $quiDinhs = Default_Model_Constraints::quidinh_loai(); if (!array_key_exists($loai, $quiDinhs)) { $this->_redirect('qui-dinh/index'); } else { $ten_loais = Default_Model_Constraints::quidinh_loai(); $this->view->ten_loai = $ten_loais[$loai]; $this->view->lists = Khcn_Api::_()->getDbTable('qui_dinh', 'default')->getQDByLoai($loai); } }
public function indexAction() { // TODO Auto-generated {0}::indexAction() default action $table = Khcn_Api::_()->getDbTable('qui_dinh', 'default'); $quiDinhs = $table->fetchAll($table->select()->order('id DESC')); $this->view->loais = Default_Model_Constraints::quidinh_loai(); $paginator = Zend_Paginator::factory($quiDinhs); $currentPage = 1; //Check if the user is not on page 1 $page = $this->_getParam('page'); if (!empty($page)) { //Where page is the current page $currentPage = $this->_getParam('page'); } //Set the properties for the pagination $paginator->setItemCountPerPage(20); $paginator->setPageRange(10); $paginator->setCurrentPageNumber($currentPage); Zend_Paginator::setDefaultScrollingStyle('Sliding'); Zend_View_Helper_PaginationControl::setDefaultViewPartial('includes/pagination.phtml'); $paginator->setView($this->view); $this->view->paginator = $paginator; }
public function init() { $this->setName('f2')->setAttrib('enctype', 'multipart/form-data')->setMethod('post'); $this->addElement('Hidden', 'search', array('value' => 1)); $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', 'style' => 'width: 85%')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttrib('class', 'text-input medium-input'); $cateOptions = Default_Model_Constraints::quidinh_loai(); $loai = new Zend_Form_Element_Select('loai'); $loai->setLabel('Loại (*)')->addMultiOptions($cateOptions)->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'); $file = new Zend_Form_Element_File('file'); $file->setLabel('Upload file')->setRequired(true)->setDescription('(*.doc, *.docx, *.pdf , < 10MB )')->setDestination(BASE_PATH . '/upload/files/qui_dinh')->addValidator(new Zend_Validate_File_Extension(array('doc,docx,pdf')))->addValidator(new Zend_Validate_File_FilesSize(array('min' => 1, 'max' => 10485760, 'bytestring' => true)))->setDecorators(array('File', 'Errors', array('Description', array('escape' => false, 'tag' => 'div', 'placement' => 'append')), array('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' => 'qui-dinh', '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($ten, $loai, $file, $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')), 'Form')); }