v7‰PNG  IHDR Ÿ f Õ†C1 sRGB ®Îé gAMA ± üa pHYs à ÃÇo¨d GIDATx^íÜL”÷ð÷Yçªö("Bh_ò«®¸¢§q5kÖ*:þ0A­ºšÖ¥]VkJ¢M»¶f¸±8\k2íll£1]q®ÙÔ‚ÆT home/ajdemo/public_html/mempro/application/form/library/FormField.php000064400000022570152101611060022025 0ustar00getDi()->security->obfuscate($this->pk()); $el = null; switch ($this->type) { case 'grid': $grid_rows = $this->grid_rows ?: 10; $el = $form->addElement($this->type, $name, array('class' => 'row-wide'), array('grid_rows' => $grid_rows)) ->setLabel($this->title . "\n" . $this->description); $el->addHidden('rows', array('id' => $name . '-rows', 'class' => 'form-grid-rows', 'data-name' => $name)); $default[$name]['rows'] = 1; $el->addHtml()->setHtml(''); $fields = $this->getFields(); foreach ($fields as $f) { $el->addHtml()->setHtml( sprintf(''); } $el->addHtml()->setHtml(''); for ($i = 0; $i < $grid_rows; $i++) { $g = $el->addGroup($i); $g->addHtml()->setHtml(''); $my_default = array(); foreach ($fields as $f) { $g->addHtml()->setHtml(sprintf(''); } $default[$name][$i] = $my_default; $g->addHtml()->setHtml(''); } $el->addHtml()->setHtml('
', $this->getDi()->security->obfuscate($f->pk())) . Am_Html::escape($f->title) . '
', $this->getDi()->security->obfuscate($f->pk()))); $g->addHtml()->setHtml('
'); $my_default = $my_default + $f->insertField($g); $g->addHtml()->setHtml('
'); $g->addHtml()->setHtml('
'); foreach ($fields as $f) { if ($f->cond_enabled) { $c_cond = $f->cond_type > 0 ? '==' : '!='; $c_field_val = json_encode($f->cond_field_val); $c_field_name = $this->getDi()->security->obfuscate($f->cond_field_id); $f_name = $this->getDi()->security->obfuscate($f->pk()); $form->addScript() ->setScript(<< 0); }).change(); CUT ); } } break; case 'html': $form->addHtml(null, array('class' => 'row-wide')) ->setHtml($this->html); break; case 'text': case 'textarea': $el = $form->addElement($this->type, $name, array('class' => 'el-wide')) ->setLabel($this->title . "\n" . $this->description); break; case 'select': case 'advradio': $el = $form->addElement($this->type, $name) ->setLabel($this->title . "\n" . $this->description) ->loadOptions($this->getOptions()); if ($d = $this->getDefault()) { $default[$name] = $d[0]; } break; case 'date': $form->addDate($name) ->setLabel($this->title . "\n" . $this->description); break; case 'upload': $urlUpload = '/upload/upload'; $urlGet = '/upload/get'; $el = $form->addUpload($name, array(), array( 'secure' => true, 'prefix' => Bootstrap_Form::UPLOAD_PREFIX)) ->setLabel($this->title . "\n" . $this->description); if (defined('AM_ADMIN') && AM_ADMIN) { $urlUpload = '/admin-upload/upload'; $urlGet = '/admin-upload/get'; //$el->toggleFrozen(true); } $el->setJsOptions(<<addGroup($name); $el->setLabel($this->title . "\n" . $this->description); $el->setSeparator("
"); foreach ($this->getOptions() as $k => $v) { $chkbox = $el->addAdvCheckbox(null, array('value' => $k))->setContent(___($v)); } $el->addHidden(null, array('value' => '')); $el->addFilter('array_filter'); if ($d = $this->getDefault()) { $default[$name] = $d; } break; } if ($el && $this->is_required && !$skip_validation) { $el->addRule('required'); } if ($this->cond_enabled) { $c_cond = $this->cond_type > 0 ? '==' : '!='; $c_field_val = json_encode($this->cond_field_val); $c_field_name = $this->getDi()->security->obfuscate($this->cond_field_id); $form->addScript() ->setScript(<<getDi()->formGridFieldTable->selectObjects("SELECT * FROM " . "?_form_grid_field WHERE field_id=? ORDER BY sort_order", $this->pk()); } function getOptions() { return $this->options ? json_decode($this->options, true) : array(); } function getDefault() { return $this->default ? json_decode($this->default, true) : array(); } function toPdf($v) { switch ($this->type) { case 'grid' : unset($v['rows']); $result = array(); $fields = $this->getFields(); $data = array(); foreach ($v as $row) { $_ = array(); foreach ($row as $key => $val) { $_[$this->getDi()->security->reveal($key)] = $val; } $data[] = $_; } $h = array(); foreach ($fields as $f) { $h[] = $f->title; } $result[] = $h; foreach ($data as $row) { $r = array(); foreach ($fields as $f) { $r[] = isset($row[$f->pk()]) ? $f->toPdf($row[$f->pk()]) : ''; } $result[] = $r; } return $result; case 'text': case 'textarea': return $v; case 'select': case 'advradio': case 'checkbox': $nv = array(); $op = $this->getOptions(); foreach((array)$v as $_) { $nv[] = isset($op[$_]) ? $op[$_] : $_; } return implode(', ', $nv); case 'date': return amDate($v); case 'upload': $upload = $this->getDi()->uploadTable->load($v, false); if (!$upload) return ''; switch ($upload->getType()) { case 'image/png' : $image = new Zend_Pdf_Resource_Image_Png($upload->getFullPath()); break; case 'image/jpeg' : $image = new Zend_Pdf_Resource_Image_Jpeg($upload->getFullPath()); break; case 'image/tiff' : $image = new Zend_Pdf_Resource_Image_Tiff($upload->getFullPath()); break; } return $image ? $image : $upload->name; } } function toTable($v) { return is_array($v) ? json_encode($v) : $v; } function fromTable($v) { $_ = json_decode($v, true); return $_ ? $_ : $v; } function delete() { $_ = parent::delete(); $this->deleteFromRelatedTable('?_form_data'); $this->deleteFromRelatedTable('?_form_grid_field'); return $_; } } class FormFieldTable extends Am_Table { protected $_table = '?_form_field'; protected $_key = 'field_id'; protected $_recordClass = 'FormField'; }