public static function tearDownAfterClass() { $leadSourceDropdown = Dropdowns::model()->findByPk(103); $leadSourceDropdown->multi = 0; $leadSourceDropdown->save(); return parent::tearDownAfterClass(); }
public function quickNoteSelector(CFormModel $formModel) { ob_start(); ob_implicit_flush(false); echo CHtml::label(Yii::t('app', 'Quick Note'), 'quickNote', array('style' => 'display:inline-block; margin-right: 10px;')); echo X2Html::dropDownList('quickNote', '', array_merge(array('' => '-'), Dropdowns::getItems(117)), array('ajax' => array('type' => 'GET', 'url' => Yii::app()->controller->createUrl('/site/dynamicDropdown'), 'data' => 'js:{"val":$(this).val(),"dropdownId":"117"}', 'update' => $this->resolveIds('#quickNote2')), 'id' => $this->resolveId('quickNote'), 'class' => 'quick-note')); echo X2Html::dropDownList('quickNote2', '', array('' => '-'), array('id' => $this->resolveId('quickNote2'), 'class' => 'quick-note')); Yii::app()->clientScript->registerScript('quickNoteSelector', "\n \$('#{$this->resolveId('quickNote2')}').change (function () {\n \$(this).next ().val (\$(this).val ());\n });\n "); return ob_get_clean(); }
public static function statusList() { $field = Fields::model()->findByAttributes(array('modelName' => 'Quotes', 'fieldName' => 'status')); $dropdown = Dropdowns::model()->findByPk($field->linkType); return json_decode($dropdown->options); /* return array( 'Draft'=>Yii::t('quotes','Draft'), 'Presented'=>Yii::t('quotes','Presented'), "Issued"=>Yii::t('quotes','Issued'), "Won"=>Yii::t('quotes','Won') ); */ }
public static function listOption($attributes, $name) { if ($attributes instanceof Fields) { $attributes = $attributes->getAttributes(); } $data = array('name' => $name, 'label' => $attributes['attributeLabel']); if (isset($attributes['type']) && $attributes['type']) { $data['type'] = $attributes['type']; } if (isset($attributes['required']) && $attributes['required']) { $data['required'] = 1; } if (isset($attributes['readOnly']) && $attributes['readOnly']) { $data['readOnly'] = 1; } if (isset($attributes['type'])) { if ($attributes['type'] === 'assignment' || $attributes['type'] === 'optionalAssignment') { $data['options'] = AuxLib::dropdownForJson(X2Model::getAssignmentOptions(true, true)); } elseif ($attributes['type'] === 'dropdown' && isset($attributes['linkType'])) { $data['linkType'] = $attributes['linkType']; $data['options'] = AuxLib::dropdownForJson(Dropdowns::getItems($attributes['linkType'])); } elseif ($attributes['type'] === 'link' && isset($attributes['linkType'])) { $staticLinkModel = X2Model::model($attributes['linkType']); if (array_key_exists('X2LinkableBehavior', $staticLinkModel->behaviors())) { $data['linkType'] = $attributes['linkType']; $data['linkSource'] = Yii::app()->controller->createUrl($staticLinkModel->autoCompleteSource); } } } return $data; }
$fax = $current_row->fax; $email = $current_row->email; $organization = $current_row->organization; $receive_newsletter = $current_row->receive_newsletter; if ($receive_newsletter == 1) { $receive_newsletter = "checked='checked'"; } } } /** * Dropdowns object. * * Intialize object from Dropdowns class which contains methods fill all dropdowns of website. * @var object. */ $dropdowns = new Dropdowns(); /** * Country object. * * Intialize object from Country controller class. * @var object. */ $this->load->controller(ADMIN . '/Country'); $country_object = new Country(); /** * Member controller object. * * Intialize object from Member controller class. * @var object. */ $this_object = new Member();
/** * Send the chart type to the widget content view */ public function getViewFileParams() { if (!isset($this->_viewFileParams)) { $this->_viewFileParams = array_merge(parent::getViewFileParams(), array('chartType' => $this->chartType, 'chartSettingsDataProvider' => self::getChartSettingsProvider($this->chartType), 'eventTypes' => array('all' => Yii::t('app', 'All Events')) + Events::$eventLabels, 'socialSubtypes' => json_decode(Dropdowns::model()->findByPk(113)->options, true), 'visibilityFilters' => array('1' => 'Public', '0' => 'Private'), 'suppressChartSettings' => false, 'chartType' => 'usersChart', 'widgetUID' => $this->widgetUID, 'metricTypes' => User::getUserOptions())); } return $this->_viewFileParams; }
?> ' value='' />--> <textarea type='text' name='name' id='feed-post-editor' placeholder='<?php echo Yii::t('app', 'Enter text here...'); ?> '></textarea> <fieldset data-role='controlgroup' data-type='horizontal'> <?php $userIds = array_keys($users); $firstUser = $userIds[0]; echo CHtml::dropDownList('associationId', $firstUser, $users, array('data-mini' => 'true', 'id' => 'feed-post-association-id')); echo CHtml::dropDownList('visibility', 1, array(1 => Yii::t('actions', 'Public'), 0 => Yii::t('actions', 'Private')), array('data-mini' => 'true', 'id' => 'feed-post-visibility')); echo CHtml::dropDownList('subtype', 1, array_map(function ($item) { return Yii::t('app', $item); }, Dropdowns::getSocialSubtypes()), array('data-mini' => 'true', 'id' => 'feed-post-subtype')); ?> </fieldset> <button type='submit' class='x2-button' id='feed-post-button' data-inline='true'><?php echo Yii::t('app', 'Submit Post'); ?> </button> <?php echo X2Html::csrfToken(); ?> </form> <div id="attachments" style='display: none;'> <?php $this->widget('Attachments', array('associationType' => 'feed', 'associationId' => Yii::app()->user->getId(), 'mobile' => true)); ?>
/** * Returns dropdown value(s) for given key(s) * @return array|string */ public function getDropdownIndex($id, $key) { $arr = Dropdowns::getItems($id); if (is_array($key)) { return array_map(function ($value) use($arr) { $index = array_search($value, $arr); if ($index === false) { return $value; } else { return $index; } }, $key); } else { if (array_search($key, $arr) !== false) { return array_search($key, $arr); } else { return $key; } } }
public function renderFilterCellContent() { switch ($this->fieldType) { case 'boolean': echo CHtml::activeDropdownList($this->grid->filter, $this->name, array('' => '- ' . Yii::t('app', 'Select') . ' -', '1' => Yii::t('app', 'Yes'), 'false' => Yii::t('app', "No")), array('class' => 'x2-minimal-select-filtercol')); break; case 'dropdown': $dropdown = Dropdowns::model()->findByPk($this->fieldModel['linkType']); if ($dropdown instanceof Dropdowns) { $options = json_decode($dropdown->options, 1); if (!$dropdown->multi) { $defaultOption = array('' => '- ' . Yii::t('app', 'Select') . ' -'); $options = is_array($options) ? array_merge($defaultOption, $options) : $defaultOption; } //$selected = isset($options[$this->grid->filter->{$this->name}]) ? //$this->grid->filter->{$this->name} : ''; echo CHtml::activeDropdownList($this->grid->filter, $this->name, $options, array('class' => 'x2-minimal-select-filtercol' . ($dropdown->multi ? ' x2-multiselect-dropdown x2-datacolumn-multiselect' : ''), 'multiple' => $dropdown->multi ? 'multiple' : '', 'data-selected-text' => $dropdown->multi ? 'option(s)' : '')); } else { parent::renderFilterCellContent(); } break; case 'visibility': echo CHtml::activeDropDownList($this->grid->filter, $this->name, array('' => '- ' . Yii::t('app', 'Select') . ' -', 1 => Yii::t('app', 'Public'), 0 => Yii::t('app', 'Private'), 2 => Yii::t('app', 'User\'s Groups')), array('class' => 'x2-minimal-select-filtercol')); break; case 'dateTime': case 'date': Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker'); $that = $this; $renderWidget = function () use($that) { echo Yii::app()->controller->widget('CJuiDateTimePicker', array('model' => $that->grid->filter, 'attribute' => $that->name, 'mode' => 'date', 'options' => array('dateFormat' => Formatter::formatDatePicker('medium')), 'htmlOptions' => array('id' => 'datePicker' . $that->name, 'class' => 'datePicker x2-gridview-filter-datepicker'), 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage()), true); }; if ($this->grid->ajax) { X2Widget::ajaxRender($renderWidget); } else { $renderWidget(); } break; default: parent::renderFilterCellContent(); } }
public function getDropdownOptions() { if ($this->linkType instanceof X2StaticDropdown) { return array('options' => $this->linkType->options, 'multi' => false); } else { return Dropdowns::getItems($this->linkType, null, true); } }
$code = $screen_row['code']; $name = $screen_row['name']; $name_ar = $screen_row['name_ar']; $url = $screen_row['url']; $parent_id = $screen_row['parent_id']; } else { $id = $screen_row->id; $code = $screen_row->code; $name = $screen_row->name; $name_ar = $screen_row->name_ar; $url = $screen_row->url; $parent_id = $screen_row->parent_id; $last_modify_date = $screen_row->last_modify_date; } } $dropdowns = new Dropdowns(); ?> <SCRIPT type="text/javascript"> pic1 = new Image(16, 16); pic1.src = "<?php echo base_url(); ?> images/icons/loader.gif"; $(document).ready(function(){ $("#code").change(function() { var code = $("#code").val().replace(/^\s+|\s+$/g, '');
public static function renderModelInput(CModel $model, Fields $field, $htmlOptions = array()) { if ($field->required) { if (isset($htmlOptions['class'])) { $htmlOptions['class'] .= ' x2-required'; } else { $htmlOptions = array_merge(array('class' => 'x2-required'), $htmlOptions); } } $fieldName = $field->fieldName; if (!isset($field)) { return null; } switch ($field->type) { case 'text': return CHtml::activeTextArea($model, $field->fieldName, array_merge(array('title' => $field->attributeLabel), $htmlOptions)); // array( // 'tabindex'=>isset($item['tabindex'])? $item['tabindex'] : null, // 'disabled'=>$item['readOnly']? 'disabled' : null, // 'title'=>$field->attributeLabel, // 'style'=>$default?'color:#aaa;':null, // )); // array( // 'tabindex'=>isset($item['tabindex'])? $item['tabindex'] : null, // 'disabled'=>$item['readOnly']? 'disabled' : null, // 'title'=>$field->attributeLabel, // 'style'=>$default?'color:#aaa;':null, // )); case 'date': $oldDateVal = $model->{$fieldName}; $model->{$fieldName} = Formatter::formatDate($model->{$fieldName}, 'medium'); Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker'); $input = Yii::app()->controller->widget('CJuiDateTimePicker', array('model' => $model, 'attribute' => $fieldName, 'mode' => 'date', 'options' => array('dateFormat' => Formatter::formatDatePicker(), 'changeMonth' => true, 'changeYear' => true), 'htmlOptions' => array_merge(array('title' => $field->attributeLabel), $htmlOptions), 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage()), true); $model->{$fieldName} = $oldDateVal; return $input; case 'dateTime': $oldDateTimeVal = $model->{$fieldName}; $model->{$fieldName} = Formatter::formatDateTime($model->{$fieldName}); Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker'); $input = Yii::app()->controller->widget('CJuiDateTimePicker', array('model' => $model, 'attribute' => $fieldName, 'mode' => 'datetime', 'options' => array('dateFormat' => Formatter::formatDatePicker('medium'), 'timeFormat' => Formatter::formatTimePicker(), 'ampm' => Formatter::formatAMPM(), 'changeMonth' => true, 'changeYear' => true), 'htmlOptions' => array_merge(array('title' => $field->attributeLabel), $htmlOptions), 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage()), true); $model->{$fieldName} = $oldDateTimeVal; return $input; case 'dropdown': // Note: if desired to translate dropdown options, change the seecond argument to // $model->module $om = Dropdowns::getItems($field->linkType, null, true); $multi = (bool) $om['multi']; $dropdowns = $om['options']; $curVal = $multi ? CJSON::decode($model->{$field->fieldName}) : $model->{$field->fieldName}; $dependencyCount = X2Model::model('Dropdowns')->countByAttributes(array('parent' => $field->linkType)); $fieldDependencyCount = X2Model::model('Fields')->countByAttributes(array('modelName' => $field->modelName, 'type' => 'dependentDropdown', 'linkType' => $field->linkType)); if ($dependencyCount > 0 && $fieldDependencyCount > 0) { $ajaxArray = array('ajax' => array('type' => 'GET', 'url' => Yii::app()->controller->createUrl('/site/dynamicDropdown'), 'data' => 'js:{"val":$(this).val(),"dropdownId":"' . $field->linkType . '", "field":true, "module":"' . $field->modelName . '"}', 'success' => 'function(data){ if(data){ data=JSON.parse(data); if(data[0] && data[1]){ $("#' . $field->modelName . '_"+data[0]).html(data[1]); } } }')); } else { $ajaxArray = array(); } $htmlOptions = array_merge($htmlOptions, $ajaxArray, array('title' => $field->attributeLabel)); if ($multi) { $multiSelectOptions = array(); if (!is_array($curVal)) { $curVal = array(); } foreach ($curVal as $option) { $multiSelectOptions[$option] = array('selected' => 'selected'); } $htmlOptions = array_merge($htmlOptions, array('options' => $multiSelectOptions, 'multiple' => 'multiple')); } else { $htmlOptions = array_merge($htmlOptions, array('empty' => Yii::t('app', "Select an option"))); } return CHtml::activeDropDownList($model, $field->fieldName, $dropdowns, $htmlOptions); case 'dependentDropdown': return CHtml::activeDropDownList($model, $field->fieldName, array('' => '-'), array_merge(array('title' => $field->attributeLabel), $htmlOptions)); case 'link': $linkSource = null; $linkId = ''; $name = ''; if (class_exists($field->linkType)) { // Create a model for autocompletion: if (!empty($model->{$fieldName})) { list($name, $linkId) = Fields::nameAndId($model->{$fieldName}); $linkModel = self::getLinkedModelMock($field->linkType, $name, $linkId, true); } else { $linkModel = X2Model::model($field->linkType); } if ($linkModel instanceof X2Model && $linkModel->asa('X2LinkableBehavior') instanceof X2LinkableBehavior) { $linkSource = Yii::app()->controller->createUrl($linkModel->autoCompleteSource); $linkId = $linkModel->id; $oldLinkFieldVal = $model->{$fieldName}; $model->{$fieldName} = $name; } } $input = CHtml::hiddenField($field->modelName . '[' . $fieldName . '_id]', $linkId, array('id' => $field->modelName . '_' . $fieldName . "_id")) . Yii::app()->controller->widget('zii.widgets.jui.CJuiAutoComplete', array('model' => $model, 'attribute' => $fieldName, 'source' => $linkSource, 'value' => $name, 'options' => array('minLength' => '1', 'select' => 'js:function( event, ui ) { $("#' . $field->modelName . '_' . $fieldName . '_id").val(ui.item.id); $(this).val(ui.item.value); return false; }', 'create' => $field->linkType == 'Contacts' ? 'js:function(event, ui) { $(this).data( "uiAutocomplete" )._renderItem = function(ul,item) { return $("<li>").data("item.autocomplete",item).append(x2.forms.renderContactLookup(item)).appendTo(ul); }; }' : ($field->linkType == 'BugReports' ? 'js:function(event, ui) { $(this).data( "uiAutocomplete" )._renderItem = function( ul, item ) { var label = "<a style=\\"line-height: 1;\\">" + item.label; label += "<span style=\\"font-size: 0.6em;\\">"; // add email if defined if(item.subject) { label += "<br>"; label += item.subject; } label += "</span>"; label += "</a>"; return $( "<li>" ) .data( "item.autocomplete", item ) .append( label ) .appendTo( ul ); }; }' : '')), 'htmlOptions' => array_merge(array('title' => $field->attributeLabel), $htmlOptions)), true); if (isset($oldLinkFieldVal)) { $model->{$fieldName} = $oldLinkFieldVal; } return $input; case 'rating': return Yii::app()->controller->widget('CStarRating', array('model' => $model, 'attribute' => $field->fieldName, 'readOnly' => isset($htmlOptions['disabled']) && $htmlOptions['disabled'], 'minRating' => Fields::RATING_MIN, 'maxRating' => Fields::RATING_MAX, 'starCount' => Fields::RATING_MAX - Fields::RATING_MIN + 1, 'cssFile' => Yii::app()->theme->getBaseUrl() . '/css/rating/jquery.rating.css', 'htmlOptions' => $htmlOptions, 'callback' => 'function(value, link){ if (typeof x2 !== "undefined" && typeof x2.InlineEditor !== "undefined" && typeof x2.InlineEditor.ratingFields !== "undefined") { x2.InlineEditor.ratingFields["' . $field->modelName . '[' . $field->fieldName . ']"] = value; } }'), true); case 'boolean': return '<div class="checkboxWrapper">' . CHtml::activeCheckBox($model, $field->fieldName, array_merge(array('unchecked' => 0, 'title' => $field->attributeLabel), $htmlOptions)) . '</div>'; case 'assignment': $oldAssignmentVal = $model->{$fieldName}; $model->{$fieldName} = !empty($model->{$fieldName}) ? $field->linkType == 'multiple' && !is_array($model->{$fieldName}) ? explode(', ', $model->{$fieldName}) : $model->{$fieldName} : self::getDefaultAssignment(); $dropdownList = CHtml::activeDropDownList($model, $fieldName, X2Model::getAssignmentOptions(true, true), array_merge(array('title' => $field->attributeLabel, 'id' => $field->modelName . '_' . $fieldName . '_assignedToDropdown', 'multiple' => $field->linkType == 'multiple' ? 'multiple' : null), $htmlOptions)); $model->{$fieldName} = $oldAssignmentVal; return $dropdownList; /* $group = is_numeric($model->$fieldName); // if(is_numeric($model->assignedTo)){ // $group=true; // $groups=Groups::getNames(); // }else{ // $group=false; // } if (is_array($model[$fieldName])) $model[$fieldName] = implode(', ', $model[$fieldName]); if (empty($model->$fieldName)) $model->$fieldName = Yii::app()->user->getName(); return CHtml::activeDropDownList($model, $fieldName, $group ? Groups::getNames() : User::getNames(), array_merge(array( // 'tabindex'=>isset($item['tabindex'])? $item['tabindex'] : null, // 'disabled'=>$item['readOnly']? 'disabled' : null, 'title' => $field->attributeLabel, 'id' => $field->modelName . '_' . $fieldName . '_assignedToDropdown', 'multiple' => ($field->linkType == 'multiple' ? 'multiple' : null), ), $htmlOptions)) /* x2temp . '<div class="checkboxWrapper">' . CHtml::checkBox('group', $group, array_merge(array( // array( // 'tabindex'=>isset($item['tabindex'])? $item['tabindex'] : null, // 'disabled'=>$item['readOnly']? 'disabled' : null, 'title' => $field->attributeLabel, 'id' => $field->modelName . '_' . $fieldName . '_groupCheckbox', 'ajax' => array( 'type' => 'POST', //request type 'url' => Yii::app()->controller->createUrl('/groups/getGroups'), //url to call. 'update' => '#' . $field->modelName . '_' . $fieldName . '_assignedToDropdown', //selector to update 'data' => 'js:{checked: $(this).attr("checked")=="checked", field:"' . $model->$fieldName . '"}', 'complete' => 'function(){ if($("#' . $field->modelName . '_' . $fieldName . '_groupCheckbox").attr("checked")!="checked"){ $("#' . $field->modelName . '_' . $fieldName . '_groupCheckbox").attr("checked","checked"); $("#' . $field->modelName . '_' . $fieldName . '_visibility option[value=\'2\']").remove(); }else{ $("#' . $field->modelName . '_' . $fieldName . '_groupCheckbox").removeAttr("checked"); $("#' . $field->modelName . '_' . $fieldName . '_visibility").append( $("<option></option>").val("2").html("User\'s Groups") ); } }') ), array_merge($htmlOptions, array('style' => 'margin-left:10px;')))) . '<label for="group" class="groupLabel">' . Yii::t('app', 'Group?') . '</label></div>'; /* end x2temp // case 'association': // if($field->linkType!='multiple') { // return CHtml::activeDropDownList($model, $fieldName, $contacts,array_merge(array( // 'title'=>$field->attributeLabel, // ),$htmlOptions)); // } else { // return CHtml::activeListBox($model, $fieldName, $contacts,array_merge(array( // 'title'=>$field->attributeLabel, // 'multiple'=>'multiple', // ),$htmlOptions)); // } */ /* $group = is_numeric($model->$fieldName); // if(is_numeric($model->assignedTo)){ // $group=true; // $groups=Groups::getNames(); // }else{ // $group=false; // } if (is_array($model[$fieldName])) $model[$fieldName] = implode(', ', $model[$fieldName]); if (empty($model->$fieldName)) $model->$fieldName = Yii::app()->user->getName(); return CHtml::activeDropDownList($model, $fieldName, $group ? Groups::getNames() : User::getNames(), array_merge(array( // 'tabindex'=>isset($item['tabindex'])? $item['tabindex'] : null, // 'disabled'=>$item['readOnly']? 'disabled' : null, 'title' => $field->attributeLabel, 'id' => $field->modelName . '_' . $fieldName . '_assignedToDropdown', 'multiple' => ($field->linkType == 'multiple' ? 'multiple' : null), ), $htmlOptions)) /* x2temp . '<div class="checkboxWrapper">' . CHtml::checkBox('group', $group, array_merge(array( // array( // 'tabindex'=>isset($item['tabindex'])? $item['tabindex'] : null, // 'disabled'=>$item['readOnly']? 'disabled' : null, 'title' => $field->attributeLabel, 'id' => $field->modelName . '_' . $fieldName . '_groupCheckbox', 'ajax' => array( 'type' => 'POST', //request type 'url' => Yii::app()->controller->createUrl('/groups/getGroups'), //url to call. 'update' => '#' . $field->modelName . '_' . $fieldName . '_assignedToDropdown', //selector to update 'data' => 'js:{checked: $(this).attr("checked")=="checked", field:"' . $model->$fieldName . '"}', 'complete' => 'function(){ if($("#' . $field->modelName . '_' . $fieldName . '_groupCheckbox").attr("checked")!="checked"){ $("#' . $field->modelName . '_' . $fieldName . '_groupCheckbox").attr("checked","checked"); $("#' . $field->modelName . '_' . $fieldName . '_visibility option[value=\'2\']").remove(); }else{ $("#' . $field->modelName . '_' . $fieldName . '_groupCheckbox").removeAttr("checked"); $("#' . $field->modelName . '_' . $fieldName . '_visibility").append( $("<option></option>").val("2").html("User\'s Groups") ); } }') ), array_merge($htmlOptions, array('style' => 'margin-left:10px;')))) . '<label for="group" class="groupLabel">' . Yii::t('app', 'Group?') . '</label></div>'; /* end x2temp // case 'association': // if($field->linkType!='multiple') { // return CHtml::activeDropDownList($model, $fieldName, $contacts,array_merge(array( // 'title'=>$field->attributeLabel, // ),$htmlOptions)); // } else { // return CHtml::activeListBox($model, $fieldName, $contacts,array_merge(array( // 'title'=>$field->attributeLabel, // 'multiple'=>'multiple', // ),$htmlOptions)); // } */ case 'optionalAssignment': // optional assignment for users (can be left blank) $users = User::getNames(); unset($users['Anyone']); return CHtml::activeDropDownList($model, $fieldName, $users, array_merge(array('title' => $field->attributeLabel, 'empty' => ''), $htmlOptions)); case 'visibility': $permissionsBehavior = Yii::app()->params->modelPermissions; return CHtml::activeDropDownList($model, $field->fieldName, $permissionsBehavior::getVisibilityOptions(), array_merge(array('title' => $field->attributeLabel, 'id' => $field->modelName . "_visibility"), $htmlOptions)); // 'varchar', 'email', 'url', 'int', 'float', 'currency', 'phone' // case 'int': // return CHtml::activeNumberField($model, $field->fieldNamearray_merge(array( // 'title' => $field->attributeLabel, // ), $htmlOptions)); // 'varchar', 'email', 'url', 'int', 'float', 'currency', 'phone' // case 'int': // return CHtml::activeNumberField($model, $field->fieldNamearray_merge(array( // 'title' => $field->attributeLabel, // ), $htmlOptions)); case 'percentage': $htmlOptions['class'] = empty($htmlOptions['class']) ? 'input-percentage' : $htmlOptions['class'] . ' input-percentage'; return CHtml::activeTextField($model, $field->fieldName, array_merge(array('title' => $field->attributeLabel), $htmlOptions)); case 'currency': $fieldName = $field->fieldName; $elementId = isset($htmlOptions['id']) ? '#' . $htmlOptions['id'] : '#' . $field->modelName . '_' . $field->fieldName; Yii::app()->controller->widget('application.extensions.moneymask.MMask', array('element' => $elementId, 'currency' => Yii::app()->params['currency'], 'config' => array('affixStay' => true, 'decimal' => Yii::app()->locale->getNumberSymbol('decimal'), 'thousands' => Yii::app()->locale->getNumberSymbol('group')))); return CHtml::activeTextField($model, $field->fieldName, array_merge(array('title' => $field->attributeLabel, 'class' => 'currency-field'), $htmlOptions)); case 'credentials': $typeAlias = explode(':', $field->linkType); $type = $typeAlias[0]; if (count($typeAlias) > 1) { $uid = Credentials::$sysUseId[$typeAlias[1]]; } else { $uid = Yii::app()->user->id; } return Credentials::selectorField($model, $field->fieldName, $type, $uid); case 'timerSum': // Sorry, no-can-do. This is field derives its value from a sum over timer records. return $model->renderAttribute($field->fieldName); case 'float': case 'int': if (isset($model->{$fieldName})) { $oldNumVal = $model->{$fieldName}; $model->{$fieldName} = Yii::app()->locale->numberFormatter->formatDecimal($model->{$fieldName}); } $input = CHtml::activeTextField($model, $field->fieldName, array_merge(array('title' => $field->attributeLabel), $htmlOptions)); if (isset($oldNumVal)) { $model->{$fieldName} = $oldNumVal; } return $input; default: return CHtml::activeTextField($model, $field->fieldName, array_merge(array('title' => $field->attributeLabel), $htmlOptions)); // array( // 'tabindex'=>isset($item['tabindex'])? $item['tabindex'] : null, // 'disabled'=>$item['readOnly']? 'disabled' : null, // 'title'=>$field->attributeLabel, // 'style'=>$default?'color:#aaa;':null, // )); } }
} $fieldTypes = Fields::getFieldTypes('title'); echo $form->dropDownList($model, 'type', ArrayUtil::asorti($fieldTypes), array('id' => 'fieldType', 'class' => $new ? 'new' : 'existing')); ?> <?php echo $form->error($model, 'type'); ?> </div> <div class="row"> <?php // Render a dropdown menu and any other fields // for the "linkType" field $genericLabel = CHtml::label(Yii::t('app', 'Type'), CHtml::resolveName($model, $assignTypeName)); switch ($model->type) { case "dropdown": $dropdowns = Dropdowns::model()->findAll(); $arr = array(); foreach ($dropdowns as $dropdown) { $arr[$dropdown->id] = $dropdown->name; } echo CHtml::activeDropDownList($model, 'linkType', $arr, array('id' => 'dropdown-type', 'class' => $new ? 'new' : 'existing')); break; case "assignment": $assignTypeName = 'linkType'; echo $genericLabel; echo CHtml::activeDropDownList($model, 'linkType', array(NULL => Yii::t('app', 'Single'), 'multiple' => Yii::t('app', 'Multiple')), array('id' => 'assignment-multiplicity', 'class' => $new ? 'new' : 'existing')); break; case "link": $linkTypes = Fields::getLinkTypes(); $options = array(); foreach ($linkTypes as $type) {
echo '<div class="formInputBox" style="width:' . $item['width'] . 'px;height:' . $item['height'] . ';">'; $default = $model->{$fieldName} == $field->attributeLabel; if ($field->type == 'varchar' || $field->type == 'email' || $field->type == 'url' || $field->type == 'int' || $field->type == 'float' || $field->type == 'currency') { echo $form->textField($model, $field->fieldName, array('tabindex' => isset($item['tabindex']) ? $item['tabindex'] : null, 'disabled' => $item['readOnly'] ? 'disabled' : null, 'title' => $field->attributeLabel, 'style' => $default ? 'color:#aaa;' : null)); } else { if ($field->type == 'text') { echo $form->textArea($model, $field->fieldName, array('tabindex' => isset($item['tabindex']) ? $item['tabindex'] : null, 'disabled' => $item['readOnly'] ? 'disabled' : null, 'title' => $field->attributeLabel, 'style' => $default ? 'color:#aaa;' : null)); } else { if ($field->type == 'text') { echo $form->textArea($model, $field->fieldName, array('tabindex' => isset($item['tabindex']) ? $item['tabindex'] : null, 'disabled' => $item['readOnly'] ? 'disabled' : null, 'title' => $field->attributeLabel, 'onfocus' => $default ? 'toggleText(this);' : null, 'onblur' => $default ? 'toggleText(this);' : null, 'style' => $default ? 'color:#aaa;' : null)); } elseif ($field->type == 'date') { $model->{$fieldName} = $this->formatDate($model->{$fieldName}); Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker'); $this->widget('CJuiDateTimePicker', array('model' => $model, 'attribute' => $field->fieldName, 'mode' => 'date', 'options' => array('dateFormat' => $this->formatDatePicker()), 'htmlOptions' => array('tabindex' => isset($item['tabindex']) ? $item['tabindex'] : null, 'disabled' => defined($item['readOnly']) && $item['readOnly'] ? 'disabled' : null, 'title' => $field->attributeLabel), 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage())); } elseif ($field->type == 'dropdown') { $dropdowns = Dropdowns::getItems($field->linkType); echo $form->dropDownList($model, $field->fieldName, $dropdowns, array('tabindex' => isset($item['tabindex']) ? $item['tabindex'] : null, 'disabled' => $item['readOnly'] ? 'disabled' : null, 'title' => $field->attributeLabel)); } elseif ($field->type == 'link') { // if(empty($model->$fieldName)) // $model->$fieldName = ''; $linkSource = null; $linkId = ''; if (class_exists($field->linkType)) { // if the field is an ID, look up the actual name if (isset($model->{$fieldName}) && ctype_digit($model->{$fieldName})) { $linkModel = CActiveRecord::model($field->linkType)->findByPk($model->{$fieldName}); if (isset($linkModel)) { $model->{$fieldName} = $linkModel->name; $linkId = $linkModel->id; } else { $model->{$fieldName} = '';
public function actionGetFields($model) { if (!class_exists($model)) { echo 'false'; return; } $fieldModels = X2Model::model($model)->getFields(); $fields = array(); foreach ($fieldModels as &$field) { if ($field->isVirtual) { continue; } $data = array('name' => $field->fieldName, 'label' => $field->attributeLabel, 'type' => $field->type); if ($field->required) { $data['required'] = 1; } if ($field->readOnly) { $data['readOnly'] = 1; } if ($field->type === 'assignment' || $field->type === 'optionalAssignment') { $data['options'] = AuxLib::dropdownForJson(X2Model::getAssignmentOptions(true, true)); } elseif ($field->type === 'dropdown') { $data['linkType'] = $field->linkType; $data['options'] = AuxLib::dropdownForJson(Dropdowns::getItems($field->linkType)); } if ($field->type === 'link') { $staticLinkModel = X2Model::model($field->linkType); if (array_key_exists('X2LinkableBehavior', $staticLinkModel->behaviors())) { $data['linkType'] = $field->linkType; $data['linkSource'] = Yii::app()->controller->createUrl($staticLinkModel->autoCompleteSource); } } $fields[] = $data; } echo CJSON::encode($fields); }
<div class="form"> <?php $feed = new Social(); ?> <?php $form = $this->beginWidget('CActiveForm', array('id' => 'feed-form', 'enableAjaxValidation' => false, 'method' => 'post', 'action' => array('addPost', 'id' => Yii::app()->user->getId(), 'redirect' => 'index'))); ?> <div class="float-row"> <?php $feed->data = Yii::t('app', 'Enter text here...'); echo $form->textArea($feed, 'data', array('style' => 'width:558px;height:50px;color:#aaa;display:block;clear:both;')); echo $form->dropDownList($feed, 'associationId', $users); $feed->visibility = 1; echo $form->dropDownList($feed, 'visibility', array(1 => Yii::t('actions', 'Public'), 0 => Yii::t('actions', 'Private'))); echo $form->dropDownList($feed, 'subtype', json_decode(Dropdowns::model()->findByPk(14)->options, true)); echo CHtml::submitButton(Yii::t('app', 'Post'), array('class' => 'x2-button', 'id' => 'save-button')); echo CHtml::button(Yii::t('app', 'Attach A File/Photo'), array('class' => 'x2-button', 'onclick' => "\$('#attachments').toggle();")); ?> </div> <?php $this->endWidget(); ?> </div> <div id="attachments" style="display:none;"> <?php $this->widget('Attachments', array('associationType' => 'feed', 'associationId' => Yii::app()->user->getId())); ?> </div>
public function getDropdown() { if ($this->type !== 'dropdown') { return null; } if (!isset($this->_dropdown)) { $this->_dropdown = Dropdowns::model()->findByPk($this->linkType); } return $this->_dropdown; }
<div id='<?php echo $this->resolveId('log-a-call'); ?> ' class='publisher-form' <?php echo $startVisible ? '' : "style='display: none;'"; ?> > <div class="row"> <div> <?php echo CHtml::label(Yii::t('app', 'Quick Note'), 'quickNote', array('style' => 'display:inline-block; margin-right: 10px;')); echo X2Html::dropDownList('quickNote', '', array_merge(array('' => '-'), Dropdowns::getItems(117)), array('ajax' => array('type' => 'GET', 'url' => Yii::app()->controller->createUrl('/site/dynamicDropdown'), 'data' => 'js:{"val":$(this).val(),"dropdownId":"117"}', 'update' => $this->resolveIds('#quickNote2'), 'complete' => $this->resolveIds('function() { auxlib.getElement("#call-action-description").val(""); }')), 'id' => $this->resolveId('quickNote'))); echo X2Html::dropDownList('quickNote2', '', array('' => '-'), array('id' => $this->resolveId('quickNote2'))); ?> </div> </div> <div class="row"> <div class="text-area-wrapper"> <?php echo $model->renderInput('actionDescription', array('rows' => 3, 'cols' => 40, 'class' => 'action-description x2-textarea', 'id' => $this->resolveId('call-action-description'))); ?> </div> </div> <div class='row action-event-panel'>
?> </div> <div class="cell"> <?php echo CHtml::label(Yii::t('dashboard', 'Date Range'), 'range'); ?> <?php echo CHtml::dropDownList('range', $dateRange['range'], array('custom' => Yii::t('dashboard', 'Custom'), 'thisWeek' => Yii::t('dashboard', 'This Week'), 'thisMonth' => Yii::t('dashboard', 'This Month'), 'lastWeek' => Yii::t('dashboard', 'Last Week'), 'lastMonth' => Yii::t('dashboard', 'Last Month'), 'thisYear' => Yii::t('dashboard', 'This Year'), 'lastYear' => Yii::t('dashboard', 'Last Year')), array('id' => 'dateRange')); ?> </div> </div> <div class="row"> <div class="cell"> <?php echo $form->label($model, 'leadSource'); $dropdown = Dropdowns::model()->findByPk(4); // lead source $dropdowns = json_decode($dropdown->options, true); foreach (array_keys($dropdowns) as $key) { $dropdowns[$key] = Yii::t(strtolower(Yii::app()->controller->id), $dropdowns[$key]); } $dropdowns = array('' => '---') + $dropdowns; echo $form->dropDownList($model, 'leadSource', $dropdowns, array()); ?> </div> <div class="cell"> <?php echo $form->label($model, 'company'); $linkId = ''; // if the field is an ID, look up the actual name if (isset($model->company) && ctype_digit($model->company)) {
/** * Show or hide a certain status in the gridview * * Called through ajax with a status and if that status should be shown or hidden. * Saves the result in the user's profile. * */ public function actionStatusFilter() { if (isset($_POST['all'])) { // show all the things!! Yii::app()->params->profile->hideCasesWithStatus = CJSON::encode(array()); // hide none Yii::app()->params->profile->update(array('hideCasesWithStatus')); } elseif (isset($_POST['none'])) { // hide all the things!!!!11 $statuses = array(); $dropdownId = Yii::app()->db->createCommand()->select('linkType')->from('x2_fields')->where('modelName="Services" AND fieldName="status" AND type="dropdown"')->queryScalar(); if ($dropdownId !== null) { $statuses = Dropdowns::getItems($dropdownId); } // get the actual statuses Yii::app()->params->profile->hideCasesWithStatus = CJSON::encode($statuses); Yii::app()->params->profile->update(array('hideCasesWithStatus')); } elseif (isset($_POST['checked'])) { $checked = CJSON::decode($_POST['checked']); $status = isset($_POST['status']) ? $_POST['status'] : false; // var_dump($checked); // var_dump($status); $hideStatuses = CJSON::decode(Yii::app()->params->profile->hideCasesWithStatus); // get a list of statuses the user wants to hide if ($hideStatuses === null || !is_array($hideStatuses)) { $hideStatuses = array(); } // var_dump($checked); // var_dump(in_array($status, $hideStatuses)); if ($checked && ($key = array_search($status, $hideStatuses)) !== false) { // if we want to show the status, and it's not being shown unset($hideStatuses[$key]); // show status } else { if (!$checked && !in_array($status, $hideStatuses)) { // if we want to hide the status, and it's not being hidden $hideStatuses[] = $status; } } Yii::app()->params->profile->hideCasesWithStatus = CJSON::encode($hideStatuses); Yii::app()->params->profile->update(array('hideCasesWithStatus')); } }
<a href="#" onclick="$('#deleteDropdown').toggle();$('#createDropdown').hide();$('#editDropdown').hide();return false;" class="x2-button"><?php echo Yii::t('admin', 'Delete Dropdown'); ?> </a> <a href="#" onclick="$('#editDropdown').toggle();$('#createDropdown').hide();$('#deleteDropdown').hide();return false;" class="x2-button"><?php echo Yii::t('admin', 'Edit Dropdown'); ?> </a> <br> <br> </div> <div id="createDropdown" style="display:none;"> <?php $this->renderPartial('createDropdown', array('model' => $model)); ?> </div> <div id="deleteDropdown" style="display:none;"> <?php $customDropdowns = Dropdowns::model()->findAll('id>=1000'); usort($customDropdowns, function ($a, $b) { return strcmp($a->name, $b->name); }); $this->renderPartial('deleteDropdown', array('dropdowns' => $customDropdowns)); ?> </div> <div id="editDropdown" style="display:none;"> <?php $this->renderPartial('editDropdown', array('model' => $model)); ?> </div>
</div> </div> </div> <form id='feed-post-publisher'><!-- submitted via ajax, doesn't need csrf token --> <textarea class='x2-textarea' type='text' name='name' id='feed-post-editor' placeholder='<?php echo Yii::t('app', 'Enter text here...'); ?> '></textarea> <div id='feed-post-controls' style='display:none;'> <?php $users = User::getUserIds(); $userIds = array_keys($users); $firstUser = $userIds[0]; echo CHtml::dropDownList('subtype', 1, Dropdowns::getItems(113), array('class' => 'x2-select', 'id' => 'feed-post-subtype')); echo CHtml::dropDownList('associationId', $firstUser, $users, array('class' => 'x2-select', 'id' => 'feed-post-association-id')); ?> <div class='post-button-row-2'> <button type='submit' class='x2-button' id='feed-post-button' data-inline='true'><?php echo Yii::t('app', 'Submit Post'); ?> </button> <?php echo CHtml::dropDownList('visibility', 1, array(1 => Yii::t('actions', 'Public'), 0 => Yii::t('actions', 'Private')), array('class' => 'x2-select', 'id' => 'feed-post-visibility')); ?> </div> </div> </form>
/** * @param type $fieldName * @param type $htmlOptions */ public function renderInput($fieldName, $htmlOptions = array()) { switch ($fieldName) { case 'color': $field = $this->getField($fieldName); $options = Dropdowns::getItems($field->linkType, null, false); $enableDropdownLegend = Yii::app()->settings->enableColorDropdownLegend; if ($enableDropdownLegend) { $htmlOptions['options'] = array(); foreach ($options as $value => $label) { $brightness = X2Color::getColorBrightness($value); $fontColor = $brightness > 127.5 ? 'black' : 'white'; $htmlOptions['options'][$value] = array('style' => 'background-color: ' . $value . '; color: ' . $fontColor); } } return CHtml::activeDropDownList($this, $field->fieldName, $options, $htmlOptions); case 'priority': return CHtml::activeDropdownList($this, 'priority', self::getPriorityLabels()); case 'associationType': return X2Html::activeMultiTypeAutocomplete($this, 'associationType', 'associationId', array('calendar' => Yii::t('app', 'Select an option')) + X2Model::getAssociationTypeOptions()); case 'reminder': $reminderInput = parent::renderInput($fieldName, array('class' => 'reminder-checkbox')); $reminderInput .= X2Html::openTag('div', X2Html::mergeHtmlOptions($htmlOptions, array('class' => 'reminder-config'))) . Yii::t('actions', 'Create a notification reminder for {user} {time} before this {action} ' . 'is due', array('{user}' => CHtml::activeDropDownList($this, 'notificationUsers', array('me' => Yii::t('actions', 'me'), 'assigned' => Yii::t('actions', 'the assigned user'), 'both' => Yii::t('actions', 'me and the assigned user'))), '{time}' => CHtml::activeDropDownList($this, 'notificationTime', array(1 => Yii::t('actions', '1 minute'), 5 => Yii::t('actions', '5 minutes'), 10 => Yii::t('actions', '10 minutes'), 15 => Yii::t('actions', '15 minutes'), 30 => Yii::t('actions', '30 minutes'), 60 => Yii::t('actions', '1 hour'), 1440 => Yii::t('actions', '1 day'), 10080 => Yii::t('actions', '1 week'))), '{action}' => lcfirst(Modules::displayName(false, 'Actions')))) . '</div>'; return $reminderInput; default: return parent::renderInput($fieldName, $htmlOptions); } }
* Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * X2Engine" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by X2Engine". *****************************************************************************************/ Yii::app()->clientScript->registerCss('filterControlsCss', "\n\n#filter-controls > .portlet-content {\n padding: 5px 0px !important;\n}\n\n#filter-controls > .portlet-content > .x2-button-group {\n text-align: center;\n margin-bottom: 5px;\n}\n\n#sidebar-full-controls-button-container {\n text-align:center;\n}\n#sidebar-full-controls-button-container > .toggle-filters-link {\n margin-bottom: 4px;\n}\n\n"); if (isset($_SESSION['filters'])) { $filters = $_SESSION['filters']; } else { $filters = array('visibility' => array(), 'users' => array(), 'types' => array(), 'subtypes' => array()); } $visibility = array('1' => 'Public', '0' => 'Private'); $socialSubtypes = Dropdowns::getSocialSubtypes(); $users = User::getNames(); $eventTypeList = Yii::app()->db->createCommand()->select('type')->from('x2_events')->group('type')->queryAll(); $eventTypes = array(); foreach ($eventTypeList as $key => $value) { if ($value['type'] != 'comment') { $eventTypes[$value['type']] = Events::parseType($value['type']); } } $profile = Yii::app()->params->profile; $this->beginWidget('LeftWidget', array('widgetLabel' => Yii::t('app', 'Filter Controls'), 'widgetName' => 'FilterControls', 'id' => 'filter-controls')); echo '<div class="x2-button-group">'; echo '<a href="#" class="simple-filters x2-button' . ($profile->fullFeedControls ? "" : " disabled-link") . '" style="width:42px">' . Yii::t('app', 'Simple') . '</a>'; echo '<a href="#" class="full-filters x2-button x2-last-child' . ($profile->fullFeedControls ? " disabled-link" : "") . '" style="width:42px">' . Yii::t('app', 'Full') . '</a>'; echo "</div>\n"; $filterList = json_decode($profile->feedFilters, true);
$parent_id = $current_row->parent_id; $controller_name = $current_row->controller_name; $alias = $current_row->alias; $title = $current_row->title; $title_ar = $current_row->title_ar; $menu_id = $current_row->menu_id; $icon = $current_row->icon; } } /** * Dropdowns object. * * Intialize object from Dropdowns class which contains methods fill all dropdowns of website. * @var object. */ $dropdowns = new Dropdowns(); /** * Menulink controller object. * * Intialize object from Menulink controller class. * @var object. */ $this_object = new Menulink(); /** * Menu object. * * Intialize object from Menu controller class. * @var object. */ $this->load->controller(ADMIN . '/Menu'); $menu_object = new Menu();
* Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * X2Engine" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by X2Engine". *****************************************************************************************/ ?> <div class="page-title rounded-top"><h2><?php echo Yii::t('admin', 'Edit Dropdown'); ?> </h2></div> <div class="form"> <?php $list = Dropdowns::model()->findAll(); $names = array(); foreach ($list as $dropdown) { $names[$dropdown->id] = $dropdown->name; } $form = $this->beginWidget('CActiveForm', array('id' => 'edit-dropdown-form', 'enableAjaxValidation' => false, 'action' => 'editDropdown')); ?> <em><?php echo Yii::t('app', 'Fields with <span class="required">*</span> are required.'); ?> </em><br /> <div class="row"> <?php echo $form->labelEx($model, 'name');
$cs->registerScript('highlightSaveContact', $js, CClientScript::POS_READY); $cs->registerCssFile($assets . '/jquery-ui-timepicker-addon.css'); $cs->registerScriptFile($assets . '/jquery-ui-timepicker-addon.js', CClientScript::POS_END); // $cs->registerScript(__CLASS__, $this->defaultOptions?'jQuery.{$this->mode}picker.setDefaults('.CJavaScript::encode($this->defaultOptions).');':''); // $cs->registerScript(__CLASS__.'#'.$id, $js); $fieldTypes = array(); $fieldLinkTypes = array(); $fieldOptions = array(); foreach ($itemModel->getFields() as $field) { $fieldTypes[$field->fieldName] = $field->type; if (!empty($field->linkType)) { $fieldLinkTypes[$field->fieldName] = $field->linkType; } switch ($field->type) { case 'dropdown': $fieldOptions[$field->fieldName] = Dropdowns::getItems($field->linkType); break; case 'assignment': $fieldOptions[$field->fieldName] = User::getNames() + Groups::getNames(); break; case 'link': $fieldOptions[$field->fieldName] = Yii::app()->request->scriptUrl . X2Model::model($field->linkType)->autoCompleteSource; break; } } $attributeLabels = $model->itemAttributeLabels; //hack tags in $fieldTypes['tags'] = 'tags'; $fieldOptions['tags'] = Tags::getAllTags(); $attributeLabels['tags'] = Yii::t('contacts', 'Tags'); natcasesort($attributeLabels);
?> <?php $form = $this->beginWidget('CActiveForm', array('id' => 'feed-form', 'enableAjaxValidation' => false, 'method' => 'post')); ?> <div class="float-row" style='overflow:visible;'> <?php echo $form->textArea($feed, 'text', array('style' => 'width:99%;height:25px;color:#aaa;display:block;clear:both;')); echo "<div id='post-buttons' style='display:none;'>"; echo $form->dropDownList($feed, 'associationId', $users, array('style' => $isMyProfile ? '' : 'display:none;', 'class' => 'x2-select')); $feed->visibility = 1; echo $form->dropDownList($feed, 'visibility', array(1 => Yii::t('actions', 'Public'), 0 => Yii::t('actions', 'Private')), array('class' => 'x2-select')); function translateOptions($item) { return Yii::t('app', $item); } echo $form->dropDownList($feed, 'subtype', array_map('translateOptions', json_decode(Dropdowns::model()->findByPk(113)->options, true)), array('class' => 'x2-select')); ?> <div id='second-row-buttons-container'> <?php echo CHtml::submitButton(Yii::t('app', 'Post'), array('class' => 'x2-button', 'id' => 'save-button')); if ($isMyProfile) { echo CHtml::button(Yii::t('app', 'Attach A File/Photo'), array('class' => 'x2-button', 'onclick' => "\$('#attachments').slideToggle();", 'id' => "toggle-attachment-menu-button")); } ?> </div> </div> <?php ?> </div> <?php $this->endWidget();
/** * Print out a dropdown's data * * This method is called via AJAX by {@link actionEditDropdown} to get the * options of the dropdown for the edit dropdown page. */ public function actionGetDropdown() { if (isset($_POST['Dropdowns']['id'])) { $id = $_POST['Dropdowns']['id']; $model = Dropdowns::model()->findByPk($id); if ($model === null) { return; } $options = json_decode($model->options); if ($id == Actions::COLORS_DROPDOWN_ID) { $this->renderPartial('application.modules.actions.views.actions._colorDropdownForm', array('model' => $model, 'options' => $options), false, true); } else { $this->renderPartial('application.components.views._dropdownForm', array('model' => $model, 'options' => $options), false, true); } } }
/** * Convert the Quote into an Invoice * An invoice is a quote with field type='invoice'. The only difference is that * when listing, printing, or emailing an invoice, we call it an invoice instead * of a quote. * * @param $id id of the quote to convert to invoice * */ public function actionConvertToInvoice($id) { $model = $this->getModel($id); // get model // convert to invoice $model->type = 'invoice'; $model->invoiceCreateDate = time(); // set invoice status to the top choice in the invoice status drop down $field = $model->getField('invoiceStatus'); if ($field) { $dropDownId = $field->linkType; if ($dropDownId) { $dropdowns = Dropdowns::getItems($field->linkType); if ($dropdowns) { reset($dropdowns); $status = key($dropdowns); if ($status) { $model->invoiceStatus = $status; } } } } $model->update(); // ajax request from a contact view, don't reload page, instead return a list of quotes // for this contact if (isset($_GET['modelName']) && isset($_GET['recordId'])) { //$contact = X2Model::model('Contacts')->findByPk($_GET['contactId']); if ($model) { Yii::app()->clientScript->scriptMap['*.js'] = false; $this->renderPartial('quoteFormWrapper', array('modelId' => $_GET['recordId'], 'modelName' => $_GET['modelName']), false, true); return; } } $this->redirect(array('view', 'id' => $model->id)); // view quote }