Commit 1c34c1b56caf50bc89273c8dcde09ad39cf4fd98
1 parent
2abd8624
work on details desc
Showing
3 changed files
with
48 additions
and
6 deletions
Show diff stats
backend/controllers/DetailsDescriptionController.php
| @@ -2,10 +2,12 @@ | @@ -2,10 +2,12 @@ | ||
| 2 | 2 | ||
| 3 | namespace backend\controllers; | 3 | namespace backend\controllers; |
| 4 | 4 | ||
| 5 | +use common\models\DetailsCriteria; | ||
| 5 | use Yii; | 6 | use Yii; |
| 6 | use common\models\DetailsDescription; | 7 | use common\models\DetailsDescription; |
| 7 | use common\models\DetailsDescriptionSearch; | 8 | use common\models\DetailsDescriptionSearch; |
| 8 | use backend\components\base\BaseController; | 9 | use backend\components\base\BaseController; |
| 10 | +use yii\data\ActiveDataProvider; | ||
| 9 | use yii\web\NotFoundHttpException; | 11 | use yii\web\NotFoundHttpException; |
| 10 | use yii\filters\VerbFilter; | 12 | use yii\filters\VerbFilter; |
| 11 | 13 | ||
| @@ -51,8 +53,19 @@ class DetailsDescriptionController extends BaseController | @@ -51,8 +53,19 @@ class DetailsDescriptionController extends BaseController | ||
| 51 | */ | 53 | */ |
| 52 | public function actionView($name, $brand) | 54 | public function actionView($name, $brand) |
| 53 | { | 55 | { |
| 56 | + $criteria_model = new DetailsCriteria(); | ||
| 57 | + $query = DetailsCriteria::find()->where(['name' => $name, 'brand' => $brand]); | ||
| 58 | + | ||
| 59 | + $dataProvider = new ActiveDataProvider([ | ||
| 60 | + 'query' => $query, | ||
| 61 | + 'pagination' => false, | ||
| 62 | + ]); | ||
| 63 | + | ||
| 64 | + | ||
| 54 | return $this->render('view', [ | 65 | return $this->render('view', [ |
| 55 | 'model' => $this->findModel($name, $brand), | 66 | 'model' => $this->findModel($name, $brand), |
| 67 | + 'criteria_model' => $criteria_model, | ||
| 68 | + 'dataProvider' => $dataProvider, | ||
| 56 | ]); | 69 | ]); |
| 57 | } | 70 | } |
| 58 | 71 | ||
| @@ -72,4 +85,6 @@ class DetailsDescriptionController extends BaseController | @@ -72,4 +85,6 @@ class DetailsDescriptionController extends BaseController | ||
| 72 | throw new NotFoundHttpException('The requested page does not exist.'); | 85 | throw new NotFoundHttpException('The requested page does not exist.'); |
| 73 | } | 86 | } |
| 74 | } | 87 | } |
| 88 | + | ||
| 89 | + | ||
| 75 | } | 90 | } |
backend/models/ImportersCheckPriceSearch.php
| @@ -47,7 +47,8 @@ class ImportersCheckPriceSearch extends Importers | @@ -47,7 +47,8 @@ class ImportersCheckPriceSearch extends Importers | ||
| 47 | public function search($params) | 47 | public function search($params) |
| 48 | { | 48 | { |
| 49 | 49 | ||
| 50 | - $query = Importers::find()->where(['active' => true])->orderBy(['price_date_update' => SORT_DESC]); | 50 | + //$query = Importers::find()->where(['active' => true])->orderBy(['price_date_update' => SORT_DESC]); |
| 51 | + $query = Importers::find(); | ||
| 51 | $provider = new ActiveDataProvider([ | 52 | $provider = new ActiveDataProvider([ |
| 52 | 'query' => $query, | 53 | 'query' => $query, |
| 53 | 'pagination' => [ | 54 | 'pagination' => [ |
| @@ -64,7 +65,7 @@ class ImportersCheckPriceSearch extends Importers | @@ -64,7 +65,7 @@ class ImportersCheckPriceSearch extends Importers | ||
| 64 | return $provider; | 65 | return $provider; |
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | - if($this->price_date_update !== null || $this->date_to !== null){ | 68 | + if( $this->price_date_update != null || $this->date_to != null ){ |
| 68 | $date_from = mktime(0,0,0,(int)substr($this->price_date_update,4,2),(int)substr($this->price_date_update,1,2),(int)substr($this->price_date_update,7,4)); | 69 | $date_from = mktime(0,0,0,(int)substr($this->price_date_update,4,2),(int)substr($this->price_date_update,1,2),(int)substr($this->price_date_update,7,4)); |
| 69 | $date_to = mktime(23,59,59,(int)substr($this->date_to,4,2),(int)substr($this->date_to,1,2),(int)substr($this->date_to,7,4)); | 70 | $date_to = mktime(23,59,59,(int)substr($this->date_to,4,2),(int)substr($this->date_to,1,2),(int)substr($this->date_to,7,4)); |
| 70 | 71 |
backend/views/details-description/view.php
| @@ -2,6 +2,9 @@ | @@ -2,6 +2,9 @@ | ||
| 2 | 2 | ||
| 3 | use yii\helpers\Html; | 3 | use yii\helpers\Html; |
| 4 | use yii\widgets\DetailView; | 4 | use yii\widgets\DetailView; |
| 5 | +use yii\widgets\ActiveForm; | ||
| 6 | +use yii\grid\GridView; | ||
| 7 | + | ||
| 5 | 8 | ||
| 6 | /* @var $this yii\web\View */ | 9 | /* @var $this yii\web\View */ |
| 7 | /* @var $model common\models\DetailsDescription */ | 10 | /* @var $model common\models\DetailsDescription */ |
| @@ -32,8 +35,31 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -32,8 +35,31 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 32 | ], | 35 | ], |
| 33 | ]) ?> | 36 | ]) ?> |
| 34 | 37 | ||
| 35 | - <fieldset> | ||
| 36 | - <legend>Характеристики товара</legend> | ||
| 37 | - <?= \backend\components\FieldEditor\FieldEditor::widget(['template'=>'options','name'=> $model->name, 'brand'=> $model->brand,'model'=>'DetailsDescription']); ?> | ||
| 38 | - </fieldset> | 38 | + |
| 39 | + <?= GridView::widget([ | ||
| 40 | + 'dataProvider' => $dataProvider, | ||
| 41 | + 'columns' => [ | ||
| 42 | + ['class' => 'yii\grid\SerialColumn'], | ||
| 43 | + 'key', | ||
| 44 | + 'value', | ||
| 45 | + ['class' => 'yii\grid\ActionColumn', | ||
| 46 | + 'template' => '{delete}'], | ||
| 47 | + ], | ||
| 48 | + ]); ?> | ||
| 49 | + | ||
| 50 | + <div class="details-criteria-form"> | ||
| 51 | + | ||
| 52 | + <?php $form = ActiveForm::begin(); ?> | ||
| 53 | + | ||
| 54 | + <?= $form->field($criteria_model, 'key')->textInput(['maxlength' => true]) ?> | ||
| 55 | + | ||
| 56 | + <?= $form->field($criteria_model, 'value')->textInput(['maxlength' => true]) ?> | ||
| 57 | + | ||
| 58 | + | ||
| 59 | + <div class="form-group"> | ||
| 60 | + <?= Html::submitButton(Yii::t('app', 'Добавить'), ['class' => 'btn btn-success']) ?> | ||
| 61 | + </div> | ||
| 62 | + | ||
| 63 | + <?php ActiveForm::end(); ?> | ||
| 64 | + </div> | ||
| 39 | </div> | 65 | </div> |