Test Failed
Push — master ( e3c39f...fe570d )
by Mihail
07:20
created

Apps/View/Front/default/feedback/read.php (2 issues)

1
<?php
2
3
use Ffcms\Core\Helper\Date;
4
use Ffcms\Core\Helper\Type\Str;
5
use Ffcms\Templex\Url\Url;
6
7
/** @var \Ffcms\Templex\Template\Template $this */
8
/** @var \Apps\ActiveRecord\FeedbackPost $post */
9
/** @var \Apps\ActiveRecord\FeedbackAnswer $answers */
10
/** @var \Apps\Model\Front\Feedback\FormAnswerAdd|null $model */
11
12
$this->layout('_layouts/default', [
13
    'title' => __('Request from %email%', ['email' => $post->email]),
14
    'breadcrumbs' => [
15
        Url::to('/') => __('Home'),
16
        Url::to('feedback/create') => __('Feedback'),
17
        __('Read message')
18
    ]
19
]);
20
?>
21
<?php $this->start('body') ?>
22
<h1><?= __('Feedback message #%id%', ['id' => $post->id]) ?></h1>
23
<?php if (\App::$User->isAuth()): ?>
24
    <?= $this->insert('feedback/_authTabs') ?>
25
<?php else: ?>
26
    <hr />
27
<?php endif; ?>
28
29
<?php
30
if (!(bool)$post->closed && \App::$User->isAuth()) {
31
    $user = App::$User->identity();
32
    if ((int)$user->getId() === (int)$post->user_id) {
33
       echo Url::a(['feedback/close', [$post->id, $post->hash]], __('Close request'), ['class' => 'btn btn-danger']);
34
    }
35
}
36
?>
37
38
<div class="row">
39
    <div class="col-md-12">
40
        <div class="card">
41
            <div class="card-header">
42
                <strong><?= $post->name ?> (<?= $post->email ?>)</strong>,
43
                <?= Date::convertToDatetime($post->created_at, Date::FORMAT_TO_HOUR) ?>
0 ignored issues
show
Are you sure Ffcms\Core\Helper\Date::...r\Date::FORMAT_TO_HOUR) of type false|string can be used in echo? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

43
                <?= /** @scrutinizer ignore-type */ Date::convertToDatetime($post->created_at, Date::FORMAT_TO_HOUR) ?>
Loading history...
44
            </div>
45
            <div class="card-body well">
46
                <?= Str::replace("\n", "<br />", $post->message) ?>
47
            </div>
48
        </div>
49
    </div>
50
</div>
51
<h3><?= __('Answers') ?></h3>
52
<hr />
53
<?php if (!(bool)$post->readed && (!$answers || $answers->count() < 1)): ?>
54
    <?= $this->bootstrap()->alert('warning', __('This message is not properly readed by website administrators')) ?>
55
<?php endif; ?>
56
57
<?php if ($answers && $answers->count() > 0) : ?>
58
    <?php foreach ($answers as $answer): ?>
59
        <div class="row" id="feedback-answer-<?= $answer->id ?>">
60
            <div class="col-md-12">
61
                <div class="card">
62
                    <div class="card-header<?= (bool)$answer->is_admin ? ' bg-success' : null ?>">
63
                        <strong><?= $answer->name ?> (<?= $answer->email ?>)</strong>,
64
                        <?= Date::convertToDatetime($answer->created_at, Date::FORMAT_TO_HOUR) ?>
0 ignored issues
show
Are you sure Ffcms\Core\Helper\Date::...r\Date::FORMAT_TO_HOUR) of type false|string can be used in echo? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

64
                        <?= /** @scrutinizer ignore-type */ Date::convertToDatetime($answer->created_at, Date::FORMAT_TO_HOUR) ?>
Loading history...
65
                    </div>
66
                    <div class="card-body">
67
                        <?= Str::replace("\n", "<br />", $answer->message) ?>
68
                    </div>
69
                </div>
70
            </div>
71
        </div>
72
    <?php endforeach; ?>
73
<?php endif; ?>
74
75
<br />
76
<?php if (!(bool)$post->closed && $model): ?>
77
    <h3><?= __('Add answer') ?></h3>
78
    <?php $form = $this->form($model) ?>
79
    <?= $form->start() ?>
80
81
    <?= $form->fieldset()->text('name') ?>
82
    <?= $form->fieldset()->text('email') ?>
83
    <?= $form->fieldset()->textarea('message', ['rows' => 5]) ?>
84
85
    <?= $form->button()->submit(__('Add'), ['class' => 'btn btn-primary']) ?>
86
87
    <?= $form->stop() ?>
88
<?php else: ?>
89
    <?= $this->bootstrap()->alert('danger', __('This request is closed! No answers is allowed')) ?>
90
<?php endif; ?>
91
92
<?php $this->stop() ?>
93