-
Notifications
You must be signed in to change notification settings - Fork 0
/
pdf_brand.dist.tpl
154 lines (139 loc) · 6.16 KB
/
pdf_brand.dist.tpl
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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
{use class="Yii"}
{use class="yii\helpers\Url"}
{use class="panix\engine\Html"}
{use class="panix\mod\shop\models\Product"}
{use class="panix\mod\shop\models\Attribute"}
{$units = \panix\mod\shop\models\Product::unitsList()}
{if Yii::$app->request->get('image')}
{$small=false}
{$rowsCount=5}
{$nums=2}
{$footnum=3}
{else}
{$rowsCount=4}
{$nums=1}
{$footnum=2}
{$small=true}
{/if}
{foreach from=$model item=order}
{if (isset($order->products))}
{foreach from=$order->products item=item}
{$original=$item->originalProduct}
{if ($original)}
{if ($original->brand)}
{$title = ($original->brand) ? $original->brand->name : null}
{if ($original->mainImage)}
{$image = $original->getMainImage('small')->url}
{else}
{$image = '/uploads/no-image.png'}
{/if}
{$newprice = ($original->hasDiscount) ? $original->discountPrice : $item->price}
{$total_price = ($newprice * $item->quantity)}
{$array[$title][] = [
'item'=>$item,
'order_date' => $order->created_at,
'order_url' => Url::to($order->getUpdateUrl(), true),
'image' => Url::to($image, true),
'username' => $order->user_name,
'price' => $newprice,
'model' => $original,
'url' => Url::to($original->getUrl()),
'title' => $title,
'price_total' => $total_price
]}
{/if}
{/if}
{/foreach}
{/if}
{/foreach}
{$total_count = 0}
{$total_price = 0}
{foreach from=$array key=key item=items}
{$brand = explode('|', $key)}
<table border="1" cellspacing="0" cellpadding="2" style="width:100%;" class="table table-bordered table-striped">
<tbody>
<tr>
<th colspan="{$rowsCount}" align="center" class="text-center" style="background-color:#9b9b9b;color:#fff">
<strong>{$key}</strong>
</th>
</tr>
<tr>
<th width="5%" align="center" class="text-center">№</th>
<th width="50%" {if (!$small)} colspan="{$nums}" {/if} align="center"
class="text-center">{Yii::t('cart/default', 'TABLE_PRODUCT')}</th>
<th width="10%" align="center" class="text-center">{Yii::t('cart/default', 'QUANTITY')}</th>
<th width="25%" align="center" class="text-center">Сумма</th>
</tr>
{usort($items, [$this->context, "titleSort"])}
{$brand_count = 0}
{$brand_price = 0}
{$num = 0}
{$i = 1}
{foreach from=$items item=row}
{assign var="brand_price" value=$brand_price+$row['price_total']}
{if Yii::$app->settings->get('cart', 'quantity_convert')}
{assign var="num" value=$num+($row['item']->quantity / $row['item']->in_box)}
{assign var="brand_count" value=$brand_count+($row['item']->quantity / $row['item']->in_box)}
{else}
{assign var="num" value=$num+$row['item']->quantity}
{assign var="brand_count" value=$brand_count+$row['item']->quantity}
{/if}
<tr>
<td align="center">{$i}</td>
{if (!$small)}
<td width="10%" align="center">
{Html::img($row['image'], ['width' => 50, 'height' => 50])}
</td>
{/if}
<td>
{$row['item']->name}<br/>
<strong>{Yii::$app->currency->number_format($row['price'])}</strong> {Yii::$app->currency->active['symbol']}
/ {Yii::t('shop/Product', 'UNITS_CUT', ['n' => 1])}
<br/>
{if ($row['model']->sku)}
{$row['item']->getAttributeLabel('sku')}:
<strong>{$row['model']->sku}</strong>
{/if}
{$query = Attribute::find()->where(['IN', 'name', array_keys($row['model']->eavAttributes)])->displayOnPdf()->sort()}
{$result = $query->all()}
{$attributes = $row['model']->eavAttributes}
{foreach from=$result item=q}
{$q->title}:
<strong>{$q->renderValue($attributes[$q->name])}</strong>;
{/foreach}
</td>
<td align="center">
{if Yii::$app->settings->get('cart', 'quantity_convert')}
<strong>{$row['item']->quantity / $row['item']->in_box}</strong> {Yii::t('shop/Product', 'UNITS_CUT', ['n' => $row['item']->unit])}
{else}
<strong>{$row['item']->quantity}</strong> {Yii::t('shop/Product', 'UNITS_CUT', ['n' => 1])}
{/if}
</td>
<td align="center">
<strong>{Yii::$app->currency->number_format($row['price_total'])}</strong> {Yii::$app->currency->active['symbol']}
</td>
</tr>
{assign var="i" value=$i++}
{/foreach}
<tr>
<td align="center" colspan="{$footnum}"></td>
<td align="center">
{Yii::t('cart/default', 'QUANTITY')}: <strong>{$num}</strong>
</td>
<td align="center">
И того:
<strong>{Yii::$app->currency->number_format($brand_price)}</strong> {Yii::$app->currency->active['symbol']}
</td>
</tr>
</tbody>
</table>
<!-- <pagebreak /> добавляем разрыв страницы -->
{assign var="total_count" value=$total_count+$brand_count}
{assign var="total_price" value=$total_price+$brand_price}
{/foreach}
<br/>
<h3 style="text-align: center">
<small>{Yii::t('shop/default', 'PRODUCTS_COUNTER', $total_count)} на сумму:
</small> {Yii::$app->currency->number_format($total_price)}
<small>{Yii::$app->currency->active['symbol']}</small>
</h3>