Commit 50ed5626f27742c7a9e749a8674d21004bd82c1e
1 parent
32ed90fd
test
Showing
6 changed files
with
408 additions
and
157 deletions
Show diff stats
common/models/Project.php
| @@ -31,6 +31,7 @@ | @@ -31,6 +31,7 @@ | ||
| 31 | * @property ProjectSpecialization[] $projectSpecializations | 31 | * @property ProjectSpecialization[] $projectSpecializations |
| 32 | * @property Specialization[] $specializations | 32 | * @property Specialization[] $specializations |
| 33 | * @property Currency $budgetCurrency | 33 | * @property Currency $budgetCurrency |
| 34 | + * @property Project $parent | ||
| 34 | */ | 35 | */ |
| 35 | class Project extends \yii\db\ActiveRecord | 36 | class Project extends \yii\db\ActiveRecord |
| 36 | { | 37 | { |
frontend/controllers/TenderController.php
| 1 | <?php | 1 | <?php |
| 2 | -namespace frontend\controllers; | 2 | + namespace frontend\controllers; |
| 3 | 3 | ||
| 4 | -use common\models\Project; | ||
| 5 | -use common\modules\comment\models\CommentProject; | ||
| 6 | -use Yii; | ||
| 7 | -use common\models\LoginForm; | ||
| 8 | -use frontend\models\PasswordResetRequestForm; | ||
| 9 | -use frontend\models\ResetPasswordForm; | ||
| 10 | -use frontend\models\SignupForm; | ||
| 11 | -use frontend\models\ContactForm; | ||
| 12 | -use frontend\models\Options; | ||
| 13 | -use frontend\models\OptionValues; | ||
| 14 | -use yii\base\InvalidParamException; | ||
| 15 | -use yii\web\BadRequestHttpException; | ||
| 16 | -use yii\web\Controller; | ||
| 17 | -use yii\filters\VerbFilter; | ||
| 18 | -use yii\filters\AccessControl; | ||
| 19 | -use frontend\models\OptionsToValues; | ||
| 20 | -use yii\validators\EmailValidator; | ||
| 21 | -use common\models\User; | ||
| 22 | -use yii\helpers\VarDumper; | ||
| 23 | -use common\models\Page; | ||
| 24 | -use frontend\models\Option; | ||
| 25 | -use common\models\Social; | 4 | + use common\models\Chat; |
| 5 | + use common\models\Message; | ||
| 6 | + use common\models\Project; | ||
| 7 | + use common\modules\comment\models\CommentProject; | ||
| 8 | + use Yii; | ||
| 9 | + use common\models\LoginForm; | ||
| 10 | + use frontend\models\PasswordResetRequestForm; | ||
| 11 | + use frontend\models\ResetPasswordForm; | ||
| 12 | + use frontend\models\SignupForm; | ||
| 13 | + use frontend\models\ContactForm; | ||
| 14 | + use frontend\models\Options; | ||
| 15 | + use frontend\models\OptionValues; | ||
| 16 | + use yii\base\InvalidParamException; | ||
| 17 | + use yii\helpers\Html; | ||
| 18 | + use yii\web\BadRequestHttpException; | ||
| 19 | + use yii\web\Controller; | ||
| 20 | + use yii\filters\VerbFilter; | ||
| 21 | + use yii\filters\AccessControl; | ||
| 22 | + use frontend\models\OptionsToValues; | ||
| 23 | + use yii\validators\EmailValidator; | ||
| 24 | + use common\models\User; | ||
| 25 | + use yii\helpers\VarDumper; | ||
| 26 | + use common\models\Page; | ||
| 27 | + use frontend\models\Option; | ||
| 28 | + use common\models\Social; | ||
| 26 | 29 | ||
| 27 | - | ||
| 28 | -/** | ||
| 29 | - * Site controller | ||
| 30 | - */ | ||
| 31 | -class TenderController extends Controller | ||
| 32 | -{ | ||
| 33 | - | ||
| 34 | - public $enableCsrfValidation = false; | ||
| 35 | - /** | ||
| 36 | - * @inheritdoc | ||
| 37 | - */ | ||
| 38 | - public function actions() | ||
| 39 | - { | ||
| 40 | - return [ | ||
| 41 | - 'error' => [ | ||
| 42 | - 'class' => 'yii\web\ErrorAction', | ||
| 43 | - ], | ||
| 44 | - 'captcha' => [ | ||
| 45 | - 'class' => 'yii\captcha\CaptchaAction', | ||
| 46 | - 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, | ||
| 47 | - ], | ||
| 48 | - 'verbs' => [ | ||
| 49 | - 'class' => \yii\filters\VerbFilter::className(), | ||
| 50 | - 'actions' => [ | ||
| 51 | - 'change-state' => ['post'], | ||
| 52 | - ], | ||
| 53 | - ], | ||
| 54 | - 'access' => [ | ||
| 55 | - 'class' => AccessControl::className(), | ||
| 56 | - 'rules' => [ | ||
| 57 | - [ | ||
| 58 | - 'actions' => ['change-state'], | ||
| 59 | - 'allow' => true, | ||
| 60 | - 'roles' => [ '@' ], | ||
| 61 | - ], | ||
| 62 | - ], | ||
| 63 | - ], | ||
| 64 | - ]; | ||
| 65 | - } | ||
| 66 | /** | 30 | /** |
| 67 | - * Displays homepage. | ||
| 68 | - * | ||
| 69 | - * @return mixed | 31 | + * Site controller |
| 70 | */ | 32 | */ |
| 71 | - public function actionIndex() | ||
| 72 | - { | ||
| 73 | - return $this->redirect(['search/project']); | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - public function actionView($tender_id) | 33 | + class TenderController extends Controller |
| 77 | { | 34 | { |
| 78 | - $model = Project::findOne($tender_id); | ||
| 79 | 35 | ||
| 80 | - return $this->render('view',[ | ||
| 81 | - 'model' => $model | ||
| 82 | - ]); | ||
| 83 | - } | 36 | + public $enableCsrfValidation = false; |
| 84 | 37 | ||
| 85 | - public function actionChangeState() | ||
| 86 | - { | ||
| 87 | - /** | ||
| 88 | - * @var User $user | ||
| 89 | - */ | ||
| 90 | - $response = \Yii::$app->response; | ||
| 91 | - $response->format = $response::FORMAT_JSON; | ||
| 92 | - $user = \Yii::$app->user->identity; | ||
| 93 | - $project_id = \Yii::$app->request->post('project_id'); | ||
| 94 | - $comment_id = \Yii::$app->request->post('comment_id'); | ||
| 95 | - $state = \Yii::$app->request->post('state'); | ||
| 96 | - if(empty($project_id) || empty($comment_id) || empty($state)) { | ||
| 97 | - return ['error' => 'project_id, comment_id, state ะดะพะปะถะฝั ะฑััั ะพัะฟัะฐะฒะปะตะฝั ะฒ ะทะฐะฟัะพัะต']; | ||
| 98 | - } | ||
| 99 | /** | 38 | /** |
| 100 | - * @var Project $project | 39 | + * @inheritdoc |
| 101 | */ | 40 | */ |
| 102 | - $project = Project::findOne($project_id); | ||
| 103 | - if(empty($project)) { | ||
| 104 | - return ['error' => 'ะัะพะตะบั ะฝะต ะฝะฐะนะดะตะฝ']; | ||
| 105 | - } elseif($project->user_id != $user->id) { | ||
| 106 | - return ['error' => 'ะั ะผะพะถะตัะต ะผะตะฝััั ััะฐััั ัะพะปัะบะพ ัะพะฑััะฒะตะฝะฝัั ะฟัะพะตะบัะพะฒ']; | 41 | + public function actions() |
| 42 | + { | ||
| 43 | + return [ | ||
| 44 | + 'error' => [ | ||
| 45 | + 'class' => 'yii\web\ErrorAction', | ||
| 46 | + ], | ||
| 47 | + 'captcha' => [ | ||
| 48 | + 'class' => 'yii\captcha\CaptchaAction', | ||
| 49 | + 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : NULL, | ||
| 50 | + ], | ||
| 51 | + 'verbs' => [ | ||
| 52 | + 'class' => \yii\filters\VerbFilter::className(), | ||
| 53 | + 'actions' => [ | ||
| 54 | + 'change-state' => [ 'post' ], | ||
| 55 | + ], | ||
| 56 | + ], | ||
| 57 | + 'access' => [ | ||
| 58 | + 'class' => AccessControl::className(), | ||
| 59 | + 'rules' => [ | ||
| 60 | + [ | ||
| 61 | + 'actions' => [ 'change-state' ], | ||
| 62 | + 'allow' => true, | ||
| 63 | + 'roles' => [ '@' ], | ||
| 64 | + ], | ||
| 65 | + ], | ||
| 66 | + ], | ||
| 67 | + ]; | ||
| 107 | } | 68 | } |
| 69 | + | ||
| 108 | /** | 70 | /** |
| 109 | - * @var CommentProject $comment | 71 | + * Displays homepage. |
| 72 | + * @return mixed | ||
| 110 | */ | 73 | */ |
| 111 | - $comment = CommentProject::find()->where(['comment_id' => $comment_id, 'model' => $project->className(), 'model_id' => $project->project_id])->one(); | ||
| 112 | - if(empty($comment)) { | ||
| 113 | - return ['error' => 'ะะฐะฝะฝะพะณะพ ะฟัะตะดะปะพะถะตะฝะธั ะฝะต ัััะตััะฒัะตั']; | 74 | + public function actionIndex() |
| 75 | + { | ||
| 76 | + return $this->redirect([ 'search/project' ]); | ||
| 114 | } | 77 | } |
| 115 | - if($comment->user_id == \Yii::$app->user->getId()) { | ||
| 116 | - $comment->scenario = $comment::SCENARIO_OWNER; | ||
| 117 | - } else { | ||
| 118 | - $comment->scenario = $comment::SCENARIO_STATE; | ||
| 119 | - } | ||
| 120 | - if($comment->state == $comment::STATE_TRASH && $comment->scenario == $comment::SCENARIO_STATE) { | ||
| 121 | - return ['error' => 'ะัะฟะพะปะฝะธัะตะปั ะพัะผะตะฝะธะป ะดะฐะฝะฝะพะต ะฟัะตะดะปะพะถะตะฝะธะต']; | 78 | + |
| 79 | + public function actionView($tender_id) | ||
| 80 | + { | ||
| 81 | + $model = Project::findOne($tender_id); | ||
| 82 | + | ||
| 83 | + return $this->render('view', [ | ||
| 84 | + 'model' => $model, | ||
| 85 | + ]); | ||
| 122 | } | 86 | } |
| 123 | - if($comment->state == $comment::STATE_DENY && $comment->scenario == $comment::SCENARIO_OWNER) { | ||
| 124 | - return ['error' => 'ะะฐะบะฐะทัะธะบ ะพัะผะตะฝะธะป ะะฐัะต ะฟัะตะดะปะพะถะตะฝะธะต']; | 87 | + |
| 88 | + public function actionChangeState() | ||
| 89 | + { | ||
| 90 | + /** | ||
| 91 | + * @var User $user | ||
| 92 | + */ | ||
| 93 | + $response = \Yii::$app->response; | ||
| 94 | + $response->format = $response::FORMAT_JSON; | ||
| 95 | + $user = \Yii::$app->user->identity; | ||
| 96 | + $project_id = \Yii::$app->request->post('project_id'); | ||
| 97 | + $comment_id = \Yii::$app->request->post('comment_id'); | ||
| 98 | + $state = \Yii::$app->request->post('state'); | ||
| 99 | + if(empty( $project_id ) || empty( $comment_id ) || empty( $state )) { | ||
| 100 | + return [ 'error' => 'project_id, comment_id, state ะดะพะปะถะฝั ะฑััั ะพัะฟัะฐะฒะปะตะฝั ะฒ ะทะฐะฟัะพัะต' ]; | ||
| 101 | + } | ||
| 102 | + /** | ||
| 103 | + * @var Project $project | ||
| 104 | + */ | ||
| 105 | + $project = Project::findOne($project_id); | ||
| 106 | + if(empty( $project )) { | ||
| 107 | + return [ 'error' => 'ะัะพะตะบั ะฝะต ะฝะฐะนะดะตะฝ' ]; | ||
| 108 | + } elseif($project->user_id != $user->id) { | ||
| 109 | + return [ 'error' => 'ะั ะผะพะถะตัะต ะผะตะฝััั ััะฐััั ัะพะปัะบะพ ัะพะฑััะฒะตะฝะฝัั ะฟัะพะตะบัะพะฒ' ]; | ||
| 110 | + } | ||
| 111 | + /** | ||
| 112 | + * @var CommentProject $comment | ||
| 113 | + */ | ||
| 114 | + $comment = CommentProject::find() | ||
| 115 | + ->where([ | ||
| 116 | + 'comment_id' => $comment_id, | ||
| 117 | + 'model' => $project->className(), | ||
| 118 | + 'model_id' => $project->project_id, | ||
| 119 | + ]) | ||
| 120 | + ->one(); | ||
| 121 | + if(empty( $comment )) { | ||
| 122 | + return [ 'error' => 'ะะฐะฝะฝะพะณะพ ะฟัะตะดะปะพะถะตะฝะธั ะฝะต ัััะตััะฒัะตั' ]; | ||
| 123 | + } | ||
| 124 | + if($comment->user_id == \Yii::$app->user->getId()) { | ||
| 125 | + $comment->scenario = $comment::SCENARIO_OWNER; | ||
| 126 | + } else { | ||
| 127 | + $comment->scenario = $comment::SCENARIO_STATE; | ||
| 128 | + } | ||
| 129 | + if($comment->state == $comment::STATE_TRASH && $comment->scenario == $comment::SCENARIO_STATE) { | ||
| 130 | + return [ 'error' => 'ะัะฟะพะปะฝะธัะตะปั ะพัะผะตะฝะธะป ะดะฐะฝะฝะพะต ะฟัะตะดะปะพะถะตะฝะธะต' ]; | ||
| 131 | + } | ||
| 132 | + if($comment->state == $comment::STATE_DENY && $comment->scenario == $comment::SCENARIO_OWNER) { | ||
| 133 | + return [ 'error' => 'ะะฐะบะฐะทัะธะบ ะพัะผะตะฝะธะป ะะฐัะต ะฟัะตะดะปะพะถะตะฝะธะต' ]; | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + $comment->state = $state; | ||
| 137 | + if(!$comment->validate()) { | ||
| 138 | + return [ 'error' => 'ะะตะดะพะฟัััะธะผะพะต ะทะฝะฐัะตะฝะธะต state' ]; | ||
| 139 | + } | ||
| 140 | + if($comment->changeState()) { | ||
| 141 | + return [ 'message' => 'ะะฒัะพั ะพะฟะพะฒะตัะตะฝ ะพ ะฒะฐัะตะผ ัะตัะตะฝะธะธ' ]; | ||
| 142 | + } else { | ||
| 143 | + return [ 'error' => 'ะัะธะฑะบะฐ ะพะฑะฝะพะฒะปะตะฝะธั.' ]; | ||
| 144 | + } | ||
| 125 | } | 145 | } |
| 126 | 146 | ||
| 127 | - $comment->state = $state; | ||
| 128 | - if(!$comment->validate()) { | ||
| 129 | - return ['error' => 'ะะตะดะพะฟัััะธะผะพะต ะทะฝะฐัะตะฝะธะต state']; | 147 | + public function actionOfferForm() |
| 148 | + { | ||
| 149 | + /** | ||
| 150 | + * @var User $user | ||
| 151 | + */ | ||
| 152 | + $response = \Yii::$app->response; | ||
| 153 | + $request = \Yii::$app->request; | ||
| 154 | + $response->format = $response::FORMAT_JSON; | ||
| 155 | + $user = \Yii::$app->user->identity; | ||
| 156 | + $performer_id = $request->post('performer_id'); | ||
| 157 | + if(empty( $performer_id )) { | ||
| 158 | + return [ 'error' => 'performer_id ะดะพะปะถะตะฝ ะฑััั ะทะฐะดะฐะฝ' ]; | ||
| 159 | + } | ||
| 160 | + $projects = $user->getProjects() | ||
| 161 | + ->with('parent') | ||
| 162 | + ->all(); | ||
| 163 | + if(empty($projects)) { | ||
| 164 | + return ['error' => 'ะฃ ะะฐั ะตัะต ะฝะตัั ะฟัะพะตะบัะพะฒ']; | ||
| 165 | + } | ||
| 166 | + return [ | ||
| 167 | + 'message' => $this->renderAjax('forms-modal-offer', [ | ||
| 168 | + 'performer_id' => $performer_id, | ||
| 169 | + 'projects' => $projects, | ||
| 170 | + ]), | ||
| 171 | + ]; | ||
| 130 | } | 172 | } |
| 131 | - if($comment->changeState()) { | ||
| 132 | - return ['message' => 'ะะฒัะพั ะพะฟะพะฒะตัะตะฝ ะพ ะฒะฐัะตะผ ัะตัะตะฝะธะธ']; | ||
| 133 | - } else { | ||
| 134 | - return ['error' => 'ะัะธะฑะบะฐ ะพะฑะฝะพะฒะปะตะฝะธั.']; | 173 | + |
| 174 | + public function actionOffer() | ||
| 175 | + { | ||
| 176 | + /** | ||
| 177 | + * @var User $user | ||
| 178 | + * @var Project $project | ||
| 179 | + * @var User $performer | ||
| 180 | + * @var Chat $chat | ||
| 181 | + */ | ||
| 182 | + $response = \Yii::$app->response; | ||
| 183 | + $request = \Yii::$app->request; | ||
| 184 | + $response->format = $response::FORMAT_JSON; | ||
| 185 | + $user = \Yii::$app->user->identity; | ||
| 186 | + $project_id = $request->post('project_id'); | ||
| 187 | + $performer_id = $request->post('performer_id'); | ||
| 188 | + if(empty( $project_id ) || empty( $performer_id )) { | ||
| 189 | + return [ 'error' => 'project_id ะธ performer_id ะดะพะปะถะฝั ะฑััั ะทะฐะดะฐะฝั' ]; | ||
| 190 | + } | ||
| 191 | + $performer = User::find() | ||
| 192 | + ->where([ 'id' => $performer_id ]) | ||
| 193 | + ->one(); | ||
| 194 | + if(empty( $performer )) { | ||
| 195 | + return [ 'error' => 'ะัะฟะพะปะฝะธัะตะปั ะฝะต ะฝะฐะนะดะตะฝ' ]; | ||
| 196 | + } | ||
| 197 | + $project = Project::find() | ||
| 198 | + ->where([ 'project_id' => $project_id ]) | ||
| 199 | + ->one(); | ||
| 200 | + if(empty( $project )) { | ||
| 201 | + return [ 'error' => 'ะัะพะตะบั ะฝะต ะฝะฐะนะดะตะฝ' ]; | ||
| 202 | + } elseif($project->user_id != $user->id) { | ||
| 203 | + return [ 'error' => 'ะั ะผะพะถะตัะต ะฟัะตะดะปะฐะณะฐัั ัะพะปัะบะพ ัะพะฑััะฒะตะฝะฝัะต ะฟัะพะตะบัั' ]; | ||
| 204 | + } | ||
| 205 | + $chat = $user->getChat($performer->id) | ||
| 206 | + ->one(); | ||
| 207 | + if(empty( $chat )) { | ||
| 208 | + $chat = new Chat([ | ||
| 209 | + 'form_user' => $user->id, | ||
| 210 | + 'to_user' => $performer->id, | ||
| 211 | + ]); | ||
| 212 | + if(!$chat->save()) { | ||
| 213 | + return [ 'error' => 'ะะต ัะดะฐะปะพัั ัะพะทะดะฐัั ัะฐั' ]; | ||
| 214 | + } | ||
| 215 | + } | ||
| 216 | + $message = new Message([ | ||
| 217 | + 'chat_id' => $chat->chat_id, | ||
| 218 | + 'user_id' => $user->id, | ||
| 219 | + 'status' => 1, | ||
| 220 | + ]); | ||
| 221 | + $text = "<p>ะะดัะฐะฒััะฒัะนัะต, {$user->name}!</p><p>ะัะตะดะปะฐะณะฐั ะะฐะผ ะฟัะธะฝััั ััะฐััะธะต ะฒ " . Html::a('ะขะตะฝะดะตัะต', [ | ||
| 222 | + 'tender/view', | ||
| 223 | + 'tender_id' => $project->project_id, | ||
| 224 | + ]) . "</p>"; | ||
| 225 | + $message->text = $text; | ||
| 226 | + if(!$message->save()) { | ||
| 227 | + return [ 'error' => 'ะะต ัะดะฐะปะพัั ะพัะฟัะฐะฒะธัั ะฟัะตะดะปะพะถะตะฝะธะต' ]; | ||
| 228 | + } else { | ||
| 229 | + return [ 'message' => 'ะัะตะดะปะพะถะตะฝะธะต ััะฟะตัะฝะพ ะพัะฟัะฐะฒะปะตะฝะพ' ]; | ||
| 230 | + } | ||
| 135 | } | 231 | } |
| 136 | - } | ||
| 137 | 232 | ||
| 138 | -} | 233 | + } |
frontend/views/layouts/company.php
| @@ -153,7 +153,7 @@ | @@ -153,7 +153,7 @@ | ||
| 153 | </div> | 153 | </div> |
| 154 | </div> | 154 | </div> |
| 155 | <div class="performance-vacancy-sidebar-comm style"><?= count($this->params[ 'company' ]->comments) ?> ะพัะทัะฒะพะฒ</div> | 155 | <div class="performance-vacancy-sidebar-comm style"><?= count($this->params[ 'company' ]->comments) ?> ะพัะทัะฒะพะฒ</div> |
| 156 | - <a href="#" class="performance-vacancy-sidebar-write style">ะฝะฐะฟะธัะฐัั ะพัะทัะฒ</a> | 156 | + <?= Html::a('ะฝะฐะฟะธัะฐัั ะพัะทัะฒ', ['company/review', 'company_id' => $this->params['company']->id], ['class' => 'performance-vacancy-sidebar-write style']) ?> |
| 157 | </div> | 157 | </div> |
| 158 | <div class="performer-vacancy-sidebar-img style"><?= Html::img($this->params[ 'company' ]->userInfo->image); ?></div> | 158 | <div class="performer-vacancy-sidebar-img style"><?= Html::img($this->params[ 'company' ]->userInfo->image); ?></div> |
| 159 | <div class="performer-vacancy-sidebar-all style"> | 159 | <div class="performer-vacancy-sidebar-all style"> |
frontend/views/layouts/performer.php
| @@ -20,8 +20,11 @@ | @@ -20,8 +20,11 @@ | ||
| 20 | <div class="box-wr"> | 20 | <div class="box-wr"> |
| 21 | <div class="box-all"> | 21 | <div class="box-all"> |
| 22 | <div class="blog-buttons-wr style"> | 22 | <div class="blog-buttons-wr style"> |
| 23 | - <a class="blog-buttons-offer" href="#">ะัะตะดะปะพะถะธัั<br>ะฟัะพะตะบั</a> | ||
| 24 | - <?= Html::a('ะัะตะดะปะพะถะธัั ะฟัะพะตะบั', Url::toRoute([ | 23 | + <?= Html::a('ะัะตะดะปะพะถะธัั ะฟัะพะตะบั', [ '#' ], [ |
| 24 | + 'class' => 'blog-buttons-offer', | ||
| 25 | + 'data-performer-id' => $this->params[ 'user' ]->id, | ||
| 26 | + ]) ?> | ||
| 27 | + <?= Html::a('ะะฐะฟะธัะฐัั ัะพะพะฑัะตะฝะธะต', Url::toRoute([ | ||
| 25 | 'chat/message', | 28 | 'chat/message', |
| 26 | 'user_id' => $this->params[ 'user' ]->id, | 29 | 'user_id' => $this->params[ 'user' ]->id, |
| 27 | ]), [ 'class' => 'blog-buttons-write' ]) ?> | 30 | ]), [ 'class' => 'blog-buttons-write' ]) ?> |
| @@ -132,7 +135,10 @@ | @@ -132,7 +135,10 @@ | ||
| 132 | </div> | 135 | </div> |
| 133 | </div> | 136 | </div> |
| 134 | <div class="performance-vacancy-sidebar-comm style"><?= count($this->params[ 'user' ]->comments) ?> ะพัะทัะฒะพะฒ</div> | 137 | <div class="performance-vacancy-sidebar-comm style"><?= count($this->params[ 'user' ]->comments) ?> ะพัะทัะฒะพะฒ</div> |
| 135 | - <a href="#" class="performance-vacancy-sidebar-write style">ะฝะฐะฟะธัะฐัั ะพัะทัะฒ</a> | 138 | + <?= Html::a('ะฝะฐะฟะธัะฐัั ะพัะทัะฒ', [ |
| 139 | + 'performer/review', | ||
| 140 | + 'performer_id' => $this->params[ 'user' ]->id, | ||
| 141 | + ], [ 'class' => 'performance-vacancy-sidebar-write style' ]) ?> | ||
| 136 | </div> | 142 | </div> |
| 137 | <div class="performer-vacancy-sidebar-img style"> | 143 | <div class="performer-vacancy-sidebar-img style"> |
| 138 | <?= Html::img($this->params[ 'user' ]->userInfo->image); ?> | 144 | <?= Html::img($this->params[ 'user' ]->userInfo->image); ?> |
| 1 | +<?php | ||
| 2 | + /** | ||
| 3 | + * @var int $performer_id | ||
| 4 | + * @var User $user | ||
| 5 | + * @var Project[] $projects | ||
| 6 | + */ | ||
| 7 | + use common\models\Project; | ||
| 8 | + use common\models\User; | ||
| 9 | + | ||
| 10 | +?> | ||
| 11 | +<script> | ||
| 12 | + $(document).ready( | ||
| 13 | + function() | ||
| 14 | + { | ||
| 15 | + jQuery('.off_list').jScrollPane( | ||
| 16 | + { | ||
| 17 | + showArrows : true, autoReinitialise : true, autoReinitialiseDelay : 200, | ||
| 18 | + scrollbarWidth : 25, arrowSize : 25 | ||
| 19 | + } | ||
| 20 | + ); | ||
| 21 | + | ||
| 22 | + $('.off_list').hide(); | ||
| 23 | + $('.main_item, .arrow.up').click( | ||
| 24 | + function() | ||
| 25 | + { | ||
| 26 | + $('.off_list').toggle() | ||
| 27 | + } | ||
| 28 | + ); | ||
| 29 | + | ||
| 30 | + var listOffer = $('.list-form-offer li'); | ||
| 31 | + var listOfferLength = listOffer.length; | ||
| 32 | + | ||
| 33 | + $(listOffer[listOfferLength - 1]).addClass('act-offer-li'); | ||
| 34 | + function activeOf() | ||
| 35 | + { | ||
| 36 | + var title1 = $('.act-offer-li').find('.title1').text(); | ||
| 37 | + var title2 = $('.act-offer-li').find('.title2').text(); | ||
| 38 | + $('#off_value').val($('.act-offer-li').data('project-id')); | ||
| 39 | + | ||
| 40 | + $('.main_item .pr_title').empty().text(title1) | ||
| 41 | + $('.main_item span').empty().text(title2) | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + activeOf(); | ||
| 45 | + | ||
| 46 | + listOffer.click( | ||
| 47 | + function() | ||
| 48 | + { | ||
| 49 | + var thisOfInd = $(this).index(); | ||
| 50 | + var actOfInd = $('.act-offer-li').index(); | ||
| 51 | + listOffer.removeClass('act-offer-li'); | ||
| 52 | + $(this).addClass('act-offer-li'); | ||
| 53 | + | ||
| 54 | + if(thisOfInd != actOfInd) | ||
| 55 | + { | ||
| 56 | + activeOf(); | ||
| 57 | + $('.off_list').hide(); | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | + ); | ||
| 61 | + $(document).on('click', '#off_submit', function(e) { | ||
| 62 | + e.preventDefault(); | ||
| 63 | + var project_id = $('#off_value').val(); | ||
| 64 | + var performer_id = $('#off_value').data('performer-id'); | ||
| 65 | + if(project_id && performer_id) { | ||
| 66 | + $.post( | ||
| 67 | + '/tender/offer', | ||
| 68 | + { | ||
| 69 | + project_id: project_id, | ||
| 70 | + performer_id: performer_id | ||
| 71 | + }, | ||
| 72 | + function(data) { | ||
| 73 | + if(data.error) { | ||
| 74 | + $('#overlay, .forms-modal-hide').remove(); | ||
| 75 | + alert(data.error); | ||
| 76 | + } else { | ||
| 77 | + $('#overlay, .forms-modal-hide').remove(); | ||
| 78 | + alert(data.message); | ||
| 79 | + } | ||
| 80 | + } | ||
| 81 | + ).fail( | ||
| 82 | + function() { | ||
| 83 | + $('#overlay, .forms-modal-hide').remove(); | ||
| 84 | + alert('ะะตะธะทะฒะตััะฝะฐั ะพัะธะฑะบะฐ'); | ||
| 85 | + } | ||
| 86 | + ) | ||
| 87 | + $(document).off('click', '#off_submit'); | ||
| 88 | + return false; | ||
| 89 | + } | ||
| 90 | + }); | ||
| 91 | + } | ||
| 92 | + ) | ||
| 93 | +</script> | ||
| 94 | + | ||
| 95 | +<div id="modal_form_offer"> | ||
| 96 | + <div class="closed-form"></div> | ||
| 97 | + <div class="form-resume-wr offer"> | ||
| 98 | + <div class="form-resume-sub style">ะัะตะดะปะพะถะธัั ะฟัะพะตะบั</div> | ||
| 99 | + <form action="" class="offer-project"> | ||
| 100 | + <input type="hidden" id="off_value" data-performer-id="<?=$performer_id?>"> | ||
| 101 | + <label>ะัะฑัะฐัั ะฟัะพะตะบั</label> | ||
| 102 | + <div class="list_item title"> | ||
| 103 | + <div class="main_item"> | ||
| 104 | + <div class="pr_title"></div> | ||
| 105 | + <span></span> | ||
| 106 | + </div> | ||
| 107 | + <div class="arrow up"></div> | ||
| 108 | + <div class="off_list"> | ||
| 109 | + <ul class="content list-form-offer"> | ||
| 110 | + <?php | ||
| 111 | + foreach($projects as $project) { | ||
| 112 | + ?> | ||
| 113 | + <li data-project-id="<?= $project->project_id ?>"> | ||
| 114 | + <div class="title1"><?= $project->name ?></div> | ||
| 115 | + <?php | ||
| 116 | + if(!empty( $project->parent )) { | ||
| 117 | + ?> | ||
| 118 | + <div class="title2">ะะพะดััะด: <?= $project->parent->name ?></div> | ||
| 119 | + <?php | ||
| 120 | + } | ||
| 121 | + ?> | ||
| 122 | + </li> | ||
| 123 | + <?php | ||
| 124 | + } | ||
| 125 | + ?> | ||
| 126 | + </ul> | ||
| 127 | + </div> | ||
| 128 | + </div> | ||
| 129 | + | ||
| 130 | + | ||
| 131 | + <input id="off_submit" type="submit" value="ะัะตะดะปะพะถะธัั"> | ||
| 132 | + </form> | ||
| 133 | + <div class="res_form_line"></div> | ||
| 134 | + </div> | ||
| 135 | +</div> |
frontend/web/js/forms.js
| @@ -69,38 +69,6 @@ $(document).ready( | @@ -69,38 +69,6 @@ $(document).ready( | ||
| 69 | ) | 69 | ) |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | - function addToOffer() | ||
| 73 | - { | ||
| 74 | - $.post( | ||
| 75 | - "/site/forms-modal-offer", function(data) | ||
| 76 | - { | ||
| 77 | - $('.forms-modal-hide').append(data) | ||
| 78 | - } | ||
| 79 | - ) | ||
| 80 | - .fail( | ||
| 81 | - function() | ||
| 82 | - { | ||
| 83 | - $('#overlay, .forms-modal-hide').remove(); | ||
| 84 | - alert(txtErrorModal) | ||
| 85 | - } | ||
| 86 | - ) | ||
| 87 | - .done( | ||
| 88 | - function() | ||
| 89 | - { | ||
| 90 | - var newMarg = $(window).scrollTop(); | ||
| 91 | - $('#overlay').fadeIn( | ||
| 92 | - 400, function() | ||
| 93 | - { | ||
| 94 | - $('body').css({overflowY : 'hidden'}) | ||
| 95 | - $('.forms-modal-hide>div') | ||
| 96 | - .css({display : 'block', marginTop : -230 + newMarg}) | ||
| 97 | - .animate({opacity : 1, top : '50%'}, 200); | ||
| 98 | - } | ||
| 99 | - ); | ||
| 100 | - } | ||
| 101 | - ) | ||
| 102 | - } | ||
| 103 | - | ||
| 104 | function addContacts() | 72 | function addContacts() |
| 105 | { | 73 | { |
| 106 | $.post( | 74 | $.post( |
| @@ -483,12 +451,58 @@ $(document).ready( | @@ -483,12 +451,58 @@ $(document).ready( | ||
| 483 | 451 | ||
| 484 | 452 | ||
| 485 | //offer | 453 | //offer |
| 454 | + function addToOffer(performer_id) | ||
| 455 | + { | ||
| 456 | + $.post( | ||
| 457 | + "/tender/offer-form", | ||
| 458 | + { | ||
| 459 | + performer_id: performer_id | ||
| 460 | + } , | ||
| 461 | + function(data) | ||
| 462 | + { | ||
| 463 | + if(data.error) { | ||
| 464 | + $('#overlay, .forms-modal-hide').remove(); | ||
| 465 | + alert(data.error); | ||
| 466 | + } else { | ||
| 467 | + $('.forms-modal-hide').append(data.message); | ||
| 468 | + } | ||
| 469 | + } | ||
| 470 | + ) | ||
| 471 | + .fail( | ||
| 472 | + function() | ||
| 473 | + { | ||
| 474 | + $('#overlay, .forms-modal-hide').remove(); | ||
| 475 | + alert(txtErrorModal) | ||
| 476 | + } | ||
| 477 | + ) | ||
| 478 | + .done( | ||
| 479 | + function() | ||
| 480 | + { | ||
| 481 | + var newMarg = $(window).scrollTop(); | ||
| 482 | + $('#overlay').fadeIn( | ||
| 483 | + 400, function() | ||
| 484 | + { | ||
| 485 | + $('body').css({overflowY : 'hidden'}) | ||
| 486 | + $('.forms-modal-hide>div') | ||
| 487 | + .css({display : 'block', marginTop : -230 + newMarg}) | ||
| 488 | + .animate({opacity : 1, top : '50%'}, 200); | ||
| 489 | + } | ||
| 490 | + ); | ||
| 491 | + } | ||
| 492 | + ) | ||
| 493 | + } | ||
| 486 | $('a.get-project, .blog-buttons-offer').click( | 494 | $('a.get-project, .blog-buttons-offer').click( |
| 487 | function(e) | 495 | function(e) |
| 488 | { | 496 | { |
| 489 | - e.preventDefault() | ||
| 490 | - addRemoveBlocks() | ||
| 491 | - addToOffer() | 497 | + e.preventDefault(); |
| 498 | + var performer_id; | ||
| 499 | + performer_id = $(this).data('performer-id'); | ||
| 500 | + if(!performer_id) { | ||
| 501 | + return false; | ||
| 502 | + } else { | ||
| 503 | + addRemoveBlocks(); | ||
| 504 | + addToOffer(performer_id); | ||
| 505 | + } | ||
| 492 | } | 506 | } |
| 493 | ) | 507 | ) |
| 494 | 508 |