Completed
Push — master ( c6b5de...db50e7 )
by Dmitry
04:45
created

src/views/cart/finish.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
use yii\helpers\Html;
4
5
/**
6
 * @var \yii\web\View
7
 * @var \hipanel\modules\finance\cart\AbstractCartPosition[] $success
8
 * @var \hipanel\modules\finance\cart\ErrorPurchaseException[] $error
9
 * @var \hipanel\modules\finance\cart\PendingPurchaseException[] $pending
10
 * @var array $remarks
11
 * @var float $balance
12
 */
13
$this->title = Yii::t('cart', 'Order execution');
14
?>
15
16 View Code Duplication
<?php if (!empty($error)) : ?>
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
    <div class="row">
18
        <div class="col-md-12">
19
            <div class="box box-danger box-solid">
20
                <div class="box-header with-border">
21
                    <?= Html::tag('h3', '<i class="fa fa-exclamation-triangle"></i>&nbsp;&nbsp;' . Yii::t('cart', 'Operations failed') . ': ' . Yii::t('cart', '{0, plural, one{# position} other{# positions}}', count($error))); ?>
22
                </div>
23
                <div class="box-body">
24
                    <table class="table table-striped">
25
                        <thead>
26
                        <tr>
27
                            <th class="text-center">#</th>
28
                            <th><?= Yii::t('cart', 'Description') ?></th>
29
                            <th class="text-right"><?= Yii::t('cart', 'Price') ?></th>
30
                            <th></th>
31
                        </tr>
32
                        </thead>
33
                        <tbody>
34
                        <?php
35
                        $no = 1;
36
                        foreach ($error as $exception) :
37
                            $item = $exception->position;
38
                            ?>
39
                            <tr>
40
                                <td class="text-center text-bold"><?= $no++ ?></td>
41
                                <td>
42
                                    <?= $item->renderDescription() ?><br>
43
                                    <?= $exception->getMessage() ?>
44
                                </td>
45
                                <td align="right" class="text-bold"><?= Yii::$app->formatter->asCurrency($item->cost, Yii::$app->params['currency']) ?></td>
46
                                <td></td>
47
                            </tr>
48
                        <?php endforeach; ?>
49
                        </tbody>
50
                    </table>
51
                </div>
52
            </div>
53
        </div>
54
    </div>
55
<?php endif; ?>
56
57
58 View Code Duplication
<?php if (!empty($pending)) : ?>
59
    <div class="row">
60
        <div class="col-md-12">
61
            <div class="box box-warning box-solid">
62
                <div class="box-header with-border">
63
                    <?= Html::tag('h3', '<i class="fa fa-exclamation-triangle"></i>&nbsp;&nbsp;' . Yii::t('cart', 'Pending operations') . ': ' . Yii::t('cart', '{0, plural, one{# position} other{# positions}}', count($pending))); ?>
64
                </div>
65
                <div class="box-body">
66
                    <table class="table table-striped">
67
                        <thead>
68
                        <tr>
69
                            <th class="text-center">#</th>
70
                            <th><?= Yii::t('cart', 'Description') ?></th>
71
                            <th class="text-right"><?= Yii::t('cart', 'Price') ?></th>
72
                            <th></th>
73
                        </tr>
74
                        </thead>
75
                        <tbody>
76
                        <?php
77
                        $no = 1;
78
                        foreach ($pending as $exception) :
79
                            $item = $exception->position;
80
                            ?>
81
                            <tr>
82
                                <td class="text-center text-bold"><?= $no++ ?></td>
83
                                <td>
84
                                    <?= $item->renderDescription() ?><br>
85
                                    <?= $exception->getMessage() ?>
86
                                </td>
87
                                <td align="right" class="text-bold"><?= Yii::$app->formatter->asCurrency($item->cost, Yii::$app->params['currency']) ?></td>
88
                                <td></td>
89
                            </tr>
90
                        <?php endforeach; ?>
91
                        </tbody>
92
                    </table>
93
                </div>
94
            </div>
95
        </div>
96
    </div>
97
<?php endif; ?>
98
99
<?php if (count($success)) : ?>
100
    <div class="row">
101
        <div class="col-md-12">
102
            <div class="box box-success">
103
                <div class="box-header with-border">
104
                    <h3 class="box-title">
105
                        <?= Yii::t('cart', 'Operations performed') ?>
106
                        : <?= Yii::t('cart', '{0, plural, one{# position} other{# positions}}', count($success)) ?>
0 ignored issues
show
count($success) is of type integer, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
107
                    </h3>
108
                </div>
109
                <div class="box-body">
110
                    <table class="table table-striped">
111
                        <thead>
112
                        <tr>
113
                            <th class="text-center">#</th>
114
                            <th><?= Yii::t('cart', 'Description') ?></th>
115
                            <th><?= Yii::t('cart', 'Notes') ?></th>
116
                            <th class="text-right"><?= Yii::t('cart', 'Price') ?></th>
117
                            <th></th>
118
                        </tr>
119
                        </thead>
120
                        <tbody>
121
                        <?php $no = 1 ?>
122
                        <?php foreach ($success as $purchase) : ?>
123
                            <?php $item = $purchase->position ?>
124
                            <tr>
125
                                <td class="text-center text-bold"><?= $no++ ?></td>
126
                                <td><?= $item->renderDescription() ?></td>
127
                                <td><?= $purchase->renderNotes() ?></td>
128
                                <td align="right" class="text-bold"><?= Yii::$app->formatter->asCurrency($item->cost, Yii::$app->params['currency']) ?></td>
129
                                <td></td>
130
                            </tr>
131
                        <?php endforeach; ?>
132
                        </tbody>
133
                    </table>
134
                </div>
135
            </div>
136
        </div>
137
    </div>
138
<?php endif ?>
139
140
<?php if (count($remarks)) : ?>
141
    <?php foreach ($remarks as $remark) : ?>
142
        <?= $remark ?>
143
    <?php endforeach ?>
144
<?php endif ?>
145
146
<div class="row">
147
    <div class="col-md-5">
148
        <div class="box box-solid">
149
            <div class="box-header with-border">
150
                <h3 class="box-title">
151
                    <?= Yii::t('hipanel:finance', 'Your balance after all operations: {amount}', [
152
                        'amount' => Yii::$app->formatter->asCurrency($balance, Yii::$app->params['currency']),
153
                    ]) ?>
154
                </h3>
155
            </div>
156
            <!-- /.box-header -->
157
            <div class="box-body text-center">
158
                <p class="text-muted well well-sm no-shadow">
159
                    <?php
160
                    if (Yii::$app->user->isGuest) {
161
                        echo Yii::t('hipanel:finance', 'If you have any further questions, please, contact us {emailLink}', [
162
                            'emailLink' => Html::a(Yii::$app->params['supportEmail'], 'mailto:' . Yii::$app->params['supportEmail']),
163
                        ]);
164
                    } else {
165
                        echo Yii::t('hipanel:finance', 'If you have any further questions, please, {ticketCreationLink}.', [
166
                            'ticketCreationLink' => Html::a(Yii::t('hipanel:finance', 'create a ticket'), '@ticket/create'),
167
                        ]);
168
                    } ?>
169
                </p>
170
            </div>
171
            <!-- /.box-body -->
172
        </div>
173
    </div>
174
</div>
175