Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.22 KB | None | 0 0
  1. http://sportpit.alex-sport.com.ua/category/index?ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=62&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0&ProductPitSearch%5Bbrand_id%5D=0
  2.  
  3. <?php
  4.  
  5. namespace commonmodels;
  6.  
  7. use Yii;
  8. use yiibaseModel;
  9. use yiidataActiveDataProvider;
  10. use commonmodelsProductPit;
  11.  
  12. /**
  13. * ProductPitSearch represents the model behind the search form about
  14. `commonmodelsProductPit`.
  15. */
  16. class ProductPitSearch extends ProductPit
  17. {
  18. /**
  19. * @inheritdoc
  20. */
  21. public function rules()
  22. {
  23. return [
  24. [['id', 'status', 'new', 'hit', 'sale', 'stock', 'top_sales', 'top_ten', 'category_id', 'img_id', 'gallery_id', 'brand_id', 'country_id', 'quantity', 'quantity_product', 'packing', 'availability', 'created_at', 'updated_at'], 'integer'],
  25. [['title', 'content', 'composition', 'vendor_code', 'seo_keywords', 'seo_description'], 'safe'],
  26. [['old_price', 'price'], 'number'],
  27. ];
  28. }
  29.  
  30. /**
  31. * @inheritdoc
  32. */
  33. public function scenarios()
  34. {
  35. // bypass scenarios() implementation in the parent class
  36. return Model::scenarios();
  37. }
  38.  
  39. /**
  40. * Creates data provider instance with search query applied
  41. *
  42. * @param array $params
  43. *
  44. * @return ActiveDataProvider
  45. */
  46. public function search($params)
  47. {
  48. $query = ProductPit::find();
  49.  
  50. // add conditions that should always apply here
  51.  
  52. $dataProvider = new ActiveDataProvider([
  53. 'query' => $query,
  54. ]);
  55.  
  56. $this->load($params);
  57.  
  58. if (!$this->validate()) {
  59. // uncomment the following line if you do not want to return any records when validation fails
  60. // $query->where('0=1');
  61. return $dataProvider;
  62. }
  63.  
  64. // grid filtering conditions
  65. $query->andFilterWhere([
  66. 'brand_id' => $this->brand_id,
  67. 'country_id' => $this->country_id,
  68. 'packing' => $this->packing,
  69. ]);
  70.  
  71. $query->andFilterWhere(['like', 'brand_id', $this->brand_id])
  72. ->andFilterWhere(['like', 'country_id', $this->country_id])
  73. ->andFilterWhere(['like', 'packing', $this->packing]);
  74.  
  75. return $dataProvider;
  76. }
  77. }
  78.  
  79. <?php
  80.  
  81. namespace sportpitcontrollers;
  82.  
  83. use Yii;
  84. use commonmodelsProductPit;
  85. use commonmodelsProductPitSearch;
  86. use yiiwebController;
  87. use yiiwebNotFoundHttpException;
  88. use yiifiltersVerbFilter;
  89.  
  90. /**
  91. * CategoryController implements the CRUD actions for ProductPit model.
  92. */
  93. class CategoryController extends Controller
  94. {
  95. /**
  96. * @inheritdoc
  97. */
  98. public function behaviors()
  99. {
  100. return [
  101. 'verbs' => [
  102. 'class' => VerbFilter::className(),
  103. 'actions' => [
  104. 'delete' => ['POST'],
  105. ],
  106. ],
  107. ];
  108. }
  109.  
  110. /**
  111. * Lists all ProductPit models.
  112. * @return mixed
  113. */
  114. public function actionIndex()
  115. {
  116. $searchModel = new ProductPitSearch();
  117. $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  118.  
  119. return $this->render('index', [
  120. 'searchModel' => $searchModel,
  121. 'dataProvider' => $dataProvider,
  122. ]);
  123. }
  124.  
  125. /**
  126. * Finds the ProductPit model based on its primary key value.
  127. * If the model is not found, a 404 HTTP exception will be thrown.
  128. * @param integer $id
  129. * @return ProductPit the loaded model
  130. * @throws NotFoundHttpException if the model cannot be found
  131. */
  132. protected function findModel($id)
  133. {
  134. if (($model = ProductPit::findOne($id)) !== null) {
  135. return $model;
  136. } else {
  137. throw new NotFoundHttpException('The requested page does not exist.');
  138. }
  139. }
  140. }
  141.  
  142. <?php
  143.  
  144. use yiihelpersHtml;
  145. use yiiwidgetsActiveForm;
  146. use commonmodelsProductPit;
  147. use yiihelpersArrayHelper;
  148.  
  149. /* @var $this yiiwebView */
  150. /* @var $model commonmodelsProductPitSearch */
  151. /* @var $form yiiwidgetsActiveForm */
  152. ?>
  153. <div class="product-pit-search">
  154. <?php $form = ActiveForm::begin([
  155. 'action' => ['index'],
  156. 'method' => 'get',
  157. ]); ?>
  158.  
  159.  
  160. <?php
  161.  
  162. $manufactures = ArrayHelper::map(ProductPit::find()->all(), 'brand_id', 'id');
  163.  
  164. foreach ($manufactures as $key => $value) {
  165.  
  166. echo $form->field($model, 'brand_id')->checkbox(
  167. [
  168. 'label' => ProductPit::getManufacturesTitle($value),
  169. 'value' => $value
  170. ]
  171. );
  172. echo '<br/>';
  173. }
  174.  
  175. ?>
  176.  
  177. <?php // echo $form->field($model, 'country_id') ?>
  178.  
  179. <?php // echo $form->field($model, 'packing') ?>
  180.  
  181. <div class="form-group">
  182. <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>
  183. <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?>
  184. </div>
  185.  
  186. <?php ActiveForm::end(); ?>
  187.  
  188. <?php
  189.  
  190. use yiihelpersHtml;
  191. use yiiwidgetsListView;
  192. use yiiwidgetsPjax;
  193.  
  194. /* @var $this yiiwebView */
  195. /* @var $searchModel commonmodelsProductPitSearch */
  196. /* @var $dataProvider yiidataActiveDataProvider */
  197.  
  198. $this->title = Yii::t('app', 'Product Pits');
  199. $this->params['breadcrumbs'][] = $this->title;
  200. ?>
  201. <div class="product-pit-index">
  202.  
  203. <?php echo $this->render('_search', ['model' => $searchModel]); ?>
  204.  
  205. <?php Pjax::begin(); ?>
  206. <?= ListView::widget([
  207. 'dataProvider' => $dataProvider,
  208. 'itemOptions' => ['class' => 'item'],
  209. 'itemView' => function ($model, $key, $index, $widget) {
  210. return $this->render('_all', ['model' => $model]);
  211. },
  212. ]) ?>
  213. <?php Pjax::end(); ?>
  214. </div>
  215.  
  216. <?php
  217.  
  218. use yiihelpersHtml;
  219. use yiihelpersUrl;
  220. use commonmodelsProductPit;
  221. use commonmodelsCategoryPit;
  222.  
  223. ?>
  224.  
  225. <div class="main_block">
  226. <?php if ($model['hit']) : ?>
  227. <div class="hit_product label label-success">Хит</div>
  228. <?php endif; ?>
  229. <?php if ($model['new']) : ?>
  230. <div class="new_product label label-primary">Новинка</div>
  231. <?php endif; ?>
  232. <?php if ($model['sale']) : ?>
  233. <div class="sale_product label label-danger">Распродажа</div>
  234. <?php endif; ?>
  235. <?php if ($model['stock']) : ?>
  236. <div class="sale_product label label-danger">Акция</div>
  237. <?php endif; ?>
  238. <div class="image_block">
  239. <a href="<?= Url::to(['product/view', 'id' => $model['id']]) ?>">
  240. <?php if ($model['img_id']) : ?>
  241. <?= Html::img('/web/uploads/products/' . ProductPit::getImageTitle($model['img_id']), ['width' => '105', 'height' => '150']) ?>
  242. <?php else: ?>
  243. <?= Html::img('/web/uploads/system/no-image.png', ['width' => '105', 'height' => '150']) ?>
  244. <?php endif; ?>
  245. </a>
  246. </div>
  247. <div class="title_block">
  248. <a href="<?= Url::to(['product/view', 'id' => $model['id']]) ?>">
  249. <h1>
  250. <?= $model['title'] ?>
  251. </h1>
  252. </a>
  253. </div>
  254. <div class="category_block"><?= CategoryPit::getTitleCategory($model['category_id']) ?></div>
  255. <div class="rating_block">*****</div>
  256. <div class="price_block"><?= $model['price'] ?> грн.</div>
  257. <div class="btn_buy_block">
  258. <a class="add-to-cart" data-id="<?= $model['id'] ?>"
  259. href="<?= Url::to(['product/view', 'id' => $model['id']]) ?>">Купить</a>
  260. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement