use yii\helpers\Url;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
-
use kartik\select2\Select2;
use dosamigos\datetimepicker\DateTimePicker;
-
use yii_app\records\Admin;
-
-use yii_app\helpers\PrintBlockHelper;
use yii_app\services\FileService;
/* @var $this yii\web\View */
/* @var $model yii_app\records\Task */
/* @var $form yii\widgets\ActiveForm */
-/* @var $comment \yii_app\records\Comment */
+/* @var $comment yii_app\records\Comment|null */
+/* @var $entities array */
+/* @var $taskEntity array */
+/* @var $tasksType array */
+/* @var $taskStatus array */
+/* @var $taskAlertLevels array */
/* @var $canUpdateAll boolean */
/* @var $canUpdateStatusAndDuration boolean */
?>
-<div class="task-form">
+ <div class="task-form">
- <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>
+<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>
<div style="display: none">
<?= $form->field($model, 'id')->hiddenInput()->label(false) ?>
</div>
- <?php PrintBlockHelper::printBlock('Тип задачи', $form->field($model, 'task_type_id')->dropDownList(
- ArrayHelper::map($tasksType, 'id', 'name'), ['disabled' => $canUpdateAll ? null : 'disabled'])->label(false)); ?>
-
- <?php PrintBlockHelper::printBlock('Название', $form->field($model, 'name')->textInput(['maxlength' => true, 'disabled' => $canUpdateAll ? null : 'disabled'])->label(false)) ?>
-
- <?php PrintBlockHelper::printBlock('Описание задачи', $form->field($model, 'description')->textarea(['rows' => 6, 'disabled' => $canUpdateAll ? null : 'disabled'])->label(false)) ?>
-
- <?php // $form->field($model, 'group_id')->textInput() ?>
-
- <?php PrintBlockHelper::printBlock('Тип сущности', $form->field($model, 'entity_type')->widget(Select2::class, [
- 'data' => ArrayHelper::map($taskEntity, 'id', 'name'),
- 'language' => 'ru',
- 'options' => ['placeholder' => 'Тип сущности для привязки...'],
- 'pluginOptions' => [
- 'allowClear' => true,
- 'disabled' => !$canUpdateAll
- ],
- 'pluginEvents' => [
- "change" => "function() {
- var value= $(this).val();
- console.log(value);
- $.ajax({
- method: 'POST',
- dataType: 'text',
- url: window.location.href,
- data: { value : value },
- success: function (response) {
- var r = JSON.parse(response);
- console.log(r);
- var myDropDownList = document.getElementById('task-entity_id');
- while (myDropDownList.options.length > 0) {
- myDropDownList.remove(myDropDownList.options.length - 1);
- }
- $.each(r, function(index, value) {
- var option = document.createElement(\"option\");
- option.text = value;
- option.value = index;
- try {
- myDropDownList.options.add(option);
- } catch (e) {
- alert(e);
- }
- });
- }
- });
- }",
- ]
- ])->label(false)) ?>
-
- <?php // $form->field($model, 'entity_id')->textInput() ?>
+ <div class="form-group">
+ <label>Тип задачи</label>
+ <?= $form->field($model, 'task_type_id')->dropDownList(
+ ArrayHelper::map($tasksType, 'id', 'name'),
+ ['disabled' => $canUpdateAll ? null : 'disabled']
+ )->label(false); ?>
+ </div>
- <?php PrintBlockHelper::printBlock('Сущность', $form->field($model, 'entity_id')->dropDownList($entities, ['disabled' => $canUpdateAll ? null : 'disabled'])->label(false)) ?>
+ <div class="form-group">
+ <label>Название</label>
+ <?= $form->field($model, 'name')->textInput([
+ 'maxlength' => true,
+ 'disabled' => $canUpdateAll ? null : 'disabled'
+ ])->label(false); ?>
+ </div>
+ <div class="form-group">
+ <label>Описание задачи</label>
+ <?= $form->field($model, 'description')->textarea([
+ 'rows' => 6,
+ 'disabled' => $canUpdateAll ? null : 'disabled'
+ ])->label(false); ?>
+ </div>
- <?php // $form->field($model, 'entity_type')->dropDownList(
- // ArrayHelper::map($entityType, 'id', 'name')) ?>
+ <div class="form-group">
+ <label>Тип сущности</label>
+ <?= $form->field($model, 'entity_type')->widget(Select2::class, [
+ 'data' => ArrayHelper::map($taskEntity, 'id', 'name'),
+ 'language' => 'ru',
+ 'options' => ['placeholder' => 'Тип сущности для привязки...'],
+ 'pluginOptions' => [
+ 'allowClear' => true,
+ 'disabled' => !$canUpdateAll
+ ],
+ 'pluginEvents' => [
+ "change" => "function() {
+ var value= $(this).val();
+ console.log(value);
+ $.ajax({
+ method: 'POST',
+ dataType: 'text',
+ url: window.location.href,
+ data: { value : value },
+ success: function (response) {
+ var r = JSON.parse(response);
+ console.log(r);
+ var myDropDownList = document.getElementById('task-entity_id');
+ while (myDropDownList.options.length > 0) {
+ myDropDownList.remove(myDropDownList.options.length - 1);
+ }
+ $.each(r, function(index, value) {
+ var option = document.createElement(\"option\");
+ option.text = value;
+ option.value = index;
+ try {
+ myDropDownList.options.add(option);
+ } catch (e) {
+ alert(e);
+ }
+ });
+ }
+ });
+ }",
+ ]
+ ])->label(false); ?>
+ </div>
- <?php PrintBlockHelper::printBlock('Статус', $form->field($model, 'status')->dropDownList(
- ArrayHelper::map($taskStatus, 'id','name'), ['disabled' => $canUpdateStatusAndDuration ? null : 'disabled'])->label(false)) ?>
+ <div class="form-group">
+ <label>Сущность</label>
+ <?= $form->field($model, 'entity_id')->dropDownList(
+ $entities,
+ ['disabled' => $canUpdateAll ? null : 'disabled']
+ )->label(false); ?>
+ </div>
- <?php //$form->field($model, 'prioritet')->textInput() ?>
+ <div class="form-group">
+ <label>Статус</label>
+ <?= $form->field($model, 'status')->dropDownList(
+ ArrayHelper::map($taskStatus, 'id', 'name'),
+ ['disabled' => $canUpdateStatusAndDuration ? null : 'disabled']
+ )->label(false); ?>
+ </div>
- <?php PrintBlockHelper::printValueWithScale('Продолжительность', 'duration', $form, $model, 'task') ?>
+ <div class="form-group">
+ <label>Продолжительность</label>
+ <?= $form->field($model, 'duration')->textInput(['type' => 'number', 'disabled' => !$canUpdateStatusAndDuration])->label(false); ?>
+ </div>
- <?php if (!$canUpdateStatusAndDuration): ?>
+<?php if (!$canUpdateStatusAndDuration): ?>
<script>
$(document).ready(() => {
$('#durationValue').attr('disabled', 'disabled');
$('#durationScale').attr('disabled', 'disabled');
- })
+ });
</script>
- <?php endif; ?>
-
- <?php //PrintBlockHelper::printBlock('Продолжительность (мин.)', $form->field($model, 'duration')->textInput(['type' => 'number'])->label(false)) ?>
-
- <?php // $form->field($model, 'is_completed')->textInput() ?>
-
- <?php PrintBlockHelper::printBlock('Дата начала', $form->field($model, 'data_start')->widget(DateTimePicker::class, [
- 'language' => 'ru',
- 'template' => '{input}',
- 'clientOptions' => [
- 'autoclose' => true,
- 'format' => 'Y-m-d H:i',
- 'todayBtn' => true
- ],
- ])->label(false)) ?>
+<?php endif; ?>
- <?php /* PrintBlockHelper::printBlock('Дата начала', $form->field($model, 'data_start', [
- 'inputOptions' => [
- 'class' => 'form-control datetime',
- 'type' => 'datetime-local',
- ],
- 'options' => ['tag' => null],
- ])->textInput()->label(false)) */ ?>
-
- <?php // $form->field($model, 'data_start')->textInput() // календарь ?>
-
- <?php
+ <div class="form-group">
+ <label>Дата начала</label>
+ <?= $form->field($model, 'data_start')->widget(DateTimePicker::class, [
+ 'language' => 'ru',
+ 'template' => '{input}',
+ 'clientOptions' => [
+ 'autoclose' => true,
+ 'format' => 'Y-m-d H:i',
+ 'todayBtn' => true
+ ],
+ ])->label(false); ?>
+ </div>
- if ($model->deadline_permission != 0 || ($model->controller && ($model->controller->id == $_SESSION['admin_id']))) {
- PrintBlockHelper::printBlock('Крайний срок', $form->field($model, 'deadline')->widget(DateTimePicker::class, [
+<?php if ($model->deadline_permission != 0 || ($model->controller && ($model->controller->id == $_SESSION['admin_id']))): ?>
+ <div class="form-group">
+ <label>Крайний срок</label>
+ <?= $form->field($model, 'deadline')->widget(DateTimePicker::class, [
'language' => 'ru',
'template' => '{input}',
'clientOptions' => [
'format' => 'Y-m-d H:i',
'todayBtn' => true
],
- ])->label(false));
- }
-
- ?>
-
- <?php /* PrintBlockHelper::printBlock('Крайний срок', $form->field($model, 'deadline', [
- 'inputOptions' => [
- 'class' => 'form-control datetime',
- 'type' => 'datetime-local',
- ],
- 'options' => ['tag' => null],
- ])->textInput()->label(false)) */ ?>
-
- <?php // $form->field($model, 'dead_line')->textInput() // календарь ?>
-
- <?php // $form->field($model, 'data_end')->textInput() ?>
-
- <?php // $form->field($model, 'result')->textarea(['rows' => 6]) ?>
-
- <?php // $form->field($model, 'updated_by')->textInput() // проверяющий id должен быть в бд, а поле это "для кого" подтягивается из админа ?>
-
- <?php PrintBlockHelper::printBlock('Уровень важности', $form->field($model, 'alert_level_id')->dropDownList(
- ArrayHelper::map($taskAlertLevels, 'id', 'name'), ['disabled' => $canUpdateAll ? null : 'disabled'])->label(false)) ?>
-
- <?php PrintBlockHelper::printBlock('Сложность задачи', $form->field($model, 'motivation_id')->dropDownList(
- ArrayHelper::map(\yii_app\records\TaskMotivation::find()->all(), 'id', 'name'), ['disabled' => $canUpdateAll ? null : 'disabled'])->label(false)) ?>
-
- <?php
-
- $adminArr = [];
- foreach (Admin::find()->with('adminGroup')->all() as $admin) {
- $adminArr[] = ['id' => $admin->id, 'name' => $admin->name, 'groupName' => $admin->adminGroup->name ?? "Другие"];
- }
-
- ?>
-
- <?php $admins = ArrayHelper::map($adminArr, 'id', 'name', 'groupName') ?>
-
- <?php PrintBlockHelper::printBlock('Получатель задачи', $form->field($model, 'updated_by')->widget(Select2::class, [
- 'data' => $admins,
- 'language' => 'ru',
- 'options' => ['placeholder' => 'Кому адресовать задачу...'],
- 'pluginOptions' => [
- 'allowClear' => true,
- 'disabled' => !$canUpdateAll
- ],
- ])->label(false)); ?>
-
- <?php PrintBlockHelper::printBlock('Контроллёр задачи', $form->field($model, 'controller_id')->widget(Select2::class, [
- 'data' => $admins,
- 'language' => 'ru',
- 'options' => ['placeholder' => 'Кто контроллирует задачу...'],
- 'pluginOptions' => [
- 'allowClear' => true,
- 'disabled' => !$canUpdateAll
- ],
- ])->label(false)); ?>
-
- <?php PrintBlockHelper::printBlock('Участники задачи', Select2::widget([
- 'name' => 'taskUsers',
- 'value' => array_values(ArrayHelper::map($model->users, 'id', 'id')),
- 'data' => $admins,
- 'options' => ['multiple' => true, 'placeholder' => 'Выберете участников ...'],
- 'pluginOptions' => [
- 'disabled' => !$canUpdateAll
- ],
- ])); ?>
-
- <?php PrintBlockHelper::printBlock('Наблюдатели задачи', Select2::widget([
- 'name' => 'taskViewers',
- 'value' => array_values(ArrayHelper::map($model->viewers, 'id', 'id')),
- 'data' => $admins,
- 'options' => ['multiple' => true, 'placeholder' => 'Выберете наблюдателей ...'],
- 'pluginOptions' => [
- 'disabled' => !$canUpdateAll
- ],
- ])); ?>
-
- <?php // $form->field($model, 'created_by')->textInput() // создаётся из под того кто сидит ?>
-
- <?php // $form->field($model, 'created_at')->textInput() // автоматом в момент создания ?>
-
- <?php // $form->field($model, 'updated_at')->textInput() ?>
-
- <?php // $form->field($model, 'close_at')->textInput() ?>
-
- <?php // $form->field($model, 'closed_by')->textInput() ?>
-
- <?php if ($model->attachedFiles): ?>
- <div class="row">
- <?php foreach($model->attachedFiles as $file): ?>
- <div class="col-2">
- <?php if ($file->file_type == 'image'): ?>
- <img width=100 src="<?= FileService::padWithSlash($file->url) ?>" alt="img" onclick="window.open(this.src, '_blank');" />
- <?php else: ?>
- <a href="<?= Url::to(['/files/download', 'url' => $file->url]) ?>" class="btn btn-link" target="_blank" data-pjax="0"><?= basename($file->url)?></a>
- <?php endif; ?>
- </div>
- <?php endforeach; ?>
- </div>
- <?php endif; ?>
+ ])->label(false); ?>
+ </div>
+<?php endif; ?>
- <?php if ($canUpdateAll): ?>
- <?php PrintBlockHelper::printBlock('Медиа файлы',
- '<div class="taskMediaFiles"><button onclick="addTaskMediaFile(); return false;" class="btn btn-success btn-sm">Добавить медиа файлы к задаче</button></div>'); ?>
- <?php endif; ?>
+ <div class="form-group">
+ <label>Уровень важности</label>
+ <?= $form->field($model, 'alert_level_id')->dropDownList(
+ ArrayHelper::map($taskAlertLevels, 'id', 'name'),
+ ['disabled' => $canUpdateAll ? null : 'disabled']
+ )->label(false); ?>
+ </div>
<div class="form-group">
- <?= Html::submitButton('Сохранить задачу', ['class' => 'btn btn-success btn-lg']) ?>
+ <label>Сложность задачи</label>
+ <?= $form->field($model, 'motivation_id')->dropDownList(
+ ArrayHelper::map(\yii_app\records\TaskMotivation::find()->all(), 'id', 'name'),
+ ['disabled' => $canUpdateAll ? null : 'disabled']
+ )->label(false); ?>
</div>
- <?php ActiveForm::end(); ?>
+<?php
+$adminArr = [];
+foreach (Admin::find()->with('adminGroup')->all() as $admin) {
+ $adminArr[] = ['id' => $admin->id, 'name' => $admin->name, 'groupName' => $admin->adminGroup->name ?? "Другие"];
+}
+$admins = ArrayHelper::map($adminArr, 'id', 'name', 'groupName');
+?>
- <?php if (isset($comment)): ?>
- <?php $commentForm = ActiveForm::begin(['id' => 'comment-form', 'options' => ['enctype' => 'multipart/form-data']]) ?>
- <?php PrintBlockHelper::printBlock('Комментарий', $commentForm->field($comment, 'msg')->textInput()->label(false)) ?>
+ <div class="form-group">
+ <label>Получатель задачи</label>
+ <?= $form->field($model, 'updated_by')->widget(Select2::class, [
+ 'data' => $admins,
+ 'language' => 'ru',
+ 'options' => ['placeholder' => 'Кому адресовать задачу...'],
+ 'pluginOptions' => [
+ 'allowClear' => true,
+ 'disabled' => !$canUpdateAll
+ ],
+ ])->label(false); ?>
+ </div>
- <?php PrintBlockHelper::printBlock('Медиа файлы',
- '<div class="mediaFiles"><button onclick="addMediaFile(); return false;" class="btn btn-success btn-sm">Добавить медиа файлы к комментарию</button></div>'); ?>
+ <div class="form-group">
+ <label>Контроллёр задачи</label>
+ <?= $form->field($model, 'controller_id')->widget(Select2::class, [
+ 'data' => $admins,
+ 'language' => 'ru',
+ 'options' => ['placeholder' => 'Кто контроллирует задачу...'],
+ 'pluginOptions' => [
+ 'allowClear' => true,
+ 'disabled' => !$canUpdateAll
+ ],
+ ])->label(false); ?>
+ </div>
- <div class="form-group">
- <?= Html::submitButton('Сохранить комментарий', ['class' => 'btn btn-success btn']) ?>
- </div>
- <?php ActiveForm::end() ?>
- <?php endif; ?>
- <?php if (isset($model->comments)): ?>
- <?php foreach ($model->comments as $cmnt): ?>
+ <div class="form-group">
+ <label>Участники задачи</label>
+ <?= Select2::widget([
+ 'name' => 'taskUsers',
+ 'value' => array_values(ArrayHelper::map($model->users, 'id', 'id')),
+ 'data' => $admins,
+ 'options' => ['multiple' => true, 'placeholder' => 'Выберете участников ...'],
+ 'pluginOptions' => [
+ 'disabled' => !$canUpdateAll
+ ],
+ ]); ?>
+ </div>
+
+ <div class="form-group">
+ <label>Наблюдатели задачи</label>
+<?= Select2::widget([
+ 'name' => 'taskViewers',
+ 'value' => array_values(ArrayHelper::map($model->viewers, 'id', 'id')),
+ 'data' => $admins,
+ 'options' => ['multiple' => true, 'placeholder' => 'Выберете наблюдателей ...'],
+ 'pluginOptions' => [
+ 'disabled' => !$canUpdateAll
+ ],
+]); ?>
+ </div>
+
+ <?php if ($model->attachedFiles): ?>
<div class="row">
- <div class="col-3 text-right">
- <?= $cmnt->createdBy->name ?> (<?= \yii_app\services\DateTimeService::formatHuman($cmnt->created_at) ?>):
+ <?php foreach ($model->attachedFiles as $file): ?>
+ <div class="col-2">
+ <?php if ($file->file_type == 'image'): ?>
+ <img width="100" src="<?= FileService::padWithSlash($file->url) ?>" alt="img" onclick="window.open(this.src, '_blank');" />
+ <?php else: ?>
+ <a href="<?= Url::to(['/files/download', 'url' => $file->url]) ?>" class="btn btn-link" target="_blank" data-pjax="0"><?= basename($file->url) ?></a>
+ <?php endif; ?>
+ </div>
+ <?php endforeach; ?>
+ </div>
+ <?php endif; ?>
+
+ <?php if ($canUpdateAll): ?>
+ <div class="form-group">
+ <label>Медиа файлы</label>
+ <div class="taskMediaFiles">
+ <button onclick="addTaskMediaFile(); return false;" class="btn btn-success btn-sm">Добавить медиа файлы к задаче</button>
</div>
- <div class="col-9">
- <?= $cmnt->msg ?>
- <?php if (isset($cmnt->attachedFiles)): ?>
- <?php foreach ($cmnt->attachedFiles as $file): ?>
- <?php if ($file->file_type == 'image'): ?>
- <?= Html::a(basename($file->url), [$file->url], ['class' => 'btn btn-link', 'target' => '_blank']) ?>
- <?php else: ?>
- <?= Html::a(basename($file->url), ['/files/download', 'url' => $file->url], ['class' => 'btn btn-link']) ?>
- <?php endif; ?>
- <?php endforeach; ?>
- <?php endif; ?>
+ </div>
+ <?php endif; ?>
+
+ <div class="form-group">
+ <?= Html::submitButton('Сохранить задачу', ['class' => 'btn btn-success btn-lg']) ?>
+ </div>
+
+ <?php ActiveForm::end(); ?>
+
+ <?php if (isset($comment)): ?>
+ <?php $commentForm = ActiveForm::begin(['id' => 'comment-form', 'options' => ['enctype' => 'multipart/form-data']]) ?>
+ <div class="form-group">
+ <label>Комментарий</label>
+ <?= $commentForm->field($comment, 'msg')->textInput()->label(false) ?>
+ </div>
+
+ <div class="form-group">
+ <label>Медиа файлы</label>
+ <div class="mediaFiles">
+ <button onclick="addMediaFile(); return false;" class="btn btn-success btn-sm">Добавить медиа файлы к комментарию</button>
</div>
</div>
- <?php endforeach; ?>
- <?php endif; ?>
-</div>
+
+ <div class="form-group">
+ <?= Html::submitButton('Сохранить комментарий', ['class' => 'btn btn-success btn']) ?>
+ </div>
+ <?php ActiveForm::end() ?>
+ <?php endif; ?>
+
+ <?php if (isset($model->comments)): ?>
+ <?php foreach ($model->comments as $cmnt): ?>
+ <div class="row">
+ <div class="col-3 text-right">
+ <?= $cmnt->createdBy->name ?> (<?= \yii_app\services\DateTimeService::formatHuman($cmnt->created_at) ?>):
+ </div>
+ <div class="col-9">
+ <?= $cmnt->msg ?>
+ <?php if (isset($cmnt->attachedFiles)): ?>
+ <?php foreach ($cmnt->attachedFiles as $file): ?>
+ <?php if ($file->file_type == 'image'): ?>
+ <?= Html::a(basename($file->url), [$file->url], ['class' => 'btn btn-link', 'target' => '_blank']) ?>
+ <?php else: ?>
+ <?= Html::a(basename($file->url), ['/files/download', 'url' => $file->url], ['class' => 'btn btn-link']) ?>
+ <?php endif; ?>
+ <?php endforeach; ?>
+ <?php endif; ?>
+ </div>
+ </div>
+ <?php endforeach; ?>
+ <?php endif; ?>
+ </div>
\ No newline at end of file