Root entity > Company RT (структура)
Root entity > Company RT
Root entity > Root Group (структура)
Root entity > Root Group
а мне надо Root Group и Company RT var keys = $("#grid").yiiGridView("getSelectedRows"); на var keys = $("#w0").yiiGridView("getSelectedRows");
.<?php Pjax::begin(); ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'layout' => "{summary}\n{pager}\n{items}\n{pager}",
'columns' => [
'class' => 'yii\grid\CheckboxColumn',
'checkboxOptions' => function () {
return [
'onchange' => 'var keys = $("#grid").yiiGridView("getSelectedRows");
$(this).parent().parent().toggleClass("danger")'
];
},
[
'label' => 'Изображения',
'attribute' => 'img_id',
'format' => 'raw',
'options' => ['width' => '100'],
'value' => function ($data) {
return !ProductSeeds::getImageTitle($data->img_id) ? Html::img('/web/uploads/system/no-image.png', ['width' => '50', 'height' => '50', 'class' => 'img-thumbnail']) : Html::img('/web/uploads/products/' . ProductSeeds::getImageTitle($data->img_id), ['width' => '50', 'height' => '50', 'class' => 'img-thumbnail']);
},
'filter' => '',
],
[
'attribute' => 'status',
'format' => 'raw',
'options' => ['width' => '80'],
'value' => function ($data) {
return !$data->status ? '<span class="glyphicon glyphicon-remove text-danger glyphicon-remove-big-size"></span>' : '<span class="glyphicon glyphicon-ok text-success glyphicon-remove-big-size"></span>';
},
'filter' => ProductSeeds::$statuses,
],
[
'attribute' => 'availability',
'format' => 'raw',
'options' => ['width' => '80'],
'value' => function ($data) {
return !$data->availability ? '<span class="glyphicon glyphicon-remove text-danger glyphicon-remove-big-size"></span>' : '<span class="glyphicon glyphicon-ok text-success glyphicon-remove-big-size"></span>';
},
'filter' => ProductSeeds::$availabilities,
],
[
'attribute' => 'hit',
'format' => 'raw',
'options' => ['width' => '80'],
'value' => function ($data) {
return !$data->hit ? '<span class="glyphicon glyphicon-remove text-danger glyphicon-remove-big-size"></span>' : '<span class="glyphicon glyphicon-ok text-success glyphicon-remove-big-size"></span>';
},
'filter' => ProductSeeds::$hits,
],
[
'attribute' => 'new',
'format' => 'raw',
'options' => ['width' => '80'],
'value' => function ($data) {
return !$data->new ? '<span class="glyphicon glyphicon-remove text-danger glyphicon-remove-big-size"></span>' : '<span class="glyphicon glyphicon-ok text-success glyphicon-remove-big-size"></span>';
},
'filter' => ProductSeeds::$novelty,
],
[
'attribute' => 'sale',
'format' => 'raw',
'options' => ['width' => '80'],
'value' => function ($data) {
return !$data->sale ? '<span class="glyphicon glyphicon-remove text-danger glyphicon-remove-big-size"></span>' : '<span class="glyphicon glyphicon-ok text-success glyphicon-remove-big-size"></span>';
},
'filter' => ProductSeeds::$sales,
],
[
'attribute' => 'top_sales',
'format' => 'raw',
'options' => ['width' => '80'],
'value' => function ($data) {
return !$data->top_sales ? '<span class="glyphicon glyphicon-remove text-danger glyphicon-remove-big-size"></span>' : '<span class="glyphicon glyphicon-ok text-success glyphicon-remove-big-size"></span>';
},
'filter' => ProductSeeds::$topSales,
],
[
'attribute' => 'top_ten',
'format' => 'raw',
'options' => ['width' => '80'],
'value' => function ($data) {
return !$data->top_ten ? '<span class="glyphicon glyphicon-remove text-danger glyphicon-remove-big-size"></span>' : '<span class="glyphicon glyphicon-ok text-success glyphicon-remove-big-size"></span>';
},
'filter' => ProductSeeds::$topTen,
],
[
'attribute' => 'category_id',
'options' => ['width' => '150'],
'value' => function ($data) {
return $data->category->title;
},
'filter' => ArrayHelper::map(CategorySeeds::find()->all(), 'id', 'title'),
],
[
'attribute' => 'title',
'format' => 'raw',
//'options' => ['width' => '180'],
'filter' => '',
],
[
'attribute' => 'price',
'headerOptions' => ['width' => '100'],
],
[
'attribute' => 'old_price',
'headerOptions' => ['width' => '100'],
],
[
'class' => 'yii\grid\ActionColumn',
'header' => 'Действие',
'headerOptions' => ['width' => '65'],
'template' => '{view} {update} {delete}{link}',
],
],
]); ?>
<?php Pjax::end(); ?>
</div>
<?php
$script = <<< JS
$("#basket").on("click", function(e){
e.preventDefault()
var keys = $("#grid").yiiGridView("getSelectedRows");
$.ajax({
url: "'. \yii\helpers\Url::toRoute('basket') .'",
type: "POST",
data: {id: keys},
success: function(){
alert("yes")
}
})
});
JS;
$this->registerJs($script, yii\web\View::POS_READY);
?>
// if (!$this->validate()) {
// return $dataProvider;
// }
'270-300'
VarDumper::dump($_GET['ProductSeedsSearch']['ripeness_group'], 11, 1);
if (isset($_GET['ProductSeedsSearch']['ripeness_group'])) {
$int = $_GET['ProductSeedsSearch']['ripeness_group'];
$int = explode('-', $this->ripeness_group);
$min = ($int[0] == 180) ? 0 : $int[0];
$max = (isset($int[1])) ? isset($int[1]) : 100000000;
$query->andFilterWhere([
'and',
['>=', 'ripeness_group', $min],
['<=', 'ripeness_group', $max]
]);
}
$a = '0-210';
<div class="checkbox">
<label>
<input type="checkbox" id="productseedssearch-ripeness_group"
name="ProductSeedsSearch[ripeness_group]" value="<?= $a ?>">
<span class="checkbox-custom"></span>
180-210
<span class="quantity"></span>
</label>
</div>
syntax error, unexpected '?'
$max = (isset($int[1])) ??100000000; объясните мне этот участок кода?
if (isset($_GET['ProductSeedsSearch']['ripeness_group'])) {
$int = $_GET['ProductSeedsSearch']['ripeness_group'];
$int = explode('-',$this->ripeness_group);
$query->andFilterWhere([
'and',
['>=', 'ripeness_group', $int[0]],
['<=', 'ripeness_group', $int[1]]
]);
}
$a = '180-210';
$b = '220-260';
$c = '270-300';
$d = '300 и больше';
<p>Группа спелости (ФАО)</p>
<div class="select-block">
<div class="checkbox">
<label>
<input type="checkbox" id="productseedssearch-ripeness_group"
name="ProductSeedsSearch[ripeness_group]" value="<?= $a ?>">
<span class="checkbox-custom"></span>
180-210
<span class="quantity"></span>
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" id="productseedssearch-ripeness_group"
name="ProductSeedsSearch[ripeness_group]" value="<?= $b ?>">
<span class="checkbox-custom"></span>
220-260
<span class="quantity"></span>
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" id="productseedssearch-ripeness_group"
name="ProductSeedsSearch[ripeness_group]" value="<?= $c ?>">
<span class="checkbox-custom"></span>
270-300
<span class="quantity"></span>
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" id="productseedssearch-ripeness_group"
name="ProductSeedsSearch[ripeness_group]" value="<?= $d ?>">
<span class="checkbox-custom"></span>
300 и больше
<span class="quantity"></span>
</label>
</div>
<?= Html::submitButton(Yii::t('app', 'OK')) ?>
</div>
public static function getFilterRipenessGroupCheckbox($id)
{
$query = new Query();
$query->select('ripeness_group')
->from('product_seeds')
->where(['category_id' => $id])
->groupBy('ripeness_group');
$command = $query->createCommand();
$data = $command->queryAll();
$result = [];
foreach ($data as $ripenessGroup) {
$result[] = $ripenessGroup['ripeness_group'];
}
return $result;
}
<p>Группа спелости (ФАО)</p>
<div class="select-block">
<?php
foreach ($ripenessGroups as $key => $value) : ?>
<?php if (!$value == null) : ?>
<?php
$checked_ripeness_group = "";
if (isset($_GET['ProductSeedsSearch']['ripeness_group'])) {
$brand = $_GET['ProductSeedsSearch']['ripeness_group'];
if ($value == $brand) {
$checked_ripeness_group = "checked";
}
}
?>
<div class="checkbox">
<label>
<input type="checkbox" id="productseedssearch-ripeness_group"
name="ProductSeedsSearch[ripeness_group]" value="<?= $value ?>"
<?= $checked_ripeness_group ?>>
<span class="checkbox-custom"></span>
<?= $value ?>
<span class="quantity"></span>
</label>
</div>
<?php $form->field($model, 'ripeness_group')->checkbox(
[
'uncheck' => null,
'label' => $value,
'value' => $value,
]
); ?>
<?php endif; ?>
<?php endforeach; ?>
<?= Html::submitButton(Yii::t('app', 'OK')) ?>
</div>
<p>Группа спелости (ФАО)</p>
<div class="select-block">
<div class="checkbox">
<label>
<input type="checkbox" id="productseedssearch-ripeness_group"
name="ProductSeedsSearch[ripeness_group]" value="1">
<span class="checkbox-custom"></span>
180-210
<span class="quantity"></span>
</label>
</div>
<?= Html::submitButton(Yii::t('app', 'OK')) ?>
</div>
где не прав то я????