$mainPhoto = $model->getMainPhoto(); // print_r($mainPhoto); // return Html::img($mainPhoto->url,['class'=>'img-responsive','style'=>'width:80px;']); return Html::a(Html::img($mainPhoto->getUrl('original'), ['class' => 'img-responsive', 'style' => 'height:50px;']), ['products/view', 'product_id' => $model->product_id], ['style' => 'display:block;']); // echo Html::a( // Html::img($mainPhoto->getUrl('original'), [ 'class' => 'img-responsive', 'style' => 'max-height:120px;' ]), // [ 'products/view', 'product_id' => $model->product_id ], [ 'style' => 'display:block;' ]); }], ['class' => 'yii\\grid\\DataColumn', 'label' => '', 'headerOptions' => ['style' => 'border-left:none;border-top:1px solid #ddd;'], 'footerOptions' => ['class' => 'text-right', 'style' => 'border-bottom:1px solid #ddd;'], 'format' => 'raw', 'value' => function ($model) { return Html::a($model->name, ['products/view', 'product_id' => $model->product_id], ['style' => 'display:block;']); }], ['class' => 'yii\\grid\\DataColumn', 'label' => 'Цена', 'format' => 'html', 'headerOptions' => ['style' => 'border-top:1px solid #ddd;border-right:0;'], 'contentOptions' => ['style' => 'border-right:0;'], 'footer' => '<span style="font-size: 22px;">Итого</span>', 'footerOptions' => ['class' => 'text-right', 'style' => 'border-right:none;border-bottom:1px solid #ddd;'], 'value' => function ($model) { return '<span style="font-size: 16px;">' . number_format($model->price, 0, '.', ' ') . '</span>'; }], ['class' => 'yii\\grid\\DataColumn', 'label' => '', 'format' => 'html', 'headerOptions' => ['style' => 'border-top:1px solid #ddd;border-left:0;'], 'contentOptions' => ['style' => 'border-left:0;padding-top: 10px;'], 'footerOptions' => ['style' => 'border-left:none;border-bottom:1px solid #ddd;'], 'value' => function ($model) { return '<i class="glyphicon-cart glyphicon-ruble" style="margin-left:20px;font-size: 14px;"></i>'; }], ['class' => 'yii\\grid\\DataColumn', 'label' => 'Количество', 'headerOptions' => ['style' => 'border-top:1px solid #ddd;'], 'contentOptions' => ['style' => 'max-width:100px!important;'], 'footer' => '<span id="cart_quantity" style="font-size: 22px;">' . Yii::$app->cart->getCount() . '</span>', 'footerOptions' => ['style' => 'border-bottom:1px solid #ddd;'], 'format' => 'raw', 'value' => function ($model) { // return Yii::$app->cart->getPositionById($model->id)->getQuantity(); return TouchSpin::widget(['name' => 'count', 'pluginOptions' => ['verticalbuttons' => true, 'min' => 1, 'initval' => Yii::$app->cart->getPositionById($model->product_id)->getQuantity(), 'verticalupclass' => 'glyphicon glyphicon-plus', 'verticaldownclass' => 'glyphicon glyphicon-minus', 'buttonup_txt' => '<i class="glyphicon glyphicon glyphicon-plus"></i>', 'buttondown_txt' => '<i class="glyphicon glyphicon glyphicon-minus"></i>'], 'pluginEvents' => ['change' => "function() { \n\n\t\t\t\t\t\t\t// if (this.value>100) {\n\t\t\t\t\t\t\t// \t//не больше 100 штук\n\t\t\t\t\t\t\t// \tthis.value = 100;\n\t\t\t\t\t\t\t// }\n\t\t\t\t\t\t\tjQuery.ajax(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'type':'POST',\n\t\t\t\t\t\t\t'data':{'product_id':\"{$model->product_id};\",'quantity':this.value},\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t'dataType':'json',\n\t\t\t\t\t\t\t'success':function(data){\n\t\t\t\t\t\t\t\$('.cart_cost').html(data.cart_cost);\n\t\t\t\t\t\t\t\$('.cartContent').html(data.cartContent);\n\t\t\t\t\t\t\t\$('#cart_quantity').html(data.cart_quantity);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\$('#position_cost_{$model->product_id}').html(data.position_cost);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'url':'/cart/change-quantity/',\n\t\t\t\t\t\t\t'cache':false\n\t\t\t\t\t\t\t});\n\n\t\t\t\t \t }"]]); }], ['class' => 'yii\\grid\\DataColumn', 'label' => 'Сумма', 'format' => 'raw', 'headerOptions' => ['style' => 'border-top:1px solid #ddd;border-right:0;'], 'contentOptions' => ['style' => 'border-right:0;'], 'footer' => '<span class="cart_cost"style="color:#d2322d;font-size: 22px;">' . number_format(Yii::$app->cart->getCost(), 0, '.', ' ') . '</span>', 'footerOptions' => ['style' => 'border-right:0; border-bottom:1px solid #ddd;min-width:100px!important;'], 'value' => function ($model) { return '<span id="position_cost_' . $model->product_id . '" style="color:#d2322d;font-size: 22px;">' . number_format(Yii::$app->cart->getPositionById($model->product_id)->getCost(), 0, '.', ' ') . '</span>'; return; }], ['class' => 'yii\\grid\\DataColumn', 'label' => ' ', 'format' => 'html', 'headerOptions' => ['style' => 'border-top:1px solid #ddd;border-left:0;'], 'contentOptions' => ['style' => 'border-left:0;padding-top: 12px;'], 'footer' => '<i class="glyphicon-cart glyphicon-ruble" style="margin-left:20px;color:#d2322d;font-size: 20px;"></i></span>', 'footerOptions' => ['style' => 'border-left:0;border-bottom:1px solid #ddd;padding-top: 12px;'], 'value' => function ($model) { return '<i id="clear" class="glyphicon-cart glyphicon-ruble" style="margin-left:20px;color:#d2322d;font-size: 20px;"></i>'; }], ['class' => '\\yii\\grid\\ActionColumn', 'header' => Html::a(Html::Tag('i', null, ['class' => 'glyphicon-cart glyphicon-remove cart-remove']), ['#'], ['id' => 'clear', 'style' => 'text-decoration:none;']), 'headerOptions' => ['style' => 'border-top:1px solid #ddd;border-right:none;'], 'contentOptions' => ['style' => 'border-right:none;'], 'footerOptions' => ['style' => 'border-right:none;'], 'template' => '{delete}', 'buttons' => ['delete' => function ($url, $model) { $url = Url::toRoute('/cart/remove/'); $jsCartRemove = <<<JS \t\t\t\$("#remove_{$model->product_id}").on('click', \t\t\t\tfunction() { \t\t\t\t\t\$.ajax({
foreach (explode(",", $d->value) as $v) { $options[trim($v)] = trim($v); $deval = $deval == "" ? trim($v) : $deval; } echo '<div class="form-group"><label class="control-label">' . Html::encode($d->label) . '</label>'; echo Select2::widget(['name' => 'Orders[data][' . $d->label . ']', 'data' => $options, 'value' => $deval, 'options' => ['placeholder' => Yii::t('app', 'Select ') . $d->label, 'class' => 'item-shopcart', "id" => "data_" . str_replace(" ", "_", $d->label)]]); echo '</div>'; } else { if ($type == 1) { echo '<div class="form-group"><label class="control-label">' . Html::encode($d->label) . '</label>'; echo Html::textInput('Orders[data][' . $d->label . ']', $d->value, ["id" => "data_" . str_replace(" ", "_", $d->label), "class" => "form-control item-shopcart", "placeholder" => Yii::t("app", $d->label), "style" => "width:100%"]); echo '</div>'; } else { if ($type == 2) { echo '<div class="form-group"><label class="control-label">' . Html::encode($d->label) . '</label>'; echo TouchSpin::widget(['name' => 'Orders[data][' . $d->label . ']', 'value' => $d->value == null ? 0 : $d->value, 'options' => ["id" => "data_" . str_replace(" ", "_", $d->label), "class" => "item-shopcart"], 'pluginOptions' => ['min' => 1, 'step' => 1, 'max' => 100000000000, 'boostat' => 10, 'maxboostedstep' => 100000, 'handle' => 'triangle', 'tooltip' => 'always']]); echo '</div>'; } else { if ($type == 3) { echo '<div class="form-group"><label class="control-label">' . Html::encode($d->label) . '</label>'; echo Html::textArea('Orders[data][' . $d->label . ']', $d->value, ["id" => "data_" . str_replace(" ", "_", $d->label), "class" => "form-control item-shopcart", "placeholder" => Yii::t("app", $d->label), "style" => "width:100%"]); echo '</div>'; } else { if ($type == 4) { echo '<div class="form-group"><label class="control-label">' . $d->value . '</label>'; echo Html::hiddenInput('Orders[data][' . $d->label . ']', $d->value, ["id" => "data_" . str_replace(" ", "_", $d->label), "class" => "form-control item-shopcart"]); echo '</div>'; } else { if ($type == 5) { echo Html::hiddenInput('Orders[data][' . $d->label . ']', $d->value, ["id" => "data_" . str_replace(" ", "_", $d->label), "class" => "form-control item-shopcart"]); }