Esempio n. 1
0
 /**
  * @param null $options
  * @param null $pluginOptions
  *
  * @return string
  * @throws \Exception
  */
 public function getItem($options = null, $pluginOptions = null)
 {
     switch ($this->type) {
         case self::TYPE_TEXT:
             return Html::input('text', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
         case self::TYPE_EMAIL:
             return Html::input('email', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
         case self::TYPE_NUMBER:
             return Html::input('number', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
         case self::TYPE_TEXTAREA:
             return Html::textarea('Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
         case self::TYPE_COLOR:
             return ColorInput::widget(['value' => $this->value, 'name' => 'Setting[' . $this->code . ']', 'options' => $options != null ? $options : ['class' => 'form-control']]);
         case self::TYPE_DATE:
             return DatePicker::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['format' => 'yyyy-mm-dd', 'todayHighlight' => true]]);
         case self::TYPE_TIME:
             return TimePicker::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['minuteStep' => 1, 'showSeconds' => true, 'showMeridian' => false]]);
         case self::TYPE_DATETIME:
             return DateTimePicker::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => ['format' => 'yyyy-mm-dd H:i:s', 'todayHighlight' => true]]);
         case self::TYPE_PASSWORD:
             return PasswordInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['showMeter' => true, 'toggleMask' => false]]);
         case self::TYPE_ROXYMCE:
             return RoxyMceWidget::widget(['id' => 'Setting_' . $this->code, 'name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'action' => Url::to(['roxymce/default']), 'options' => $options != null ? $options : ['title' => $this->getName()], 'clientOptions' => $pluginOptions != null ? $pluginOptions : []]);
         case self::TYPE_SELECT:
             return Select2::widget(['value' => $this->value, 'name' => 'Setting[' . $this->code . ']', 'data' => $this->getStoreRange(), 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => ['allowClear' => true]]);
         case self::TYPE_MULTI_SELECT:
             $options['multiple'] = true;
             if (!isset($options['class'])) {
                 $options['class'] = 'form-control';
             }
             return Select2::widget(['name' => 'Setting[' . $this->code . ']', 'value' => explode(",", $this->value), 'data' => $this->getStoreRange(), 'options' => $options, 'pluginOptions' => ['allowClear' => true]]);
         case self::TYPE_FILE_PATH:
             $value = Yii::getAlias($this->store_dir) . DIRECTORY_SEPARATOR . $this->value;
             return FileInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $value, 'options' => $options != null ? $options : ['class' => 'form-control', 'multiple' => false], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['previewFileType' => 'any', 'showRemove' => false, 'showUpload' => false, 'initialPreview' => !$this->isNewRecord ? [$this->value] : []]]);
         case self::TYPE_FILE_URL:
             $value = $this->store_url . '/' . $this->value;
             return FileInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['previewFileType' => 'any', 'showRemove' => false, 'showUpload' => false, 'initialPreviewAsData' => true, 'initialPreviewFileType' => self::fileType(pathinfo($this->value, PATHINFO_EXTENSION)), 'initialPreview' => !$this->isNewRecord ? $value : [], 'initialCaption' => $this->value]]);
         case self::TYPE_PERCENT:
             return RangeInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'html5Options' => ['min' => 0, 'max' => 100, 'step' => 1], 'options' => $options != null ? $options : ['class' => 'form-control'], 'addon' => ['append' => ['content' => '%']]]);
         case self::TYPE_SWITCH:
             $selector = explode(',', $this->store_range);
             if (count($selector) != 2) {
                 throw new ErrorException(Yii::t('setting', 'Switch Field should have store with 2 value, and negative is first. Example: no,yes'), 500);
             }
             return Html::hiddenInput('Setting[' . $this->code . ']', $selector[0]) . SwitchInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $selector[1], 'containerOptions' => ['class' => 'nv-switch-container'], 'options' => $options != null ? $options : [], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['state' => $this->value == $selector[1], 'size' => 'small', 'offText' => ucfirst($selector[0]), 'onText' => ucfirst($selector[1])]]);
         case self::TYPE_CHECKBOX:
             $random = rand(1000, 9999);
             return Html::checkboxList('Setting[' . $this->code . ']', explode(",", $this->value), $this->getStoreRange(), $options != null ? $options : ['class' => 'nv-checkbox-list checkbox', 'item' => function ($index, $label, $name, $checked, $value) use($random) {
                 $html = Html::beginTag('div');
                 $html .= Html::checkbox($name, $checked, ['id' => 'Setting_checkbox_' . $label . '_' . $index . '_' . $random, 'value' => $value]);
                 $html .= Html::label($label, 'Setting_checkbox_' . $label . '_' . $index . '_' . $random);
                 $html .= Html::endTag('div');
                 return $html;
             }]);
         case self::TYPE_RADIO:
             $random = rand(1000, 9999);
             return Html::radioList('Setting[' . $this->code . ']', $this->value, $this->getStoreRange(), $options != null ? $options : ['class' => 'nv-checkbox-list radio', 'item' => function ($index, $label, $name, $checked, $value) use($random) {
                 $html = Html::beginTag('div');
                 $html .= Html::radio($name, $checked, ['id' => 'Setting_radio_' . $label . '_' . $index . '_' . $random, 'value' => $value]);
                 $html .= Html::label($label, 'Setting_radio_' . $label . '_' . $index . '_' . $random);
                 $html .= Html::endTag('div');
                 return $html;
             }]);
         case self::TYPE_SEPARATOR:
             return '<hr>';
         default:
             return Html::input('text', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
     }
 }
Esempio n. 2
0
use kartik\widgets\FileInput;
use kartik\icons\Icon;
use kartik\popover\PopoverX;
use kartik\password\PasswordInput;
/**
 * @var yii\web\View $this
 * @var common\models\Osusuarios $model
 */
$this->title = $model->usu_nombre;
$this->params['breadcrumbs'][] = ['label' => Yii::t('admin', 'Osusuarios'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $model->usu_nomusu;
?>
<div class="osusuarios-view">
    <!--<div class="page-header">
        <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    </div>-->


    <?php 
echo DetailView::widget(['model' => $model, 'condensed' => false, 'hover' => true, 'mode' => Yii::$app->request->get('edit') == 't' ? DetailView::MODE_EDIT : DetailView::MODE_VIEW, 'panel' => ['heading' => $this->title, 'type' => DetailView::TYPE_INFO], 'formOptions' => ['options' => ['enctype' => 'multipart/form-data']], 'attributes' => [['attribute' => 'uploadedFile', 'format' => 'raw', 'value' => $model->usu_type ? '<a href="#" class="thumbnail">
                        <img src="data:' . $model->usu_type . ';base64,' . base64_encode($model->usu_foto) . '" alt="" class="">
                    </a>' : '<a href="#" class="thumbnail">
                        <img src="' . Yii::$app->params['assetUrl'] . 'images/noavatar_man.png" alt="" class="">
                    </a>', 'type' => DetailView::INPUT_WIDGET, 'widgetOptions' => ['class' => FileInput::classname(), 'pluginOptions' => ['showCaption' => false, 'showRemove' => false, 'showUpload' => false, 'browseClass' => 'btn btn-primary btn-block', 'browseIcon' => '<i class="glyphicon glyphicon-camera"></i> ', 'browseLabel' => Yii::t('admin', 'Select Photo')], 'options' => ['accept' => 'image/*']]], 'usu_nomusu', 'usu_nombre', ['attribute' => 'usu_feccre', 'format' => ['datetime', isset(Yii::$app->modules['datecontrol']['displaySettings']['datetime']) ? Yii::$app->modules['datecontrol']['displaySettings']['datetime'] : 'd-m-Y H:i:s A'], 'type' => DetailView::INPUT_WIDGET, 'displayOnly' => true, 'widgetOptions' => ['class' => DateControl::classname(), 'type' => DateControl::FORMAT_DATETIME]], ['attribute' => 'usu_ulting', 'format' => ['datetime', isset(Yii::$app->modules['datecontrol']['displaySettings']['datetime']) ? Yii::$app->modules['datecontrol']['displaySettings']['datetime'] : 'd-m-Y H:i:s A'], 'type' => DetailView::INPUT_WIDGET, 'displayOnly' => true, 'widgetOptions' => ['class' => DateControl::classname(), 'type' => DateControl::FORMAT_DATETIME]], ['attribute' => 'usu_activo', 'format' => 'raw', 'value' => $model->usu_activo ? '<span class="label label-success">Activo</span>' : '<span class="label label-danger">Inactivo</span>', 'type' => DetailView::INPUT_SWITCH], ['attribute' => 'usu_ultemp', 'displayOnly' => true]], 'deleteOptions' => ['url' => ['delete', 'id' => $model->usu_id], 'data' => ['confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), 'method' => 'post']], 'enableEditMode' => true, 'buttons' => [['label' => Icon::show('key'), 'title' => Yii::t('admin', 'Change Password'), 'html' => PopoverX::widget(['header' => '<i class="glyphicon glyphicon-lock"></i> ' . Yii::t('admin', 'Change Password'), 'placement' => PopoverX::ALIGN_BOTTOM_RIGHT, 'size' => PopoverX::SIZE_LARGE, 'footer' => Html::submitButton(Yii::t('admin', 'Enviar'), ['class' => 'btn btn-sm btn-primary']), 'content' => '<label class="control-label">' . Yii::t('admin', 'Password') . '</label>' . PasswordInput::widget(['model' => $model, 'attribute' => 'passwd']), 'toggleButton' => ['label' => Icon::show('key'), 'class' => 'btn btn-xs btn-info', 'data-toggle' => 'tooltip', 'data-original-title' => Yii::t('admin', 'Change Password')]])]]]);
?>

</div>