Completed
Push — master ( c2bc12...ef5bc2 )
by Dmitry
04:55
created

src/views/cart/finish.php (1 issue)

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\AbstractPurchase[] $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
 * @var string $currency
13
 */
14
$this->title = Yii::t('cart', 'Order execution');
15
?>
16
17 View Code Duplication
<?php if (!empty($error)) : ?>
18
    <div class="row">
19
        <div class="col-md-12">
20
            <div class="box box-danger box-solid">
21
                <div class="box-header with-border">
22
                    <?= 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))); ?>
0 ignored issues
show
count($error) 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...
23
                </div>
24
                <div class="box-body">
25
                    <table class="table table-striped">
26
                        <thead>
27
                        <tr>
28
                            <th class="text-center">#</th>
29
                            <th><?= Yii::t('cart', 'Description') ?></th>
30
                            <th class="text-right"><?= Yii::t('cart', 'Price') ?></th>
31
                            <th></th>
32
                        </tr>
33
                        </thead>
34
                        <tbody>
35
                        <?php
36
                        $no = 1;
37
                        foreach ($error as $exception) :
38
                            $item = $exception->position;
39
                            ?>
40
                            <tr>
41
                                <td class="text-center text-bold"><?= $no++ ?></td>
42
                                <td>
43
                                    <?= $item->renderDescription() ?><br>
44
                                    <?= $exception->getMessage() ?>
45
                                </td>
46
                                <td align="right" class="text-bold"><?= Yii::$app->formatter->asCurrency($item->cost, $item->getCurrency()) ?></td>
47
                                <td></td>
48
                            </tr>
49
                        <?php endforeach; ?>
50
                        </tbody>
51
                    </table>
52
                </div>
53
            </div>
54
        </div>
55
    </div>
56
<?php endif; ?>
57
58
59 View Code Duplication
<?php if (!empty($pending)) : ?>
60
    <div class="row">
61
        <div class="col-md-12">
62
            <div class="box box-warning box-solid">
63
                <div class="box-header with-border">
64
                    <?= 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))); ?>
65
                </div>
66
                <div class="box-body">
67
                    <table class="table table-striped">
68
                        <thead>
69
                        <tr>
70
                            <th class="text-center">#</th>
71
                            <th><?= Yii::t('cart', 'Description') ?></th>
72
                            <th class="text-right"><?= Yii::t('cart', 'Price') ?></th>
73
                            <th></th>
74
                        </tr>
75
                        </thead>
76
                        <tbody>
77
                        <?php
78
                        $no = 1;
79
                        foreach ($pending as $exception) :
80
                            $item = $exception->position;
81
                            ?>
82
                            <tr>
83
                                <td class="text-center text-bold"><?= $no++ ?></td>
84
                                <td>
85
                                    <?= $item->renderDescription() ?><br>
86
                                    <?= $exception->getMessage() ?>
87
                                </td>
88
                                <td align="right" class="text-bold"><?= Yii::$app->formatter->asCurrency($item->cost, $item->getCurrency()) ?></td>
89
                                <td></td>
90
                            </tr>
91
                        <?php endforeach; ?>
92
                        </tbody>
93
                    </table>
94
                </div>
95
            </div>
96
        </div>
97
    </div>
98
<?php endif; ?>
99
100
<?php if (count($success)) : ?>
101
    <div class="row">
102
        <div class="col-md-12">
103
            <div class="box box-success">
104
                <div class="box-header with-border">
105
                    <h3 class="box-title">
106
                        <?= Yii::t('cart', 'Operations performed') ?>
107
                        : <?= Yii::t('cart', '{0, plural, one{# position} other{# positions}}', count($success)) ?>
108
                    </h3>
109
                </div>
110
                <div class="box-body">
111
                    <table class="table table-striped">
112
                        <thead>
113
                        <tr>
114
                            <th class="text-center">#</th>
115
                            <th><?= Yii::t('cart', 'Description') ?></th>
116
                            <th><?= Yii::t('cart', 'Notes') ?></th>
117
                            <th class="text-right"><?= Yii::t('cart', 'Price') ?></th>
118
                            <th></th>
119
                        </tr>
120
                        </thead>
121
                        <tbody>
122
                        <?php $no = 1 ?>
123
                        <?php foreach ($success as $purchase) : ?>
124
                            <?php $item = $purchase->position ?>
125
                            <tr>
126
                                <td class="text-center text-bold"><?= $no++ ?></td>
127
                                <td><?= $item->renderDescription() ?></td>
128
                                <td><?= $purchase->renderNotes() ?></td>
129
                                <td align="right" class="text-bold"><?= Yii::$app->formatter->asCurrency($item->cost, $item->getCurrency()) ?></td>
130
                                <td></td>
131
                            </tr>
132
                        <?php endforeach; ?>
133
                        </tbody>
134
                    </table>
135
                </div>
136
            </div>
137
        </div>
138
    </div>
139
<?php endif ?>
140
141
<?php if (count($remarks)) : ?>
142
    <?php foreach ($remarks as $remark) : ?>
143
        <?= $remark ?>
144
    <?php endforeach ?>
145
<?php endif ?>
146
147
<div class="row">
148
    <div class="col-md-5">
149
        <div class="box box-solid">
150
            <div class="box-header with-border">
151
                <h3 class="box-title">
152
                    <?= Yii::t('hipanel:finance', 'Your balance after all operations: {amount}', [
153
                        'amount' => Yii::$app->formatter->asCurrency($balance, $currency),
154
                    ]) ?>
155
                </h3>
156
            </div>
157
            <!-- /.box-header -->
158
            <div class="box-body text-center">
159
                <p class="text-muted well well-sm no-shadow">
160
                    <?php
161
                    if (Yii::$app->user->isGuest) {
162
                        echo Yii::t('hipanel:finance', 'If you have any further questions, please, contact us {emailLink}', [
163
                            'emailLink' => Html::a(Yii::$app->params['supportEmail'], 'mailto:' . Yii::$app->params['supportEmail']),
164
                        ]);
165
                    } else {
166
                        echo Yii::t('hipanel:finance', 'If you have any further questions, please, {ticketCreationLink}.', [
167
                            'ticketCreationLink' => Html::a(Yii::t('hipanel:finance', 'create a ticket'), '@ticket/create'),
168
                        ]);
169
                    } ?>
170
                </p>
171
            </div>
172
            <!-- /.box-body -->
173
        </div>
174
    </div>
175
</div>
176