/** * Изменение статуса */ public function actionChangestatus() { if (Yii::$app->getRequest()->getIsAjax() && Yii::$app->getRequest()->post()) { Yii::$app->getResponse()->format = Response::FORMAT_JSON; $params = Yii::$app->getRequest()->post(); if (empty($params['userId']) || empty($params['leadId']) || empty($params['selectedStatus'])) { return ['status' => false]; } /** @var \common\models\User $user */ $user = User::findIdentity($params['userId']); /** @var \common\models\Lead $lead */ $lead = Lead::findOne(['lead_id' => $params['leadId'], 'company_id' => $user->getCompanyId(), 'is_deleted' => false]); if (!$lead) { return ['status' => false]; } $lead->setStatus($params['selectedStatus']); $lead->setChangeStatusUserId($params['userId']); $status = $lead->save(); $this->leadLogger->write($lead, LeadActionLog::ACTION_CHANGE_STATUS); return ['status' => $status, 'selectedStatus' => $params['selectedStatus'], 'result' => ChangeLeadStatusWidget::widget(['userId' => $params['userId'], 'leadId' => $params['leadId'], 'status' => $params['selectedStatus']])]; } $this->redirect('/lead/index'); }
echo $lead->getLeadId(); ?> </a> </td> <td><?php echo StringHelper::truncate($lead->getLanding()->getName(), 40); ?> </td> <td> <?php echo $this->render('_userData', ['userData' => $lead->getData()]); ?> </td> <td> <?php echo \backend\widgets\ChangeLeadStatusWidget::widget(['userId' => $user->getId(), 'leadId' => $lead->getLeadId(), 'status' => $lead->getStatus()]); ?> </td> <td><?php echo $lead->getPrice(); ?> </td> <td> <?php $comments = $lead->getComments(); if (!empty($comments)) { /** @var \common\models\LeadComment $lastComment */ $lastComment = array_pop($comments); echo StringHelper::truncate($lastComment->getComment(), 150); } ?>