/**
  *
  * @static
  * @param string $value
  * @param Zend_View_Interface $view
  * @return string
  */
 public static function getHtml($value, Zend_View_Interface $view = null)
 {
     $value = json_decode($value, true);
     if (!is_array($value)) {
         $value = json_decode(self::getSaveValue('25'), true);
     }
     $html = '<script type="text/javascript">
         function removeRate(id) {
             $(\'#wraper-\' + id).remove();
         }
         function addRate() {
             var rand = Math.floor(Math.random() * 2147483647);
             var html = $(\'#shippingmultirate-template\').html();
             html = html.replace(/{template_id}/g, rand)
                 .replace(/{template}/g, \'confValue[\' + rand + \']\');
             $(\'#shippingmultirate-template\').before(html);
         }
     </script>';
     $i = 1;
     foreach ($value as $subcode => $item) {
         $html .= '<div id="wraper-' . $i . '">' . 'Subcode : ' . $view->formText('confValue[' . $i . '][subcode]', $subcode, array('size' => '10')) . 'Title : ' . $view->formText('confValue[' . $i . '][title]', $item['title'], array('size' => '10')) . 'Price : ' . $view->formText('confValue[' . $i . '][price]', $item['price'], array('size' => '10')) . 'Min Subtotal : ' . $view->formText('confValue[' . $i . '][minOrderTotal]', isset($item['minOrderTotal']) ? $item['minOrderTotal'] : '', array('size' => '10')) . 'Max Subtotal : ' . $view->formText('confValue[' . $i . '][maxOrderTotal]', isset($item['maxOrderTotal']) ? $item['maxOrderTotal'] : '', array('size' => '10')) . $view->formButton('shippingmultirate-template-remove', 'Remove', array('onclick' => 'removeRate(' . $i . ');')) . '</div>';
         $i++;
     }
     $html .= '<div id="shippingmultirate-template" style="display:none" >' . '<div id="wraper-{template_id}">' . 'Subcode : ' . $view->formText('{template}[subcode]', $subcode, array('size' => '10')) . 'Title : ' . $view->formText('{template}[title]', $item['title'], array('size' => '10')) . 'Price : ' . $view->formText('{template}[price]', $item['price'], array('size' => '10')) . 'Min Subtotal : ' . $view->formText('{template}[minOrderTotal]', isset($item['minOrderTotal']) ? $item['minOrderTotal'] : '', array('size' => '10')) . 'Max Subtotal : ' . $view->formText('{template}[maxOrderTotal]', isset($item['maxOrderTotal']) ? $item['maxOrderTotal'] : '', array('size' => '10')) . $view->formButton('shippingmultirate-template-remove', 'Remove', array('onclick' => 'removeRate(\'{template_id}\');')) . '</div>' . '</div>' . $view->formButton('shippingmultirate-template-add', 'Add', array('onclick' => 'addRate();'));
     return $html;
 }
Example #2
0
 /**
  * Generate the form element required for a particular question/response
  *
  * @param  QuestionModel question object for which an element is being generated 
  * @param  ResponseModel response object
  * @return string
  */
 public function questionElement($q, $r)
 {
     $b = new Tag_Builder();
     $responseText = $this->view->h($r->responseText);
     switch (strtolower(substr($q->format, 0, 1))) {
         case 'd':
             return '<br/>' . $this->view->formText("q{$q->questionID}", $responseText, array('class' => 'calendarText', 'size' => 13, 'readonly' => 1)) . $this->view->linkTo('#showCalendar', $this->view->imageTag('icons/calendar.png', array('id' => "c{$q->questionID}", 'class' => 'calendarButton', 'title' => 'calendar')));
         case 't':
             return '<br/>' . $this->view->formText("q{$q->questionID}", $responseText, array('size' => 50));
         case 's':
             $response = '<br/>';
             if (count($q->prompts) > 4) {
                 $options = '';
                 foreach ($q->prompts as $prompt) {
                     $class = $prompt['requireAddlInfo'] ? 'require-addl' : null;
                     $selected = $prompt['promptID'] == $responseText ? 'selected' : null;
                     $options .= $b->option(array_filter(array('value' => $prompt['promptID'], 'class' => $class, 'selected' => $selected)), $this->view->h($prompt['value']));
                     $response .= $this->rulesElements($prompt);
                 }
                 $response .= $b->select(array('name' => "q{$q->questionID}"), $options);
             } else {
                 foreach ($q->prompts as $prompt) {
                     $class = $prompt['requireAddlInfo'] ? 'require-addl' : null;
                     $checked = $prompt['promptID'] == $r->responseText ? 'checked' : null;
                     $response .= $b->input(array_filter(array('type' => 'radio', 'value' => $prompt['promptID'], 'name' => "q{$q->questionID}", 'checked' => $checked, 'class' => $class)));
                     $response .= $this->rulesElements($prompt);
                     $response .= $b->label($this->view->h($prompt['value']));
                 }
             }
             return $response;
         case 'm':
             $response = '<br/>';
             foreach (split(',', $responseText) as $id) {
                 $responseIDs[$id] = true;
             }
             foreach ($q->prompts as $prompt) {
                 $class = $prompt['requireAddlInfo'] ? 'require-addl' : null;
                 $checked = isset($responseIDs[$prompt['promptID']]) ? 'checked' : null;
                 $response .= $b->input(array_filter(array('type' => 'checkbox', 'value' => $prompt['promptID'], 'name' => "q{$q->questionID}_m{$prompt['promptID']}", 'checked' => $checked, 'class' => $class)));
                 $response .= $this->rulesElements($prompt);
                 $response .= $b->label($this->view->h($prompt['value']));
                 $response .= '<br/>';
             }
             return $response;
         case '_':
             return $this->view->formHidden("q{$q->questionID}", '');
         default:
             throw new Exception('Unrecognized question type');
     }
     return '';
 }
Example #3
0
 /**
  *
  * @param array $value
  * @param Zend_View_Interface $view
  * @return string
  */
 public static function getHtml($value, Zend_View_Interface $view = null)
 {
     $value = json_decode($value, true);
     foreach (self::_getOptions() as $options) {
         switch ($options['type']) {
             case 'bool':
                 $html .= $view->formRadio('confValue[' . $options['name'] . ']', $value[$options['id']], null, array('1' => Axis::translate()->__(' Yes'), '0' => Axis::translate()->__(' No')));
                 break;
             case 'select':
                 $html .= $view->formSelect('confValue[' . $options['name'] . ']', $value[$options['id']], null, $options['config_options']);
                 break;
             case 'multiple':
                 $html .= '<br />';
                 foreach ($options['config_options'] as $key => $dataItem) {
                     $html .= $view->formCheckbox('confValue[' . $options['name'] . '][' . $key . ']', isset($value[$options['name']][$key]) && $value[$options['name']][$key] ? 1 : null, null, array(1, 0)) . " {$dataItem} <br /> ";
                 }
                 break;
             case 'text':
                 $html .= $view->formTextarea('confValue[' . $options['name'] . ']', $value[$options['id']], array('rows' => 8, 'cols' => 45));
                 break;
             default:
                 $html .= $view->formText('confValue[' . $options['name'] . ']', $value[$options['id']], array('size' => '50'));
         }
     }
     return $html;
 }
 /**
  *
  * @static
  * @param string $value
  * @param Zend_View_Interface $view
  * @return string
  */
 public static function getHtml($value, Zend_View_Interface $view = null)
 {
     $value = Zend_Json_Decoder::decode($value);
     $html = '';
     foreach (self::_getOptions() as $options) {
         $html .= $options['name'] . ' ' . $view->formText('confValue[' . $options['name'] . ']', $value[$options['id']], array('size' => '50'));
     }
     return $html;
 }
Example #5
0
 /**
  * Render form controls for a date question
  *
  * @param  ModelQuestionModel question being rendered
  * @return string
  */
 public function renderDate(ModelQuestionModel $question)
 {
     $name = "response[{$question->questionID}][target]";
     $value = $question->hasModelResponse() ? $question->nextModelResponse()->target : null;
     return $this->view->formText($name, $value, array('class' => 'calendarText', 'size' => 13, 'readonly' => 1)) . $this->view->linkTo('#showCalendar', $this->view->imageTag('icons/calendar.png', array('id' => "c{$question->questionID}", 'class' => 'calendarButton', 'title' => 'calendar')));
 }
 /**
  *
  * @static
  * @param array $value
  * @param Zend_View_Interface $view
  * @return string
  */
 public static function getHtml($value, Zend_View_Interface $view = null)
 {
     $html = $view->formText('confValue', $value);
     return $html;
 }
Example #7
0
 /**
  *
  * @param string $value
  * @param Zend_View_Interface $view
  * @return string
  */
 public static function getHtml($value, Zend_View_Interface $view = null)
 {
     return $view->formText('confValue', Axis_Crypt::factory()->decrypt($value), array('size' => '50'));
 }