showSuccess.php 18 KB
Newer Older
Яков's avatar
first  
Яков committed
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
<?php
$translation = $product['Translation'][$culture];
slot('title', $translation['title']);
use_javascript('fotorama.js');
use_stylesheet('fotorama.css');

$offers = $product['Offer'];
$images = array();
$images = explode(';', $product['product_img']);
$offers_images = array();
foreach ($offers as $offer) {
    if($offer['img']){
        echo '<!--';
        print_r($offer['img']);
        echo '-->';
        $images[] = $offer['img'];
        if(!isset($offers_images[$offer['id']])){
            $offers_images[$offer['id']] = count($images) - 1;
        }
    }
}
if(count($offers_images) > 0){
    ?>
    <script type="text/javascript">
        counterLite.offerImages = JSON.parse('<?php echo json_encode($offers_images);?>');
    </script>
    <?php
}

$view = 'much';
?>
<style type="text/css">
    .content__main {
        padding-bottom: 40px;
    }
</style>
<div class="content__main">
    <div class="max_width">
        <?php
        include_component('main', 'breadcrumbs', array('product_id' => $product['id']));

        echo '<h1 class="content_title">' . $translation['title'] . '</h1>';

        ?>
        <div class="catalog_product_wrap">
            <table class="to_div" cellspacing="0" cellpadding="0" width="100%">
                <tbody valign="top">
                <tr class="product_main product_main_<?php echo $view;?>">
                    <td width="48%">
                        <div id="fotorama" class="fotorama" data-width="100%" data-ratio="3/2" width="100%" max-height="400px" data-nav="thumbs" data-auto="false">
                            <?php
                            if (count($images) == 1 && strlen($images[0]) < 3) {
                                echo '<img src="/i/no_photo.png">';
                            }else {
                                foreach ($images as $image) {
                                    echo '<img src="/u/i/' . Page::replaceImageSize($image, 'M') . '">';
                                }
                            }
                            ?>
                        </div>
                    </td>
                    <td width="50"></td>
                    <td>
                        <table cellpadding="0" cellspacing="0" width="100%">
                            <tbody valign="middle" align="left">
                            <tr>
                                <?php
                                if ($view == 'much') { ?>
                                    <td>
                                        <?php
                                        $first_cost = 0;
                                        if (count($offers) > 0) {
                                            $sum = 0;
                                            foreach ($offers as $offer) {
                                                if ($i == 1) {
                                                    $first_cost = $offer['price'];
                                                }

                                                $quantity_type = $offer->getQuantityTypeValue($culture);
                                                $quantity_type = ($quantity_type != '' ? ', ' . $quantity_type : '');
                                                $infoAmount = false;
                                                if (trim($quantity_type) == ', ведро')
                                                {
                                                    if ($product->getTheWeight()) {
                                                        $quantity_type .= ', ' . $product->getTheWeight() . 'кг';
                                                    }else {
                                                        $quantity_type .= ', 10кг';
                                                    }
                                                }

                                                if (isset($offer['BasketOffer'][0]) && $offer['BasketOffer'][0]['amount'] > 0)
                                                {
                                                    $infoAmount = $offer['BasketOffer'][0]['amount'];
                                                }
                                                $sum += intval($infoAmount)*$offer['price'];

                                                $array_price = array_map('intval', str_split($offer['price']));
                                                if (strlen($offer['price']) > 3)
                                                {
                                                    $offer_str = '';
                                                    $length_str_price = 0;
                                                    if (count($array_price) > 6)
                                                    {
                                                        $offer_str .= implode('', array_slice($array_price, 0, count($array_price)-6)) . ' ';
                                                        $length_str_price = strlen($offer_str)-1;
                                                    }
                                                    $offer_str .= implode('', array_slice($array_price, $length_str_price, count($array_price)-$length_str_price-3)) . ' ' . implode('', array_slice($array_price, count($array_price)-3));
                                                }else
                                                {
                                                    $offer_str = '' . $offer['price'];
                                                }

                                                ?>
                                                <label class="product_offer">
                                                    <input data-initialized="1" data-id="<?php echo $offer['id']; ?>" type="radio" name="offer" onchange="counterLite.change($(this))">
                                                    <?php if ($offer['price'] > 1) { ?>
                                                    <table width="100%" cellpadding="0" cellspacing="0">
Яков's avatar
test    
Яков committed
118
                                                        <tr <?php echo ($offer['discount_available'] == 1 ? 'class="discount' : '') ?>">
Яков's avatar
first  
Яков committed
119
120
121
122
123
124
125
126
127
                                                            <td><?php echo $offer['title'] . $quantity_type; ?></td>
                                                            <td style="white-space: nowrap;"  align="right">
                                                                <?php echo $offer_str; ?>
                                                                <span class="rub">i</span>
                                                            </td>
                                                            <td width="1" align="right">
                                                                <div class="product_counter min" data-id="<?php echo $offer['id']; ?>" data-price="<?php echo $offer['price'];?>">
                                                                    <input type="button" class="product_counter_minus" data-symbol="-" onclick="counterLite.update($(this))">
                                                                    <input autocomplete="off" type="text" class="product_counter_val" value="<?php echo ( $infoAmount ? $infoAmount : 0 ) ?>" data-symbol="-+" onkeyup="counterLite.update($(this))">
Яков's avatar
test    
Яков committed
128
                                                                    <input type="button" class="product_counter_plus" data-symbol="+" onclick="counterLite.update($(this))">
Яков's avatar
first  
Яков committed
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
                                                                </div>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                    <?php }else
                                                        { ?>
                                                    <table width="100%" cellpadding="0" cellspacing="0">
                                                        <tr>
                                                            <td><?php echo $offer['title'] . $quantity_type; ?></td>
                                                            <td colspan="2"  width="1"  align="right">
                                                                <div class="find_price" onclick="callback.open($(this));return false;" data-offer-id="<?php echo $offer['id']; ?>" >
                                                                    <span>Узнать цену</span>
                                                                </div>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                    <?php } ?>
                                                </label>
                                                <?php
                                                $i++;
                                            }
                                        }
                                        $array_sum  = array_map('intval', str_split($sum));
                                        if (count($array_sum) > 3)
                                        {
                                            $sum_str = '';
                                            $length_str = 0;
                                            if (count($array_sum) > 6)
                                            {
                                                $sum_str .= implode('', array_slice($array_sum, 0, count($array_sum)-6)) . ' ';
                                                $length_str = strlen($sum_str)-1;
                                            }
                                            $sum_str .= implode('', array_slice($array_sum, $length_str, count($array_sum)-$length_str-3)) . ' ' . implode('', array_slice($array_sum, count($array_sum)-3));
                                        }else
                                        {
                                            $sum_str = '' . $sum;
                                        }
                                        ?>
                                        <i class="br10"></i>
                                        <table cellspacing="0" cellpadding="0" width="100%">
                                            <tbody align="right">
                                            <tr>
                                                <td style="padding-right: 25px;">
                                                    <span class="product_price">
                                                        <span class="product_price_value" data-price="0"><?php echo ($sum > 0 ? $sum_str : '') ?></span>
                                                        <span class="rub fs_10em" <?php echo ($sum > 0 ? ' style="visibility: visible;"' : '')?>>i</span></span>
                                                </td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </td>
                                    <?php
                                }
                                ?>
                            </tr>
                            <tr>
                                <td class="product__advantages__info" colspan="3">
                                    <?php
                                    $productDescription = $product->getDescription(ESC_RAW);
                                    $productPropValue = $product->getPropertyArray();
                                    echo '<i class="br10"></i>';
                                    if ($productDescription) {
                                        echo '<a href="" class="product__advantages__info__link fs_18 bbs_d green_link active" data-tab="description">' . __('Описание') . '</a>';
                                    }
                                    if (count($productPropValue) > 0) {?>
                                        <a href="" class="product__advantages__info__link fs_18 bbs_d green_link <?php echo (!$productDescription) ? 'active' : '' ?>" data-tab="features"><?php echo __('Характеристики'); ?></a>
                                <?php
                                    }
                                    if ($product->getCertificate()) {?>
                                        <a href="" class="product__advantages__info__link fs_18 bbs_d green_link <?php echo (!$productDescription && count($productPropValue) <= 0) ? 'active' : '' ?>" data-tab="certificate"><?php echo __('Сертификат'); ?></a>
                                    <?php
                                    }
                                    ?>
                                    <i class="br20"></i>
                                    <div class="product__advantages__info__tab active" data-tab="description">
                                        <div class="product__advantages__info__tab__description">
                                            <div><?php echo $productDescription ?></div>
                                        </div>
                                        <a href="" class="product__advantages__info__tab__description_btn" onclick="$('.product__advantages__info__tab__description').toggleClass('show');return false;"></a>
                                    </div>
                                    <div class="product__advantages__info__tab <?php echo (!$productDescription) ? 'active' : '' ?>" " data-tab="features">
                                        <table cellspacing="0" cellpadding="0" width="100%" style="max-width: 450px;">
                                            <tbody valign="top" align="left">
                                            <?php
                                            foreach ($productPropValue as $prop) {
                                                if($prop['value'] != ''){
                                                    echo '<tr>';
                                                    echo '<td style="font-family: \'robotoregular\';">' . $prop['prop'] . '</td>';
                                                    echo '<td></td>';
                                                    echo '<td>' . $prop['value'] . '</td>';
                                                    echo '</tr>';
                                                }
                                            }
                                            ?>
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="product__advantages__info__tab  <?php echo (!$productDescription && count($productPropValue) <= 0) ? 'active' : '' ?>" data-tab="certificate">
                                        <?php
                                        if($product->getCertificate()){
                                            echo '<a download="" href="/u/i/' . $product->getCertificate() . '" class="document_file_icon" data-val="' . $product->getCertificate() . '"></a>';
                                        }
                                        ?>
                                    </div>
                                    <script type="text/javascript">
                                        $('.product__advantages__info__link').click(function (e) {
                                            $('.product__advantages__info a, .product__advantages__info__tab').removeClass('active');
                                            $(this).addClass('active');
                                            $('.product__advantages__info__tab[data-tab=' + $(this).data('tab') + ']').addClass('active');
                                            return false;
                                        })
                                    </script>
                                </td>
                            </tr>
                            </tbody>
                        </table>

                    </td>
                </tr>
                </tbody>
            </table>
        </div>

    </div>
</div>
<?php
foreach ($product->getCats() as $cat){
    if($cat['Translation'][$sf_user->getCulture()]['title'] == 'Камень для бани'){
        echo '<div class="product_section product__calculator">';
        echo '<div class="max_width">';
        include_partial("catalog/product_calculator", array('offers' => $product['Offer']));
        echo '</div>';
        echo '</div>';
        break;
    }
}
?>
<div style="border-top: 1px solid #ececec; width: 100%; height: 1px"></div>
<?php include_partial("pages/landingArea2"); ?>
<?php
/*
<div class="product_section product__advantages">
    <div class="caption">С этим товаром покупают</div>
    <div class="max_width">
        <table cellpadding="0" cellspacing="0" width="100%">
            <tbody valign="top" align="left">
            <tr>
                <td>
                    <?php include_partial("product/product", array("count" => 4)); ?>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>
*/
?>
<?php
//print_r($product->getId());
include_component('video', 'video', array('limit' => 2, 'tag_id' => $product->getId()));
include_component('article', 'article', array('limit' => 4, 'tag_id' => $product->getId()));
include_component('review', 'review', array('limit' => 5, 'tag_id' => $product->getId()));
?>
<script type="text/javascript">
    var $fotoramaDiv = $('#fotorama').fotorama();
    var fotorama = $fotoramaDiv.data('fotorama');

    $(document).ready(function(){
        var diff = parseInt($('.product__advantages__info__tab__description > div').height()) - parseInt($('.product__advantages__info__tab__description').height());
        if(diff > 10 && diff < 85) {
            $('.product__advantages__info__tab__description').css('max-height','225px')
        } else if(diff > 10) {
            $('.product__advantages__info__tab__description_btn').addClass('show')
        }
    });
</script>