Since: 2.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends yii\base\Object
Exemplo n.º 1
1
 /**
  * Renders the header cell content.
  * The default implementation simply renders [[header]].
  * This method may be overridden to customize the rendering of the header cell.
  * @return string the rendering result
  */
 protected function renderHeaderCellContent()
 {
     $name = rtrim($this->name, '[]') . '_all';
     $id = $this->grid->options['id'];
     $options = json_encode(['name' => $this->name, 'multiple' => $this->multiple, 'checkAll' => $name]);
     $this->grid->getView()->registerJs("jQuery('#{$id}').yiiGridView('setSelectionColumn', {$options});");
     if ($this->header !== null || !$this->multiple) {
         return parent::renderHeaderCellContent();
     } else {
         return Html::checkBox($name, false, ['class' => 'select-on-check-all']);
     }
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  * @throws \yii\base\InvalidConfigException if [[name]] is not set.
  */
 public function init()
 {
     parent::init();
     if (empty($this->name)) {
         throw new InvalidConfigException('The "name" property must be set.');
     }
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $script = '
     $(document).ready(function(){
         function hideFirstLast() {
             $(\'.sort-up, .sort-down\').show();
             $(\'.sort-up\').first().hide();
             $(\'.sort-down\').last().hide();
         }
         function refresh() {
             $(\'#' . $this->grid->id . '\').yiiGridView("applyFilter");
             hideFirstLast();
         }
         $(\'.sort-up\').on(\'click\', function(){
             var id = $(this).parent().parent().attr(\'data-key\');
             $.post("' . Url::toRoute(['swap']) . '?id="+id+"&dir=up").always(refresh);
             return false;
         });
         $(\'.sort-down\').on(\'click\' ,function(){
             var id = $(this).parent().parent().attr(\'data-key\');
             $.post("' . Url::toRoute(['swap']) . '?id="+id+"&dir=down").always(refresh);
             return false;
         });
         hideFirstLast();
     });';
     $this->grid->getView()->registerJs($script);
 }
Exemplo n.º 4
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     /* @var $dataProvider ActiveDataProvider */
     $dataProvider = $this->grid->dataProvider;
     if (!$dataProvider instanceof ActiveDataProvider) {
         throw new InvalidConfigException('SortableColumn works only with ActiveDataProvider.');
     }
     if (!$this->gridContainerId) {
         throw new InvalidConfigException('$gridContainerId property must be set.');
     }
     Yii::setAlias('@sortable', dirname(__DIR__));
     Yii::$app->i18n->translations['sortable'] = ['class' => PhpMessageSource::className(), 'basePath' => '@sortable/messages'];
     /* @var $query \yii\db\ActiveQuery */
     $query = $dataProvider->query;
     $this->_model = new $query->modelClass();
     $this->contentOptions = function ($model) {
         /* @var $model ActiveRecord|BaseNumericalSortableBehavior */
         return ['class' => 'sortable-cell', 'data-position' => $model->getSortablePosition()];
     };
     if (!$this->header) {
         $this->header = Yii::t('sortable', 'Sort');
     }
     $this->visible = $this->isVisible();
     if (!$this->template) {
         $this->template = '<div class="sortable-section">{currentPosition}</div>
         <div class="sortable-section">{moveWithDragAndDrop}</div>
         <div class="sortable-section">{moveForward} {moveBack}</div>
         <div class="sortable-section">{moveAsFirst} {moveAsLast}</div>';
     }
     $this->initDefaultButtons();
     if (!Yii::$app->request->isAjax) {
         $this->registerJs();
     }
 }
 /**
  * Initializes the object.
  * This method is invoked at the end of the constructor after the object is initialized with the
  * given configuration.
  */
 public function init()
 {
     if ($this->defaultItems) {
         $this->defaultItems = [['label' => Yii::t('yii', 'Update'), 'url' => ['update', 'id' => '{id}']], ['label' => Yii::t('yii', 'View'), 'url' => ['view', 'id' => '{id}']], ['label' => Yii::t('yii', 'Delete'), 'url' => ['delete', 'id' => '{id}']]];
     }
     parent::init();
 }
Exemplo n.º 6
0
 protected function renderFilterCellContent()
 {
     $filter = $this->guessFilter();
     if ($filter instanceof BaseFilter) {
         return $filter->render();
     }
     return Column::renderFilterCellContent();
 }
Exemplo n.º 7
0
 public function init()
 {
     parent::init();
     $this->defaultButtons = [['url' => 'edit', 'icon' => 'pencil', 'class' => 'btn-primary', 'label' => Yii::t('app', 'Edit')], ['url' => 'delete', 'icon' => 'trash-o', 'class' => 'btn-danger', 'label' => Yii::t('app', 'Delete'), 'options' => ['data-action' => 'delete']]];
     if (null === $this->buttons) {
         $this->buttons = $this->defaultButtons;
     } elseif ($this->buttons instanceof Closure) {
         $this->callbackButtons = $this->buttons;
     }
 }
Exemplo n.º 8
0
 /**
  * @inheritdoc
  */
 protected function renderHeaderCellContent()
 {
     if ($this->label !== null) {
         return $this->label;
     }
     if ($this->attribute !== null) {
         $model = $this->grid->filterModel;
         return $model->getAttributeLabel($this->attribute);
     }
     return parent::renderHeaderCell();
 }
Exemplo n.º 9
0
 /**
  * Renders the header cell content.
  * The default implementation simply renders [[header]].
  * This method may be overridden to customize the rendering of the header cell.
  * @return string the rendering result
  */
 protected function renderHeaderCellContent()
 {
     if ($this->gridType == 'datatable-select') {
         if ($this->header !== null || !$this->multiple) {
             return Column::renderHeaderCellContent();
         } else {
             $name = rtrim($this->name, '[]') . '_all';
             return Html::checkBox($name, false, ['class' => 'group-checkable']);
         }
     } else {
         return parent::renderHeaderCellContent();
     }
 }
 /**
  * @inheritDoc
  */
 public function init()
 {
     parent::init();
     /**
      * @var ActiveDataProvider $provider
      * @var ActiveQuery        $query
      */
     $provider = $this->grid->dataProvider;
     Yii2::assertType($provider, ActiveDataProvider::class);
     $query = $provider->query;
     Yii2::assertType($query, ActiveQuery::class);
     $this->provider = $provider;
     $this->query = $query;
 }
Exemplo n.º 11
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $view = $this->grid->getView();
     $script = '
     $(document).ready(function(){
         function hideFirstLast() {
             $(\'.sort-up, .sort-down\').show();
             $(\'.sort-up\').first().hide();
             $(\'.sort-down\').last().hide();
         }
         $(\'.sort-up\').on(\'click\', function(){
             var element = $(this).parent().parent();
             var id1 = element.attr(\'data-key\');
             var id2 = element.prev().attr(\'data-key\');
             element.prev().before(element);
             hideFirstLast();
             $.ajax({
                 url: "' . Url::toRoute(['swap']) . '?idFrom="+id1+"&idTo="+id2
             });
             return false;
         });
         $(\'.sort-down\').on(\'click\' ,function(){
             var element = $(this).parent().parent();
             var id1 = element.attr(\'data-key\');
             var id2 = element.next().attr(\'data-key\');
             element.next().after(element);
             hideFirstLast();
             $.ajax({
                 url: "' . Url::toRoute(['swap']) . '?idFrom="+id1+"&idTo="+id2
             });
             return false;
         });
         hideFirstLast();
     });';
     $view->registerJs($script);
 }
Exemplo n.º 12
0
 /**
  * @inheritdoc
  */
 protected function renderDataCellContent($model, $key, $index)
 {
     if ($this->content === null) {
         return $this->grid->formatter->format($this->getDataCellValue($model, $key, $index), $this->format);
     } else {
         return parent::renderDataCellContent($model, $key, $index);
     }
 }
Exemplo n.º 13
0
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Создать номер', ['create'], ['class' => 'btn btn-success']);
?>
        <?php 
echo Html::a('Загрузить из файла', ['uploadform'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
$cols = [['class' => 'yii\\grid\\SerialColumn'], 'id', 'voip_number', ['attribute' => 'secret', 'value' => function ($model) {
    return Html::a($model->secret ? '* * *' : '', '', ['title' => $model->secret]);
}, 'format' => 'raw'], 'description', 'context', ['class' => Column::className(), 'content' => function ($model) use($id_wp) {
    return Html::a('Выбрать', ['voipnumbers/choicewp', 'id' => $model->id, 'id_wp' => $id_wp]);
}], ['class' => 'yii\\grid\\ActionColumn']];
if (!isset($id_wp)) {
    unset($cols[6]);
}
?>


    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $cols]);
?>

</div>
Exemplo n.º 14
0
 /**
  * Renders the header cell content.
  * The default implementation simply renders [[header]].
  * This method may be overridden to customize the rendering of the header cell.
  * @return string the rendering result
  */
 protected function renderHeaderCellContent()
 {
     if ($this->header !== null || !$this->multiple) {
         return parent::renderHeaderCellContent();
     } else {
         return Html::checkbox($this->getHeaderCheckBoxName(), false, ['class' => 'select-on-check-all']);
     }
 }
 /**
  * Initializes the object.
  * This method is invoked at the end of the constructor after the object is initialized with the
  * given configuration.
  */
 public function init()
 {
     $this->defaultItems = !$this->items;
     parent::init();
 }
Exemplo n.º 16
0
<?php

/**
 * User: ivan
 * Date: 09.02.2016
 * Time: 12:31
 *
 * @var $this yii\web\View
 * @var $dp yii\data\ActiveDataProvider
 */
use yii\grid\GridView;
use yii\helpers\Html;
use yii\grid\Column;
use backend\models\Devices;
$this->title = '' . $title;
$this->params['breadcrumbs'][] = ['label' => 'Отчет', 'url' => ['reports/aindex']];
$this->params['breadcrumbs'][] = $this->title;
echo 'Отчет по устройству';
echo '<h1>' . $title . '</h1>';
echo GridView::widget(['dataProvider' => $dp, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'branch_id', 'label' => 'Подразделение'], ['attribute' => 'workplaces_title', 'label' => 'Рабочее место', 'value' => function ($dp) {
    return Html::a($dp['workplaces_title'], ['workplaces/view', 'id' => $dp['workplace_id']]);
}, 'format' => 'raw'], ['class' => Column::className(), 'header' => 'Кол-во', 'content' => function ($dp) use($type_id) {
    return Devices::getCountOnWp($type_id, $dp['workplace_id']);
}], ['attribute' => 'snp', 'label' => 'Ответственное лицо'], ['attribute' => 'job_title', 'label' => 'Должность'], ['attribute' => 'date', 'label' => 'Дата']]]);
Exemplo n.º 17
0
 /**
  * Renders the header cell content.
  * The default implementation simply renders [[header]].
  * This method may be overridden to customize the rendering of the header cell.
  * @return string the rendering result
  */
 protected function renderHeaderCellContent()
 {
     $name = $this->name;
     if (substr_compare($name, '[]', -2, 2) === 0) {
         $name = substr($name, 0, -2);
     }
     if (substr_compare($name, ']', -1, 1) === 0) {
         $name = substr($name, 0, -1) . '_all]';
     } else {
         $name .= '_all';
     }
     $id = $this->grid->options['id'];
     $options = json_encode(['name' => $this->name, 'multiple' => $this->multiple, 'checkAll' => $name], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
     $this->grid->getView()->registerJs("jQuery('#{$id}').yiiGridView('setSelectionColumn', {$options});");
     if ($this->header !== null || !$this->multiple) {
         return parent::renderHeaderCellContent();
     } else {
         return Html::checkBox($name, false, ['class' => 'select-on-check-all']);
     }
 }
Exemplo n.º 18
0
 /**
  * Renders the header cell content.
  * The default implementation simply renders [[header]].
  * This method may be overridden to customize the rendering of the header cell.
  * @return string the rendering result
  */
 protected function renderHeaderCellContent()
 {
     $name = rtrim($this->name, '[]') . '_all';
     $id = $this->grid->options['id'];
     $options = json_encode(['name' => $this->name, 'multiple' => $this->multiple, 'checkAll' => $name], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
     $this->grid->getView()->registerJs("jQuery('#{$id}').yiiGridView('setSelectionColumn', {$options});");
     if ($this->header !== null || !$this->multiple) {
         return parent::renderHeaderCellContent();
     } else {
         //            return Html::checkBox($name, false, ['class' => 'select-on-check-all']);
         return "<label class=\"control-label\">" . Html::checkBox($name, false, ['class' => 'select-on-check-all']) . "<span class=\"text\"></span></label>";
     }
 }
Exemplo n.º 19
0
 public function init(){
     parent::init();
 }
 public function init()
 {
     parent::init();
     $this->initDefaultItems();
 }
Exemplo n.º 21
0
 public function init()
 {
     parent::init();
     $this->header = Yii::t('easyii', 'Status');
 }
Exemplo n.º 22
0
 /**
  * Renders the header cell content.
  * The default implementation simply renders [[header]].
  * This method may be overridden to customize the rendering of the header cell.
  * @return string the rendering result
  */
 protected function renderHeaderCellContent()
 {
     $name = rtrim($this->name, '[]') . '_all';
     $id = $this->grid->options['id'];
     $options = json_encode(['name' => $this->name, 'multiple' => $this->multiple, 'checkAll' => $name]);
     $this->grid->getView()->registerJs("jQuery('#{$id}').yiiGridView('setSelectionColumn', {$options});");
     if ($this->header !== null || !$this->multiple) {
         return parent::renderHeaderCellContent();
     } else {
         $content = Html::tag('button', Html::checkBox($name, false, ['class' => 'select-on-check-all', 'data-target' => $this->name, 'data-checkall' => 1, 'data-parent-id' => $id]) . ' <span class="caret"></span>', ['type' => 'button', 'class' => 'btn btn-default dropdown-toggle', 'data-toggle' => 'dropdown']);
         $buttons = preg_replace_callback('/\\{([\\w\\-\\/]+)\\}/', function ($matches) use($model, $key, $index) {
             $name = $matches[1];
             $module = \Yii::$app->user->can(\Yii::$app->controller->module->id . '/' . \Yii::$app->controller->id . '/' . $name);
             if ($module) {
                 if (isset($this->buttons[$name])) {
                     $url = $this->createUrl($name, $model, $key, $index);
                     if (call_user_func($this->checkaccess, $url)) {
                         return call_user_func($this->buttons[$name], $url, $model);
                     } else {
                         return '';
                     }
                 } else {
                     return '';
                 }
             }
         }, $this->template);
         if ($buttons == '') {
             return $buttons;
         }
         $content .= Html::tag('ul', $buttons, ['class' => 'dropdown-menu pull-right', 'role' => 'menu']);
         return Html::tag('div', $content, ['class' => 'dropdown']);
     }
 }
Exemplo n.º 23
0
 public function init()
 {
     parent::init();
     $this->initDefaultButtons();
 }
Exemplo n.º 24
0
 public function init(){
     if(!class_exists($this->modelClass)){
         throw new HttpException(400, 'Model Class Must Be Set');
     }
     parent::init();
 }
Exemplo n.º 25
0
echo Html::a(Html::img('/admin/img/search.png', ['width' => '16px']) . 'Потерянные', ['index?' . $query . '&WorkplacesSearch%5Bworkplaces_title%5D=потерянные'], ['class' => 'btn btn-default']);
?>
        <?php 
echo Html::a(Html::img('/admin/img/cross.png', ['width' => '16px']) . 'Сбросить фильтр', ['index?' . $query], ['class' => 'btn btn-default']);
?>

    </p>

    <?php 
$columns = [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'branch_id', 'value' => 'branch.branch_title'], ['attribute' => 'room_id', 'value' => 'room.room_title'], ['attribute' => 'workplaces_title', 'value' => function ($model) {
    return Html::a($model->workplaces_title, ['workplaces/view', 'id' => $model->id]);
}, 'format' => 'raw'], ['attribute' => '_owner', 'value' => function ($model) {
    if ($model->owner) {
        return $model->owner[0]['snp'];
    } else {
        return '-';
    }
}, 'format' => 'raw'], ['class' => \yii\grid\Column::className(), 'content' => function ($model) use($id_dev) {
    return Html::a(Html::img('/admin/img/ok.png', ['width' => '25px']), ['devices/addtowp', 'id' => $id_dev, 'id_wp' => $model->id]);
}], ['attribute' => 'inventoryDate', 'value' => function ($model) {
    return $model->inventoryDate ? $model->inventoryDate : '-';
}, 'filter' => DatePicker::widget(['model' => $searchModel, 'attribute' => 'inventoryDate', 'clientOptions' => ['dateFormat' => 'dd.MM.yyyy', 'options' => ['class' => 'form-control']]]), 'options' => ['class' => 'form-control']], ['class' => 'yii\\grid\\ActionColumn']];
if ($mode == 'sel') {
    unset($columns[6]);
} else {
    unset($columns[5]);
}
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $columns]);
?>
</div>
Exemplo n.º 26
0
?>
<div class="images-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Новое изображение', ['create?' . $query], ['class' => 'btn btn-success']);
?>
    </p>
    <?php 
$columns = [['class' => 'yii\\grid\\SerialColumn'], 'id', ['class' => \yii\grid\Column::className(), 'header' => 'Изображение', 'content' => function ($model) {
    return Html::img('/admin/' . $model->linkfile, ['style' => 'width:200px']);
}], 'linkfile', 'owner', 'title', ['class' => \yii\grid\Column::className(), 'content' => function ($model) {
    return Html::a('выбрать', ['images/setowner', 'id' => $model->id, 'param' => Yii::$app->request->queryString]);
}], ['class' => 'yii\\grid\\ActionColumn']];
if (!isset($owner)) {
    unset($columns[6]);
}
?>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $columns]);
?>
</div>
Exemplo n.º 27
0
 /**
  * @inheritdoc
  */
 protected function renderHeaderCellContent()
 {
     if ($this->header !== null || !$this->showClear) {
         return parent::renderHeaderCellContent();
     } else {
         $label = ArrayHelper::remove($this->clearOptions, 'label', '&times;');
         Html::addCssClass($this->clearOptions, 'kv-clear-radio');
         if (empty($this->clearOptions['title'])) {
             $this->clearOptions['title'] = Yii::t('kvgrid', 'Clear selection');
         }
         $this->_view->registerJs("kvClearRadio({$this->_clientVars});");
         return Html::button($label, $this->clearOptions);
     }
 }
Exemplo n.º 28
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $this->contentOptions = array_merge($this->contentOptions, ['width' => 90]);
     $this->initDefaultButtons();
     if (!$this->checkaccess) {
         $this->checkaccess = function ($url) {
             return true;
         };
     }
 }
Exemplo n.º 29
0
                    <?php 
    echo Html::submitButton('Создать автоматом', ['class' => 'btn btn-success']);
    ?>
                </form>
            </div>
        <?php 
}
?>
        <?php 
echo GridView::widget(['dataProvider' => $deviceProvider, 'filterModel' => $searchDeviceModel, 'layout' => "{items}", 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'type_id', 'value' => function ($moddev) use($model) {
    $str = '-';
    if (isset($moddev->type_id)) {
        $str = $moddev->deviceType->title;
        $str .= empty($moddev->deviceType->synonyms) ? '' : ' (' . $moddev->deviceType->synonyms . ')';
    }
    return Html::a($str, ['devices/view', 'id' => $moddev->id, 'id_wp' => $model->id]);
}, 'format' => 'raw'], 'brand', 'model', 'sn', 'id', ['attribute' => 'device_note', 'value' => function ($moddev) use($model) {
    /* @var $moddev \backend\models\Devices */
    return Html::a($moddev->device_note, ['devices/view', 'id' => $moddev->id, 'id_wp' => $model->id]);
}, 'format' => 'raw'], ['class' => Column::className(), 'content' => function ($moddev) use($model) {
    return Html::a(Html::img('/admin/img/view.png', ['style' => 'height:24px']), ['devices/view', 'id' => $moddev->id, 'id_wp' => $model->id], ['title' => 'Подробно...']);
    //['data-method' => 'post']);
}, 'options' => ['style' => 'width:10px']], ['class' => Column::className(), 'content' => function ($moddev) use($model) {
    return Html::a('', ['devices/delfromwp', 'id' => $moddev->id, 'id_wp' => $model->id], ['class' => 'cross', 'title' => 'Удалить устройство с рабочего места...']);
    //['data-method' => 'post']);
}, 'options' => ['style' => 'width:10px']]]]);
?>

    </div>
</div>
Exemplo n.º 30
0
        <?php 
echo $id_wp == 0 ? '' : 'Выберите ответсвенного сотрудника или создайте нового:';
?>
        <?php 
echo Html::a('Создать нового', ['create', 'id_wp' => $id_wp], ['class' => 'btn btn-success']);
?>

        <?php 
if (Yii::$app->user->can('admin')) {
    //echo Html::a('Загрузить', ['readfile'], ['class' => 'btn btn-success']);
    echo Html::a('Загрузить', ['uploadform'], ['class' => 'btn btn-success']);
}
?>
    </p>
    <?php 
$cols = [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'id', 'value' => 'id', 'options' => ['style' => 'width:10px']], 'snp', 'job_title', ['attribute' => 'branch_id', 'value' => 'branch.branch_title'], ['class' => Column::className(), 'content' => function ($model) use($id_wp) {
    return Html::a('', ['wpowners/adduser', 'id_empl' => $model->id, 'id_wp' => $id_wp], ['class' => 'ok', 'title' => 'Выбрать сотрудника...']);
}], ['class' => 'yii\\grid\\ActionColumn']];
if ($mode !== 'select') {
    unset($cols[5]);
} else {
    unset($cols[6]);
}
?>

    <?php 
//выводим алфавит для быстрого фильтра по первой букве ФИО
echo '<ul class="pagination">';
foreach (range(chr(0xc0), chr(0xdf)) as $a) {
    $a = iconv('CP1251', 'UTF-8', $a);
    echo '<li><a href = "index?EmployeesSearch[snp]=' . $a . '&r=employees/index&mode=' . $mode . '&id_wp=' . $id_wp . '&pag=0">' . $a . '</a></li>';