Guest User

Untitled

a guest
Apr 25th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. <?= $form->field($model, 'maincatalog')->dropDownList($maincatalog, ["prompt" => Yii::t('app', 'select_cat')])->label(false) ?>
  2.  
  3. <?= $form->field($model, 'listproduct')->dropDownList($listproduct, ["prompt" => Yii::t('app', 'select_cat')])->label(false) ?>
  4.  
  5. <?= $form->field($model, 'q')->textInput(['class' => 'input'])->label('')?>
  6.  
  7.  
  8. $query = Addproduct::find()
  9. ->where(['catalog' => $maincatalog])
  10. ->andWhere(['product' => $listproduct])
  11. ->andWhere(['like', 'titleru', $q])->all();
  12.  
  13. $query = Addproduct::find();
  14.  
  15. if ($maincatalog != NULL)
  16. $query->where(['catalog' => $maincatalog]);
  17.  
  18. if ($listproduct != NULL)
  19. $query->andWhere(['product' => $listproduct]);
  20.  
  21.  
  22. $query->andWhere(['like', 'titleru', $q])->all();
  23.  
  24. if($maincatalog == "" && $listproduct == "" && $q == ""){
  25. $query = "all empty";
  26. } elseif($maincatalog == "" && $listproduct != "" && $q == ""){
  27. $query = Addproduct::find()->where(['product' => $listproduct])
  28. ->andWhere(['like', 'titleru', $q])->all();
  29. } elseif($maincatalog != "" && $listproduct == "" && $q == "") {
  30. $query = Addproduct::find()->where(['catalog' => $maincatalog])
  31. ->andWhere(['like', 'titleru', $q])->all();
  32. } elseif($maincatalog == "" && $listproduct == "" && $q != "") {
  33. $query = Addproduct::find()->where(['like', 'titleru', $q])->all();
  34. } elseif($maincatalog == "" && $listproduct != "" && $q != "") {
  35. $query = Addproduct::find()->where(['product' => $listproduct])
  36. ->andWhere(['like', 'titleru', $q])->all();
  37. } elseif($maincatalog != "" && $listproduct == "" && $q != "") {
  38. $query = Addproduct::find()->where(['catalog' => $maincatalog])
  39. ->andWhere(['like', 'titleru', $q])->all();
  40. } else {
  41. $query = Addproduct::find()->where(['catalog' => $maincatalog])
  42. ->andWhere(['product' => $listproduct])->andWhere(['like', 'titleru', $q])->all();
  43. }
  44.  
  45. $query = Addproduct::find();
  46.  
  47. if ( $maincatalog != NULL )
  48. $query->where(['catalog' => $maincatalog]);
  49.  
  50.  
  51. $query->andWhere(['product' => $listproduct])
  52. ->andWhere(['like', 'titleru', $q])->all();
  53.  
  54. if($maincatalog == "" && $listproduct == "" && $q == ""){
  55. $query = "all empty";
  56. } elseif($maincatalog == "" && $listproduct != "" && $q == ""){
  57. $query = Addproduct::find()->where(['product' => $listproduct])- >andWhere(['like', 'titleru', $q])->all();
  58. } elseif($maincatalog != "" && $listproduct == "" && $q == "") {
  59. $query = Addproduct::find()->where(['catalog' => $maincatalog])- >andWhere(['like', 'titleru', $q])->all();
  60. } elseif($maincatalog == "" && $listproduct == "" && $q != "") {
  61. $query = Addproduct::find()->where(['like', 'titleru', $q])->all();
  62. } elseif($maincatalog == "" && $listproduct != "" && $q != "") {
  63. $query = Addproduct::find()->where(['product' => $listproduct])->andWhere(['like', 'titleru', $q])->all();
  64. } elseif($maincatalog != "" && $listproduct == "" && $q != "") {
  65. $query = Addproduct::find()->where(['catalog' => $maincatalog])- >andWhere(['like', 'titleru', $q])->all();
  66. } else {
  67. $query = Addproduct::find()->where(['catalog' => $maincatalog])- >andWhere(['product' => $listproduct])->andWhere(['like', 'titleru', $q])- >all();
  68. }
  69.  
  70. $query = Addproduct::find();
  71.  
  72. if ($maincatalog != NULL)
  73. $query->where(['catalog' => $maincatalog]);
  74.  
  75. if ($listproduct != NULL)
  76. $query->andWhere(['product' => $listproduct]);
  77.  
  78.  
  79. $query->andWhere(['like', 'titleru', $q])->all();
  80.  
  81. $query = Addproduct::find()->where('***');
  82.  
  83. $query->andFilterWhere(['catalog' => $maincatalog]);
  84.  
  85. $query->all();
  86.  
  87. public $q;
  88. public $listproduct;
  89. public $maincatalog;
  90.  
  91. public function rules()
  92. {
  93. return [
  94. ['q', 'string'],
  95. ['listproduct', 'string'],
  96. ['maincatalog', 'string']
  97. ];
  98. }
Add Comment
Please, Sign In to add comment