Commit ce4a4468117285cf58ac3713e1aa246559ba0c81

Authored by Yarik
1 parent 492ed7f7

test

common/models/ProjectSearch.php
@@ -91,7 +91,7 @@ @@ -91,7 +91,7 @@
91 */ 91 */
92 public function search($params) 92 public function search($params)
93 { 93 {
94 - $query = Project::find(); 94 + $query = Project::find()->with('comments');
95 95
96 // add conditions that should always apply here 96 // add conditions that should always apply here
97 97
@@ -133,7 +133,6 @@ @@ -133,7 +133,6 @@
133 'view_count' => $this->view_count, 133 'view_count' => $this->view_count,
134 'payment_variant' => $this->payment_variant, 134 'payment_variant' => $this->payment_variant,
135 'deadline' => $this->deadline, 135 'deadline' => $this->deadline,
136 - 'contractual' => $this->contractual,  
137 ]); 136 ]);
138 137
139 $query->andFilterWhere([ 138 $query->andFilterWhere([
@@ -153,23 +152,18 @@ @@ -153,23 +152,18 @@
153 152
154 $query->andFilterWhere([ 153 $query->andFilterWhere([
155 'like', 154 'like',
156 - 'name',  
157 - $this->name, 155 + 'LOWER(name)',
  156 + mb_strtolower($this->name),
158 ]) 157 ])
159 ->andFilterWhere([ 158 ->andFilterWhere([
160 'like', 159 'like',
161 - 'link',  
162 - $this->link,  
163 - ])  
164 - ->andFilterWhere([  
165 - 'like',  
166 'budget', 160 'budget',
167 $this->budget, 161 $this->budget,
168 ]) 162 ])
169 ->andFilterWhere([ 163 ->andFilterWhere([
170 'like', 164 'like',
171 - 'city',  
172 - $this->city, 165 + 'LOWER(city)',
  166 + mb_strtolower($this->city),
173 ]) 167 ])
174 ->andFilterWhere([ 168 ->andFilterWhere([
175 'like', 169 'like',
@@ -197,6 +191,12 @@ @@ -197,6 +191,12 @@
197 $query->andWhere(['not', ['contractual' => 1]]); 191 $query->andWhere(['not', ['contractual' => 1]]);
198 } 192 }
199 193
  194 + if($this->contractual == 1) {
  195 + $query->andWhere(['contractual' => 1]);
  196 + } elseif($this->contractual == 2) {
  197 + $query->andWhere(['not', ['contractual' => 1]]);
  198 + }
  199 +
200 return $dataProvider; 200 return $dataProvider;
201 } 201 }
202 } 202 }
common/models/Team.php
@@ -139,7 +139,7 @@ @@ -139,7 +139,7 @@
139 139
140 public function getUser() 140 public function getUser()
141 { 141 {
142 - return $this->lastname. ' ' . $this->firstname . ' ' . $this->middlename; 142 + return $this->lastname. ' ' . $this->firstname;
143 } 143 }
144 144
145 } 145 }
common/models/TenderSearch.php
@@ -117,7 +117,8 @@ @@ -117,7 +117,8 @@
117 { 117 {
118 $query = Project::find() 118 $query = Project::find()
119 ->joinWith('projectSpecializations') 119 ->joinWith('projectSpecializations')
120 - ->joinWith('projectPayments'); 120 + ->joinWith('projectPayments')
  121 + ->andWhere([ 'hidden' => 0 ]);
121 122
122 $dataProvider = new ActiveDataProvider([ 123 $dataProvider = new ActiveDataProvider([
123 'query' => $query, 124 'query' => $query,
frontend/controllers/AccountsController.php
@@ -70,7 +70,7 @@ @@ -70,7 +70,7 @@
70 'portfolio-delete' => [ 'POST' ], 70 'portfolio-delete' => [ 'POST' ],
71 'projects-delete' => [ 'POST' ], 71 'projects-delete' => [ 'POST' ],
72 'blog-delete' => [ 'POST' ], 72 'blog-delete' => [ 'POST' ],
73 - 'gallery-cover' => [ 'POST' ], 73 + 'gallery-cover' => [ 'POST' ],
74 ], 74 ],
75 ], 75 ],
76 ]; 76 ];
@@ -970,14 +970,9 @@ @@ -970,14 +970,9 @@
970 ->column(); 970 ->column();
971 $post = \Yii::$app->request->post(); 971 $post = \Yii::$app->request->post();
972 if($team->load($post) && $team->save()) { 972 if($team->load($post) && $team->save()) {
973 - return $this->render('_team_form', [  
974 - 'team' => $team,  
975 - 'department' => $department,  
976 - 'country' => $country, 973 + return $this->redirect([
  974 + 'team',
977 ]); 975 ]);
978 - // return $this->redirect([  
979 - // 'team',  
980 - // ]);  
981 } else { 976 } else {
982 return $this->render('_team_form', [ 977 return $this->render('_team_form', [
983 'team' => $team, 978 'team' => $team,
@@ -1179,13 +1174,15 @@ @@ -1179,13 +1174,15 @@
1179 } 1174 }
1180 } 1175 }
1181 1176
1182 -  
1183 public function actionGalleryCover() 1177 public function actionGalleryCover()
1184 { 1178 {
1185 $gallery_id = Yii::$app->request->post('gallery_id'); 1179 $gallery_id = Yii::$app->request->post('gallery_id');
1186 1180
1187 - $cover = Gallery::find()->select('cover')->where(['gallery_id'=>$gallery_id])->column();  
1188 - die($cover[0]); 1181 + $cover = Gallery::find()
  1182 + ->select('cover')
  1183 + ->where([ 'gallery_id' => $gallery_id ])
  1184 + ->column();
  1185 + die( $cover[ 0 ] );
1189 1186
1190 } 1187 }
1191 1188
frontend/controllers/TenderController.php
@@ -52,6 +52,8 @@ @@ -52,6 +52,8 @@
52 'class' => \yii\filters\VerbFilter::className(), 52 'class' => \yii\filters\VerbFilter::className(),
53 'actions' => [ 53 'actions' => [
54 'change-state' => [ 'post' ], 54 'change-state' => [ 'post' ],
  55 + 'offer-form' => [ 'post' ],
  56 + 'offer' => [ 'post' ],
55 ], 57 ],
56 ], 58 ],
57 'access' => [ 59 'access' => [
@@ -68,8 +70,9 @@ @@ -68,8 +70,9 @@
68 } 70 }
69 71
70 /** 72 /**
71 - * Displays homepage.  
72 - * @return mixed 73 + * Redirect to search page.
  74 + *
  75 + * @return string
73 */ 76 */
74 public function actionIndex() 77 public function actionIndex()
75 { 78 {
@@ -78,7 +81,13 @@ @@ -78,7 +81,13 @@
78 81
79 public function actionView($tender_id) 82 public function actionView($tender_id)
80 { 83 {
  84 + /**
  85 + * @var Project $model
  86 + */
81 $model = Project::findOne($tender_id); 87 $model = Project::findOne($tender_id);
  88 + if(!empty($model)) {
  89 + $model->updateCounters(['view_count' => 1]);
  90 + }
82 91
83 return $this->render('view', [ 92 return $this->render('view', [
84 'model' => $model, 93 'model' => $model,
@@ -160,8 +169,8 @@ @@ -160,8 +169,8 @@
160 $projects = $user->getProjects() 169 $projects = $user->getProjects()
161 ->with('parent') 170 ->with('parent')
162 ->all(); 171 ->all();
163 - if(empty($projects)) {  
164 - return ['error' => 'У Вас еще нету проектов']; 172 + if(empty( $projects )) {
  173 + return [ 'error' => 'У Вас еще нету проектов' ];
165 } 174 }
166 return [ 175 return [
167 'message' => $this->renderAjax('forms-modal-offer', [ 176 'message' => $this->renderAjax('forms-modal-offer', [
frontend/views/accounts/_projects_form.php
@@ -248,7 +248,7 @@ @@ -248,7 +248,7 @@
248 248
249 <div class="input-blocks-wrapper"> 249 <div class="input-blocks-wrapper">
250 <div class="input-blocks admin-project-list admin-currency-second"> 250 <div class="input-blocks admin-project-list admin-currency-second">
251 - <?= $form->field($project, 'hidden')->checkbox() ?> 251 + <?= $form->field($project, 'hidden')->checkbox()->hint('Проект, снятый с тендера, будет добавлен в Архив (не доступен в поиске, но доступен по ссылке)') ?>
252 </div> 252 </div>
253 </div> 253 </div>
254 254
frontend/views/accounts/projects.php
@@ -71,12 +71,21 @@ @@ -71,12 +71,21 @@
71 */ 71 */
72 if($model->contractual) { 72 if($model->contractual) {
73 return 'Договорной'; 73 return 'Договорной';
  74 + } elseif(empty($model->budget)) {
  75 + return 'Не задано';
74 } else { 76 } else {
75 return $model->budget; 77 return $model->budget;
76 } 78 }
77 }, 79 },
78 'label' => $searchModel->getAttributeLabel('budget').' +/- 10%', 80 'label' => $searchModel->getAttributeLabel('budget').' +/- 10%',
79 ], 81 ],
  82 + [
  83 + 'attribute' => 'contractual',
  84 + 'filter' => Html::activeDropDownList($searchModel, 'contractual', [1 => 'Только договорные', 2 => 'Без договорных'], ['prompt' => 'Все']),
  85 + 'value' => function($model) {
  86 + return \Yii::$app->formatter->asBoolean($model->contractual);
  87 + }
  88 + ],
80 'city', 89 'city',
81 [ 90 [
82 'attribute' => 'specializationString', 91 'attribute' => 'specializationString',
@@ -84,7 +93,7 @@ @@ -84,7 +93,7 @@
84 'view_count', 93 'view_count',
85 [ 94 [
86 'value' => function($model, $key, $index, $column) { 95 'value' => function($model, $key, $index, $column) {
87 - return 0; 96 + return count($model->comments);
88 }, 97 },
89 'label' => 'Отклики', 98 'label' => 'Отклики',
90 ], 99 ],
frontend/views/company/_company_list_view.php
1 <?php 1 <?php
  2 + /**
  3 + * @var Team $model
  4 + */
  5 + use common\models\Team;
2 use yii\helpers\Html; 6 use yii\helpers\Html;
3 - use yii\helpers\Url;  
4 -  
5 ?> 7 ?>
6 <div class="command-block-wrapper"> 8 <div class="command-block-wrapper">
7 <div class="command-block-wr-two"> 9 <div class="command-block-wr-two">
@@ -14,7 +16,17 @@ @@ -14,7 +16,17 @@
14 } 16 }
15 ?> 17 ?>
16 </div> 18 </div>
17 - <div class="command-block-name"><?= $model->user ?></div> 19 + <div class="command-block-name">
  20 + <?php
  21 + if(!empty($model->firstname)) {
  22 + echo "<p>{$model->firstname}</p>";
  23 + }
  24 + ?>
  25 + <?php
  26 + if(!empty($model->firstname)) {
  27 + echo "<p>{$model->lastname}</p>";
  28 + }
  29 + ?>
18 <?php 30 <?php
19 if(!empty( $model->department->name )) { 31 if(!empty( $model->department->name )) {
20 ?> 32 ?>
frontend/views/search/_projects_list_view.php
@@ -16,8 +16,10 @@ use yii\helpers\Url; @@ -16,8 +16,10 @@ use yii\helpers\Url;
16 <span></span> 16 <span></span>
17 Бюджет: 17 Бюджет:
18 <?php 18 <?php
19 - if(empty($model->contractual)) { 19 + if(empty($model->contractual) && !empty($model->budget)) {
20 echo $model->budget.' '.$model->budgetCurrency->label; 20 echo $model->budget.' '.$model->budgetCurrency->label;
  21 + } elseif(empty($model->budget)) {
  22 + echo "Не задано";
21 } else { 23 } else {
22 echo "Договорной"; 24 echo "Договорной";
23 } 25 }