Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Application_Form_Types_Drevotrieska extends Zend_Form_SubForm
- {
- public function init()
- {
- // základní skupina políček
- //$this->addSubForm(new Application_Form_Types_Default(array('ident' => Application_Model_Order::DREVOTRIESKA)), 'default');
- $this->addElements(array(
- $topEdge = new Zend_Form_Element_Checkbox('top_edge'),
- $bottomEdge = new Zend_Form_Element_Checkbox('bottom_edge'),
- $leftEdge = new Zend_Form_Element_Checkbox('left_edge'),
- $rightEdge = new Zend_Form_Element_Checkbox('right_edge'),
- $atyp = new Zend_Form_Element_File('atyp'),
- $image = new Zend_Form_Element_Image('image'),
- $hinge = new Zend_Form_Element_Select('hinge'),
- $sizes = new Zend_Form_Element_Select('id_size'),
- $decors = new Zend_Form_Element_Select('id_decor'),
- ));
- // ABS hrany
- $topEdge->setLabel('ABS horní');
- $bottomEdge->setLabel('ABS spodní');
- $leftEdge->setLabel('ABS levá');
- $rightEdge->setLabel('ABS pravá');
- // atyp
- $atyp->setLabel('Přiložte Atyp: ')
- ->setDestination(APPLICATION_PATH . '/../data/atyp')
- ->addFilter('Rename', array('source' => $atyp->getFileName(), 'target' => APPLICATION_PATH . '/../data/atyp/' . uniqid()));
- // panty
- $hinge->addMultiOptions(array(
- 0 => 'Žádný',
- 2 => 'Dva',
- 3 => 'Tři',
- ));
- // dekory
- $decors->addMultiOptions(Application_Model_Decor::getDecorListForm());
- $sizes->addMultiOptions(Application_Model_Decor::getSizeListForm());
- }
- }
- class OrderController extends Zend_Controller_Action
- public function indexAction()
- {
- if (!$this->_orderSession->parts) {
- $this->_orderSession->parts = array();
- }
- $this->view->parts = $this->_orderSession->parts;
- $type = $this->getRequest()->default['type'];
- if ($this->getRequest()->isPost()) {
- $defaultForm = new Application_Form_Types_Default(array('type' => $type));
- $customForm = Application_Model_Order::getForm($type);
- // zjištění který formulář používáme
- $form = new Application_Form_Types_Global(array('defaultForm' => $defaultForm,'customForm' => $customForm));
- if ($form->isValid($this->_getAllParams())) {
- // pokud nezadal jméno dokoru přiřadíme mu vlastní
- if (!$form->default->getValue('name')) {
- $form->default->name->setValue('Dílec ' . count($this->_orderSession->parts));
- }
- // pokud jsme u drevotriesky, podíváme se na file
- if($type == Application_Model_Order::TYPES_DREVOTRIESKA){
- $fileName = uniqid() . '-' . $customForm->atyp->getValue();
- $customForm->atyp->receive();
- Zend_Registry::get('Firebug')->log($customForm->getValues(), Zend_Log::DEBUG);
- // vytvoříme jiný název
- //$rename = new Zend_Filter_File_Rename(array('source' => $customForm->atyp->getFileName(), 'target' => APPLICATION_PATH . '/../data/atyp/' . $fileName));
- //$rename->filter(APPLICATION_PATH . '/../data/atyp/' . $fileName);
- //$form->getSubForm('custom')->getElement('atyp')->setValue($fileName);
- }
- //$this->_orderSession->parts[] = $form->getValues();
- $this->_helper->FlashMessenger(
- array('ok' => 'Dílec byl vytvořen.')
- );
- //$this->_helper->redirector('index', 'order');
- }
- }
- $this->view->form = $form;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement