Blame view

frontend/views/checkout/payment.php 8 KB
950817c6   Alex Savenko   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  <?php
      /**
       * @var \yii\web\View                  $this
       * @var \frontend\models\Order         $model
       * @var \artbox\order\models\Payment[] $payments
       * @var \artbox\order\models\Basket    $basket
       */
      use yii\bootstrap\ActiveForm;
      use yii\bootstrap\Html;
      
      $formatter = \Yii::$app->formatter;
      $basket = \Yii::$app->get('basket');
      $sum = 0;
      $sumDiscount = 0;
      foreach ($basket->findModels(array_keys($basket->getData())) as $variant) {
          $count = $basket->getItem($variant->id)[ 'count' ];
          $sum += $variant->price * $count;
          if (!empty($variant->price_old)) {
              $sumDiscount += ( $variant->price_old - $variant->price ) * $count;
          }
      }
  ?>
  <div id="content">
    <div class="container">
      
      <div class="row">
        
        <div class="col-md-9 clearfix" id="checkout">
          
          <div class="box">
              <?php
                  $form = ActiveForm::begin();
              ?>
            <ul class="nav nav-pills nav-justified">
                <?php
                    echo Html::tag(
                        'li',
                        Html::a(
                            Html::icon(
                                'map-marker',
                                [
                                    'prefix' => 'fa fa-',
                                ]
10e74468   mzavalniuk   translate to ua r...
44
                            ) . Html::tag('br') . \Yii::t('app', 'address'),
950817c6   Alex Savenko   first commit
45
46
47
48
49
50
51
52
53
54
55
                            [ 'checkout/info' ]
                        )
                    );
                    echo Html::tag(
                        'li',
                        Html::a(
                            Html::icon(
                                'truck',
                                [
                                    'prefix' => 'fa fa-',
                                ]
10e74468   mzavalniuk   translate to ua r...
56
                            ) . Html::tag('br') . \Yii::t('app', 'Method of delivery'),
950817c6   Alex Savenko   first commit
57
58
59
60
61
62
63
64
65
66
67
                            [ 'checkout/delivery' ]
                        )
                    );
                    echo Html::tag(
                        'li',
                        Html::a(
                            Html::icon(
                                'money',
                                [
                                    'prefix' => 'fa fa-',
                                ]
10e74468   mzavalniuk   translate to ua r...
68
                            ) . Html::tag('br') . \Yii::t('app', 'Payment method'),
950817c6   Alex Savenko   first commit
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
                            [
                                '#',
                            ]
                        ),
                        [
                            'class' => 'active',
                        ]
                    );
                    echo Html::tag(
                        'li',
                        Html::a(
                            Html::icon(
                                'eye',
                                [
                                    'prefix' => 'fa fa-',
                                ]
10e74468   mzavalniuk   translate to ua r...
85
                            ) . Html::tag('br') . \Yii::t('app', 'View order'),
950817c6   Alex Savenko   first commit
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
                            [
                                'checkout/confirm',
                            ]
                        ),
                        [
                            'class' => 'disabled',
                        ]
                    );
                ?>
            </ul>
            
            
            <div class="content">
              <div class="row">
                  <?php
                      if ($model->hasErrors()) {
                          echo Html::tag(
                              'p',
                              \Yii::t('app', 'Please choose payment method.'),
                              [
                                  'class' => 'text-danger',
                              ]
                          );
                      }
                      foreach ($payments as $index => $payment) {
                          ?>
                        <div class="col-sm-4">
                          <div class="box shipping-method">
                            
                            <div class="box-header text-center">
                                <?php
                                    echo $form->field(
                                        $model,
                                        'payment_id',
                                        [
                                            'options' => [
                                                'class' => 'form-group order-radio',
                                            ],
                                        ]
                                    )
                                              ->radio(
                                                  [
                                                      'uncheck' => ( $index === 0 ) ? 0 : null,
                                                      'label'   => null,
                                                      'tag'     => false,
                                                      'value'   => $payment->id,
                                                  ]
                                              )
                                              ->label(false)
                                              ->error(false);
                                ?>
                              <h4><?php echo $payment->lang->title; ?></h4>
                            </div>
                            
                            <p><?php echo $payment->lang->description; ?></p>
                          
                          </div>
                        </div>
                          <?php
                      }
                  ?>
              </div>
              <!-- /.row -->
            
            </div>
            <!-- /.content -->
            
            <div class="box-footer">
              <div class="pull-left">
                  <?php
                      echo Html::a(
                          Html::icon(
                              'chevron-left',
                              [
                                  'prefix' => 'fa fa-',
                              ]
10e74468   mzavalniuk   translate to ua r...
162
                          ) . \Yii::t('app', 'Delivery'),
950817c6   Alex Savenko   first commit
163
164
165
166
167
168
169
170
171
172
173
174
                          [
                              'checkout/delivery',
                          ],
                          [
                              'class' => 'btn btn-default',
                          ]
                      );
                  ?>
              </div>
              <div class="pull-right">
                  <?php
                      echo Html::submitButton(
10e74468   mzavalniuk   translate to ua r...
175
                          \Yii::t('app', 'Go to view order') . Html::icon(
950817c6   Alex Savenko   first commit
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
                              'chevron-right',
                              [
                                  'prefix' => 'fa fa-',
                              ]
                          ),
                          [
                              'class' => 'btn btn-success',
                          ]
                      );
                  ?>
              </div>
            </div>
              <?php
                  $form::end();
              ?>
          </div>
          <!-- /.box -->
        
        
        </div>
        <!-- /.col-md-9 -->
        
        <div class="col-md-3">
          <div class="box" id="order-summary">
            <div class="box-header">
10e74468   mzavalniuk   translate to ua r...
201
              <h3><?=Yii::t('app','Total count')?></h3>
950817c6   Alex Savenko   first commit
202
203
204
            </div>
            <p class="text-muted small"><?php echo \Yii::t(
                    'app',
10e74468   mzavalniuk   translate to ua r...
205
                    'total_text'
950817c6   Alex Savenko   first commit
206
207
208
209
210
211
                ); ?></p>
            
            <div class="table-responsive">
              <table class="table">
                <tbody>
                  <tr>
10e74468   mzavalniuk   translate to ua r...
212
                    <td><?php echo \Yii::t('app', 'Total for goods'); ?></td>
950817c6   Alex Savenko   first commit
213
214
215
                    <th><?php echo $formatter->asDecimal($sum, 2); ?></th>
                  </tr>
                  <tr>
10e74468   mzavalniuk   translate to ua r...
216
                    <td><?php echo \Yii::t('app', 'Discount amount'); ?></td>
950817c6   Alex Savenko   first commit
217
218
219
                    <th><?php echo $formatter->asDecimal($sumDiscount, 2); ?></th>
                  </tr>
                  <tr class="total">
10e74468   mzavalniuk   translate to ua r...
220
                    <td><?php echo \Yii::t('app', 'Total to pay'); ?></td>
950817c6   Alex Savenko   first commit
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
                    <th><?php echo $formatter->asDecimal($sum, 2); ?></th>
                  </tr>
                </tbody>
              </table>
            </div>
          </div>
        </div>
        <!-- /.col-md-3 -->
      
      </div>
      <!-- /.row -->
    
    </div>
    <!-- /.container -->
  </div>