/**
  * Список заявок.
  *
  * @return string
  */
 public function actionIndex()
 {
     /** @var \common\models\User $user */
     $user = Yii::$app->getUser()->getIdentity();
     $query = Lead::find()->where(['company_id' => $user->getCompanyId(), 'is_deleted' => false]);
     if ($selectedLandingId = Yii::$app->getSession()->get('selected_landing_id')) {
         $query->andWhere(['landing_id' => $selectedLandingId]);
     }
     if ($selectedLeadStatus = Yii::$app->getSession()->get('selected_lead_status')) {
         $query->andWhere(['status' => $selectedLeadStatus]);
     }
     $countQuery = clone $query;
     $pagination = new Pagination(['totalCount' => $countQuery->count()]);
     $pagination->setPageSize(LeadHelper::SHOW_LEAD_PER_PAGE);
     $leads = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['lead_id' => SORT_DESC])->all();
     $landingNames = (new LandingComponent())->getActiveLandingNamesByCompanyId($user->getCompanyId());
     if (empty($landingNames)) {
         Yii::$app->getSession()->setFlash('warning', sprintf('Не возможно добавлять заявки, так как не было создано ни одной промо-страницы! <a href="%s">Добавить промо-страницу.</a>', Url::to('/landing/add')));
     }
     return $this->render('index', ['user' => $user, 'leads' => $leads, 'pagination' => $pagination, 'landingNames' => $landingNames, 'selectedLandingId' => $selectedLandingId, 'selectedLeadStatus' => $selectedLeadStatus]);
 }
Example #2
0
?>
">Профиль</a></li>
                                <li class="divider"></li>
                                <li><a href="<?php 
echo Url::to('/logout');
?>
">Выйти</a></li>
                            </ul>
                        </div>
                        <div class="logo-element">
                            IN+
                        </div>
                    </li>
                    <?php 
$request = Yii::$app->getRequest();
echo MainMenuWidget::widget(['menu' => [['label' => 'Главная', 'url' => '/', 'icon' => 'home', 'active' => '/' == $request->getUrl()], ['label' => 'Профиль', 'url' => '/profile', 'icon' => 'user', 'active' => '/profile' == $request->getUrl()], ['label' => 'Компания', 'url' => '/company', 'icon' => 'building', 'active' => '/company' == $request->getUrl()], ['label' => 'Сотрудники', 'url' => '/users', 'icon' => 'users', 'roles' => ['boss'], 'active' => preg_match("/^\\/user\\/.*|\\/users/", $request->getUrl())], ['label' => 'Промо-страницы', 'url' => '/landing', 'icon' => 'bullhorn', 'active' => preg_match("/^\\/landing\\/.*|\\/landing/", $request->getUrl())], ['label' => 'Заявки', 'url' => '/lead', 'icon' => 'bell', 'active' => preg_match("/^\\/lead\\/.*|^\\/lead/", $request->getUrl()), 'notification' => ['type' => 'warning', 'value' => \common\models\Lead::find()->where(['status' => \common\models\Lead::STATUS_OPEN, 'is_deleted' => false, 'company_id' => Yii::$app->getUser()->getIdentity()->getCompanyId()])->count()]]], 'user' => Yii::$app->getUser()]);
?>
                </ul>
            </div>
        </nav>
        <div id="page-wrapper" class="gray-bg">
        <div class="row border-bottom">
            <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
                <!--div class="navbar-header">
                    <a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="#"><i class="fa fa-bars"></i> </a>
                    <form role="search" class="navbar-form-custom" method="post" action="search_results.html">
                        <div class="form-group">
                            <input type="text" placeholder="Search for something..." class="form-control" name="top-search" id="top-search">
                        </div>
                    </form>
                </div-->