'sorter'); protected $_reorderTitleColumn = 'name'; protected $_hasFilter = true; protected $_formDefaults = array('type' => App_Product_AbstractObj::UTILITY_POLE); protected function _bindListColumns(Qs_ViewController_List $list) { $list->addColumn('image', 'image') ->addColumn('text', 'name', array('orderBy' => 'name', 'attribs' => array('align' => 'center'))) ->addColumn('text', 'typeTitle', array('orderBy' => 'type', 'attribs' => array('align' => 'center'), 'title' => 'Type')) ->addColumn( 'link_enum', 'enabled', array( 'title' => 'Show', 'orderBy' => 'enabled', 'attribs' => array('width' => 60), 'values' => array('y' => 'Yes', 'n' => 'No'), ) ) ->addColumn('options', 'options'); return $this; } protected function _bindFormFields(Qs_Form $form) { $form->addElement('text', 'name', array('label' => 'Name', 'required' => true)); $form->addElement('text', 'subtitle', array('label' => 'Subtitle', 'required' => true)); $form->addElement('text', 'specie', array('label' => 'Species', 'required' => false)); $form->addElement('select', 'type', array( 'label' => 'Product Type', 'required' => true, 'multioptions' => $this->dataObj->getDProductType4Select(), 'onchange' => "$('dl:first', this.form).attr('class', this.value);" )); $form->addElement('numeric', 'selfUnloadMeter', array('label' => 'M3',)); $form->addElement('numeric', 'selfUnloadFoot', array('label' => 'Ft3')); $form->addDisplayGroup(array('selfUnloadMeter', 'selfUnloadFoot'), 'self', array('legend' => 'Self unload truck volume limits')); $form->addElement('numeric', 'conventionalMeter', array('label' => 'M3',)); $form->addElement('numeric', 'conventionalFoot', array('label' => 'Ft3')); $form->addDisplayGroup(array('conventionalMeter', 'conventionalFoot'), 'conv', array('legend' => 'Conventional truck volume limits')); $form->addElement('extendedImage', 'image', array( 'label' => 'Image', 'required' => true, 'resize' => self::IMAGE_WIDTH . 'x' . self::IMAGE_HEIGHT, )); $form->addElement('HtmlEditor', 'description', array( 'label' => 'Description', 'required' => true )); $form->addElement('HtmlEditor', 'installations', array('label' => 'Installations')); $form->addElement('HtmlEditor', 'dimension', array( 'label' => 'ANSI Dimensions', 'required' => false )); $form->addElement('HtmlEditor', 'weight', array( 'label' => 'Shipping weights, PENTA, CuNAP', 'required' => false )); $form->addElement('HtmlEditor', 'weightCreo', array( 'label' => 'Shipping weights, CREO', 'required' => false )); $form->addElement('extendedFile', 'file', array( 'label' => 'File (.pdf)', 'validators' => array(array('File_Extension', false, array('pdf'))) )); $type = $this->_getData('type', $this->getFormDefaults('type')); foreach (array('selfUnloadMeter', 'selfUnloadFoot', 'conventionalMeter', 'conventionalFoot') as $elementName) { $form->getElement($elementName)->getDecorator('Label')->setOption('class', 'required'); } $description = ''; if (App_Product_AbstractObj::UTILITY_POLE == $type) { foreach (array('selfUnloadMeter', 'selfUnloadFoot', 'conventionalMeter', 'conventionalFoot') as $elementName) { $form->getElement($elementName)->setRequired(true); } $specieUniqueValidator = new Qs_Validate_Unique($this->dataObj->table, 'specie', $this->dataObj->getPrimaryKey()); $specieUniqueValidator->setMessage('Specie must be unique', Qs_Validate_Unique::NOT_UNIQUE); $form->specie->addValidator($specieUniqueValidator); $form->getDecorator('HtmlTag')->setOption('class', 'product-form_elements ' . $type); $description = 'Please note only ' . self::POLE_MENU_LIMIT . ' products can be shown in the products menu pop-up'; } $form->addElement( 'checkbox', 'showInMenu', array( 'label' => 'Show in menu', 'checkedValue' => 'y', 'uncheckedValue' => 'n', 'decoration' => 'simple', 'description' => $description ) ); $form->addElement( 'checkbox', 'enabled', array( 'label' => 'Show on user end', 'checkedValue' => 'y', 'uncheckedValue' => 'n', 'decoration' => 'simple', ) ); $form->addFormRule(array($this, 'validateForm')); return $this; } public function validateForm($data) { $errors = array(); $oldData = $this->dataObj->getData(); if ($data['type'] == App_Product_AbstractObj::UTILITY_POLE && $data['showInMenu'] == 'y' && $this->dataObj->getPoleProductCount() >= self::POLE_MENU_LIMIT && $oldData['showInMenu'] == 'n') { $errors['showInMenu'] = 'You have already checked ' . self::POLE_MENU_LIMIT . ' products to show in the products menu pop-up'; } return (empty($errors)) ? true : $errors; } protected function _bindFilterFields(Qs_Form $form) { parent::_bindFilterFields($form); $form->addElement( 'select', 'type', array( 'multioptions' => array('' => 'Select One') + $this->dataObj->getDProductType4Select(), ) ); return $this; } }