public function run() { $form = new Am_Form_Admin('form-grid-config'); $form->setAttribute('name', 'customize'); $form->addSortableMagicSelect('fields')->loadOptions($this->getFieldsOptions())->setLabel(___('Fields to Display in Grid'))->setJsOptions(<<<CUT { allowSelectAll:true, sortable: true } CUT ); foreach ($this->grid->getVariablesList() as $k) { $form->addHidden($this->grid->getId() . '_' . $k)->setValue($this->grid->getRequest()->get($k, "")); } $form->addSaveButton(); $form->setDataSources(array($this->grid->getCompleteRequest())); if ($form->isSubmitted()) { $values = $form->getValue(); $this->setConfig($values['fields']); $this->grid->redirectBack(); } else { $form->setDataSources(array(new HTML_QuickForm2_DataSource_Array(array('fields' => $this->getSelectedFields())))); echo $this->renderTitle(); echo sprintf('<div class="info">%s</div>', ___('You can change Number of %sRecords per Page%s in section %sSetup/Configuration%s', '<strong>', '</strong>', '<a class="link" href="' . REL_ROOT_URL . '/admin-setup" target="_top">', '</a>')); echo $form; } }
public function run() { $form = new Am_Form_Admin(); $form->setAction($this->getUrl()); $form->setAttribute('name', 'export'); $form->setAttribute('target', '_blank'); $form->addSortableMagicSelect('fields_to_export')->loadOptions($this->getExportOptions())->setLabel(___('Fields To Export'))->setJsOptions(<<<CUT { allowSelectAll:true, sortable: true } CUT ); $form->addElement('select', 'export_type')->loadOptions(Am_Grid_Export_Processor_Factory::getOptions())->setLabel(___('Export Format'))->setId('form-export-type'); foreach (Am_Grid_Export_Processor_Factory::createAll() as $id => $obj) { $obj->buildForm($form->addElement('fieldset', $id)->setId('form-export-options-' . $id)); } $form->addSubmit('export', array('value' => ___('Export'))); $script = <<<CUT (function(\$){ \$(function(){ function update_options(\$sel) { \$('[id^=form-export-options-]').hide(); \$('#form-export-options-' + \$sel.val()).show(); } update_options(\$('#form-export-type')); \$('#form-export-type').bind('change', function() { update_options(\$(this)); }) }) })(jQuery) CUT; $form->addScript('script')->setScript($script); $this->initForm($form); if ($form->isSubmitted()) { $values = $form->getValue(); $fields = array(); foreach ($values['fields_to_export'] as $fieldName) { $fields[$fieldName] = $this->getField($fieldName); } $export = Am_Grid_Export_Processor_Factory::create($values['export_type']); $export->run($this->grid, $this->getDataSource($fields), $fields, $values); exit; } else { echo $this->renderTitle(); echo $form; } }
public function createWidgetSalesConfigForm() { $form = new Am_Form_Admin(); $form->addSortableMagicSelect('interval', null, array('options' => $this->getDi()->interval->getOptions()))->setLabel(___('Period'))->setValue(array(Am_Interval::PERIOD_TODAY)); return $form; }