/**
  * Render a hidden input, a text input with an auto-complete
  * event, and a select button. These three items together
  * form the Opportunity Editable Element
  * @return The element's content as a string.
  */
 protected function renderControlEditable()
 {
     $content = null;
     $content .= ZurmoHtml::textField('stageToProbabilityMapping_notUsed', null, array('id' => $this->getEditableInputId(), 'style' => "display:none;"));
     $fieldData = CustomFieldData::getByName('SalesStages');
     if ($fieldData->serializedData != null) {
         $values = unserialize($fieldData->serializedData);
         if (!is_array($values)) {
             $values = array();
         }
     } else {
         $values = array();
     }
     $stagesToProbabilities = OpportunitiesModule::getStageToProbabilityMappingData();
     foreach ($values as $value) {
         if (isset($stagesToProbabilities[$value])) {
             $probability = $stagesToProbabilities[$value];
         } else {
             $probability = 0;
         }
         $htmlOptions = array('name' => $this->getNameForInputField($value), 'value' => $probability);
         $element = $this->form->textField($this->model, $this->attribute, $htmlOptions);
         $element .= ZurmoHtml::tag('span', array(), $value);
         $content .= ZurmoHtml::tag('div', array('class' => 'has-lang-label'), $element);
     }
     return $content;
 }
 public function run()
 {
     $id = $this->getId();
     $this->htmlOptions['id'] = $id;
     if (isset($this->htmlOptions['disabled']) && $this->htmlOptions['disabled'] == 'disabled') {
         $tokenListClassSuffix = ' disabled';
     } else {
         $tokenListClassSuffix = '';
     }
     echo ZurmoHtml::textField($this->name, null, $this->htmlOptions);
     $javaScript = "\$(document).ready(function () { ";
     $javaScript .= "\$('#{$id}').tokenInput('{$this->sourceUrl}', { ";
     $javaScript .= "queryParam: 'term',";
     // Not Coding Standard
     if ($this->hintText != null) {
         $javaScript .= "hintText: '" . Yii::app()->format->text($this->hintText) . "',";
         // Not Coding Standard
     }
     if ($this->onAdd != null) {
         $javaScript .= "onAdd: " . $this->onAdd . ",";
         // Not Coding Standard
     }
     if ($this->onDelete != null) {
         $javaScript .= "onDelete: " . $this->onDelete . ",";
         // Not Coding Standard
     }
     if ($this->jsonEncodedIdsAndLabels != null) {
         $javaScript .= "prePopulate: " . $this->jsonEncodedIdsAndLabels . ",";
         // Not Coding Standard
     }
     $javaScript .= "preventDuplicates: 'true', classes: {tokenList: 'token-input-list" . $tokenListClassSuffix . "'}";
     $javaScript .= "});";
     $javaScript .= "});";
     Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $id, $javaScript);
 }
 /**
  * This function overrides the run method from CJuiDatePicker and fixes the jQuery issue for the Datepicker showing
  * wrong language in the portlet views popup.
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     if (isset($this->htmlOptions['name'])) {
         $name = $this->htmlOptions['name'];
     } else {
         $this->htmlOptions['name'] = $name;
     }
     if (!isset($this->options['currentText'])) {
         $this->options['currentText'] = ZurmoHtml::wrapLabel(Zurmo::t('Core', 'Now'));
     }
     if (!isset($this->options['closeText'])) {
         $this->options['closeText'] = ZurmoHtml::wrapLabel(Zurmo::t('Core', 'Done'));
     }
     if ($this->flat === false) {
         if ($this->hasModel()) {
             echo ZurmoHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
         } else {
             echo ZurmoHtml::textField($name, $this->value, $this->htmlOptions);
         }
     } else {
         if ($this->hasModel()) {
             echo ZurmoHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
             $attribute = $this->attribute;
             $this->options['defaultDate'] = $this->model->{$attribute};
         } else {
             echo ZurmoHtml::hiddenField($name, $this->value, $this->htmlOptions);
             $this->options['defaultDate'] = $this->value;
         }
         if (!isset($this->options['onSelect'])) {
             $this->options['onSelect'] = "js:function( selectedDate ) { jQuery('#{$id}').val(selectedDate);}";
             // Not Coding Standard
         }
         $id = $this->htmlOptions['id'] = $this->htmlOptions['id'] . '_container';
         $this->htmlOptions['name'] = $this->htmlOptions['name'] . '_container';
         echo ZurmoHtml::tag('div', $this->htmlOptions, '');
     }
     $options = CJavaScript::encode($this->options);
     $js = "jQuery('#{$id}').datepicker({$options});";
     if ($this->language != '' && $this->language != 'en') {
         $this->registerScriptFile($this->i18nScriptFile);
         $js = "jQuery(function(){jQuery('#{$id}').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));})";
     }
     $cs = Yii::app()->getClientScript();
     if (isset($this->defaultOptions)) {
         $this->registerScriptFile($this->i18nScriptFile);
         $cs->registerScript(__CLASS__, $this->defaultOptions !== null ? 'jQuery.datepicker.setDefaults(' . CJavaScript::encode($this->defaultOptions) . ');' : '');
     }
     $cs->registerScript(__CLASS__ . '#' . $id, $js);
 }
 public function run()
 {
     // Begin Not Coding Standard
     $javaScript = "\n                \$(document).ready(function()\n                {\n                    \$('#{$this->inputId}').iris({\n                        change: {$this->change},\n                        palettes: {$this->palettes},\n                    });\n                }\n                );\n            ";
     // End Not Coding Standard
     Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->id, $javaScript, CClientScript::POS_END);
     $this->resolveHtmlOptions();
     $inputField = ZurmoHtml::textField($this->inputName, $this->inputValue, $this->htmlOptions);
     $icon = ZurmoHtml::icon('icon-color-picker');
     echo ZurmoHtml::tag('div', array('class' => 'has-color-picker'), $inputField . $icon);
 }
Example #5
0
 /**
  * Renders content for a calendar.
  * @return A string containing the element's content.
  */
 protected function renderContent()
 {
     $content = $this->renderViewToolBar();
     $cClipWidget = new CClipWidget();
     $cClipWidget->beginClip("Calendar");
     $cClipWidget->widget('ext.zurmoinc.framework.widgets.Calendar', array('language' => YiiToJqueryUIDatePickerLocalization::getLanguage(), 'htmlOptions' => array('id' => 'calendar' . $this->uniqueLayoutId, 'name' => 'calendar' . $this->uniqueLayoutId), 'options' => array('dateFormat' => YiiToJqueryUIDatePickerLocalization::resolveDateFormat(DateTimeUtil::getLocaleDateFormat()), 'onChangeMonthYear' => $this->getOnChangeMonthScript(), 'onSelect' => $this->getOnSelectScript(), 'altFormat' => 'yy-mm-dd', 'altField' => '#calendarSelectedDate' . $this->uniqueLayoutId), 'dayEvents' => $this->makeDayEvents()));
     $cClipWidget->endClip();
     $content .= $cClipWidget->getController()->clips['Calendar'];
     $content .= ZurmoHtml::textField('calendarSelectedDate' . $this->uniqueLayoutId, null, array('id' => 'calendarSelectedDate' . $this->uniqueLayoutId, 'style' => 'display:none;'));
     return $content;
 }
 protected function renderAddInputAndAddButton()
 {
     $activeLanguagesData = $this->getActiveLanguagesData();
     $baseLanguage = $this->getBaseLanguage();
     $content = '<table id="picklist-values">';
     $content .= '<colgroup><col style="width:50%" />';
     $content .= '</colgroup>';
     $content .= '<tbody>';
     $content .= '<tr><td>';
     $content .= '<div class="has-lang-label">' . ZurmoHtml::textField($this->attribute . '_AddInput', '', array('size' => 50));
     $content .= static::renderLanguageLabelHtmlContent($activeLanguagesData[$baseLanguage]['name']);
     $content .= '</div>';
     $content .= '<div id="' . $this->attribute . '_AddInput_em_" class="errorMessage" style="display:none"></div>';
     $content .= '</td></tr>';
     $content .= '<tr><td>';
     $content .= ZurmoHtml::link(ZurmoHtml::wrapLabel(Zurmo::t('Core', 'Add Item')), '#', array('id' => $this->attribute . '_AddInputButton'));
     $content .= '</td></tr>';
     $content .= '</tbody>';
     $content .= '</table>';
     return $content;
 }
 protected function getPanelSettingsDisplay($title, $detailViewOnly, $locked, $panelIdName)
 {
     assert('is_bool($locked) || $locked == null');
     $content = '<div class="panel-settings modal-settings" title="' . Zurmo::t('Core', 'Panel Settings') . '">';
     $content .= '<div class="wide form">';
     $content .= '<table>';
     $content .= TableUtil::getColGroupContent(1);
     $content .= '<tr>';
     $content .= '<th><label>' . Zurmo::t('Core', 'Panel Title') . '</label></th>';
     $content .= '<td>' . ZurmoHtml::textField('title_' . $panelIdName, $title, array('class' => 'panel-title settings-form-field')) . ZurmoHtml::hiddenField('locked_' . $panelIdName, $locked, array('class' => 'panel-title settings-form-field')) . '</td>';
     $content .= '</tr>';
     $content .= '<tr>';
     $content .= '<th><label>' . Zurmo::t('Core', 'Detail View Only') . '</label></th>';
     $content .= '<td>' . ZurmoHtml::checkBox('detailViewOnly_' . $panelIdName, $detailViewOnly, array('class' => 'panel-title settings-form-field')) . '</td>';
     $content .= '</tr>';
     $content .= '</table>';
     $content .= '<div class="view-toolbar-container clearfix"><div class="form-toolbar">';
     $content .= $this->renderSaveModalSettingsButton();
     $content .= '</div></div>';
     $content .= '</div>';
     $content .= '</div>';
     return $content;
 }
Example #8
0
 /**
  * Run this widget.
  * This method registers necessary javascript and renders the needed HTML code.
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     if (isset($this->htmlOptions['name'])) {
         $name = $this->htmlOptions['name'];
     } else {
         $this->htmlOptions['name'] = $name;
     }
     if ($this->hasModel()) {
         echo ZurmoHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo ZurmoHtml::textField($name, $this->value, $this->htmlOptions);
     }
     $this->registerScriptForNowButton();
     if (!isset($this->options['currentText'])) {
         $this->options['currentText'] = ZurmoHtml::wrapLabel(Zurmo::t('TimepickerExtension', 'Now'));
     }
     if (!isset($this->options['closeText'])) {
         $this->options['closeText'] = ZurmoHtml::wrapLabel(Zurmo::t('TimepickerExtension', 'Done'));
     }
     $options = CJavaScript::encode($this->options);
     if ($this->timePickerOnly) {
         $js = "jQuery('#{$id}').timepicker({$options});";
     } else {
         $js = "jQuery('#{$id}').datetimepicker({$options});";
     }
     if (isset($this->language)) {
         $this->registerScriptFile($this->i18nScriptFile);
         if ($this->timePickerOnly) {
             $js = "jQuery('#{$id}').timepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));";
         } else {
             $js = "jQuery('#{$id}').datetimepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));";
         }
     }
     Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $id, $js);
 }