guild/backend/modules/document/views/template/view.php

144 lines
4.6 KiB
PHP
Raw Normal View History

2021-12-27 16:50:17 +03:00
<?php
use backend\modules\document\models\DocumentField;
use common\helpers\TemplateDocumentTypeHelper;
2021-12-27 16:50:17 +03:00
use yii\helpers\Html;
2022-01-05 17:11:31 +03:00
use yii\helpers\Url;
use yii\web\YiiAsset;
2021-12-27 16:50:17 +03:00
use yii\widgets\DetailView;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $templateFieldDataProvider yii\data\ActiveDataProvider */
/* @var $model backend\modules\document\models\Template */
2022-01-07 15:04:11 +03:00
$this->title = cut_title($model->title);
2021-12-27 16:50:17 +03:00
$this->params['breadcrumbs'][] = ['label' => 'Templates', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
2022-01-05 17:11:31 +03:00
YiiAsset::register($this);
2022-01-07 15:04:11 +03:00
function cut_title($str)
{
if(strlen($str) > 35){
return mb_substr($str, 0, 35, 'UTF-8') . '...';
}
return $str;
}
2021-12-27 16:50:17 +03:00
?>
2022-01-07 15:04:11 +03:00
2021-12-27 16:50:17 +03:00
<div class="template-view">
<p>
<?= Html::a('Список', ['index', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
2022-01-05 17:11:31 +03:00
2021-12-27 16:50:17 +03:00
'attributes' => [
'id',
2022-01-10 15:22:51 +03:00
[
'label'=>'title',
'format'=>'raw',
'value' => function($model){
return $model->title . Html::a(' <i class="glyphicon glyphicon-pencil"></i>',
Url::to(['template/update-title', 'id' => $model->id]), [
'title' => 'update-title',
// 'class' => 'pull-right detail-button',
]);
}
],
2022-01-07 15:04:11 +03:00
'created_at',
'updated_at',
2022-01-05 17:11:31 +03:00
[
2022-01-07 15:04:11 +03:00
'label'=>'template_file_name',
2022-01-05 17:11:31 +03:00
'format'=>'raw',
'value' => function($model){
2022-01-07 15:04:11 +03:00
return $model->template_file_name . Html::a(' <i class="glyphicon glyphicon-pencil"></i>',
2022-01-10 15:22:51 +03:00
Url::to(['template/update-file', 'id' => $model->id]), [
'title' => 'update-file',
2022-01-07 15:04:11 +03:00
// 'class' => 'pull-right detail-button',
]);
2022-01-05 17:11:31 +03:00
}
],
[
'attribute' => 'document_type',
'format' => 'raw',
'value' => TemplateDocumentTypeHelper::getDocumentType($model->document_type),
],
2021-12-27 16:50:17 +03:00
],
]) ?>
2022-01-05 17:11:31 +03:00
<?php
$button1 = Html::a('<i class="glyphicon glyphicon-trash"></i>', Url::to(['delete', 'id' => $model->id]), [
'title' => 'Eliminar',
'class' => 'pull-right detail-button',
'data' => [
'confirm' => '¿Realmente deseas eliminar este elemento?',
'method' => 'post',
]
]);
$button2 = Html::a('<i class="glyphicon glyphicon-pencil"></i>', Url::to(['actualizar', 'id' => $model->id]), [
'title' => 'Actualizar',
'class' => 'pull-right detail-button',
]);
?>
2021-12-27 16:50:17 +03:00
<div>
<h2>
<?= 'Поля шаблона:'?>
</h2>
</div>
<?= GridView::widget([
'dataProvider' => $templateFieldDataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'field_id',
'value' => 'field.title',
],
2022-01-07 15:04:11 +03:00
[
'attribute' => 'field.field_template',
'value' => 'field.field_template',
],
2021-12-27 16:50:17 +03:00
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view}{delete}',
'controller' => 'template-document-field',
'buttons' => [
'delete' => function ($url,$model) {
return Html::a(
'<span class="glyphicon glyphicon-trash"></span>',
[
'template-document-field/delete', 'id' => $model['id'], 'template_id' => $model['template_id']
],
[
'data' => ['confirm' => 'Вы уверены, что хотите удалить этот вопрос?', 'method' => 'post']
]
);
},
],
],
],
]); ?>
<p>
<?= Html::a(
'Добавить поле',
['template-document-field/create', 'template_id' => $model->id],
['class' => 'btn btn-primary']
) ?>
</p>
</div>