示例#1
0
 public function execute($context)
 {
     $context['APPLICATION']->AddHeadScript('/js/forms.js');
     //$availableSessionsIDs = $this->registry->getModel('Auth')->getAvailableSessions($_SESSION['accesses'], $context['project']['projectID']);
     $viewHelper = new \Ecoplay\View\Helper();
     if (isset($_POST['action'])) {
         if ($_POST['action'] == 'add') {
             if ($_POST['name'] && $_POST['package']) {
                 $this->registry->getDbHelper('TestsHelper')->addSession(array('projectID' => $context['project']['projectID'], 'packageID' => intval($_POST['package']), 'name' => $_POST['name'], 'status' => 'active', 'active' => 1));
             }
         } elseif ($_POST['action'] == 'edit') {
             $session = $this->registry->getDbHelper('TestsHelper')->findSessionByID(intval($_POST['session_id']));
             if ($session && $_POST['name']) {
                 $res = $this->registry->getDbHelper('TestsHelper')->editSession($session['sessionID'], array('name' => $_POST['name']));
             }
         }
     }
     $sessionsCnt = 0;
     //if (count($availableSessionsIDs)) {
     $sessions = $this->registry->getDbHelper('TestsHelper')->getSessionsInfoByProjectID($context['project']['projectID']);
     $sessionsCnt = count($sessions);
     $this->component->arResult['table_data'] = str_replace("'", "\\'", $viewHelper->prepareJsonDataForTable($sessions, array('sessionID', 'name', 'status', 'package_name', 'cnt')));
     /*}
       else {
         $this->component->arResult['table_data'] = null;
       }*/
     $this->component->arResult['cnt'] = $sessionsCnt;
     $this->component->arResult['packages'] = $this->registry->getDbHelper('TestsHelper')->getAllPackages();
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Группы тестируемых');
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('title' => 'Главная', 'link' => '/'), 1 => array('title' => 'Проекты', 'link' => '/projects/'), 2 => array('title' => $context['project']['project_name'], 'link' => '/projects/' . $context['project']['projectID'] . '/continuing/stat/'), 3 => array('title' => 'Группы тестируемых'))));
     $this->component->IncludeComponentTemplate('template_testing');
 }
示例#2
0
 public function execute($context)
 {
     $context['APPLICATION']->AddHeadScript('/js/icheck/icheck.min.js');
     $context['APPLICATION']->SetAdditionalCSS('/js/icheck/skins/minimal/eco.css');
     $cnt = $this->registry->getDbHelper('LinearProjectsHelper')->getGroupKeyRespondentsCount($context['project']['projectID'], $context['groupKey']['group_keyID']);
     $onPage = 100;
     $pagesCnt = ceil($cnt / $onPage);
     $page = $_GET['PAGE'] && $_GET['PAGE'] <= $pagesCnt ? intval($_GET['PAGE']) : 1;
     $this->component->arResult['cntInfo'] = $pagesCnt == 1 ? $cnt : 0;
     $respondents = $this->registry->getDbHelper('TestsSeancesHelper')->getGroupKeyRespondents($context['project']['projectID'], $context['groupKey']['group_keyID'], $page, $onPage);
     $this->component->arResult['respondents'] = $respondents;
     $this->component->arResult['groupKey'] = $context['groupKey'];
     $languagesIDs = json_decode($context['project']['~languages']);
     $languagesSrc = $this->registry->getDbHelper('TranslationHelper')->getLanguagesByIDs($languagesIDs);
     $languages = array();
     foreach ($languagesSrc as $language) {
         $languages[$language['langID']] = $language['name'];
     }
     $this->component->arResult['languages'] = $languages;
     $this->component->arResult['statuses'] = $this->registry->getDbHelper('MembersHelper')->getTestingRespondentsStatusesNames();
     $this->component->IncludeComponentTemplate('linear/table');
     $navResult = new \CDBResult();
     $navResult->NavPageCount = ceil($cnt / $onPage);
     $navResult->NavPageNomer = $page;
     $navResult->NavNum = 1;
     $navResult->NavPageSize = $onPage;
     $navResult->NavRecordCount = $cnt;
     $navResult->nPageWindow = 11;
     $context['APPLICATION']->IncludeComponent('ecoplay:system.pagenavigation', '', array('NAV_RESULT' => $navResult, 'NAV_URL' => '/projects/' . $context['project']['projectID'] . '/settings/groupkeys/' . $context['groupKey']['group_keyID'] . '/respondents/', 'NAV_QUERY_STRING' => isset($_GET['checkAll']) ? 'checkAll=1' : ''));
     $viewHelper = new \Ecoplay\View\Helper();
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Респонденты группового ключа');
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('link' => '/', 'title' => 'Главная'), 1 => array('link' => '/projects/', 'title' => 'Проекты'), 2 => array('link' => '/projects/' . $context['project']['projectID'] . '/continuing/stat/', 'title' => $context['project']['project_name']), 3 => array('link' => '/projects/' . $context['project']['projectID'] . '/settings/groupkeys/', 'title' => ' Групповые ключи'), 4 => array('title' => $context['groupKey']['name']), 5 => array('title' => 'Список Респондентов'))));
     $this->component->IncludeComponentTemplate('linear/template');
 }
示例#3
0
 public function execute($context)
 {
     $context['APPLICATION']->AddHeadScript('/js/forms.js');
     $context['APPLICATION']->AddHeadScript('/js/icheck/icheck.min.js');
     $context['APPLICATION']->SetAdditionalCSS('/js/icheck/skins/minimal/eco.css');
     // выполняем с респондентами действия
     if (isset($_POST['respondents_ids'])) {
         $selectedIDs = $_POST['respondents_ids'];
         if (isset($_POST['mode'])) {
             if ($_POST['mode'] == 'reset') {
                 $seances = $this->registry->getDbHelper('SeancesHelper')->findSeanceByProjectAndRespondentsIDs($context['project']['projectID'], $selectedIDs);
                 foreach ($seances as $seance) {
                     // деактивируем текущий сеанс
                     $this->registry->getDbHelper('SeancesHelper')->editSeance($seance['seanceID'], array('active' => 0, 'private_access_key' => ''));
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'seance', $seance['seanceID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_DELETE, $seance);
                     $this->registry->getDbHelper('MembersHelper')->editRespondent($seance['respondentID'], array('status' => 'active'));
                     // создаем новый сеанс
                     $BlankDataSource = new \Ecoplay\Model\BlankDataSource($this->registry->getDbConnect(), 0, 0);
                     $seanceKey = $BlankDataSource->addSeanceAndCookies($seance['private_access_key']);
                     $newSeance = $this->registry->getDbHelper('SeancesHelper')->findSeanceByKey($seanceKey);
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'seance', $newSeance['seanceID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                 }
             }
         }
     }
     $cnt = $this->registry->getDbHelper('LinearProjectsHelper')->getGroupKeyRespondentsCount($context['project']['projectID'], $context['groupKey']['group_keyID']);
     $onPage = 100;
     $pagesCnt = ceil($cnt / $onPage);
     $page = $_GET['PAGE'] && $_GET['PAGE'] <= $pagesCnt ? intval($_GET['PAGE']) : 1;
     $this->component->arResult['cntInfo'] = $pagesCnt == 1 ? $cnt : 0;
     $respondents = $this->registry->getDbHelper('LinearProjectsHelper')->getGroupKeyRespondents($context['project']['projectID'], $context['groupKey']['group_keyID'], $page, $onPage);
     $this->component->arResult['respondents'] = $respondents;
     $this->component->arResult['groupKey'] = $context['groupKey'];
     $languagesIDs = json_decode($context['project']['~languages']);
     $languagesSrc = $this->registry->getDbHelper('TranslationHelper')->getLanguagesByIDs($languagesIDs);
     $languages = array();
     foreach ($languagesSrc as $language) {
         $languages[$language['langID']] = $language['name'];
     }
     $this->component->arResult['languages'] = $languages;
     $this->component->arResult['statuses'] = $this->registry->getDbHelper('MembersHelper')->getLinearRespondentsStatusesNames();
     $this->component->IncludeComponentTemplate('linear/table');
     $navResult = new \CDBResult();
     $navResult->NavPageCount = ceil($cnt / $onPage);
     $navResult->NavPageNomer = $page;
     $navResult->NavNum = 1;
     $navResult->NavPageSize = $onPage;
     $navResult->NavRecordCount = $cnt;
     $navResult->nPageWindow = 11;
     $context['APPLICATION']->IncludeComponent('ecoplay:system.pagenavigation', '', array('NAV_RESULT' => $navResult, 'NAV_URL' => '/projects/' . $context['project']['projectID'] . '/settings/groupkeys/' . $context['groupKey']['group_keyID'] . '/respondents/', 'NAV_QUERY_STRING' => isset($_GET['checkAll']) ? 'checkAll=1' : ''));
     $viewHelper = new \Ecoplay\View\Helper();
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Респонденты группового ключа');
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('link' => '/', 'title' => 'Главная'), 1 => array('link' => '/projects/', 'title' => 'Проекты'), 2 => array('link' => '/projects/' . $context['project']['projectID'] . '/continuing/stat/', 'title' => $context['project']['project_name']), 3 => array('link' => '/projects/' . $context['project']['projectID'] . '/settings/groupkeys/', 'title' => ' Групповые ключи'), 4 => array('title' => $context['groupKey']['name']), 5 => array('title' => 'Список Респондентов'))));
     $this->component->IncludeComponentTemplate('linear/template');
 }
示例#4
0
 public function execute($context)
 {
     $scripts = $this->registry->getDbHelper('WorkflowHelper')->getProjectScripts($context['project']['projectID']);
     $viewHelper = new \Ecoplay\View\Helper();
     $this->component->arResult['cnt'] = count($scripts);
     $tData = $viewHelper->prepareJsonDataForTable($scripts, array('scriptID', 'name', 'text'));
     $this->component->arResult['table_data'] = $tData;
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'WorkFlow скрипты');
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('title' => 'Главная', 'link' => '/'), 1 => array('title' => 'Проекты', 'link' => '/projects/'), 2 => array('link' => '/projects/' . $context['project']['projectID'] . '/continuing/info/', 'title' => $context['project']['project_name']), 3 => array('title' => 'WorkFlow скрипты'))));
     $this->component->IncludeComponentTemplate();
 }
示例#5
0
 public function execute($context)
 {
     $context['APPLICATION']->AddHeadScript('https://www.google.com/jsapi');
     // проверка прав доступа к разделу
     if (!$this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'projects')) {
         $this->registry->getModel('Auth')->restrict();
     }
     if (!$this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'project', $context['project']['projectID'])) {
         $this->registry->getModel('Auth')->restrict();
     }
     $availableSessionsIDs = $this->registry->getModel('Auth')->getAvailableSessions($_SESSION['accesses'], $context['project']['projectID']);
     // определяем даты
     $from = $context['project']['dt_from'] ? strtotime($context['project']['dt_from']) : strtotime($context['project']['dt_create']);
     $to = $context['project']['dt_to'] ? strtotime($context['project']['dt_to']) : time();
     //получаем опрашиваемых проекта
     if (count($availableSessionsIDs)) {
         // стата по анкетам
         $seancesStat = $this->registry->getDbHelper('MembersHelper')->getSessionsSeancesStat($context['project']['projectID'], $availableSessionsIDs);
         $states = array(\Ecoplay\Helper\Db\BlanksHelper::SEANCE_STATE_NEW => 'Заполнение не начато', \Ecoplay\Helper\Db\BlanksHelper::SEANCE_STATE_PROGRESS => 'Идёт заполнение', \Ecoplay\Helper\Db\BlanksHelper::SEANCE_STATE_COMPLETE => 'Заполнение завершено');
         $statesColors = array(\Ecoplay\Helper\Db\BlanksHelper::SEANCE_STATE_NEW => 'c8331f', \Ecoplay\Helper\Db\BlanksHelper::SEANCE_STATE_PROGRESS => 'ffcc33', \Ecoplay\Helper\Db\BlanksHelper::SEANCE_STATE_COMPLETE => '336600');
         $busyStates = array();
         $seancesAllCnt = 0;
         foreach ($seancesStat as $key => $seances) {
             $busyStates[] = $seances['name'];
             $seancesStat[$key]['color'] = array_key_exists($seances['name'], $statesColors) ? $statesColors[$seances['name']] : '606060';
             $seancesStat[$key]['name'] = array_key_exists($seances['name'], $states) ? $states[$seances['name']] : 'Неизвестно';
             $seancesAllCnt += $seances['val'];
         }
         foreach ($states as $key => $name) {
             if (!in_array($key, $busyStates)) {
                 $seancesStat[] = array('color' => $statesColors[$key], 'name' => $name, 'val' => 0);
             }
         }
         if (!$seancesAllCnt) {
             $seancesStat = false;
         }
         ### таймлайн
         $timelineStat = $this->registry->getModel('Stat')->getTimelineStat($from, $to, $availableSessionsIDs);
     } else {
         $assessStat = false;
         $seancesStat = false;
         $timelineStat = false;
     }
     $this->component->arResult['assessStat'] = $assessStat;
     $this->component->arResult['seancesStat'] = $seancesStat;
     $this->component->arResult['timelineStat'] = $timelineStat;
     $this->component->arResult['from'] = $from;
     $this->component->arResult['to'] = $to;
     $viewHelper = new \Ecoplay\View\Helper();
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Статистика');
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('title' => 'Главная', 'link' => '/'), 1 => array('title' => 'Проекты', 'link' => '/projects/'), 2 => array('title' => $context['project']['project_name']))));
     $this->component->IncludeComponentTemplate('linear/template');
 }
示例#6
0
 public function execute($context)
 {
     // проверка прав доступа к разделу
     if (!$this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'seances', $context['project']['projectID'])) {
         $this->registry->getModel('Auth')->restrict();
     }
     $availableSessionsIDs = $this->registry->getModel('Auth')->getAvailableSessions($_SESSION['accesses'], $context['project']['projectID'], $context['project']['project_type']);
     $viewHelper = new \Ecoplay\View\Helper();
     if (count($availableSessionsIDs)) {
         if (isset($_POST['reseted_id'])) {
             // обнуляем заполнение
             $seance = $this->registry->getDbHelper('TestsSeancesHelper')->findSeanceByID($_POST['reseted_id']);
             if ($seance) {
                 $respondent = $this->registry->getDbHelper('MembersHelper')->findRespondentById($seance['respondentID']);
                 $this->registry->getModel('Tests')->deleteSeance($seance);
                 if ($respondent) {
                     $this->registry->getModel('Tests')->createSeance($respondent);
                 }
             }
         }
         $cnt = $this->registry->getDbHelper('TestsSeancesHelper')->getProjectsSeancesCount($context['project']['projectID']);
         $onPage = 100;
         $pagesCnt = ceil($cnt / $onPage);
         $page = $_GET['PAGE'] && $_GET['PAGE'] <= $pagesCnt ? intval($_GET['PAGE']) : 1;
         $navResult = new \CDBResult();
         $navResult->NavPageCount = ceil($cnt / $onPage);
         $navResult->NavPageNomer = $page;
         $navResult->NavNum = 1;
         $navResult->NavPageSize = $onPage;
         $navResult->NavRecordCount = $cnt;
         $context['APPLICATION']->IncludeComponent('ecoplay:system.pagenavigation', '', array('NAV_RESULT' => $navResult, 'NAV_URL' => '/projects/' . $context['project']['projectID'] . '/groups/seances/'));
         $seances = $this->registry->getDbHelper('TestsSeancesHelper')->getSeancesByProjectIDAndSessionsIds($context['project']['projectID'], $availableSessionsIDs, $page, $onPage);
         $statesNames = $this->registry->getDbHelper('BlanksHelper')->getSeancesStatesNames();
         $this->component->arResult['table_data'] = str_replace("'", "\\'", $viewHelper->prepareJsonDataForTable($seances, array('tests_seanceID', 'name', 'surname', 'email', 'state'), array(), array('state' => $statesNames)));
         $this->component->arResult['cnt'] = count($seances);
     } else {
         $this->component->arResult['table_data'] = null;
         $this->component->arResult['cnt'] = 0;
     }
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Сеансы заполнения');
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('link' => '/', 'title' => 'Главная'), 1 => array('link' => '/projects/', 'title' => 'Проекты'), 2 => array('link' => '/projects/' . $context['project']['projectID'] . '/continuing/stat/', 'title' => $context['project']['project_name']), 3 => array('link' => '/projects/' . $context['project']['projectID'] . '/groups/', 'title' => 'Группы оцениваемых'), 4 => array('title' => 'Сеансы заполнения'))));
     $this->component->IncludeComponentTemplate('template_testing');
 }
示例#7
0
 public function execute($context)
 {
     $availableSessionsIDs = $this->registry->getModel('Auth')->getAvailableSessions($_SESSION['accesses'], $context['project']['projectID']);
     $viewHelper = new \Ecoplay\View\Helper();
     $sessionsCnt = 0;
     if (count($availableSessionsIDs)) {
         $sessions = $this->registry->getDbHelper('ProjectsHelper')->getSessionsInfoBySessionsIDs($context['project']['projectID'], $availableSessionsIDs);
         $this->component->arResult['sessions'] = $sessions;
         $sessionsCnt = count($sessions);
         $this->component->arResult['table_data'] = str_replace("'", "\\'", $viewHelper->prepareJsonDataForTable($sessions, array('sessionID', 'name', 'status', 'start_dt', 'finish_dt', 'blank_name', 'assess_count', 'myCSS_path'), array('start_dt' => 'date', 'finish_dt' => 'date')));
     } else {
         $this->component->arResult['table_data'] = null;
     }
     $this->component->arResult['cnt'] = $sessionsCnt;
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Группы оцениваемых');
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('title' => 'Главная', 'link' => '/'), 1 => array('title' => 'Проекты', 'link' => '/projects/'), 2 => array('title' => $context['project']['project_name'], 'link' => '/projects/' . $context['project']['projectID'] . '/continuing/stat/'), 3 => array('title' => 'Группы оцениваемых'))));
     $this->component->arResult['projectID'] = $context['project']['projectID'];
     $this->component->IncludeComponentTemplate();
 }
示例#8
0
 public function execute($context)
 {
     // проверка прав доступа к разделу
     if (!$this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'seances', $context['project']['projectID'])) {
         $this->registry->getModel('Auth')->restrict();
     }
     $availableSessionsIDs = $this->registry->getModel('Auth')->getAvailableSessions($_SESSION['accesses'], $context['project']['projectID']);
     $viewHelper = new \Ecoplay\View\Helper();
     if (count($availableSessionsIDs)) {
         $seances = $this->registry->getDbHelper('ProjectsHelper')->getSeancesByProjectIDAndSessionsIds($context['project']['projectID'], $availableSessionsIDs);
         $this->component->arResult['seances'] = $seances;
         $this->component->arResult['table_data'] = str_replace("'", "\\'", $viewHelper->prepareJsonDataForTable($seances, array('seanceID', 'name', 'surname', 'email', 'start_dt', 'finish_dt', 'assess', 'role', 'answered')));
         $this->component->arResult['cnt'] = count($seances);
     } else {
         $this->component->arResult['table_data'] = null;
         $this->component->arResult['cnt'] = 0;
     }
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Сеансы заполнения');
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('link' => '/', 'title' => 'Главная'), 1 => array('link' => '/projects/', 'title' => 'Проекты'), 2 => array('link' => '/projects/' . $context['project']['projectID'] . '/continuing/stat/', 'title' => $context['project']['project_name']), 3 => array('link' => '/projects/' . $context['project']['projectID'] . '/groups/', 'title' => 'Группы оцениваемых'), 4 => array('title' => 'Сеансы заполнения'))));
     $this->component->IncludeComponentTemplate();
 }
示例#9
0
 public function execute($context)
 {
     // проверка прав доступа к разделу
     if (!$this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'members', $context['project']['projectID'])) {
         $this->registry->getModel('Auth')->restrict();
     }
     $context['APPLICATION']->AddHeadScript('/js/forms.js');
     $context['APPLICATION']->AddHeadScript('/js/icheck/icheck.min.js');
     $context['APPLICATION']->SetAdditionalCSS('/js/icheck/skins/minimal/eco.css');
     if (isset($_POST['type'])) {
         if ($_POST['type'] == 'exist') {
             if (isset($_POST['member_id'])) {
                 // проверяем, может уже есть респондент с таким участником
                 $existRespondent = $this->registry->getDbHelper('MembersHelper')->findRespondentByMemberIDAndSessionID($context['project']['projectID'], $_POST['member_id'], $_POST['session_id']);
                 if (!$existRespondent) {
                     // добавляем респондента
                     $respondentID = $this->registry->getDbHelper('MembersHelper')->addRespondent(array('project_memberID' => intval($_POST['member_id']), 'active' => 1, 'projectID' => $context['project']['projectID'], 'sessionID' => intval($_POST['session_id']), 'stat1_assessID' => 0, 'status' => \Ecoplay\Helper\Db\MembersHelper::RESPONDENT_STATUS_NEW, 'private_access_key' => $this->registry->getModel('Auth')->generateUid('prep_respondents', 'private_access_key'), 'stat1_roleID' => 0, 'last_email' => '0000-00-00 00:00:00', 'langID' => 0, 'last_entrance' => '0000-00-00 00:00:00', 'deny_deletion' => 0, 'addedd_by_assess' => 0, 'need_remind' => 0));
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'respondent', $respondentID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                 }
             }
         } else {
             // пробуем добавить участника
             $validations = array('name' => 'anything', 'surname' => 'anything', 'email' => 'email', 'position' => 'anything', 'department' => 'anything', 'language' => 'identifier');
             $required = array('name', 'email', 'language');
             $validator = new \Ecoplay\Form\Validator($validations, $required, array());
             if ($validator->validate($_POST)) {
                 // проверяем чтобы не было уже участника с таким email
                 if (!$this->registry->getDbHelper('MembersHelper')->findByEmailAndProjectId($_POST['email'], $context['project']['projectID'])) {
                     $memberID = $this->registry->getDbHelper('MembersHelper')->addMember(trim($_POST["name"]), trim($_POST["surname"]), trim($_POST["position"]), trim($_POST["email"]), $context['project']['projectID'], $this->registry->getModel('Auth')->generateUid('prep_projects_members', 'private_lk_access_key'), intval($_POST["language"]), 1, 'new', trim($_POST['department']));
                     $eventListener = new EventListener($this->registry, $context['project'], $_SERVER["DOCUMENT_ROOT"] . '/');
                     $eventListener->executeEvent('MemberAdded', array('memberID' => $memberID), true);
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'member', $memberID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                     // добавляем респондента
                     $respondentID = $this->registry->getDbHelper('MembersHelper')->addRespondent(array('project_memberID' => $memberID, 'active' => 1, 'projectID' => $context['project']['projectID'], 'sessionID' => intval($_POST['session_id']), 'stat1_assessID' => 0, 'status' => \Ecoplay\Helper\Db\MembersHelper::RESPONDENT_STATUS_NEW, 'private_access_key' => $this->registry->getModel('Auth')->generateUid('prep_respondents', 'private_access_key'), 'stat1_roleID' => 0, 'last_email' => '0000-00-00 00:00:00', 'langID' => 0, 'last_entrance' => '0000-00-00 00:00:00', 'deny_deletion' => 0, 'addedd_by_assess' => 0, 'need_remind' => 0));
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'respondent', $respondentID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                 } else {
                     $this->component->arResult['statusError'] = 'Участник с таким email (' . $_POST['email'] . ') уже существует';
                 }
             }
         }
     }
     if ($_FILES["filepath"] && !$_FILES['filepath']['error']) {
         $sessionID = (int) $_POST["fgroup"];
         if ($sessionID) {
             $session = $this->registry->getDbHelper('ProjectsHelper')->findSessionById($sessionID);
         }
         // обрабатываем загруженный файл
         $csvImporter = new \Ecoplay\Import\Csv($_FILES["filepath"]["tmp_name"], $_SERVER["DOCUMENT_ROOT"] . "/temp/csv/");
         $data = $csvImporter->parse();
         $sessionIndex = $csvImporter->getColumnIndex('Группа');
         if (!((!$sessionIndex || !$data[0][$sessionIndex]) && (!$sessionID || !$session))) {
             // определяем группу
             if ($sessionIndex && $data[0][$sessionIndex]) {
                 // ищем группу
                 $session = $this->registry->getDbHelper('ProjectsHelper')->findSessionByProjectIDAndName($context['project']['projectID'], $data[0][$sessionIndex]);
                 if ($session) {
                     $sessionID = $session['sessionID'];
                 } else {
                     $session = array('name' => $data[0][$sessionIndex], 'active' => 1, 'status' => 'active', 'projectID' => $context['project']['projectID']);
                     $sessionID = $this->registry->getDbHelper('ProjectsHelper')->addSession($session);
                     $session['sessionID'] = $sessionID;
                 }
             }
             $inserted = $skipped = 0;
             $validations = array(0 => 'anything', 1 => 'anything', 2 => 'email', 3 => 'anything', 4 => 'anything');
             $required = array(2);
             $validator = new \Ecoplay\Form\Validator($validations, $required, array());
             $projectLangID = $this->registry->getModel('Projects')->getDefaultLangID($context['project']);
             $languageIndex = $csvImporter->getColumnIndex('Язык');
             $languagesIDs = array();
             $availableLanguages = $this->registry->getDbHelper('TranslationHelper')->getLanguagesByIDs(json_decode($context['project']['~languages']));
             foreach ($availableLanguages as $language) {
                 $languagesIDs[$language['abbr']] = $language['langID'];
             }
             foreach ($data as $row) {
                 if ($sessionIndex && $row[$sessionIndex] && $row[$sessionIndex] != $session['name']) {
                     // ищем группу
                     $session = $this->registry->getDbHelper('ProjectsHelper')->findSessionByProjectIDAndName($context['project']['projectID'], $row[$sessionIndex]);
                     if ($session) {
                         $sessionID = $session['sessionID'];
                     } else {
                         $session = array('name' => $row[$sessionIndex], 'active' => 1, 'status' => 'active', 'projectID' => $context['project']['projectID']);
                         $sessionID = $this->registry->getDbHelper('ProjectsHelper')->addSession($session);
                         $session['sessionID'] = $sessionID;
                     }
                 }
                 // валидируем исходные данные
                 if (!$validator->validate($row)) {
                     $skipped++;
                 } elseif (!$row[0] && !$row[1]) {
                     // должно быть хотябы или имя, или фамилия
                     $skipped++;
                 } else {
                     // ищем такого участника уже в базе
                     $member = $this->registry->getDbHelper('MembersHelper')->findByEmailAndProjectId($row[2], $context['project']['projectID']);
                     if (!$member) {
                         // добавляем участника
                         // определяем язык по структуре
                         $staff = $this->registry->getDbHelper('MembersHelper')->findStaffByProjectIDAndEmail($context['project']['projectID'], $row[2]);
                         $langID = $languageIndex && $row[$languageIndex] && array_key_exists($row[$languageIndex], $languagesIDs) ? $languagesIDs[$row[$languageIndex]] : $projectLangID;
                         $memberID = $this->registry->getDbHelper('MembersHelper')->addMember($row[0], $row[1], $row[3], $row[2], $context['project']['projectID'], $this->registry->getModel('Auth')->generateUid('prep_projects_members', 'private_lk_access_key', false), $langID, 1, 'new', $row[4]);
                         $eventListener = new EventListener($this->registry, $context['project'], $_SERVER["DOCUMENT_ROOT"] . '/');
                         $eventListener->executeEvent('MemberAdded', array('memberID' => $memberID, 'staff' => $staff), true);
                         $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'member', $memberID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                     } else {
                         $memberID = $member['projects_memberID'];
                     }
                     if ($this->registry->getDbHelper('MembersHelper')->findRespondentByProjectIDAndSessionIDAndMemberID($context['project']['projectID'], $sessionID, $memberID)) {
                         // такой оцениваемый уже есть
                         $skipped++;
                     } else {
                         $respondentID = $this->registry->getDbHelper('MembersHelper')->addRespondent(array('projectID' => $context['project']['projectID'], 'sessionID' => $sessionID, 'project_memberID' => $memberID, 'active' => 1, 'status' => 'new', 'stat1_assessID' => 0, 'private_access_key' => $this->registry->getModel('Auth')->generateUid('prep_respondents', 'private_access_key', false), 'stat1_roleID' => 0));
                         $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'respondent', $respondentID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                         $inserted++;
                     }
                 }
             }
             $this->component->arResult['statusSuccess'] = 'Импортировано: ' . $inserted . ', проигнорировано: ' . $skipped;
         }
     }
     $statuses = $this->registry->getDbHelper('MembersHelper')->getLinearRespondentsStatusesNames();
     $this->component->arResult['statuses'] = $statuses;
     $sorts = array('respondentID' => 'respondentID', 'name' => 'name', 'surname' => 'surname', 'email' => 'email', 'position' => 'position', 'status' => 'status', 'private_lk_access_key' => 'private_lk_access_key');
     if (isset($_GET['sort']) && array_key_exists($_GET['sort'], $sorts)) {
         $sort = $_GET['sort'];
     } else {
         $sort = 'respondentID';
     }
     $order = isset($_GET['order']) && in_array($_GET['order'], array('asc', 'desc')) ? $_GET['order'] : 'asc';
     $filterQueryString = DataFilter::getFilterQueryString($_GET);
     $this->component->arResult['filterQueryString'] = $filterQueryString;
     // настройки фильтров для данных
     $filters = array(0 => array('title' => 'Имя', 'name' => 'name', 'type' => 'text', 'data_type' => 'string', 'field' => 'm.`name`'), 1 => array('title' => 'Фамилия', 'name' => 'surname', 'type' => 'text', 'data_type' => 'string', 'field' => 'm.`surname`'), 2 => array('title' => 'ID', 'name' => 'id', 'type' => 'text', 'data_type' => 'number', 'field' => 'r.`respondentID`'), 3 => array('title' => 'Текст', 'name' => 'text', 'type' => 'text', 'data_type' => 'string', 'field' => array('m.`search_text`')), 4 => array('title' => 'Статус ', 'name' => 'status', 'type' => 'select', 'data_type' => 'string', 'field' => 'r.`status`', 'values' => array(0 => 'Любой') + $statuses));
     $filterData = array('FILTERS' => $filters, 'BASE_URL' => '/projects/' . $context['project']['projectID'] . '/groups/' . (isset($_GET['TYPE']) && $_GET['TYPE'] ? $_GET['TYPE'] . '/' : '') . 'respondents/', 'SORT' => $sort, 'ORDER' => $order);
     // проверяем, введен ли фильтр
     $filterValue = DataFilter::getFilterValue($filters, $_GET, $this->registry->getDbConnect());
     if ($filterValue['valid']) {
         $filterData = array_merge($filterData, $filterValue);
     }
     // компонент отображения фильтра
     $context['APPLICATION']->IncludeComponent('ecoplay:data.filter', '', $filterData);
     // выполняем с респондентами действия
     if (isset($_POST['respondents_ids'])) {
         if (isset($_POST['all']) && $_POST['all']) {
             $selectedIDs = $this->registry->getDbHelper('LinearProjectsHelper')->getProjectRespondentsIDs($context['project']['projectID'], $filterValue['filter_strings']);
         } else {
             $selectedIDs = $_POST['respondents_ids'];
         }
         if (isset($_POST['mode'])) {
             if ($_POST['mode'] == 'send_notifications') {
                 $editedRespondents = $this->registry->getDbHelper('LinearProjectsHelper')->getRespondentsByIDs($selectedIDs);
                 $this->registry->getDbHelper('MembersHelper')->editRespondents($selectedIDs, array('need_remind' => 1));
                 foreach ($editedRespondents as $respondent) {
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'respondent', $respondent['respondentID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_CHANGE, $respondent);
                 }
             } elseif ($_POST['mode'] == 'reset') {
                 /*$editedRespondents =  $this->registry->getDbHelper('LinearProjectsHelper')->getRespondentsByIDs($selectedIDs);
                   
                   $this->registry->getDbHelper('MembersHelper')->editRespondents($selectedIDs, array(
                     'status'  => \Ecoplay\Helper\Db\MembersHelper::RESPONDENT_STATUS_ACTIVE,
                   ));
                   
                   foreach ($editedRespondents as $respondent) {
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'respondent', $respondent['respondentID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_CHANGE, $respondent);
                   }*/
                 $seances = $this->registry->getDbHelper('SeancesHelper')->findSeanceByProjectAndRespondentsIDs($context['project']['projectID'], $selectedIDs);
                 foreach ($seances as $seance) {
                     // деактивируем текущий сеанс
                     $this->registry->getDbHelper('SeancesHelper')->editSeance($seance['seanceID'], array('active' => 0, 'private_access_key' => ''));
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'seance', $seance['seanceID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_DELETE, $seance);
                     $this->registry->getDbHelper('MembersHelper')->editRespondent($seance['respondentID'], array('status' => 'active'));
                     // создаем новый сеанс
                     $BlankDataSource = new \Ecoplay\Model\BlankDataSource($this->registry->getDbConnect(), 0, 0);
                     $seanceKey = $BlankDataSource->addSeanceAndCookies($seance['private_access_key']);
                     $newSeance = $this->registry->getDbHelper('SeancesHelper')->findSeanceByKey($seanceKey);
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'seance', $newSeance['seanceID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                 }
             } elseif ($_POST['mode'] == 'return') {
                 if ($context['project']['allow_edit_seance_answers']) {
                     $seances = $this->registry->getDbHelper('SeancesHelper')->findSeanceByProjectAndRespondentsIDs($context['project']['projectID'], $selectedIDs);
                     foreach ($seances as $seance) {
                         if ($seance['state'] == \Ecoplay\Helper\Db\BlanksHelper::SEANCE_STATE_COMPLETE) {
                             $respondent = $this->registry->getDbHelper('MembersHelper')->findRespondentById($seance['respondentID']);
                             $this->registry->getDbHelper('MembersHelper')->editRespondent($seance['respondentID'], array('status' => \Ecoplay\Helper\Db\MembersHelper::RESPONDENT_STATUS_ACTIVE));
                             // обновляем сеанс
                             $lastScreen = $this->registry->getDbHelper('BlanksHelper')->getBlankPrevScreen($seance['blankID'], $seance['last_screenID']);
                             $this->registry->getDbHelper('SeancesHelper')->editSeance($seance['seanceID'], array('state' => \Ecoplay\Helper\Db\BlanksHelper::SEANCE_STATE_PROGRESS, 'last_screenID' => $lastScreen ? $lastScreen['screenID'] : 0));
                         }
                     }
                 }
             } else {
                 $newStatus = false;
                 switch ($_POST['mode']) {
                     case 'to_new':
                         $newStatus = \Ecoplay\Helper\Db\MembersHelper::RESPONDENT_STATUS_NEW;
                         break;
                     case 'to_active':
                         $newStatus = \Ecoplay\Helper\Db\MembersHelper::RESPONDENT_STATUS_ACTIVE;
                         break;
                     case 'to_complete':
                         $newStatus = \Ecoplay\Helper\Db\MembersHelper::RESPONDENT_STATUS_COMPLETE;
                         break;
                     case 'to_archive':
                         $newStatus = \Ecoplay\Helper\Db\MembersHelper::RESPONDENT_STATUS_ARCHIVE;
                         break;
                 }
                 if ($newStatus) {
                     $editedRespondents = $this->registry->getDbHelper('LinearProjectsHelper')->getRespondentsByIDs($selectedIDs);
                     $this->registry->getDbHelper('MembersHelper')->editRespondents($selectedIDs, array('status' => $newStatus));
                     foreach ($editedRespondents as $respondent) {
                         $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'respondent', $respondent['respondentID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_CHANGE, $respondent);
                     }
                 }
             }
         }
     }
     $arResult['selectedIDs'] = $selectedIDs;
     // получаем респондентов проекта
     $cnt = $this->registry->getDbHelper('LinearProjectsHelper')->getProjectRespondentsCount($context['project']['projectID'], $filterValue['filter_strings']);
     $onPage = 100;
     $pagesCnt = ceil($cnt / $onPage);
     $page = $_GET['PAGE'] && $_GET['PAGE'] <= $pagesCnt ? intval($_GET['PAGE']) : 1;
     $respondents = $this->registry->getDbHelper('LinearProjectsHelper')->getProjectRespondents($context['project']['projectID'], $page, $onPage, $sorts[$sort], $order, $filterValue['filter_strings']);
     $this->component->arResult['respondents'] = $respondents;
     $this->component->arResult['sort'] = $sort;
     $this->component->arResult['order'] = $order;
     $this->component->arResult['cntInfo'] = $pagesCnt == 1 ? $cnt : 0;
     $navResult = new \CDBResult();
     $navResult->NavPageCount = ceil($cnt / $onPage);
     $navResult->NavPageNomer = $page;
     $navResult->NavNum = 1;
     $navResult->NavPageSize = $onPage;
     $navResult->NavRecordCount = $cnt;
     $navResult->nPageWindow = 11;
     $context['APPLICATION']->IncludeComponent('ecoplay:system.pagenavigation', '', array('NAV_RESULT' => $navResult, 'NAV_URL' => '/projects/' . $context['project']['projectID'] . '/groups/' . (isset($_GET['TYPE']) && $_GET['TYPE'] ? $_GET['TYPE'] . '/' : '') . 'respondents/', 'NAV_QUERY_STRING' => 'sort=' . $sort . '&order=' . $order . ($filterQueryString ? '&' . $filterQueryString : '') . (isset($_GET['checkAll']) ? '&checkAll=1' : '')));
     $this->component->arResult['sessions'] = $this->registry->getDbHelper('ProjectsHelper')->getSessionsByProjectID($context['project']['projectID']);
     $languagesIDs = json_decode($context['project']['~languages']);
     $languagesSrc = $this->registry->getDbHelper('TranslationHelper')->getLanguagesByIDs($languagesIDs);
     $languages = array();
     foreach ($languagesSrc as $language) {
         $languages[$language['langID']] = $language['name'];
     }
     $this->component->arResult['languages'] = $languages;
     $this->component->arResult['project'] = $context['project'];
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Респонденты');
     $viewHelper = new \Ecoplay\View\Helper();
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('link' => '/', 'title' => 'Главная'), 1 => array('link' => '/projects/', 'title' => 'Проекты'), 2 => array('link' => '/projects/' . $context['project']['projectID'] . '/continuing/stat/', 'title' => $context['project']['project_name']), 3 => array('title' => 'Респонденты'))));
     $this->component->IncludeComponentTemplate("template_linear");
 }
示例#10
0
 public function execute($context)
 {
     $context['APPLICATION']->AddHeadScript('/js/forms.js');
     // проверка прав доступа к разделу
     if (!$this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'project_edit', $context['project']['projectID'])) {
         $this->registry->getModel('Auth')->restrict();
     }
     // выбираем языки проекта
     $projectLanguagesIds = json_decode($context['project']['~languages']);
     $languages = $this->registry->getDbHelper('TranslationHelper')->getSortedLanguages();
     $projectLanguages = array();
     foreach ($languages as $language) {
         if (in_array($language['langID'], $projectLanguagesIds)) {
             $projectLanguages[] = $language;
         }
     }
     $this->component->arResult['projectLanguages'] = $projectLanguages;
     switch ($this->getType()) {
         case '360':
             $events = array('fi' => array('name' => 'MailEvent_360_FirstInvite', 'title' => 'Первое уведомление респондента', 'replaces' => array('#EMAIL_FROM#' => 'email адрес отправителя письма', '#EMAIL_TO#' => 'email адрес на который отправляется письмо', '#ASSESS#' => 'Имя Фамилия оцениваемого (или список при групповой отправке)', '#RESPONDENT#' => 'Имя Фамилия того, кому отправляем письмо', '#RESPONDENT_LK_LINK#' => 'Ссылка на ЛК респондента', '#RESPONDENT_FILL_LINK#' => 'Ссылка на опросник респондента (недоступно при групповой отправке)')), 'nrn' => array('name' => 'MailEvent_360_NextRespondentNotification', 'title' => 'Последующее уведомление респондента', 'replaces' => array('#EMAIL_FROM#' => 'email адрес отправителя письма', '#EMAIL_TO#' => 'email адрес на который отправляется письмо', '#ASSESS#' => 'Имя Фамилия оцениваемого (или список при групповой отправке)', '#RESPONDENT#' => 'Имя Фамилия того, кому отправляем письмо', '#RESPONDENT_LK_LINK#' => 'Ссылка на ЛК респондента', '#RESPONDENT_FILL_LINK#' => 'Ссылка на опросник респондента (недоступно при групповой отправке)')), 'asr' => array('name' => 'MailEvent_360_AssessSelectRespondents', 'title' => 'Информирование оцениваемого о выборе респондентов', 'replaces' => array('#EMAIL_FROM#' => 'email адрес отправителя письма', '#EMAIL_TO#' => 'email адрес на который отправляется письмо', '#ASSESS#' => 'Имя Фамилия оцениваемого', '#ASSESS_LK_LINK#' => 'Ссылка на ЛК оцениваемого')), 'rsa' => array('name' => 'MailEvent_360_RespondentSelectAssess', 'title' => 'Информирование респондента о выборе оцениваемых', 'replaces' => array('#EMAIL_FROM#' => 'email адрес отправителя письма', '#EMAIL_TO#' => 'email адрес на который отправляется письмо', '#ASSESS#' => 'Имя Фамилия оцениваемого', '#ASSESS_LK_LINK#' => 'Ссылка на ЛК оцениваемого')), 'rasr' => array('name' => 'MailEvent_360_AssessSelectRespondentsRemind', 'title' => 'Напоминание оцениваемому о выборе респондентов', 'replaces' => array('#EMAIL_FROM#' => 'email адрес отправителя письма', '#EMAIL_TO#' => 'email адрес на который отправляется письмо', '#ASSESS#' => 'Имя Фамилия оцениваемого', '#ASSESS_LK_LINK#' => 'Ссылка на ЛК оцениваемого')), 'rrsa' => array('name' => 'MailEvent_360_RespondentSelectAssessRemind', 'title' => 'Напоминание респонденту о выборе оцениваемых', 'replaces' => array('#EMAIL_FROM#' => 'email адрес отправителя письма', '#EMAIL_TO#' => 'email адрес на который отправляется письмо', '#ASSESS#' => 'Имя Фамилия оцениваемого', '#ASSESS_LK_LINK#' => 'Ссылка на ЛК оцениваемого')), 'mr' => array('name' => 'MailEvent_360_MemeberReportNotification', 'title' => 'Информирование участника о доступности отчета', 'replaces' => array('#EMAIL_FROM#' => 'email адрес отправителя письма', '#EMAIL_TO#' => 'email адрес на который отправляется письмо', '#ASSESS#' => 'Имя Фамилия оцениваемого', '#REPORT_LINK#' => 'Ссылка на отчет')), 'dhr' => array('name' => 'MailEvent_360_DirectHeadReportNotification', 'title' => 'Информирование руководителя о доступности отчета', 'replaces' => array('#EMAIL_FROM#' => 'email адрес отправителя письма', '#EMAIL_TO#' => 'email адрес на который отправляется письмо', '#ASSESS#' => 'Имя Фамилия руководителя', '#REPORT_LINK#' => 'Ссылка на отчет', '#RESPONDENT_LK_LINK#' => 'Ссылка на ЛК респондента')), 'dn' => array('name' => 'MailEvent_360_DirectHeadNotification', 'title' => 'Информирование руководителя о необходимости подтвердить списки респондентов по подчиненным', 'replaces' => array('#EMAIL_FROM#' => 'email адрес отправителя письма', '#EMAIL_TO#' => 'email адрес на который отправляется письмо', '#DIRECT_HEAD#' => 'Имя Фамилия руководителя', '#ASSESS#' => 'Имя Фамилия подчиненного', '#LINK#' => 'Ссылка на страницу подтверждения')));
             break;
         case 'testing':
             $events = array('fi' => array('name' => 'MailEvent_Testing_FirstInvite', 'title' => 'Первое уведомление респондента', 'replaces' => array('#EMAIL_FROM#' => 'email адрес отправителя письма', '#EMAIL_TO#' => 'email адрес на который отправляется письмо', '#RESPONDENT#' => 'Имя Фамилия того, кому отправляем письмо', '#RESPONDENT_LK_LINK#' => 'Ссылка на ЛК респондента')), 'gkfi' => array('name' => 'MailEvent_Testing_GroupKey_FirstInvite', 'title' => 'Уведомление о групповой ссылке', 'replaces' => array('#EMAIL_FROM#' => 'email адрес отправителя письма', '#EMAIL_TO#' => 'email адрес на который отправляется письмо', '#RESPONDENT#' => 'Имя Фамилия того, кому отправляем письмо', '#GROUP_KEY_LINK#' => 'Групповая ссылка')), 'gknrn' => array('name' => 'MailEvent_Testing_GroupKey_Notification', 'title' => 'Напоминание о групповой ссылке', 'replaces' => array('#EMAIL_FROM#' => 'email адрес отправителя письма', '#EMAIL_TO#' => 'email адрес на который отправляется письмо', '#RESPONDENT#' => 'Имя Фамилия того, кому отправляем письмо', '#GROUP_KEY_LINK#' => 'Групповая ссылка')), 'mr' => array('name' => 'MailEvent_Testing_MailResend', 'title' => 'Напоминание о заполнении', 'replaces' => array('#EMAIL_FROM#' => 'email адрес отправителя письма', '#EMAIL_TO#' => 'email адрес на который отправляется письмо', '#RESPONDENT#' => 'Имя Фамилия того, кому отправляем письмо', '#RESPONDENT_LK_LINK#' => 'Ссылка на ЛК респондента')), 'rr' => array('name' => 'MailEvent_Testing_RespondentReport', 'title' => 'Письмо с последним отчетом тестируемого', 'replaces' => array('#EMAIL_FROM#' => 'email адрес отправителя письма', '#EMAIL_TO#' => 'email адрес на который отправляется письмо', '#RESPONDENT#' => 'Имя Фамилия того, кому отправляем письмо')));
             break;
         case 'linear':
             $events = array('fi' => array('name' => 'MailEvent_Linear_FirstInvite', 'title' => 'Первое уведомление респондента', 'replaces' => array('#EMAIL_FROM#' => 'email адрес отправителя письма', '#EMAIL_TO#' => 'email адрес на который отправляется письмо', '#RESPONDENT#' => 'Имя Фамилия того, кому отправляем письмо', '#RESPONDENT_LK_LINK#' => 'Ссылка на ЛК респондента', '#SEANCE_LINK#' => 'Ссылка на анкету')), 'nrn' => array('name' => 'MailEvent_Linear_NextRespondentNotification', 'title' => 'Последующее уведомление респондента', 'replaces' => array('#EMAIL_FROM#' => 'email адрес отправителя письма', '#EMAIL_TO#' => 'email адрес на который отправляется письмо', '#RESPONDENT#' => 'Имя Фамилия того, кому отправляем письмо', '#RESPONDENT_LK_LINK#' => 'Ссылка на ЛК респондента', '#SEANCE_LINK#' => 'Ссылка на анкету')), 'gkfi' => array('name' => 'MailEvent_Linear_GroupKey_FirstInvite', 'title' => 'Уведомление о групповой ссылке', 'replaces' => array('#EMAIL_FROM#' => 'email адрес отправителя письма', '#EMAIL_TO#' => 'email адрес на который отправляется письмо', '#RESPONDENT#' => 'Имя Фамилия того, кому отправляем письмо', '#GROUP_KEY_LINK#' => 'Групповая ссылка')), 'gknrn' => array('name' => 'MailEvent_Linear_GroupKey_Notification', 'title' => 'Напоминание о групповой ссылке', 'replaces' => array('#EMAIL_FROM#' => 'email адрес отправителя письма', '#EMAIL_TO#' => 'email адрес на который отправляется письмо', '#RESPONDENT#' => 'Имя Фамилия того, кому отправляем письмо', '#GROUP_KEY_LINK#' => 'Групповая ссылка')));
             break;
     }
     $this->component->arResult['events'] = $events;
     // ищем шаблоны проекта
     $projectTemplatesSrc = $this->registry->getDbHelper('EmailHelper')->getProjectTemplates($context['project']['projectID']);
     $projectTemplates = array();
     foreach ($projectTemplatesSrc as $template) {
         // определяем ключ ивента
         $ek = null;
         foreach ($events as $key => $event) {
             if ($event['name'] == $template['event']) {
                 $ek = $key;
                 break;
             }
         }
         if ($ek) {
             $templateData = array('from' => $template['from'], 'to' => $template['to'], 'is_html' => $template['is_html'], 'id' => $template['ID'], 'lang' => array());
             foreach ($projectLanguages as $language) {
                 if ($language['is_default']) {
                     $templateData['lang'][$language['abbr']] = array('theme' => $template['theme'], 'body' => $template['body']);
                 } else {
                     $translation = $this->registry->getDbHelper('TranslationHelper')->findTranslation('email_theme', $template['ID'], $language['langID']);
                     if ($translation) {
                         $templateData['lang'][$language['abbr']]['theme'] = $translation['value'];
                         $templateData['lang'][$language['abbr']]['theme_id'] = $translation['translationID'];
                     }
                     $translation = $this->registry->getDbHelper('TranslationHelper')->findTranslation('email_body', $template['ID'], $language['langID']);
                     if ($translation) {
                         $templateData['lang'][$language['abbr']]['body'] = $translation['value'];
                         $templateData['lang'][$language['abbr']]['body_id'] = $translation['translationID'];
                     }
                 }
             }
             $projectTemplates[$ek] = $templateData;
         }
     }
     $this->component->arResult['projectTemplates'] = $projectTemplates;
     $errors = array();
     if (isset($_POST['send'])) {
         $validations = array();
         $required = array();
         foreach ($events as $ek => $event) {
             $validations[$ek . '_from'] = 'anything';
             $validations[$ek . '_to'] = 'anything';
             $required[] = $ek . '_from';
             $required[] = $ek . '_to';
         }
         $validator = new \Ecoplay\Form\Validator($validations, $required, array());
         if (!$validator->validate($_POST)) {
             $errors = $validator->getErrors();
         } else {
             foreach ($events as $ek => $event) {
                 // заполняем шаблоны для каждого события
                 $translations = array();
                 $templateID = 0;
                 if (array_key_exists($ek, $projectTemplates)) {
                     // шаблон уже есть в базе, обновляем его
                     $templateData = array('from' => trim($_POST[$ek . '_from']), 'to' => trim($_POST[$ek . '_to']), 'is_html' => isset($_POST[$ek . '_is_html']) ? 1 : 0);
                     // обрабатываем языки
                     foreach ($projectLanguages as $language) {
                         if ($language['is_default']) {
                             $templateData['theme'] = trim($_POST[$ek . '_' . $language['abbr'] . '_theme']);
                             $templateData['body'] = trim($_POST[$ek . '_' . $language['abbr'] . '_body']);
                         } else {
                             $translations[$language['langID']] = array('theme' => trim($_POST[$ek . '_' . $language['abbr'] . '_theme']), 'body' => trim($_POST[$ek . '_' . $language['abbr'] . '_body']), 'lang' => $language['abbr']);
                         }
                     }
                     $this->registry->getDbHelper('EmailHelper')->editProjectTemplate($projectTemplates[$ek]['id'], $templateData);
                     $templateID = $projectTemplates[$ek]['id'];
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'email_template', $templateID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_CHANGE, $projectTemplatesSrc[$templateID]);
                 } else {
                     // шаблона в базе нет, добавляем его
                     $templateData = array('projectID' => $context['project']['projectID'], 'event' => $event['name'], 'from' => trim($_POST[$ek . '_from']), 'to' => trim($_POST[$ek . '_to']), 'is_html' => isset($_POST[$ek . '_is_html']) ? 1 : 0);
                     // обрабатываем языки
                     foreach ($projectLanguages as $language) {
                         if ($language['is_default']) {
                             $templateData['theme'] = trim($_POST[$ek . '_' . $language['abbr'] . '_theme']);
                             $templateData['body'] = trim($_POST[$ek . '_' . $language['abbr'] . '_body']);
                         } else {
                             $translations[$language['langID']] = array('theme' => trim($_POST[$ek . '_' . $language['abbr'] . '_theme']), 'body' => trim($_POST[$ek . '_' . $language['abbr'] . '_body']), 'lang' => $language['abbr']);
                         }
                     }
                     $templateID = $this->registry->getDbHelper('EmailHelper')->addProjectTemplate($templateData);
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'email_template', $templateID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                 }
                 foreach ($translations as $langID => $translation) {
                     if ($translation['theme']) {
                         $translationData = array('objectType' => 'email_theme', 'objectID' => $templateID, 'langID' => $langID, 'value' => $translation['theme'], 'projectID' => $context['project']['projectID']);
                         if ($projectTemplates[$ek]['lang'][$translation['lang']]['theme_id']) {
                             $this->registry->getDbHelper('TranslationHelper')->editTranslation($projectTemplates[$ek]['lang'][$translation['lang']]['theme_id'], $translationData);
                         } else {
                             $this->registry->getDbHelper('TranslationHelper')->addTranslation($translationData);
                         }
                     } elseif ($projectTemplates[$ek]['lang'][$translation['lang']]['theme_id']) {
                         // удаляем перевод
                         $this->registry->getDbHelper('TranslationHelper')->deleteTranslationByID($projectTemplates[$ek]['lang'][$translation['lang']]['theme_id']);
                     }
                     if ($translation['body']) {
                         $translationData = array('objectType' => 'email_body', 'objectID' => $templateID, 'langID' => $langID, 'value' => $translation['body'], 'projectID' => $context['project']['projectID']);
                         if ($projectTemplates[$ek]['lang'][$translation['lang']]['body_id']) {
                             $this->registry->getDbHelper('TranslationHelper')->editTranslation($projectTemplates[$ek]['lang'][$translation['lang']]['body_id'], $translationData);
                         } else {
                             $this->registry->getDbHelper('TranslationHelper')->addTranslation($translationData);
                         }
                     } elseif ($projectTemplates[$ek]['lang'][$translation['lang']]['body_id']) {
                         // удаляем перевод
                         $this->registry->getDbHelper('TranslationHelper')->deleteTranslationByID($projectTemplates[$ek]['lang'][$translation['lang']]['body_id']);
                     }
                 }
             }
             if (!isset($_GET['TYPE']) || !$_GET['TYPE']) {
                 LocalRedirect('/projects/' . $context['project']['projectID'] . '/settings/email/');
             } else {
                 LocalRedirect('/projects/' . $context['project']['projectID'] . '/settings/' . $_GET['TYPE'] . '/email/');
             }
         }
     }
     $viewHelper = new \Ecoplay\View\Helper();
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Почтовые шаблоны');
     $navigationLinks = array(0 => array('link' => '/', 'title' => 'Главная'), 1 => array('link' => '/projects/', 'title' => 'Проекты'), 2 => array('link' => '/projects/' . $context['project']['projectID'] . '/continuing/stat/', 'title' => $context['project']['project_name']), 3 => array('title' => 'Почтовые шаблоны'));
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation($navigationLinks));
     $this->component->arResult['errors'] = $viewHelper->prepareJsonErrors($errors);
     $this->component->IncludeComponentTemplate();
 }
示例#11
0
 public function execute($context)
 {
     $context['APPLICATION']->AddHeadScript('/js/forms.js');
     // проверка прав доступа к разделу
     if (!$this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'members', $context['project']['projectID'])) {
         $this->registry->getModel('Auth')->restrict();
     }
     $availableSessionsIDs = $this->registry->getModel('Auth')->getAvailableSessions($_SESSION['accesses'], $context['project']['projectID']);
     $member = $this->registry->getDbHelper('MembersHelper')->findById(intval($_GET['MEMBER_ID']));
     if (!$member) {
         LocalRedirect('/projects/' . $context['project']['projectID'] . '/settings/members/');
     }
     $this->component->arResult['member'] = $member;
     $languagesIDs = json_decode($context['project']['~languages']);
     $languagesSrc = $this->registry->getDbHelper('TranslationHelper')->getLanguagesByIDs($languagesIDs);
     $languages = array();
     foreach ($languagesSrc as $language) {
         $languages[$language['langID']] = $language['name'];
     }
     $this->component->arResult['languages'] = $languages;
     $this->component->arResult['languagesFull'] = $languagesSrc;
     // переводы участника
     $translationsSrc = $this->registry->getDbHelper('TranslationHelper')->getObjectAllTranslations(array('member_name', 'member_surname'), $member['projects_memberID']);
     $translations = array();
     foreach ($translationsSrc as $translation) {
         if (!array_key_exists($translation['langID'], $translations)) {
             $translations[$translation['langID']] = array();
         }
         $translations[$translation['langID']][$translation['objectType']] = $translation['value'];
     }
     $this->component->arResult['translations'] = $translations;
     // отчеты участника
     /*$reports = $this->registry->getDbHelper('ReportsHelper')->getReportsByMemberID($member['projects_memberID']);
       $this->component->arResult['reports'] = $reports;
       if (count($reports)) {
         $sessionsIDs = array();
         $generatorsIDs = array();
         foreach ($reports as $report) {
           if (!in_array($report['sessionID'], $sessionsIDs)) {
             $sessionsIDs[] = $report['sessionID'];
           }
           if (!in_array($report['report_generatorID'], $generatorsIDs)) {
             $generatorsIDs[] = $report['report_generatorID'];
           }
         }
         $this->component->arResult['sessions'] = $this->registry->getDbHelper('ProjectsHelper')->getSessionsByIDsKeyed($sessionsIDs);
         $this->component->arResult['generators'] = $this->registry->getDbHelper('ReportsHelper')->getGeneratorsCollectionByIds($generatorsIDs, true);
       }*/
     $sessions = $this->registry->getDbHelper('TestsHelper')->getSessionsByProjectID($context['project']['projectID']);
     $this->component->arResult['sessions'] = $sessions;
     $packagesIDs = array();
     foreach ($sessions as $session) {
         if (!in_array($session['packageID'], $packagesIDs)) {
             $packagesIDs[] = $session['packageID'];
         }
     }
     $this->component->arResult['packages'] = $this->registry->getDbHelper('TestsHelper')->getPackagesByIDs($packagesIDs);
     $this->component->arResult['progress_settings'] = $this->registry->getModel('Tests')->getProjectProgressSettings($context['project']['projectID']);
     $statuses = $this->registry->getDbHelper('MembersHelper')->getTestingRespondentsStatusesNames();
     $this->component->arResult['statuses'] = $statuses;
     $respondents = $this->registry->getDbHelper('TestsSeancesHelper')->getRespondentsByProjectIDAndMemberID($context['project']['projectID'], $member['projects_memberID']);
     $this->component->arResult['respondents'] = $respondents;
     $viewHelper = new \Ecoplay\View\Helper();
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Участник ' . $member['name'] . ' ' . $member['surname']);
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('title' => 'Главная', 'link' => '/'), 1 => array('title' => 'Проекты', 'link' => '/projects/'), 2 => array('link' => '/projects/' . $context['project']['projectID'] . '/continuing/info/', 'title' => $context['project']['project_name']), 3 => array('link' => '/projects/' . $context['project']['projectID'] . '/settings/members/', 'title' => 'Все участники'), 4 => array('title' => $member['name'] . ' ' . $member['surname']))));
     $this->component->IncludeComponentTemplate('testing/template');
 }
示例#12
0
 public function execute($context)
 {
     $context['APPLICATION']->AddHeadScript('/js/forms.js');
     $context['APPLICATION']->AddHeadScript('/js/icheck/icheck.min.js');
     $context['APPLICATION']->SetAdditionalCSS('/js/icheck/skins/minimal/eco.css');
     if (isset($_POST['type'])) {
         if ($_POST['type'] == 'edit') {
             // находим участника
             $member = $this->registry->getDbHelper('MembersHelper')->findById($_POST['memberID']);
             if ($member['email'] != $_POST['email'] && $_POST['email']) {
                 $sameEmailMember = $this->registry->getDbHelper('MembersHelper')->findByEmailAndProjectId($_POST['email'], $context['project']['projectID']);
                 $email = $sameEmailMember ? $member['email'] : $_POST['email'];
             } else {
                 $email = $member['email'];
             }
             $this->registry->getDbHelper('MembersHelper')->updateMember($member['projects_memberID'], $_POST['name'], $_POST['surname'], $_POST['position'], $email, $_POST['language'], $_POST['department']);
             $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'member', $member['projects_memberID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_CHANGE, $member);
         } elseif ($_POST['type'] == 'exist') {
             if (isset($_POST['member_id'])) {
                 // проверяем, может этот участник уже привязан к ключу
                 $linkExist = $this->registry->getDbHelper('LinearProjectsHelper')->isMemberLinkedToGroupKey($context['project']['projectID'], $context['groupKey']['group_keyID'], intval($_POST['member_id']));
                 if (!$linkExist) {
                     // добавляем привязку
                     $itemID = $this->registry->getDbHelper('LinearProjectsHelper')->addGroupKeyMember(array('projectID' => $context['project']['projectID'], 'group_keyID' => $context['groupKey']['group_keyID'], 'memberID' => intval($_POST['member_id'])));
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'group_key_member', $itemID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                 }
             }
         } else {
             // пробуем добавить участника
             $validations = array('name' => 'anything', 'surname' => 'anything', 'email' => 'email', 'position' => 'anything', 'department' => 'anything', 'language' => 'identifier');
             $required = array('name', 'email', 'language');
             $validator = new \Ecoplay\Form\Validator($validations, $required, array());
             if ($validator->validate($_POST)) {
                 // проверяем чтобы не было уже участника с таким email
                 if (!$this->registry->getDbHelper('MembersHelper')->findByEmailAndProjectId($_POST['email'], $context['project']['projectID'])) {
                     $memberID = $this->registry->getDbHelper('MembersHelper')->addMember(trim($_POST["name"]), trim($_POST["surname"]), trim($_POST["position"]), trim($_POST["email"]), $context['project']['projectID'], $this->registry->getModel('Auth')->generateUid('prep_projects_members', 'private_lk_access_key'), intval($_POST["language"]), 1, 'new', trim($_POST['department']));
                     $eventListener = new EventListener($this->registry, $context['project'], $_SERVER["DOCUMENT_ROOT"] . '/');
                     $eventListener->executeEvent('MemberAdded', array('memberID' => $memberID), true);
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'member', $memberID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                     // добавляем привязку
                     $itemID = $this->registry->getDbHelper('LinearProjectsHelper')->addGroupKeyMember(array('projectID' => $context['project']['projectID'], 'group_keyID' => $context['groupKey']['group_keyID'], 'memberID' => $memberID));
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'group_key_member', $itemID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                 } else {
                     $this->component->arResult['statusError'] = 'Участник с таким email (' . $_POST['email'] . ') уже существует';
                 }
             }
         }
     }
     $selectedIDs = array();
     if (isset($_POST['items_ids'])) {
         if (isset($_POST['all']) && $_POST['all']) {
             $selectedIDs = $this->registry->getDbHelper('LinearProjectsHelper')->getGroupKeyMembersIDsByProjectIDAndKeyID($context['project']['projectID'], $context['groupKey']['group_keyID']);
         } else {
             $selectedIDs = $_POST['items_ids'];
         }
         if (isset($_POST['mode'])) {
             if ($_POST['mode'] == 'delete') {
                 $deletedItems = $this->registry->getDbHelper('LinearProjectsHelper')->getGroupKeyMembersByIDs($selectedIDs);
                 $this->registry->getDbHelper('LinearProjectsHelper')->deleteGroupKeyMembersByIDs($selectedIDs);
                 foreach ($deletedItems as $item) {
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'group_key_member', $item['itemID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_DELETE, $item);
                 }
             } elseif ($_POST['mode'] == 'email') {
                 $emailedItems = $this->registry->getDbHelper('LinearProjectsHelper')->getGroupKeyMembersByIDs($selectedIDs);
                 $this->registry->getDbHelper('LinearProjectsHelper')->editGroupKeyMembers($selectedIDs, array('send_email' => 1));
                 foreach ($emailedItems as $item) {
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'group_key_member', $item['itemID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_CHANGE, $item);
                 }
             }
         }
     }
     $arResult['selectedIDs'] = $selectedIDs;
     if ($_FILES["filepath"] && !$_FILES['filepath']['error']) {
         // обрабатываем загруженный файл
         $csvImporter = new \Ecoplay\Import\Csv($_FILES["filepath"]["tmp_name"], $_SERVER["DOCUMENT_ROOT"] . "/temp/csv/");
         $data = $csvImporter->parse();
         $inserted = $skipped = 0;
         $validations = array(0 => 'anything', 1 => 'anything', 2 => 'email', 3 => 'anything', 4 => 'anything');
         $required = array(2);
         $validator = new \Ecoplay\Form\Validator($validations, $required, array());
         $projectLangID = $this->registry->getModel('Projects')->getDefaultLangID($context['project']);
         $languageIndex = $csvImporter->getColumnIndex('Язык');
         $languagesIDs = array();
         $availableLanguages = $this->registry->getDbHelper('TranslationHelper')->getLanguagesByIDs(json_decode($context['project']['~languages']));
         foreach ($availableLanguages as $language) {
             $languagesIDs[$language['abbr']] = $language['langID'];
         }
         foreach ($data as $row) {
             // валидируем исходные данные
             if (!$validator->validate($row)) {
                 $skipped++;
             } elseif (!$row[0] && !$row[1]) {
                 // должно быть хотябы или имя, или фамилия
                 $skipped++;
             } else {
                 // ищем такого участника уже в базе
                 $member = $this->registry->getDbHelper('MembersHelper')->findByEmailAndProjectId($row[2], $context['project']['projectID']);
                 if (!$member) {
                     // добавляем участника
                     // определяем язык по структуре
                     $staff = $this->registry->getDbHelper('MembersHelper')->findStaffByProjectIDAndEmail($context['project']['projectID'], $row[2]);
                     $langID = $languageIndex && $row[$languageIndex] && array_key_exists($row[$languageIndex], $languagesIDs) ? $languagesIDs[$row[$languageIndex]] : $projectLangID;
                     $memberID = $this->registry->getDbHelper('MembersHelper')->addMember($row[0], $row[1], $row[3], $row[2], $context['project']['projectID'], $this->registry->getModel('Auth')->generateUid('prep_projects_members', 'private_lk_access_key', false), $langID, 1, 'new', $row[4]);
                     $eventListener = new EventListener($this->registry, $context['project'], $_SERVER["DOCUMENT_ROOT"] . '/');
                     $eventListener->executeEvent('MemberAdded', array('memberID' => $memberID), true);
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'member', $memberID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                 } else {
                     $memberID = $member['projects_memberID'];
                 }
                 if ($this->registry->getDbHelper('LinearProjectsHelper')->isMemberLinkedToGroupKey($context['project']['projectID'], $context['groupKey']['group_keyID'], $memberID)) {
                     // такой оцениваемый уже есть
                     $skipped++;
                 } else {
                     // добавляем привязку
                     $itemID = $this->registry->getDbHelper('LinearProjectsHelper')->addGroupKeyMember(array('projectID' => $context['project']['projectID'], 'group_keyID' => $context['groupKey']['group_keyID'], 'memberID' => intval($memberID)));
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'group_key_member', $itemID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                     $inserted++;
                 }
             }
         }
         $this->component->arResult['statusSuccess'] = 'Импортировано: ' . $inserted . ', проигнорировано: ' . $skipped;
     }
     $cnt = $this->registry->getDbHelper('TestsHelper')->getGroupKeyLinkedMembersCount($context['project']['projectID'], $context['groupKey']['group_keyID']);
     $onPage = 100;
     $pagesCnt = ceil($cnt / $onPage);
     $page = $_GET['PAGE'] && $_GET['PAGE'] <= $pagesCnt ? intval($_GET['PAGE']) : 1;
     $this->component->arResult['cntInfo'] = $pagesCnt == 1 ? $cnt : 0;
     $members = $this->registry->getDbHelper('TestsHelper')->getGroupKeyLinkedMembers($context['project']['projectID'], $context['groupKey']['group_keyID'], $page, $onPage);
     $this->component->arResult['members'] = $members;
     $this->component->arResult['groupKey'] = $context['groupKey'];
     $languagesIDs = json_decode($context['project']['~languages']);
     $languagesSrc = $this->registry->getDbHelper('TranslationHelper')->getLanguagesByIDs($languagesIDs);
     $languages = array();
     foreach ($languagesSrc as $language) {
         $languages[$language['langID']] = $language['name'];
     }
     $this->component->arResult['languages'] = $languages;
     $this->component->IncludeComponentTemplate('linear/table');
     $navResult = new \CDBResult();
     $navResult->NavPageCount = ceil($cnt / $onPage);
     $navResult->NavPageNomer = $page;
     $navResult->NavNum = 1;
     $navResult->NavPageSize = $onPage;
     $navResult->NavRecordCount = $cnt;
     $navResult->nPageWindow = 11;
     $context['APPLICATION']->IncludeComponent('ecoplay:system.pagenavigation', '', array('NAV_RESULT' => $navResult, 'NAV_URL' => '/projects/' . $context['project']['projectID'] . '/settings/groupkeys/' . $context['groupKey']['group_keyID'] . '/members/', 'NAV_QUERY_STRING' => isset($_GET['checkAll']) ? 'checkAll=1' : ''));
     $viewHelper = new \Ecoplay\View\Helper();
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Респонденты группового ключа');
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('link' => '/', 'title' => 'Главная'), 1 => array('link' => '/projects/', 'title' => 'Проекты'), 2 => array('link' => '/projects/' . $context['project']['projectID'] . '/continuing/stat/', 'title' => $context['project']['project_name']), 3 => array('link' => '/projects/' . $context['project']['projectID'] . '/settings/groupkeys/', 'title' => ' Групповые ключи'), 4 => array('title' => $context['groupKey']['name']), 5 => array('title' => 'Список Респондентов'))));
     $this->component->IncludeComponentTemplate('linear/template');
 }
示例#13
0
 public function execute($context)
 {
     // проверка прав доступа к разделу
     if (!$this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'members', $context['project']['projectID'])) {
         $this->registry->getModel('Auth')->restrict();
     }
     $context['APPLICATION']->AddHeadScript('/js/forms.js');
     $context['APPLICATION']->AddHeadScript('/js/icheck/icheck.min.js');
     $context['APPLICATION']->SetAdditionalCSS('/js/icheck/skins/minimal/eco.css');
     $availableSessionsIDs = $this->registry->getModel('Auth')->getAvailableSessions($_SESSION['accesses'], $context['project']['projectID']);
     $viewHelper = new \Ecoplay\View\Helper();
     if (count($availableSessionsIDs)) {
         $selectedIDs = array();
         $sorts = array('project_memberID' => 'project_memberID', 'name' => 'name', 'surname' => 'surname', 'email' => 'email', 'position' => 'position', 'private_lk_access_key' => 'private_lk_access_key', 'amount' => 'amount', 'seances' => 'seances');
         if (isset($_GET['sort']) && array_key_exists($_GET['sort'], $sorts)) {
             $sort = $_GET['sort'];
         } else {
             $sort = 'project_memberID';
         }
         $order = isset($_GET['order']) && in_array($_GET['order'], array('asc', 'desc')) ? $_GET['order'] : 'asc';
         $filterQueryString = DataFilter::getFilterQueryString($_GET);
         $this->component->arResult['filterQueryString'] = $filterQueryString;
         // настройки фильтров для данных
         $filters = array(0 => array('title' => 'Имя', 'name' => 'name', 'type' => 'text', 'data_type' => 'string', 'field' => 'pm.`name`'), 1 => array('title' => 'Фамилия', 'name' => 'surname', 'type' => 'text', 'data_type' => 'string', 'field' => 'pm.`surname`'), 2 => array('title' => 'ID', 'name' => 'id', 'type' => 'text', 'data_type' => 'number', 'field' => 'r.`respondentID`'), 3 => array('title' => 'Текст', 'name' => 'text', 'type' => 'text', 'data_type' => 'string', 'field' => array('pm.`search_text`')), 4 => array('title' => 'Анкет', 'name' => 'amount', 'type' => 'range', 'data_type' => 'number', 'field' => '`amount`'));
         $filterData = array('FILTERS' => $filters, 'BASE_URL' => '/projects/' . $context['project']['projectID'] . '/groups/' . (isset($_GET['TYPE']) && $_GET['TYPE'] ? $_GET['TYPE'] . '/' : '') . 'respondents/', 'SORT' => $sort, 'ORDER' => $order);
         // проверяем, введен ли фильтр
         $filterValue = DataFilter::getFilterValue($filters, $_GET, $this->registry->getDbConnect());
         if ($filterValue['valid']) {
             $filterData = array_merge($filterData, $filterValue);
         }
         // компонент отображения фильтра
         $context['APPLICATION']->IncludeComponent('ecoplay:data.filter', '', $filterData);
         $cnt = $this->registry->getDbHelper('MembersHelper')->getRespondentsCountByProjectIDAndSessionsIds($context['project']['projectID'], $availableSessionsIDs, $filterValue['filter_strings']);
         $onPage = 100;
         $pagesCnt = ceil($cnt / $onPage);
         $page = $_GET['PAGE'] && $_GET['PAGE'] <= $pagesCnt ? intval($_GET['PAGE']) : 1;
         // отправляем email уведомления
         if (isset($_POST['respondents_ids'])) {
             if (isset($_POST['all']) && $_POST['all']) {
                 $selectedIDs = $this->registry->getDbHelper('MembersHelper')->getRespondentsIDsByProjectIDAndSessionsIds($context['project']['projectID'], $availableSessionsIDs, $filterValue['filter_strings']);
             } else {
                 $selectedIDs = $_POST['respondents_ids'];
             }
             if (isset($_POST['mode']) && $_POST['mode'] == 'send_notifications') {
                 $emailedRespondents = $this->registry->getDbHelper('MembersHelper')->getMembersRespondentsForNotification($context['project']['projectID'], $selectedIDs);
                 $this->registry->getDbHelper('MembersHelper')->editRespondents(array_keys($emailedRespondents), array('need_remind' => 1));
                 $this->registry->getModel('ActionsLogger')->logMultiSimple($context['USER']->GetID(), 'respondent', array_keys($emailedRespondents), \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_NOTIFY);
             }
         }
         $this->component->arResult['selectedIDs'] = $selectedIDs;
         $respondents = $this->registry->getDbHelper('MembersHelper')->getRespondentsByProjectIDAndSessionsIdsPaged($context['project']['projectID'], $availableSessionsIDs, $page, $onPage, $sorts[$sort], $order, $filterValue['filter_strings']);
         $this->component->arResult['respondents'] = $respondents;
         if (isset($_GET['checkAll'])) {
             $selectedIDs = array();
             foreach ($respondents as $responent) {
                 $selectedIDs[] = $responent['project_memberID'];
             }
             $this->component->arResult['selectedIDs'] = $selectedIDs;
         }
         $fillings = array();
         $emailsCnt = array();
         if (count($respondents)) {
             $membersIDs = array();
             foreach ($respondents as $respondent) {
                 $membersIDs[] = $respondent['project_memberID'];
             }
             $fillings = $this->registry->getDbHelper('MembersHelper')->getRespondentsFillingsByMembersIDs($context['project']['projectID'], $availableSessionsIDs, $membersIDs);
             $emailsCnt = $this->registry->getDbHelper('MembersHelper')->getMembersRespondentsAssessForNotificationCnt($context['project']['projectID'], $membersIDs);
         }
         $this->component->arResult['fillings'] = $fillings;
         $this->component->arResult['emailsCnt'] = $emailsCnt;
         $this->component->arResult['sort'] = $sort;
         $this->component->arResult['order'] = $order;
         $this->component->arResult['cntInfo'] = $pagesCnt == 1 ? $cnt : 0;
         // выводим таблицу с данными
         $this->component->IncludeComponentTemplate('table');
         $navResult = new \CDBResult();
         $navResult->NavPageCount = ceil($cnt / $onPage);
         $navResult->NavPageNomer = $page;
         $navResult->NavNum = 1;
         $navResult->NavPageSize = $onPage;
         $navResult->NavRecordCount = $cnt;
         $navResult->nPageWindow = 11;
         $context['APPLICATION']->IncludeComponent('ecoplay:system.pagenavigation', '', array('NAV_RESULT' => $navResult, 'NAV_URL' => '/projects/' . $context['project']['projectID'] . '/groups/' . (isset($_GET['TYPE']) && $_GET['TYPE'] ? $_GET['TYPE'] . '/' : '') . 'respondents/', 'NAV_QUERY_STRING' => 'sort=' . $sort . '&order=' . $order . ($filterQueryString ? '&' . $filterQueryString : '') . (isset($_GET['checkAll']) ? '&checkAll=1' : '')));
         /*$this->component->arResult['cnt'] = count($respondents);
           $this->component->arResult['table_data'] = $viewHelper->prepareJsonDataForTable($respondents, array('respondentID', 'name', 'surname', 'email', 'position', 'private_lk_access_key', 'amount', 'seances'));*/
     } else {
         //$this->component->arResult['table_data'] = null;
         $this->component->arResult['respondents'] = null;
     }
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Респонденты');
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('link' => '/', 'title' => 'Главная'), 1 => array('link' => '/projects/', 'title' => 'Проекты'), 2 => array('link' => '/projects/' . $context['project']['projectID'] . '/continuing/stat/', 'title' => $context['project']['project_name']), 3 => array('title' => 'Респонденты'))));
     $this->component->IncludeComponentTemplate();
 }
示例#14
0
 public function execute($context)
 {
     $context['APPLICATION']->AddHeadScript('/js/forms.js');
     // проверка прав доступа к разделу
     if (!$this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'members', $context['project']['projectID'])) {
         $this->registry->getModel('Auth')->restrict();
     }
     $this->component->arResult['project'] = $context['project'];
     $availableSessionsIDs = $this->registry->getModel('Auth')->getAvailableSessions($_SESSION['accesses'], $context['project']['projectID']);
     $member = $this->registry->getDbHelper('MembersHelper')->findById(intval($_GET['MEMBER_ID']));
     if (!$member) {
         LocalRedirect('/projects/' . $context['project']['projectID'] . '/settings/members/');
     }
     $this->component->arResult['member'] = $member;
     $languagesIDs = json_decode($context['project']['~languages']);
     $languagesSrc = $this->registry->getDbHelper('TranslationHelper')->getLanguagesByIDs($languagesIDs);
     $languages = array();
     foreach ($languagesSrc as $language) {
         $languages[$language['langID']] = $language['name'];
     }
     $this->component->arResult['languages'] = $languages;
     $this->component->arResult['languagesFull'] = $languagesSrc;
     // переводы участника
     $translationsSrc = $this->registry->getDbHelper('TranslationHelper')->getObjectAllTranslations(array('member_name', 'member_surname'), $member['projects_memberID']);
     $translations = array();
     foreach ($translationsSrc as $translation) {
         if (!array_key_exists($translation['langID'], $translations)) {
             $translations[$translation['langID']] = array();
         }
         $translations[$translation['langID']][$translation['objectType']] = $translation['value'];
     }
     $this->component->arResult['translations'] = $translations;
     // информация об оцениваемом участника
     $memberAssess = $this->registry->getDbHelper('MembersHelper')->findAssessByProjectIDAndMemberID($context['project']['projectID'], $member['projects_memberID']);
     $this->component->arResult['memberAssess'] = $memberAssess;
     if ($memberAssess) {
         $this->component->arResult['assessStatuses'] = $this->registry->getDbHelper('MembersHelper')->getAssessStatusesNames();
         $lastSend = null;
         $lastSendTime = 0;
         if ($memberAssess['status'] == \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_SELECT_RESPONDENTS) {
             $lastSend = $memberAssess['last_select_respondents_email'] == '0000-00-00 00:00:00' ? false : date('d.m.Y H:i:s', strtotime($memberAssess['last_select_respondents_email']));
             $lastSendTime = $memberAssess['last_select_respondents_email'] == '0000-00-00 00:00:00' ? 0 : strtotime($memberAssess['last_select_respondents_email']);
         } elseif ($memberAssess['status'] == \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_SELECT_ASSESS) {
             $lastSend = $memberAssess['last_select_assess_email'] == '0000-00-00 00:00:00' ? false : date('d.m.Y H:i:s', strtotime($memberAssess['last_select_assess_email']));
             $lastSendTime = $memberAssess['last_select_assess_email'] == '0000-00-00 00:00:00' ? 0 : strtotime($memberAssess['last_select_assess_email']);
         }
         $this->component->arResult['lastSend'] = $lastSend;
         $nextSend = false;
         if (!$context['project']['freeze_email'] && $lastSend) {
             if ($lastSendTime) {
                 $nextSend = date('d.m.Y H:i:s', $lastSendTime + $context['project']['remind_after'] * 24 * 60 * 60);
             } else {
                 $mod = time() % 60;
                 $nextSend = date('d.m.Y H:i:s', time() + 60 - $mod);
             }
         }
         $this->component->arResult['nextSend'] = $nextSend;
     }
     // отчеты участника
     $reports = $this->registry->getDbHelper('ReportsHelper')->getReportsByMemberID($member['projects_memberID']);
     $this->component->arResult['reports'] = $reports;
     if (count($reports)) {
         $sessionsIDs = array();
         $generatorsIDs = array();
         foreach ($reports as $report) {
             if (!in_array($report['sessionID'], $sessionsIDs)) {
                 $sessionsIDs[] = $report['sessionID'];
             }
             if (!in_array($report['report_generatorID'], $generatorsIDs)) {
                 $generatorsIDs[] = $report['report_generatorID'];
             }
         }
         $this->component->arResult['sessions'] = $this->registry->getDbHelper('ProjectsHelper')->getSessionsByIDsKeyed($sessionsIDs);
         $this->component->arResult['generators'] = $this->registry->getDbHelper('ReportsHelper')->getGeneratorsCollectionByIds($generatorsIDs, true);
     }
     // оценивающие участника
     $respondents = $this->registry->getDbHelper('MembersHelper')->getRespondentsInfoByAssessMemberID($member['projects_memberID'], $context['project']['projectID'], $availableSessionsIDs);
     $this->component->arResult['respondents'] = $respondents;
     // оцениваемые участника
     $assess = $this->registry->getDbHelper('MembersHelper')->getAssessInfoByRespondentMemberID($member['projects_memberID'], $context['project']['projectID'], $availableSessionsIDs);
     $this->component->arResult['assess'] = $assess;
     $viewHelper = new \Ecoplay\View\Helper();
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Участник ' . $member['name'] . ' ' . $member['surname']);
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('title' => 'Главная', 'link' => '/'), 1 => array('title' => 'Проекты', 'link' => '/projects/'), 2 => array('link' => '/projects/' . $context['project']['projectID'] . '/continuing/info/', 'title' => $context['project']['project_name']), 3 => array('link' => '/projects/' . $context['project']['projectID'] . '/settings/members/', 'title' => 'Все участники'), 4 => array('title' => $member['name'] . ' ' . $member['surname']))));
     $this->component->IncludeComponentTemplate();
 }
示例#15
0
 public function execute($context)
 {
     // проверка прав доступа к разделу
     if (!$this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'members', $context['project']['projectID'])) {
         $this->registry->getModel('Auth')->restrict();
     }
     $context['APPLICATION']->AddHeadScript('/js/forms.js');
     $context['APPLICATION']->AddHeadScript('/js/icheck/icheck.min.js');
     $context['APPLICATION']->SetAdditionalCSS('/js/icheck/skins/minimal/eco.css');
     $availableSessionsIDs = $this->registry->getModel('Auth')->getAvailableSessions($_SESSION['accesses'], $context['project']['projectID'], $context['project']['project_type']);
     $viewHelper = new \Ecoplay\View\Helper();
     if (count($availableSessionsIDs)) {
         // нормогруппы для генераторов отчетов
         $projectSettings = json_decode($context['project']['~param_roles'], true);
         $haveValuation = false;
         if (array_key_exists('rgenerators', $projectSettings) && $projectSettings['rgenerators']) {
             $generatorsSrc = $this->registry->getDbHelper('ReportsHelper')->getGeneratorsCollectionByIds($projectSettings['rgenerators']);
             foreach ($generatorsSrc as $generator) {
                 if ($generator['use_valuation_group']) {
                     $haveValuation = true;
                     break;
                 }
             }
         }
         if ($haveValuation) {
             //  определяем тип админа (экопси или нет)
             $isEcopsy = false;
             $groups = $this->registry->getDbHelper('UsersHelper')->getUserGroups($context['USER']->GetID());
             if (count($groups) > 1) {
                 $isEcopsy = true;
             } else {
                 $clientID = $this->registry->getDbHelper('UsersHelper')->getUserClient($context['USER']->GetID());
                 if ($clientID == \Ecoplay\Helper\Db\ClientsHelper::ECOPSY_CLIENT_ID) {
                     $isEcopsy = true;
                 }
             }
             $this->component->arResult['valuationGroups'] = $this->registry->getDbHelper('TestsHelper')->getProjectValuationGroups($context['project']['projectID'], $isEcopsy);
         }
         $this->component->arResult['haveValuation'] = $haveValuation;
         if (isset($_POST['type'])) {
             if ($_POST['type'] == 'edit') {
                 // находим респондента
                 $respondent = $this->registry->getDbHelper('MembersHelper')->findRespondentById($_POST['respondentID']);
                 if ($respondent) {
                     // обновляем участника
                     $member = $this->registry->getDbHelper('MembersHelper')->findById($respondent['project_memberID']);
                     if ($member['email'] != $_POST['email'] && $_POST['email']) {
                         $sameEmailMember = $this->registry->getDbHelper('MembersHelper')->findByEmailAndProjectId($_POST['email'], $context['project']['projectID']);
                         $email = $sameEmailMember ? $member['email'] : $_POST['email'];
                     } else {
                         $email = $member['email'];
                     }
                     $this->registry->getDbHelper('MembersHelper')->updateMember($respondent['project_memberID'], $_POST['name'], $_POST['surname'], $_POST['position'], $email, $_POST['language'], $_POST['department']);
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'member', $respondent['project_memberID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_CHANGE, $member);
                     if ($respondent['sessionID'] != $_POST['session_id']) {
                         $seance = $this->registry->getDbHelper('TestsSeancesHelper')->findSeanceByProjectIDAndRespondentID($context['project']['projectID'], $respondent['respondentID']);
                         if (!$seance) {
                             $this->registry->getDbHelper('MembersHelper')->editRespondent($respondent['respondentID'], array('sessionID' => $_POST['session_id']));
                             $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'respondent', $respondent['respondentID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_CHANGE, $respondent);
                         }
                     }
                 }
                 echo 'Редактирование<br/>';
             } elseif ($_POST['type'] == 'exist') {
                 if (isset($_POST['member_id'])) {
                     // проверяем, может уже есть респондент с таким участником
                     //$existRespondent = $this->registry->getDbHelper('MembersHelper')->findRespondentByMemberID($context['project']['projectID'], $_POST['member_id']);
                     //if (!$existRespondent) {
                     // добавляем респондента
                     $respondentID = $this->registry->getDbHelper('MembersHelper')->addRespondent(array('project_memberID' => intval($_POST['member_id']), 'active' => 1, 'projectID' => $context['project']['projectID'], 'sessionID' => intval($_POST['session_id']), 'stat1_assessID' => 0, 'status' => \Ecoplay\Helper\Db\MembersHelper::RESPONDENT_STATUS_NEW, 'private_access_key' => $this->registry->getModel('Auth')->generateUid('prep_respondents', 'private_access_key'), 'stat1_roleID' => 0, 'last_email' => '0000-00-00 00:00:00', 'langID' => 0, 'last_entrance' => '0000-00-00 00:00:00', 'deny_deletion' => 0, 'addedd_by_assess' => 0, 'need_remind' => 0));
                     $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'respondent', $respondentID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                 }
                 //}
             } else {
                 // пробуем добавить участника
                 $validations = array('name' => 'anything', 'surname' => 'anything', 'email' => 'email', 'position' => 'anything', 'department' => 'anything', 'language' => 'identifier');
                 $required = array('name', 'email', 'language');
                 $validator = new \Ecoplay\Form\Validator($validations, $required, array());
                 if ($validator->validate($_POST)) {
                     // проверяем чтобы не было уже участника с таким email
                     if (!$this->registry->getDbHelper('MembersHelper')->findByEmailAndProjectId($_POST['email'], $context['project']['projectID'])) {
                         $memberID = $this->registry->getDbHelper('MembersHelper')->addMember(trim($_POST["name"]), trim($_POST["surname"]), trim($_POST["position"]), trim($_POST["email"]), $context['project']['projectID'], $this->registry->getModel('Auth')->generateUid('prep_projects_members', 'private_lk_access_key'), intval($_POST["language"]), 1, 'new', trim($_POST['department']));
                         $eventListener = new EventListener($this->registry, $context['project'], $_SERVER["DOCUMENT_ROOT"] . '/');
                         $eventListener->executeEvent('MemberAdded', array('memberID' => $memberID), true);
                         $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'member', $memberID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                         // добавляем респондента
                         $respondentID = $this->registry->getDbHelper('MembersHelper')->addRespondent(array('project_memberID' => $memberID, 'active' => 1, 'projectID' => $context['project']['projectID'], 'sessionID' => intval($_POST['session_id']), 'stat1_assessID' => 0, 'status' => \Ecoplay\Helper\Db\MembersHelper::RESPONDENT_STATUS_NEW, 'private_access_key' => $this->registry->getModel('Auth')->generateUid('prep_respondents', 'private_access_key'), 'stat1_roleID' => 0, 'last_email' => '0000-00-00 00:00:00', 'langID' => 0, 'last_entrance' => '0000-00-00 00:00:00', 'deny_deletion' => 0, 'addedd_by_assess' => 0, 'need_remind' => 0));
                         $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'respondent', $respondentID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                     } else {
                         $this->component->arResult['statusError'] = 'Участник с таким email (' . $_POST['email'] . ') уже существует';
                     }
                 }
             }
         }
         if ($_FILES["filepath"] && !$_FILES['filepath']['error']) {
             $sessionID = (int) $_POST["fgroup"];
             if ($sessionID) {
                 $session = $this->registry->getDbHelper('TestsHelper')->findSessionByID($sessionID);
             }
             // обрабатываем загруженный файл
             $csvImporter = new \Ecoplay\Import\Csv($_FILES["filepath"]["tmp_name"], $_SERVER["DOCUMENT_ROOT"] . "/temp/csv/");
             $data = $csvImporter->parse();
             $sessionIndex = $csvImporter->getColumnIndex('Группа');
             if (!((!$sessionIndex || !$data[0][$sessionIndex]) && (!$sessionID || !$session))) {
                 // определяем группу
                 if ($sessionIndex && $data[0][$sessionIndex]) {
                     // ищем группу
                     $session = $this->registry->getDbHelper('TestsHelper')->findSessionByProjectIDAndName($context['project']['projectID'], $data[0][$sessionIndex]);
                     if ($session) {
                         $sessionID = $session['sessionID'];
                     } else {
                         /*$session = array(
                             'name'  => $data[0][$sessionIndex],
                             'active'  => 1,
                             'status'  => 'active',
                             'projectID'  => $context['project']['projectID'],
                           );
                           $sessionID = $this->registry->getDbHelper('TestsHelper')->addSession($session);
                           $session['sessionID'] = $sessionID;*/
                         $sessionID = 0;
                     }
                 }
                 $inserted = $skipped = 0;
                 $validations = array(0 => 'anything', 1 => 'anything', 2 => 'email', 3 => 'anything', 4 => 'anything');
                 $required = array(2);
                 $validator = new \Ecoplay\Form\Validator($validations, $required, array());
                 $projectLangID = $this->registry->getModel('Projects')->getDefaultLangID($context['project']);
                 $languageIndex = $csvImporter->getColumnIndex('Язык');
                 $languagesIDs = array();
                 $availableLanguages = $this->registry->getDbHelper('TranslationHelper')->getLanguagesByIDs(json_decode($context['project']['~languages']));
                 foreach ($availableLanguages as $language) {
                     $languagesIDs[$language['abbr']] = $language['langID'];
                 }
                 $rowIndex = 0;
                 $skippedRows = array();
                 foreach ($data as $row) {
                     $rowIndex++;
                     if ($sessionIndex && $row[$sessionIndex] && (!$sessionID || $row[$sessionIndex] != $session['name'])) {
                         // ищем группу
                         $session = $this->registry->getDbHelper('TestsHelper')->findSessionByProjectIDAndName($context['project']['projectID'], $row[$sessionIndex]);
                         if ($session) {
                             $sessionID = $session['sessionID'];
                         } else {
                             /*$session = array(
                                 'name'  => $row[$sessionIndex],
                                 'active'  => 1,
                                 'status'  => 'active',
                                 'projectID'  => $context['project']['projectID'],
                               );
                               $sessionID = $this->registry->getDbHelper('TestsHelper')->addSession($session);
                               $session['sessionID'] = $sessionID;*/
                             $sessionID = 0;
                         }
                     }
                     if (!$sessionID) {
                         $skipped++;
                         $skippedRows[] = $rowIndex;
                         continue;
                     }
                     // валидируем исходные данные
                     if (!$validator->validate($row)) {
                         $skipped++;
                         $skippedRows[] = $rowIndex;
                     } elseif (!$row[0] && !$row[1]) {
                         // должно быть хотябы или имя, или фамилия
                         $skipped++;
                         $skippedRows[] = $rowIndex;
                     } else {
                         // ищем такого участника уже в базе
                         $member = $this->registry->getDbHelper('MembersHelper')->findByEmailAndProjectId($row[2], $context['project']['projectID']);
                         if (!$member) {
                             // добавляем участника
                             // определяем язык по структуре
                             $staff = $this->registry->getDbHelper('MembersHelper')->findStaffByProjectIDAndEmail($context['project']['projectID'], $row[2]);
                             $langID = $languageIndex && $row[$languageIndex] && array_key_exists($row[$languageIndex], $languagesIDs) ? $languagesIDs[$row[$languageIndex]] : $projectLangID;
                             $memberID = $this->registry->getDbHelper('MembersHelper')->addMember($row[1], $row[0], $row[3], $row[2], $context['project']['projectID'], $this->registry->getModel('Auth')->generateUid('prep_projects_members', 'private_lk_access_key', false), $langID, 1, 'new', $row[4]);
                             $eventListener = new EventListener($this->registry, $context['project'], $_SERVER["DOCUMENT_ROOT"] . '/');
                             $eventListener->executeEvent('MemberAdded', array('memberID' => $memberID), true);
                             $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'member', $memberID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                         } else {
                             $memberID = $member['projects_memberID'];
                         }
                         if ($this->registry->getDbHelper('MembersHelper')->findRespondentByProjectIDAndSessionIDAndMemberID($context['project']['projectID'], $sessionID, $memberID)) {
                             // такой оцениваемый уже есть
                             $skipped++;
                             $skippedRows[] = $rowIndex;
                         } else {
                             $respondentID = $this->registry->getDbHelper('MembersHelper')->addRespondent(array('projectID' => $context['project']['projectID'], 'sessionID' => $sessionID, 'project_memberID' => $memberID, 'active' => 1, 'status' => 'new', 'stat1_assessID' => 0, 'private_access_key' => $this->registry->getModel('Auth')->generateUid('prep_respondents', 'private_access_key', false), 'stat1_roleID' => 0));
                             $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'respondent', $respondentID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                             $inserted++;
                         }
                     }
                 }
                 $this->component->arResult['statusSuccess'] = 'Импортировано: ' . $inserted . ', проигнорировано: ' . $skipped . ($skipped ? ' (строки ' . implode(', ', $skippedRows) . ')' : '');
             }
         }
         $statuses = $this->registry->getDbHelper('MembersHelper')->getTestingRespondentsStatusesNames();
         $this->component->arResult['statuses'] = $statuses;
         $sorts = array('respondentID' => 'respondentID', 'name' => 'name', 'surname' => 'surname', 'email' => 'email', 'position' => 'position', 'session' => 'sessionID', 'status' => 'status', 'private_lk_access_key' => 'private_lk_access_key', 'last_email' => 'last_email', 'last_action' => 'last_entrance');
         if (isset($_GET['sort']) && array_key_exists($_GET['sort'], $sorts)) {
             $sort = $_GET['sort'];
         } else {
             $sort = 'respondentID';
         }
         $order = isset($_GET['order']) && in_array($_GET['order'], array('asc', 'desc')) ? $_GET['order'] : 'asc';
         $filterQueryString = DataFilter::getFilterQueryString($_GET);
         $this->component->arResult['filterQueryString'] = $filterQueryString;
         $sessions = $this->registry->getDbHelper('TestsHelper')->getSessionsByProjectID($context['project']['projectID']);
         $userSessions = array();
         foreach ($sessions as $session) {
             if (in_array($session['sessionID'], $availableSessionsIDs)) {
                 $userSessions[$session['sessionID']] = $session['name'];
             }
         }
         $this->component->arResult['userSessions'] = $userSessions;
         // настройки фильтров для данных
         $filters = array(0 => array('title' => 'Имя', 'name' => 'name', 'type' => 'text', 'data_type' => 'string', 'field' => 'm.`name`'), 1 => array('title' => 'Фамилия', 'name' => 'surname', 'type' => 'text', 'data_type' => 'string', 'field' => 'm.`surname`'), 2 => array('title' => 'ID', 'name' => 'id', 'type' => 'text', 'data_type' => 'number', 'field' => 'r.`respondentID`'), 3 => array('title' => 'Текст', 'name' => 'text', 'type' => 'text', 'data_type' => 'string', 'field' => array('m.`search_text`')), 4 => array('title' => 'Статус ', 'name' => 'status', 'type' => 'select', 'data_type' => 'string', 'field' => 'r.`status`', 'values' => array(0 => 'Любой') + $statuses), 5 => array('title' => 'Группа ', 'name' => 'session_id', 'type' => 'select', 'data_type' => 'number', 'field' => 'r.`sessionID`', 'values' => array(0 => 'Любая') + $userSessions), 6 => array('title' => 'В архиве ', 'name' => 'is_archive', 'type' => 'select', 'data_type' => 'number', 'field' => 'r.`is_archive`', 'values' => array(-1 => '-', 0 => 'Нет', 1 => 'Да'), 'explicit' => 1));
         $filterData = array('FILTERS' => $filters, 'BASE_URL' => '/projects/' . $context['project']['projectID'] . '/groups/respondents/', 'SORT' => $sort, 'ORDER' => $order);
         // проверяем, введен ли фильтр
         $filterValue = DataFilter::getFilterValue($filters, $_GET, $this->registry->getDbConnect());
         if ($filterValue['valid']) {
             $filterData = array_merge($filterData, $filterValue);
         }
         // компонент отображения фильтра
         $context['APPLICATION']->IncludeComponent('ecoplay:data.filter', '', $filterData);
         // выполняем с респондентами действия
         if (isset($_POST['respondents_ids'])) {
             if (isset($_POST['all']) && $_POST['all']) {
                 $selectedIDs = $this->registry->getDbHelper('TestsSeancesHelper')->getRespondentsIDsByProjectIDAndSessionsIDs($context['project']['projectID'], $availableSessionsIDs, $filterValue['filter_strings']);
             } else {
                 $selectedIDs = $_POST['respondents_ids'];
             }
             if (isset($_POST['mode'])) {
                 if ($_POST['mode'] == 'delete') {
                     $deletedRespondents = $this->registry->getDbHelper('TestsSeancesHelper')->getRespondentsByIDs($selectedIDs);
                     $this->registry->getDbHelper('MembersHelper')->deleteRespondentsByIDs($selectedIDs);
                     foreach ($deletedRespondents as $respondent) {
                         $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'respondent', $respondent['respondentID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_DELETE, $respondent);
                     }
                 } elseif ($_POST['mode'] == 'zip') {
                     $editedRespondents = $this->registry->getDbHelper('TestsSeancesHelper')->getRespondentsByIDs($selectedIDs);
                     $this->registry->getDbHelper('MembersHelper')->editRespondents($selectedIDs, array('is_archive' => 1));
                     foreach ($editedRespondents as $respondent) {
                         $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'respondent', $respondent['respondentID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_CHANGE, $respondent);
                     }
                 } elseif ($_POST['mode'] == 'unzip') {
                     $editedRespondents = $this->registry->getDbHelper('TestsSeancesHelper')->getRespondentsByIDs($selectedIDs);
                     $this->registry->getDbHelper('MembersHelper')->editRespondents($selectedIDs, array('is_archive' => 0));
                     foreach ($editedRespondents as $respondent) {
                         $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'respondent', $respondent['respondentID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_CHANGE, $respondent);
                     }
                 } elseif ($_POST['mode'] == 'mail_resend') {
                     $editedRespondents = $this->registry->getDbHelper('TestsSeancesHelper')->getRespondentsByIDs($selectedIDs);
                     $membersIds = array(0);
                     foreach ($editedRespondents as $respondent) {
                         $membersIds[intval($respondent["project_memberID"])] = intval($respondent["project_memberID"]);
                     }
                     $selectedMemebers = $this->registry->getDbHelper('MembersHelper')->getMembersByIDs($membersIds);
                     $languagesIDs = json_decode($context['project']['~languages']);
                     foreach ($selectedMemebers as $selectedMemeber) {
                         if ($selectedMemeber["email"] != "") {
                             $smtpMail = \Ecoplay\Model\SmtpMail::getInstance($this->registry->getDbConnect(), SMTP_HOST, SMTP_PORT, SMTP_USERNAME, SMTP_PASSWORD);
                             $smtpMail->sendFromTemplate($context['project']['projectID'], 'MailEvent_Testing_MailResend', $languagesIDs[0], array("RESPONDENT" => $selectedMemeber["name"] . " " . $selectedMemeber["surname"], "RESPONDENT_LK_LINK" => 'http://' . SITE_HOST . '/enter/' . $selectedMemeber['private_lk_access_key'] . "/", 'EMAIL_TO' => $selectedMemeber["email"], 'EMAIL_FROM' => EMAIL_FROM), 'member', $selectedMemeber['projects_memberID']);
                         }
                     }
                 } elseif ($_POST['mode'] == 'reports') {
                     $valid = false;
                     $params = array();
                     if ($haveValuation) {
                         if ($_POST['valuation_group']) {
                             // валидируем выбранную нормогруппу
                             $valuationGroup = $this->registry->getDbHelper('TestsHelper')->findValuationGroupByID(intval($_POST['valuation_group']));
                             if ($valuationGroup) {
                                 $params['valuationGroupID'] = $valuationGroup['vgroupID'];
                                 $valid = true;
                             }
                         }
                     } else {
                         $valid = true;
                     }
                     if ($valid) {
                         // Создаем задачу на генерацию отчетов
                         $taskID = $this->registry->getDbHelper('TasksHelper')->addTask(array('name' => '', 'type' => \Ecoplay\Helper\Db\TasksHelper::TASK_TYPE_REPORT, 'params' => json_encode(array_merge($params, array('projectID' => $context['project']['projectID'], 'respondentsIDs' => $selectedIDs))), 'userID' => $context['USER']->GetID(), 'status' => \Ecoplay\Helper\Db\TasksHelper::TASK_STATUS_NEW, 'dt_created' => date('d-m-Y H:i:s')));
                         $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'task', $taskID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                     }
                 } else {
                     $newStatus = false;
                     switch ($_POST['mode']) {
                         case 'to_new':
                             $newStatus = \Ecoplay\Helper\Db\MembersHelper::RESPONDENT_STATUS_NEW;
                             break;
                         case 'to_waiting':
                             $newStatus = \Ecoplay\Helper\Db\MembersHelper::RESPONDENT_STATUS_WAITING;
                             break;
                         case 'to_active':
                             $newStatus = \Ecoplay\Helper\Db\MembersHelper::RESPONDENT_STATUS_ACTIVE;
                             break;
                         case 'to_complete':
                             $newStatus = \Ecoplay\Helper\Db\MembersHelper::RESPONDENT_STATUS_COMPLETE;
                             break;
                             /*case 'to_report':
                                 $newStatus = \Ecoplay\Helper\Db\MembersHelper::RESPONDENT_STATUS_REPORT;
                                 break;
                               case 'to_archive':
                                 $newStatus = \Ecoplay\Helper\Db\MembersHelper::RESPONDENT_STATUS_ARCHIVE;
                                 break;*/
                     }
                     if ($newStatus) {
                         $editedRespondents = $this->registry->getDbHelper('TestsSeancesHelper')->getRespondentsByIDs($selectedIDs);
                         $this->registry->getDbHelper('MembersHelper')->editRespondents($selectedIDs, array('status' => $newStatus));
                         foreach ($editedRespondents as $respondent) {
                             $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'respondent', $respondent['respondentID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_CHANGE, $respondent);
                         }
                     }
                 }
             }
         }
         $arResult['selectedIDs'] = $selectedIDs;
         // получаем респондентов проекта
         $cnt = $this->registry->getDbHelper('TestsSeancesHelper')->getRespondentsCountByProjectIDAndSessionsIDs($context['project']['projectID'], $availableSessionsIDs, $filterValue['filter_strings']);
         $onPage = 100;
         $pagesCnt = ceil($cnt / $onPage);
         $page = $_GET['PAGE'] && $_GET['PAGE'] <= $pagesCnt ? intval($_GET['PAGE']) : 1;
         $respondents = $this->registry->getDbHelper('TestsSeancesHelper')->getRespondentsByProjectIDAndSessionsIDsPaged($context['project']['projectID'], $availableSessionsIDs, $page, $onPage, $sorts[$sort], $order, $filterValue['filter_strings']);
         $this->component->arResult['respondents'] = $respondents;
         $this->component->arResult['sort'] = $sort;
         $this->component->arResult['order'] = $order;
         $this->component->arResult['cntInfo'] = $pagesCnt == 1 ? $cnt : 0;
         // инфа для редактирования
         $respondentsJson = array();
         $respondentsIDs = array();
         foreach ($respondents as $respondent) {
             $respondentsJson[$respondent['respondentID']] = array('name' => $respondent['name'], 'surname' => $respondent['surname'], 'email' => $respondent['email'], 'position' => $respondent['position'], 'department' => $respondent['department'], 'langID' => $respondent['langID'], 'sessionID' => $respondent['sessionID']);
             $respondentsIDs[] = $respondent['respondentID'];
         }
         $jsonRespondents = json_encode($respondentsJson);
         $jsonRespondents = str_replace("'", "\\'", $jsonRespondents);
         $jsonRespondents = str_replace("\\", "\\\\", $jsonRespondents);
         $this->component->arResult['json_respondents'] = $jsonRespondents;
         // отчеты респондентов
         $reports = array();
         if (count($respondentsIDs)) {
             $reportsSrc = $this->registry->getDbHelper('ReportsHelper')->getReportsByProjectIDAndRespondentsIDs($context['project']['projectID'], $respondentsIDs);
             foreach ($reportsSrc as $report) {
                 if (!array_key_exists($report['stat1_respondentID'], $reports)) {
                     $reports[$report['stat1_respondentID']] = array('reportID' => $report['generated_reportID'], 'cnt' => 1);
                 } else {
                     $reports[$report['stat1_respondentID']]['cnt']++;
                     if ($report['generated_reportID'] > $reports[$report['stat1_respondentID']]['reportID']) {
                         $reports[$report['stat1_respondentID']]['reportID'] = $report['generated_reportID'];
                     }
                 }
             }
         }
         $this->component->arResult['reports'] = $reports;
         // инфа для построения прогресса
         $this->component->arResult['progress_settings'] = $this->registry->getModel('Tests')->getProjectProgressSettings($context['project']['projectID']);
         // статистика по статусам
         $get = $_GET;
         if (array_key_exists('status_fvalue', $get)) {
             unset($get['status_fvalue']);
         }
         $filterValue = DataFilter::getFilterValue($filters, $get, $this->registry->getDbConnect());
         $statusesStatSrc = $this->registry->getDbHelper('TestsSeancesHelper')->getRespondentsStatusesStat($context['project']['projectID'], $availableSessionsIDs, $filterValue['filter_strings']);
         $statusesStat = array();
         $allStatusesCnt = 0;
         foreach ($statuses as $status => $name) {
             $statusesStat[$status] = 0;
         }
         foreach ($statusesStatSrc as $stat) {
             //foreach ($respondents as $respondent) {
             $statusesStat[$stat['status']] += $stat['cnt'];
             $allStatusesCnt += $stat['cnt'];
         }
         $this->component->arResult['statuses_stat'] = $statusesStat;
         $this->component->arResult['all_statuses_cnt'] = $allStatusesCnt;
         $this->component->IncludeComponentTemplate("testing_statuses_filter");
         $navResult = new \CDBResult();
         $navResult->NavPageCount = ceil($cnt / $onPage);
         $navResult->NavPageNomer = $page;
         $navResult->NavNum = 1;
         $navResult->NavPageSize = $onPage;
         $navResult->NavRecordCount = $cnt;
         $navResult->nPageWindow = 11;
         $context['APPLICATION']->IncludeComponent('ecoplay:system.pagenavigation', '', array('NAV_RESULT' => $navResult, 'NAV_URL' => '/projects/' . $context['project']['projectID'] . '/groups/respondents/', 'NAV_QUERY_STRING' => 'sort=' . $sort . '&order=' . $order . ($filterQueryString ? '&' . $filterQueryString : '') . (isset($_GET['checkAll']) ? '&checkAll=1' : '')));
         $this->component->arResult['sessions'] = $sessions;
         $packagesIDs = array();
         foreach ($sessions as $session) {
             if (!in_array($session['packageID'], $packagesIDs)) {
                 $packagesIDs[] = $session['packageID'];
             }
         }
         $this->component->arResult['packages'] = $this->registry->getDbHelper('TestsHelper')->getPackagesByIDs($packagesIDs);
         $languagesIDs = json_decode($context['project']['~languages']);
         $languagesSrc = $this->registry->getDbHelper('TranslationHelper')->getLanguagesByIDs($languagesIDs);
         $languages = array();
         foreach ($languagesSrc as $language) {
             $languages[$language['langID']] = $language['name'];
         }
         $this->component->arResult['languages'] = $languages;
     } else {
         $this->component->arResult['respondents'] = null;
     }
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Тестируемые');
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('link' => '/', 'title' => 'Главная'), 1 => array('link' => '/projects/', 'title' => 'Проекты'), 2 => array('link' => '/projects/' . $context['project']['projectID'] . '/continuing/stat/', 'title' => $context['project']['project_name']), 3 => array('title' => 'Тестируемые'))));
     $this->component->arResult['canReports'] = $this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'reports', $context['project']['projectID']);
     $this->component->IncludeComponentTemplate("template_testing");
 }
示例#16
0
 public function execute($context)
 {
     $context['APPLICATION']->AddHeadScript('https://www.google.com/jsapi');
     // проверка прав доступа к разделу
     if (!$this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'projects')) {
         $this->registry->getModel('Auth')->restrict();
     }
     if (!$this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'project', $context['project']['projectID'])) {
         $this->registry->getModel('Auth')->restrict();
     }
     $availableSessionsIDs = $this->registry->getModel('Auth')->getAvailableSessions($_SESSION['accesses'], $context['project']['projectID']);
     // определяем даты
     $from = $context['project']['dt_from'] ? strtotime($context['project']['dt_from']) : strtotime($context['project']['dt_create']);
     $to = $context['project']['dt_to'] ? strtotime($context['project']['dt_to']) : time();
     //получаем опрашиваемых проекта
     if (count($availableSessionsIDs)) {
         $assessStatSrc = $this->registry->getDbHelper('MembersHelper')->getSessionsAssessStat($context['project']['projectID'], $availableSessionsIDs);
         // статусы выбора респондентов и оцениваемых аггрегируем в подготовку
         $newAddon = 0;
         $newIndex = false;
         $excludedIndexes = array();
         $assessAllCnt = 0;
         foreach ($assessStatSrc as $index => $data) {
             $assessAllCnt += $data['val'];
             if (in_array($data['name'], array(\Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_SELECT_RESPONDENTS, \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_RESPONDENTS_SELECTED, \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_SELECT_ASSESS, \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_ASSESS_SELECTED))) {
                 $newAddon += $data['val'];
                 $excludedIndexes[] = $index;
             } elseif ($data['name'] == \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_NEW) {
                 $newIndex = $index;
             }
         }
         if ($newAddon) {
             foreach ($excludedIndexes as $index) {
                 unset($assessStatSrc[$index]);
             }
             if ($newIndex !== false) {
                 $assessStatSrc[$newIndex]['val'] += $newAddon;
             } else {
                 $assessStatSrc[] = array('name' => \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_NEW, 'val' => $newAddon);
             }
         }
         if ($assessAllCnt) {
             $statuses = array(\Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_COMPLETE => 'Оценка завершена', \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_ASSESS => 'Оценивается', \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_NEW => 'Подготовка');
             $statusesColors = array(\Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_NEW => 'c8331f', \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_ASSESS => 'ffcc33', \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_COMPLETE => '336600');
             $statusesSorts = array(\Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_COMPLETE => 0, \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_ASSESS => 1, \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_NEW => 2);
             $assessStat = array();
             foreach ($statusesSorts as $key => $sort) {
                 $assessStat[$sort] = array('color' => $statusesColors[$key], 'name' => $statuses[$key], 'val' => 0);
             }
             foreach ($assessStatSrc as $assess) {
                 $assessStat[$statusesSorts[$assess['name']]]['val'] = $assess['val'];
             }
         } else {
             $assessStat = false;
         }
         // стата по анкетам
         $seancesStat = $this->registry->getDbHelper('MembersHelper')->getSessionsSeancesStat($context['project']['projectID'], $availableSessionsIDs);
         $states = array(\Ecoplay\Helper\Db\BlanksHelper::SEANCE_STATE_NEW => 'Заполнение не начато', \Ecoplay\Helper\Db\BlanksHelper::SEANCE_STATE_PROGRESS => 'Идёт заполнение', \Ecoplay\Helper\Db\BlanksHelper::SEANCE_STATE_COMPLETE => 'Заполнение завершено');
         $statesCombines = array(\Ecoplay\Helper\Db\BlanksHelper::SEANCE_STATE_RESULTS => \Ecoplay\Helper\Db\BlanksHelper::SEANCE_STATE_PROGRESS);
         $statesColors = array(\Ecoplay\Helper\Db\BlanksHelper::SEANCE_STATE_NEW => 'c8331f', \Ecoplay\Helper\Db\BlanksHelper::SEANCE_STATE_PROGRESS => 'ffcc33', \Ecoplay\Helper\Db\BlanksHelper::SEANCE_STATE_COMPLETE => '336600');
         // объединяем нужные статусы
         $statesAddons = array();
         $keysToUnset = array();
         foreach ($seancesStat as $key => $seances) {
             if (array_key_exists($seances['name'], $statesCombines)) {
                 $statesAddons[$statesCombines[$seances['name']]] = $seances['val'];
                 $keysToUnset[] = $key;
             }
         }
         foreach ($keysToUnset as $key) {
             unset($seancesStat[$key]);
         }
         $busyStates = array();
         $seancesAllCnt = 0;
         foreach ($seancesStat as $key => $seances) {
             $busyStates[] = $seances['name'];
             $seancesStat[$key]['color'] = array_key_exists($seances['name'], $statesColors) ? $statesColors[$seances['name']] : '606060';
             $seancesStat[$key]['name'] = array_key_exists($seances['name'], $states) ? $states[$seances['name']] : 'Неизвестно';
             $addon = array_key_exists($seances['name'], $statesAddons) ? $statesAddons[$seances['name']] : 0;
             $seancesStat[$key]['val'] += $addon;
             $seancesAllCnt += $seances['val'] + $addon;
         }
         foreach ($states as $key => $name) {
             if (!in_array($key, $busyStates)) {
                 $addon = array_key_exists($name, $statesAddons) ? $statesAddons[$name] : 0;
                 $seancesStat[] = array('color' => $statesColors[$key], 'name' => $name, 'val' => $addon);
                 $seancesAllCnt += $addon;
             }
         }
         if (!$seancesAllCnt) {
             $seancesStat = false;
         }
         ### таймлайн
         $timelineStat = $this->registry->getModel('Stat')->getTimelineStat($from, $to, $availableSessionsIDs);
     } else {
         $assessStat = false;
         $seancesStat = false;
         $timelineStat = false;
     }
     $this->component->arResult['assessStat'] = $assessStat;
     $this->component->arResult['seancesStat'] = $seancesStat;
     $this->component->arResult['timelineStat'] = $timelineStat;
     $this->component->arResult['from'] = $from;
     $this->component->arResult['to'] = $to;
     $viewHelper = new \Ecoplay\View\Helper();
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Статистика');
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('title' => 'Главная', 'link' => '/'), 1 => array('title' => 'Проекты', 'link' => '/projects/'), 2 => array('title' => $context['project']['project_name']))));
     $this->component->IncludeComponentTemplate();
 }
示例#17
0
 public function execute($context)
 {
     $context['APPLICATION']->AddHeadScript('/js/forms.js');
     $context['APPLICATION']->AddHeadScript('/js/icheck/icheck.min.js');
     $context['APPLICATION']->SetAdditionalCSS('/js/icheck/skins/minimal/eco.css');
     // проверка прав доступа к разделу
     if (!$this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'members', $context['project']['projectID'])) {
         $this->registry->getModel('Auth')->restrict();
     }
     $this->component->arResult['canImport'] = $this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'imports', $context['project']['projectID']);
     $isProjectAdmin = $this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'project_edit', $context['project']['projectID']);
     $this->component->arResult['isProjectAdmin'] = $isProjectAdmin;
     $selectedIDs = array();
     // обнуление заполнения
     $this->component->arResult['isAdmin'] = $_SESSION['accesses']['is_admin'] ? true : false;
     if (isset($_POST['reseted_id'])) {
         $selectedIDs[] = $_POST['reseted_id'];
         $seance = $this->registry->getDbHelper('SeancesHelper')->findSeanceByRespondentAndProject($_POST['reseted_id'], $context['project']['projectID']);
         if ($seance) {
             // деактивируем текущий сеанс
             $this->registry->getDbHelper('SeancesHelper')->editSeance($seance['seanceID'], array('active' => 0, 'private_access_key' => ''));
             $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'seance', $seance['seanceID'], LogsHelper::ACTION_TYPE_DELETE, $seance);
             // создаем новый сеанс
             $BlankDataSource = new \Ecoplay\Model\BlankDataSource($this->registry->getDbConnect(), 0, 0);
             $seanceKey = $BlankDataSource->addSeanceAndCookies($seance['private_access_key']);
             $seance = $this->registry->getDbHelper('SeancesHelper')->findSeanceByKey($seanceKey);
             $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'seance', $seance['seanceID'], LogsHelper::ACTION_TYPE_ADD, null);
             //ставим флаг чтобы данные по отчету для оцениваемого пересчитались
             $respondent = $this->registry->getDbHelper('MembersHelper')->findRespondentById($seance['respondentID']);
             $assessCompetencyData = $this->registry->getDbHelper('CompetencyHelper')->getAssessCompetencyData($respondent['stat1_assessID']);
             if ($assessCompetencyData) {
                 $this->registry->getDbHelper('CompetencyHelper')->editAssessCompetency($assessCompetencyData['ID'], array('need_recount' => 1));
             }
         }
     }
     $availableSessionsIDs = $this->registry->getModel('Auth')->getAvailableSessions($_SESSION['accesses'], $context['project']['projectID']);
     $sessions = $this->registry->getDbHelper('ProjectsHelper')->getUserAvailableSessionsByProjectID($context['project']['projectID'], $availableSessionsIDs);
     $this->component->arResult['jsessions'] = json_encode($sessions);
     $this->component->arResult['sessions'] = $sessions;
     $sorts = array('respondentID' => 'respondentID', 'assess' => 'assess', 'assess_email' => 'assess_email', 'assess_position' => 'assess_position', 'role' => 'role', 'respondent' => 'respondent', 'email' => 'email', 'position' => 'position', 'percent' => 'percent', 'sessionID' => 'sessionID', 'seanceID' => 'seanceID', 'sortby' => 'sortby');
     if (isset($_GET['sort']) && array_key_exists($_GET['sort'], $sorts)) {
         $sort = $_GET['sort'];
     } else {
         $sort = 'respondentID';
     }
     $order = isset($_GET['order']) && in_array($_GET['order'], array('asc', 'desc')) ? $_GET['order'] : 'asc';
     $filterQueryString = DataFilter::getFilterQueryString($_GET);
     $this->component->arResult['filterQueryString'] = $filterQueryString;
     // настройки фильтров для данных
     $filters = array(0 => array('title' => 'Оцениваемый Имя', 'name' => 'assess_name', 'type' => 'text', 'data_type' => 'string', 'field' => 'pma.`name`'), 1 => array('title' => 'Оцениваемый Фамилия', 'name' => 'assess_surname', 'type' => 'text', 'data_type' => 'string', 'field' => 'pma.`surname`'), 2 => array('title' => 'Оцениваемый ID', 'name' => 'assess_id', 'type' => 'text', 'data_type' => 'number', 'field' => 'a.`assessID`'), 3 => array('title' => 'Респондент Имя', 'name' => 'respondent_name', 'type' => 'text', 'data_type' => 'string', 'field' => 'pm.`name`'), 4 => array('title' => 'Респондент Фамилия', 'name' => 'respondent_surname', 'type' => 'text', 'data_type' => 'string', 'field' => 'pm.`surname`'), 5 => array('title' => 'Респондент ID', 'name' => 'respondent_id', 'type' => 'text', 'data_type' => 'number', 'field' => 'r.`respondentID`'), 6 => array('title' => 'Текст', 'name' => 'text', 'type' => 'text', 'data_type' => 'string', 'field' => array('pma.`search_text`', 'pm.`search_text`', 'rt.`name`')), 7 => array('title' => 'Группа ', 'name' => 'session_id', 'type' => 'select', 'data_type' => 'number', 'field' => 's.`sessionID`', 'values' => array(0 => 'Любая') + $sessions));
     $filterData = array('FILTERS' => $filters, 'BASE_URL' => '/projects/' . $context['project']['projectID'] . '/members/scheme360/', 'SORT' => $sort, 'ORDER' => $order);
     // проверяем, введен ли фильтр
     $filterValue = DataFilter::getFilterValue($filters, $_GET, $this->registry->getDbConnect());
     if ($filterValue['valid']) {
         $filterData = array_merge($filterData, $filterValue);
     }
     // компонент отображения фильтра
     $context['APPLICATION']->IncludeComponent('ecoplay:data.filter', '', $filterData);
     $cnt = $this->registry->getDbHelper('MembersHelper')->getRespondentsForScheme360Cnt($context['project']['projectID'], $availableSessionsIDs, $filterValue['filter_strings']);
     $onPage = 100;
     $pagesCnt = ceil($cnt / $onPage);
     $page = $_GET['PAGE'] && $_GET['PAGE'] <= $pagesCnt ? intval($_GET['PAGE']) : 1;
     if ($isProjectAdmin && isset($_POST['deny'])) {
         if (isset($_POST['all']) && $_POST['all']) {
             $selectedIDs = $this->registry->getDbHelper('MembersHelper')->getRespondentsIDsForScheme360($context['project']['projectID'], $availableSessionsIDs, $filterValue['filter_strings']);
         } else {
             $selectedIDs = $_POST['respondents_ids'];
         }
         $this->registry->getDbHelper('MembersHelper')->editRespondents($selectedIDs, array('deny_deletion' => 1));
     }
     $this->component->arResult['selectedIDs'] = $selectedIDs;
     $respondents = $this->registry->getDbHelper('MembersHelper')->getRespondentsForScheme360($context['project']['projectID'], $availableSessionsIDs, $page, $onPage, $sorts[$sort], $order, $filterValue['filter_strings']);
     $this->component->arResult['respondents'] = $respondents;
     if (isset($_GET['checkAll'])) {
         $selectedIDs = array();
         foreach ($respondents as $responent) {
             $selectedIDs[] = $responent['respondentID'];
         }
         $this->component->arResult['selectedIDs'] = $selectedIDs;
     }
     $viewHelper = new \Ecoplay\View\Helper();
     $this->component->arResult['sort'] = $sort;
     $this->component->arResult['order'] = $order;
     $this->component->arResult['cntInfo'] = $pagesCnt == 1 ? $cnt : 0;
     $roles = $this->registry->getDbHelper('ProjectsHelper')->getProjectRoles($context['project']['projectID']);
     $selfRoleID = 0;
     foreach ($roles as $role) {
         if ($role['fixed_role'] == 'self') {
             $selfRoleID = $role['roleID'];
             break;
         }
     }
     $this->component->arResult['selfRoleID'] = $selfRoleID;
     // выводим таблицу с данными
     $this->component->IncludeComponentTemplate('table');
     $navResult = new \CDBResult();
     $navResult->NavPageCount = ceil($cnt / $onPage);
     $navResult->NavPageNomer = $page;
     $navResult->NavNum = 1;
     $navResult->NavPageSize = $onPage;
     $navResult->NavRecordCount = $cnt;
     $navResult->nPageWindow = 11;
     $context['APPLICATION']->IncludeComponent('ecoplay:system.pagenavigation', '', array('NAV_RESULT' => $navResult, 'NAV_URL' => '/projects/' . $context['project']['projectID'] . '/members/scheme360/', 'NAV_QUERY_STRING' => 'sort=' . $sort . '&order=' . $order . ($filterQueryString ? '&' . $filterQueryString : '') . (isset($_GET['checkAll']) ? '&checkAll=1' : '')));
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Схема 360&deg;');
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('link' => '/', 'title' => 'Главная'), 1 => array('link' => '/projects/', 'title' => 'Проекты'), 2 => array('link' => '/projects/' . $context['project']['projectID'] . '/continuing/stat/', 'title' => $context['project']['project_name']), 3 => array('title' => 'Схема 360&deg;'))));
     $this->component->IncludeComponentTemplate();
 }
示例#18
0
 public function execute($context)
 {
     $context['APPLICATION']->AddHeadScript('/js/forms.js');
     // проверка прав доступа к разделу
     if (!$this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'members', $context['project']['projectID'])) {
         $this->registry->getModel('Auth')->restrict();
     }
     $this->component->arResult['canImport'] = $this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'imports', $context['project']['projectID']);
     $languagesIDs = json_decode($context['project']['~languages']);
     $languagesSrc = $this->registry->getDbHelper('TranslationHelper')->getLanguagesByIDs($languagesIDs);
     $languages = array();
     foreach ($languagesSrc as $language) {
         $languages[$language['langID']] = $language['name'];
     }
     $this->component->arResult['languages'] = $languages;
     $this->component->arResult['languagesFull'] = $languagesSrc;
     $sorts = array('projects_memberID' => 'projects_memberID', 'FIO' => 'FIO', 'position' => 'position', 'email' => 'email', 'private_lk_access_key' => 'private_lk_access_key', 'assess_count' => 'assess_count', 'respondent_count' => 'respondent_count', 'userID' => 'userID', 'projectID' => 'projectID', 'status' => 'status', 'langID' => 'langID', 'language' => 'language', 'department' => 'department');
     if (isset($_GET['sort']) && array_key_exists($_GET['sort'], $sorts)) {
         $sort = $_GET['sort'];
     } else {
         $sort = 'projects_memberID';
     }
     $order = isset($_GET['order']) && in_array($_GET['order'], array('asc', 'desc')) ? $_GET['order'] : 'asc';
     $filterQueryString = DataFilter::getFilterQueryString($_GET);
     $this->component->arResult['filterQueryString'] = $filterQueryString;
     // настройки фильтров для данных
     $filters = array(0 => array('title' => 'Имя', 'name' => 'name', 'type' => 'text', 'data_type' => 'string', 'field' => '`name`'), 1 => array('title' => 'Фамилия', 'name' => 'surname', 'type' => 'text', 'data_type' => 'string', 'field' => '`surname`'), 2 => array('title' => 'ID', 'name' => 'id', 'type' => 'text', 'data_type' => 'number', 'field' => '`projects_memberID`'), 3 => array('title' => 'Текст', 'name' => 'text', 'type' => 'text', 'data_type' => 'string', 'field' => array('`search_text`')), 4 => array('title' => 'Язык ', 'name' => 'language', 'type' => 'select', 'data_type' => 'number', 'field' => '`langID`', 'values' => array(0 => 'Любой') + $languages), 5 => array('title' => 'Оценивается', 'name' => 'assess', 'type' => 'range', 'data_type' => 'number', 'field' => '`assess_count`', 'sql_type' => 'where'), 6 => array('title' => 'Оценивает ', 'name' => 'respondent', 'type' => 'range', 'data_type' => 'number', 'field' => '`respondent_count`', 'sql_type' => 'where'));
     $filterData = array('FILTERS' => $filters, 'BASE_URL' => '/projects/' . $context['project']['projectID'] . '/settings/members/', 'SORT' => $sort, 'ORDER' => $order);
     // проверяем, введен ли фильтр
     $filterValue = DataFilter::getFilterValue($filters, $_GET, $this->registry->getDbConnect());
     if ($filterValue['valid']) {
         $filterData = array_merge($filterData, $filterValue);
     }
     // компонент отображения фильтра
     $context['APPLICATION']->IncludeComponent('ecoplay:data.filter', '', $filterData);
     $cnt = $this->registry->getDbHelper('MembersHelper')->getProjectsMembersCount($context['project']['projectID'], $filterValue['filter_strings']);
     $onPage = 100;
     $pagesCnt = ceil($cnt / $onPage);
     $page = $_GET['PAGE'] && $_GET['PAGE'] <= $pagesCnt ? intval($_GET['PAGE']) : 1;
     $navResult = new \CDBResult();
     $navResult->NavPageCount = ceil($cnt / $onPage);
     $navResult->NavPageNomer = $page;
     $navResult->NavNum = 1;
     $navResult->NavPageSize = $onPage;
     $navResult->NavRecordCount = $cnt;
     $context['APPLICATION']->IncludeComponent('ecoplay:system.pagenavigation', '', array('NAV_RESULT' => $navResult, 'NAV_URL' => '/projects/' . $context['project']['projectID'] . '/settings/members/', 'NAV_QUERY_STRING' => 'sort=' . $sort . '&order=' . $order . ($filterQueryString ? '&' . $filterQueryString : '')));
     $membersSrc = $this->registry->getDbHelper('MembersHelper')->getProjectsMembersForView($context['project']['projectID'], $page, $onPage, $sorts[$sort], $order, $filterValue['filter_strings']);
     $members = array();
     foreach ($membersSrc as $member) {
         $member['FIO'] = $member['name'] && $member['surname'] ? '<span class="surname">' . $member['surname'] . '</span> <span class="name">' . $member['name'] . '</span>' : '<span class="surname">' . $member['surname'] . '</span><span class="name">' . $member['name'] . '</span>';
         $members[] = $member;
     }
     $viewHelper = new \Ecoplay\View\Helper();
     $this->component->arResult['cnt'] = count($this->component->arResult['members']);
     $tData = str_replace("'", "\\'", $viewHelper->prepareJsonDataForTable($members, array('projects_memberID', 'FIO', 'position', 'email', 'private_lk_access_key', 'assess_count', 'respondent_count', 'userID', 'projectID', 'status', 'langID', 'language', 'department'), array(), array('language' => $languages)));
     $tData = str_replace("\\", "\\\\", $tData);
     $this->component->arResult['table_data'] = $tData;
     $this->component->arResult['projectID'] = $context['project']['projectID'];
     $this->component->arResult['sort'] = $sort;
     $this->component->arResult['order'] = $order;
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Все участники');
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('title' => 'Главная', 'link' => '/'), 1 => array('title' => 'Проекты', 'link' => '/projects/'), 2 => array('link' => '/projects/' . $context['project']['projectID'] . '/continuing/info/', 'title' => $context['project']['project_name']), 3 => array('title' => 'Участники проекта'))));
     $this->component->IncludeComponentTemplate();
 }
示例#19
0
 public function execute($context)
 {
     $context['APPLICATION']->AddHeadScript('/js/forms.js');
     $context['APPLICATION']->AddHeadScript('/js/icheck/icheck.min.js');
     $context['APPLICATION']->SetAdditionalCSS('/js/icheck/skins/minimal/eco.css');
     // проверка прав доступа к разделу
     if (!$this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'project_edit', $context['project']['projectID'])) {
         $this->registry->getModel('Auth')->restrict();
     }
     $sessionsSrc = $this->registry->getDbHelper('ProjectsHelper')->getSessionsByProjectId($context['project']['projectID']);
     $sessions = array();
     $sessionsNames = array();
     foreach ($sessionsSrc as $session) {
         $sessions[$session['sessionID']] = $session['name'];
         $sessionsNames[$session['name']] = $session['sessionID'];
     }
     if (isset($_POST['session_id']) && $_POST['mode'] == 'add') {
         // добавляем ключ
         $keyData = array('projectID' => $context['project']['projectID'], 'sessionID' => intval($_POST['session_id']), 'active' => 1, 'status' => 'active', 'access_key' => \Ecoplay\Helper\Db\BlanksHelper::uuid(), 'name' => $_POST['name'], 'is_need_complete_previous' => intval($_POST['is_need_complete_previous']), 'is_need_export' => intval($_POST['is_need_export']), 'fact_count' => intval($_POST['fact_count']), 'member_type' => $_POST['member_type']);
         if ($_POST['member_type'] == \Ecoplay\Helper\Db\TestsHelper::GROUP_KEY_MEMBER_TYPE_FLEXIBLE) {
             $keyData['plan_count'] = intval($_POST['plan_count']);
             $keyData['is_registration_available'] = intval($_POST['is_registration_available']);
         } else {
             $keyData['plan_count'] = 0;
             $keyData['is_registration_available'] = 0;
         }
         $keyID = $this->registry->getDbHelper('TestsHelper')->addGroupKey($keyData);
         $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'group_key', $keyID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
     } elseif (isset($_POST['session_id']) && $_POST['mode'] == 'update') {
         $key = $this->registry->getDbHelper('TestsHelper')->findGroupKeyByID(intval($_POST['key_id']));
         if ($key) {
             $keyData = array('sessionID' => intval($_POST['session_id']), 'name' => $_POST['name'], 'is_need_complete_previous' => intval($_POST['is_need_complete_previous']), 'fact_count' => intval($_POST['fact_count']), 'member_type' => $_POST['member_type'], 'is_need_export' => intval($_POST['is_need_export']));
             if ($_POST['member_type'] == \Ecoplay\Helper\Db\TestsHelper::GROUP_KEY_MEMBER_TYPE_FLEXIBLE) {
                 $keyData['plan_count'] = intval($_POST['plan_count']);
                 $keyData['is_registration_available'] = intval($_POST['is_registration_available']);
             } else {
                 $keyData['plan_count'] = 0;
                 $keyData['is_registration_available'] = 0;
             }
             $this->registry->getDbHelper('TestsHelper')->editGroupKey($key['group_keyID'], $keyData);
             $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'group_key', $key['group_keyID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_CHANGE, $key);
         }
     } elseif ($_POST['mode'] == 'delete') {
         if (isset($_POST['all']) && $_POST['all']) {
             $selectedIDs = $this->registry->getDbHelper('LinearProjectsHelper')->getGroupKeysIDsByProjectID($context['project']['projectID']);
         } else {
             $selectedIDs = $_POST['keys_ids'];
         }
         foreach ($selectedIDs as $keyID) {
             $key = $this->registry->getDbHelper('TestsHelper')->findGroupKeyByID(intval($keyID));
             if ($key) {
                 $this->registry->getDbHelper('TestsHelper')->editGroupKey($key['group_keyID'], array('status' => 'deleted', 'active' => '0'));
                 $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'group_key', $key['group_keyID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_DELETE, $key);
             }
         }
     } elseif ($_POST['mode'] == 'activate') {
         foreach ($_POST['keys_ids'] as $keyID) {
             $key = $this->registry->getDbHelper('TestsHelper')->findGroupKeyByID(intval($keyID));
             if ($key) {
                 $this->registry->getDbHelper('TestsHelper')->editGroupKey($key['group_keyID'], array('status' => \Ecoplay\Helper\Db\TestsHelper::GROUP_KEY_STATUS_ACTIVE));
                 $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'group_key', $key['group_keyID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_CHANGE, $key);
             }
         }
     } elseif ($_POST['mode'] == 'deactivate') {
         foreach ($_POST['keys_ids'] as $keyID) {
             $key = $this->registry->getDbHelper('TestsHelper')->findGroupKeyByID(intval($keyID));
             if ($key) {
                 $this->registry->getDbHelper('TestsHelper')->editGroupKey($key['group_keyID'], array('status' => \Ecoplay\Helper\Db\TestsHelper::GROUP_KEY_STATUS_DISABLED));
                 $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'group_key', $key['group_keyID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_CHANGE, $key);
             }
         }
     } elseif ($_POST['mode'] == 'delay') {
         foreach ($_POST['keys_ids'] as $keyID) {
             $key = $this->registry->getDbHelper('TestsHelper')->findGroupKeyByID(intval($keyID));
             if ($key) {
                 $this->registry->getDbHelper('TestsHelper')->editGroupKey($key['group_keyID'], array('status' => \Ecoplay\Helper\Db\TestsHelper::GROUP_KEY_STATUS_ENDING));
                 $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'group_key', $key['group_keyID'], \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_CHANGE, $key);
             }
         }
     } elseif ($_POST['mode'] == 'export') {
         if (isset($_POST['all']) && $_POST['all']) {
             $selectedIDs = $this->registry->getDbHelper('LinearProjectsHelper')->getGroupKeysIDsByProjectID($context['project']['projectID']);
         } else {
             $selectedIDs = $_POST['keys_ids'];
         }
         $context['APPLICATION']->RestartBuffer();
         $csvContent = '"Название";"Группа";"ID ключа";"С регистрацией или без";"Плановое кол-во";"Ограничение на количество";"Продолжать прерванную сессию";"Ссылка";"Количество завершенных анкет";"Количество начатых анкет";"Процент"';
         $exportedKeys = $this->registry->getDbHelper('LinearProjectsHelper')->getGroupsKeysExportData($context['project']['projectID'], $selectedIDs);
         foreach ($exportedKeys as $key) {
             //$percent = $key['plan_count'] ? round($key['respondents_count']/$key['plan_count']*100, 2) : 0;
             $percent = $key['plan_count'] ? round($key['finished_seances_count'] / $key['plan_count'] * 100, 2) : 0;
             $csvContent .= "\n" . '"' . addslashes($key['~name']) . '";"' . addslashes($sessions[$key['sessionID']]) . '";"' . $key['group_keyID'] . '";' . '"' . $key['is_registration_available'] . '";"' . $key['plan_count'] . '";"' . $key['fact_count'] . '";"' . $key['is_need_complete_previous'] . '";"http://' . SITE_HOST . '/g/' . $key['access_key'] . '";' . $key['finished_seances_count'] . ';' . $key['seances_count'] . ';' . $percent . ' %';
         }
         header("Cache-Control: public");
         header("Content-Description: File Transfer");
         header("Content-Disposition: attachment; filename=export.csv");
         header("Content-type: text/csv");
         $csvContent = iconv('UTF-8', 'Windows-1251', $csvContent);
         header("Content-Length: " . mb_strlen($csvContent, 'Windows-1251'));
         echo $csvContent;
         die;
     }
     if ($_FILES["filepath"] && !$_FILES['filepath']['error']) {
         // обрабатываем загруженный файл
         $csvImporter = new \Ecoplay\Import\Csv($_FILES["filepath"]["tmp_name"], $_SERVER["DOCUMENT_ROOT"] . "/temp/csv/");
         $data = $csvImporter->parse();
         $inserted = $skipped = 0;
         $validations = array(0 => 'anything', 1 => 'anything');
         $required = array(0, 1);
         $validator = new \Ecoplay\Form\Validator($validations, $required, array());
         $registrationAvailableIndex = $csvImporter->getColumnIndex('С регистрацией или без');
         $needCompletePreviousIndex = $csvImporter->getColumnIndex('Продолжать прерванную сессию');
         $planCountIndex = $csvImporter->getColumnIndex('Плановое кол-во');
         $factCountIndex = $csvImporter->getColumnIndex('Ограничение на количество');
         $memberTypeIndex = $csvImporter->getColumnIndex('Список участников');
         $keyIDIndex = $csvImporter->getColumnIndex('ID ключа');
         $notExistSessions = array();
         foreach ($data as $row) {
             // валидируем исходные данные
             if (!$validator->validate($row)) {
                 $skipped++;
             } else {
                 if (!array_key_exists($row[1], $sessionsNames)) {
                     if (!in_array($row[1], $notExistSessions)) {
                         $notExistSessions[] = $row[1];
                     }
                     $skipped++;
                 } else {
                     $memberType = $memberTypeIndex && $row[$memberTypeIndex] == 'Известен' ? \Ecoplay\Helper\Db\TestsHelper::GROUP_KEY_MEMBER_TYPE_FIXED_LIST : \Ecoplay\Helper\Db\TestsHelper::GROUP_KEY_MEMBER_TYPE_FLEXIBLE;
                     $keyData = array('sessionID' => $sessionsNames[$row[1]], 'name' => $row[0], 'is_need_complete_previous' => $needCompletePreviousIndex && $row[$needCompletePreviousIndex] == 1 ? 1 : 0, 'fact_count' => $factCountIndex ? intval($row[$factCountIndex]) : 0, 'member_type' => $memberType);
                     if ($memberType == \Ecoplay\Helper\Db\TestsHelper::GROUP_KEY_MEMBER_TYPE_FLEXIBLE) {
                         $keyData['plan_count'] = $planCountIndex ? intval($row[$planCountIndex]) : 0;
                         $keyData['is_registration_available'] = $registrationAvailableIndex && $row[$registrationAvailableIndex] == 0 ? 0 : 1;
                     } else {
                         $keyData['plan_count'] = 0;
                         $keyData['is_registration_available'] = 0;
                     }
                     $updatedKeyID = 0;
                     if ($keyIDIndex && $row[$keyIDIndex]) {
                         $updatedKey = $this->registry->getDbHelper('TestsHelper')->findGroupKeyByID($row[$keyIDIndex]);
                         if ($updatedKey && $updatedKey['projectID'] == $context['project']['projectID']) {
                             $updatedKeyID = $updatedKey['group_keyID'];
                         }
                     }
                     if ($updatedKeyID) {
                         $keyID = $updatedKeyID;
                         $this->registry->getDbHelper('TestsHelper')->editGroupKey($keyID, $keyData);
                         $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'group_key', $keyID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_CHANGE, $updatedKey);
                     } else {
                         $keyData['access_key'] = \Ecoplay\Helper\Db\BlanksHelper::uuid();
                         $keyData['active'] = 1;
                         $keyData['status'] = 'active';
                         $keyData['projectID'] = $context['project']['projectID'];
                         $keyID = $this->registry->getDbHelper('TestsHelper')->addGroupKey($keyData);
                         $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'group_key', $keyID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                     }
                     $inserted++;
                 }
             }
             $this->component->arResult['statusSuccess'] = 'Импортировано: ' . $inserted . ', проигнорировано: ' . $skipped;
             if (count($notExistSessions)) {
                 $this->component->arResult['action_warning'] = 'Групповые ключи для групп ' . implode(', ', $notExistSessions) . ' проигнорированы, так как указанные группы не существуют.';
             }
         }
     }
     $cnt = $this->registry->getDbHelper('TestsHelper')->getProjectGroupKeysCount($context['project']['projectID']);
     $onPage = 100;
     $pagesCnt = ceil($cnt / $onPage);
     $page = $_GET['PAGE'] && $_GET['PAGE'] <= $pagesCnt ? intval($_GET['PAGE']) : 1;
     $this->component->arResult['cntInfo'] = $pagesCnt == 1 ? $cnt : 0;
     // получаем список существующих групповых ключей
     $groupKeys = $this->registry->getDbHelper('TestsHelper')->getGroupKeysByProjectIDPaged($context['project']['projectID'], $page, $onPage);
     // количество респондентов для известных
     $fixedKeysIDs = array();
     foreach ($groupKeys as $key) {
         if ($key['member_type'] == \Ecoplay\Helper\Db\TestsHelper::GROUP_KEY_MEMBER_TYPE_FIXED_LIST) {
             $fixedKeysIDs[] = $key['group_keyID'];
         }
     }
     if (count($fixedKeysIDs)) {
         $this->component->arResult['fixedCnt'] = $this->registry->getDbHelper('TestsHelper')->getFixedKeysMembersCount($fixedKeysIDs);
     }
     $viewHelper = new \Ecoplay\View\Helper();
     /*foreach ($groupKeys as $ind => $key) {
         $groupKeys[$ind]['real_sessionID'] = $key['sessionID'];
         $groupKeys[$ind]['statusd'] = $key['status'];
       }
           
       $this->component->arResult['table_data'] = str_replace("'", "\'", $viewHelper->prepareJsonDataForTable($groupKeys,
         array('group_keyID', 'access_key', 'sessionID', 'status', 'statusd', 'name', 'cnt', 'is_registration_available', 'is_need_complete_previous', 'plan_count', 'fact_count', 'real_sessionID'),
         array(), array('sessionID' => $sessions)));
       $this->component->arResult['cnt'] = count($groupKeys);*/
     $this->component->arResult['sessions'] = $sessions;
     $this->component->arResult['memberTypes'] = \Ecoplay\Helper\Db\TestsHelper::getGroupKeyMemberTypes();
     $this->component->arResult['memberTypesDetailed'] = \Ecoplay\Helper\Db\TestsHelper::getGroupKeyMemberTypesDetailed();
     $this->component->arResult['statuses'] = \Ecoplay\Helper\Db\TestsHelper::getGroupKeyStatuses();
     $this->component->arResult['groupKeys'] = $groupKeys;
     // выводим таблицу с данными
     $this->component->IncludeComponentTemplate('linear/table');
     $navResult = new \CDBResult();
     $navResult->NavPageCount = ceil($cnt / $onPage);
     $navResult->NavPageNomer = $page;
     $navResult->NavNum = 1;
     $navResult->NavPageSize = $onPage;
     $navResult->NavRecordCount = $cnt;
     $navResult->nPageWindow = 11;
     $context['APPLICATION']->IncludeComponent('ecoplay:system.pagenavigation', '', array('NAV_RESULT' => $navResult, 'NAV_URL' => '/projects/' . $context['project']['projectID'] . '/settings/groupkeys/', 'NAV_QUERY_STRING' => isset($_GET['checkAll']) ? 'checkAll=1' : ''));
     $this->component->arResult['projectID'] = $context['project']['projectID'];
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Групповые ключи');
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('link' => '/', 'title' => 'Главная'), 1 => array('link' => '/projects/', 'title' => 'Проекты'), 2 => array('link' => '/projects/' . $context['project']['projectID'] . '/continuing/stat/', 'title' => $context['project']['project_name']), 3 => array('title' => 'Групповые ключи'))));
     $this->component->IncludeComponentTemplate('linear/template');
 }
示例#20
0
 public function execute($context)
 {
     $context['APPLICATION']->AddHeadScript('/js/forms.js');
     $context['APPLICATION']->AddHeadScript('/js/icheck/icheck.min.js');
     $context['APPLICATION']->SetAdditionalCSS('/js/icheck/skins/minimal/eco.css');
     $this->component->arResult['canSelectRespondents'] = $context['project']['allow_assess_to_select_respondents'];
     $this->component->arResult['canSelectAssess'] = $context['project']['allow_respondent_to_select_assess'];
     // проверка прав доступа к разделу
     if (!$this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'members', $context['project']['projectID'])) {
         $this->registry->getModel('Auth')->restrict();
     }
     $this->component->arResult['canImport'] = $this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'imports', $context['project']['projectID']);
     $availableSessionsIDs = $this->registry->getModel('Auth')->getAvailableSessions($_SESSION['accesses'], $context['project']['projectID']);
     $viewHelper = new \Ecoplay\View\Helper();
     if (count($availableSessionsIDs)) {
         $userSessions = $this->registry->getDbHelper('ProjectsHelper')->getUserAvailableSessionsByProjectID($context['project']['projectID'], $availableSessionsIDs);
         $this->component->arResult['jsessions'] = json_encode($userSessions);
         $this->component->arResult['sessions'] = $userSessions;
         $selectedIDs = array();
         $statuses = $this->registry->getDbHelper('MembersHelper')->getAssessStatusesNames();
         $sorts = array('assessID' => 'assessID', 'name' => 'name', 'surname' => 'surname', 'email' => 'email', 'position' => 'position', 'private_lk_access_key' => 'private_lk_access_key', 'respondents' => 'respondents', 'report' => 'report', 'sessionID' => 'sessionID', 'status' => 'status');
         if (isset($_GET['sort']) && array_key_exists($_GET['sort'], $sorts)) {
             $sort = $_GET['sort'];
         } else {
             $sort = 'assessID';
         }
         $order = isset($_GET['order']) && in_array($_GET['order'], array('asc', 'desc')) ? $_GET['order'] : 'asc';
         $filterQueryString = DataFilter::getFilterQueryString($_GET);
         $this->component->arResult['filterQueryString'] = $filterQueryString;
         $reportsStates = array(\Ecoplay\Helper\Db\MembersHelper::ASSESS_REPORT_STATE_EMPTY => 'Нет данных', \Ecoplay\Helper\Db\MembersHelper::ASSESS_REPORT_STATE_NOT_READY => 'Отчёт строить нельзя', \Ecoplay\Helper\Db\MembersHelper::ASSESS_REPORT_STATE_MINIMAL => 'Не полностью заполнено, но можно строить отчёт', \Ecoplay\Helper\Db\MembersHelper::ASSESS_REPORT_STATE_FULL => 'Заполнено на 100%');
         $this->component->arResult['reportsStates'] = $reportsStates;
         // настройки фильтров для данных
         $filters = array(0 => array('title' => 'Имя', 'name' => 'name', 'type' => 'text', 'data_type' => 'string', 'field' => 'pm.`name`'), 1 => array('title' => 'Фамилия', 'name' => 'surname', 'type' => 'text', 'data_type' => 'string', 'field' => 'pm.`surname`'), 2 => array('title' => 'ID', 'name' => 'id', 'type' => 'text', 'data_type' => 'number', 'field' => 'a.`assessID`'), 3 => array('title' => 'Текст', 'name' => 'text', 'type' => 'text', 'data_type' => 'string', 'field' => array('pm.`search_text`')), 4 => array('title' => 'Группа ', 'name' => 'session_id', 'type' => 'select', 'data_type' => 'number', 'field' => 'a.`sessionID`', 'values' => array(0 => 'Любая') + $userSessions), 5 => array('title' => 'Респондентов', 'name' => 'respondents', 'type' => 'range', 'data_type' => 'number', 'field' => '`respondents`'), 6 => array('title' => 'Статус ', 'name' => 'status', 'type' => 'select', 'data_type' => 'string', 'field' => 'a.`status`', 'values' => array(0 => 'Любой') + $statuses), 7 => array('title' => 'Утверждено ', 'name' => 'direct_viewed', 'type' => 'select', 'data_type' => 'number', 'field' => 'a.`viewed_by_direct_head`', 'values' => array(-1 => '-', 0 => 'Нет', 1 => 'Да'), 'explicit' => 1), 8 => array('title' => 'Отчеты ', 'name' => 'report_state', 'type' => 'select', 'data_type' => 'string', 'field' => 'a.`report_state`', 'values' => array(0 => 'Не учитывать') + $reportsStates));
         $filterData = array('FILTERS' => $filters, 'BASE_URL' => '/projects/' . $context['project']['projectID'] . '/groups/assess/', 'SORT' => $sort, 'ORDER' => $order);
         // проверяем, введен ли фильтр
         $filterValue = DataFilter::getFilterValue($filters, $_GET, $this->registry->getDbConnect());
         if ($filterValue['valid']) {
             $filterData = array_merge($filterData, $filterValue);
         }
         // компонент отображения фильтра
         $context['APPLICATION']->IncludeComponent('ecoplay:data.filter', '', $filterData);
         $cnt = $this->registry->getDbHelper('MembersHelper')->getAssessCountByProjectIDAndSessionsIds($context['project']['projectID'], $availableSessionsIDs, $filterValue['filter_strings']);
         $onPage = 100;
         $pagesCnt = ceil($cnt / $onPage);
         $page = $_GET['PAGE'] && $_GET['PAGE'] <= $pagesCnt ? intval($_GET['PAGE']) : 1;
         // обрабатываем статусы опрашиваемых
         if (isset($_POST['assess_ids'])) {
             if (isset($_POST['all']) && $_POST['all']) {
                 $selectedIDs = $this->registry->getDbHelper('MembersHelper')->getAssessIdsByProjectIDAndSessionsIds($context['project']['projectID'], $availableSessionsIDs, $filterValue['filter_strings']);
             } else {
                 $selectedIDs = $_POST['assess_ids'];
             }
             $assesses = $this->registry->getDbHelper('MembersHelper')->getAssessByIDs($selectedIDs);
             $newStatus = '';
             $needLog = true;
             if (isset($_POST['mode']) && $_POST['mode'] == 'report') {
                 // переводим в отчеты
                 $assessData = array('status' => \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_COMPLETE);
                 if ($context['project']['auto_send_report_email']) {
                     $assessData['last_report_email'] = '0000-00-00 00:00:00';
                 } else {
                     $assessData['last_report_email'] = date('d-m-Y H:i:s');
                 }
                 $this->registry->getDbHelper('MembersHelper')->editSeveralAssess($selectedIDs, $assessData);
                 //$this->registry->getDbHelper('MembersHelper')->changeAssessesStatus($selectedIDs, Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_COMPLETE);
                 $newStatus = \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_COMPLETE;
                 $this->component->arResult['statusSuccess'] = 'Оцениваемые переведены в статус отчета';
             } elseif (isset($_POST['mode']) && $_POST['mode'] == 'activate') {
                 // проверяем, чтобы у сессий оцениваемых был задан бланк!
                 $sessions = $this->registry->getDbHelper('MembersHelper')->getAssessSessions($selectedIDs);
                 $emptySession = false;
                 foreach ($sessions as $session) {
                     if (!$session['blankID']) {
                         $emptySession = $session['name'];
                         break;
                     }
                 }
                 if (!$emptySession) {
                     $this->registry->getDbHelper('MembersHelper')->changeAssessesStatus($selectedIDs, \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_ASSESS);
                     $this->component->arResult['statusSuccess'] = 'Оцениваемые переведены в статус опроса';
                     $newStatus = \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_ASSESS;
                 } else {
                     $this->component->arResult['statusError'] = 'Для группы "' . $emptySession . '" не задан бланк!';
                 }
             } elseif (isset($_POST['mode']) && $_POST['mode'] == 'select_respondents' && $context['project']['allow_assess_to_select_respondents']) {
                 $this->registry->getDbHelper('MembersHelper')->changeAssessesStatus($selectedIDs, \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_SELECT_RESPONDENTS);
                 $newStatus = \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_SELECT_RESPONDENTS;
                 $this->component->arResult['statusSuccess'] = 'Оцениваемые переведены в статус выбора респондента';
             } elseif (isset($_POST['mode']) && $_POST['mode'] == 'select_assess' && $context['project']['allow_respondent_to_select_assess']) {
                 $this->registry->getDbHelper('MembersHelper')->changeAssessesStatus($selectedIDs, \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_SELECT_ASSESS);
                 $newStatus = \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_SELECT_ASSESS;
                 $this->component->arResult['statusSuccess'] = 'Оцениваемые переведены в статус выбора оцениваемых';
             } elseif (isset($_POST['mode']) && $_POST['mode'] == 'new') {
                 $this->registry->getDbHelper('MembersHelper')->changeAssessesStatus($selectedIDs, \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_NEW);
                 $newStatus = \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_NEW;
                 $this->component->arResult['statusSuccess'] = 'Оцениваемые переведены в статус "Новый"';
             } elseif (isset($_POST['mode']) && $_POST['mode'] == 'email') {
                 // рассылка напоминалок респондентам
                 if ($context['project']['freeze_email']) {
                     $this->component->arResult['statusError'] = 'Невозможно отправить напоминания, так как проект заблокирован на рассылку почты';
                 } else {
                     $emailedAssessIDs = array();
                     $fillingEmailedAssessIDs = array();
                     foreach ($assesses as $assess) {
                         if ($assess['status'] == \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_ASSESS) {
                             $fillingEmailedAssessIDs[] = $assess['assessID'];
                         } elseif ($assess['status'] == \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_SELECT_RESPONDENTS) {
                             if ($assess['last_select_respondents_email'] != '0000-00-00 00:00:00') {
                                 $emailedAssessIDs[] = $assess['assessID'];
                             }
                         } elseif ($assess['status'] == \Ecoplay\Helper\Db\MembersHelper::ASSESS_STATUS_SELECT_ASSESS) {
                             if ($assess['last_select_assess_email'] != '0000-00-00 00:00:00') {
                                 $emailedAssessIDs[] = $assess['assessID'];
                             }
                         }
                     }
                     if (count($emailedAssessIDs)) {
                         $this->registry->getDbHelper('MembersHelper')->editSeveralAssess($emailedAssessIDs, array('need_remind' => 1));
                         $this->registry->getModel('ActionsLogger')->logMultiSimple($context['USER']->GetID(), 'assess', $emailedAssessIDs, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_NOTIFY);
                     }
                     if (count($fillingEmailedAssessIDs)) {
                         $emailedRespondents = $this->registry->getDbHelper('MembersHelper')->getRespondentsForAssessNotification($context['project']['projectID'], $fillingEmailedAssessIDs);
                         if ($emailedRespondents) {
                             $emailedRespondentsIDs = array();
                             foreach ($emailedRespondents as $respondent) {
                                 $emailedRespondentsIDs[] = $respondent['respondentID'];
                             }
                             $this->registry->getDbHelper('MembersHelper')->editRespondents($emailedRespondentsIDs, array('need_remind' => 1));
                             $this->registry->getModel('ActionsLogger')->logMultiSimple($context['USER']->GetID(), 'respondent', $emailedRespondentsIDs, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_NOTIFY);
                         }
                     }
                     $this->component->arResult['statusSuccess'] = 'Оцениваемые поставлены в очередь для email - напоминания';
                 }
             } elseif (isset($_POST['mode']) && $_POST['mode'] == 'report_email') {
                 // выслать уведомления о получении отчетов
                 $this->registry->getDbHelper('MembersHelper')->editSeveralAssess($selectedIDs, array('last_report_email' => '0000-00-00 00:00:00'));
                 $this->component->arResult['statusSuccess'] = 'Оцениваемым будут высланы уведомления о получении отчета';
             } elseif (isset($_POST['mode']) && $_POST['mode'] == 'report_zip') {
                 // задача на архив отчетов
                 // Создаем задачу
                 $taskID = $this->registry->getDbHelper('TasksHelper')->addTask(array('name' => '', 'type' => \Ecoplay\Helper\Db\TasksHelper::TASK_TYPE_REPORT_ZIP, 'params' => json_encode(array('projectID' => $context['project']['projectID'], 'assessIDs' => $selectedIDs)), 'userID' => $context['USER']->GetID(), 'status' => \Ecoplay\Helper\Db\TasksHelper::TASK_STATUS_NEW, 'dt_created' => date('d-m-Y H:i:s')));
                 $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'task', $taskID, \Ecoplay\Helper\Db\LogsHelper::ACTION_TYPE_ADD, null);
                 $this->component->arResult['statusSuccess'] = 'Генерация архива отчетов поставлена в очередь. Он будет доступен <a href="/projects/' . $context['project']['projectID'] . '/reportsArchives/">тут</a>';
             }
             $eventListener = new EventListener($this->registry, $context['project'], $_SERVER["DOCUMENT_ROOT"] . '/');
             if (isset($this->component->arResult['statusSuccess']) && $this->component->arResult['statusSuccess']) {
                 foreach ($assesses as $assess) {
                     if ($newStatus) {
                         $eventListener->executeEvent('Poll360_AssessStatusChanged', array('assessID' => $assess['assessID'], 'status_old' => $assess['status'], 'status_new' => $newStatus));
                     }
                     if ($needLog) {
                         $this->registry->getModel('ActionsLogger')->log($context['USER']->GetID(), 'assess', $assess['assessID'], LogsHelper::ACTION_TYPE_CHANGE, $assess);
                     }
                 }
             }
         }
         $this->component->arResult['selectedIDs'] = $selectedIDs;
         $assess = $this->registry->getDbHelper('MembersHelper')->getAssessByProjectIDAndSessionsIdsPaged($context['project']['projectID'], $availableSessionsIDs, $page, $onPage, $sorts[$sort], $order, $filterValue['filter_strings']);
         $this->component->arResult['assess'] = $assess;
         $this->component->arResult['statuses'] = $statuses;
         // кол-во email нотификаций для оцениваемого
         $emailsCnt = array();
         $editsAbility = array();
         if (count($assess)) {
             $assessIDs = array();
             foreach ($assess as $oneAssess) {
                 $assessIDs[] = $oneAssess['assessID'];
             }
             $emailsCnt = $this->registry->getDbHelper('MembersHelper')->getRespondentsForAssessNotificationCnt($context['project']['projectID'], $assessIDs);
             // чек, можно ли оцениваемому сменить группу
             $editsAbility = $this->registry->getDbHelper('MembersHelper')->getAssessEditsAbiliy($context['project']['projectID'], $assessIDs);
         }
         $this->component->arResult['emailsCnt'] = $emailsCnt;
         $this->component->arResult['editsAbility'] = $editsAbility;
         if (isset($_GET['checkAll'])) {
             $selectedIDs = array();
             foreach ($assess as $oneAssess) {
                 $selectedIDs[] = $oneAssess['assessID'];
             }
             $this->component->arResult['selectedIDs'] = $selectedIDs;
         }
         $this->component->arResult['sort'] = $sort;
         $this->component->arResult['order'] = $order;
         $this->component->arResult['cntInfo'] = $pagesCnt == 1 ? $cnt : 0;
         $roles = $this->registry->getDbHelper('ProjectsHelper')->getProjectRoles($context['project']['projectID']);
         $this->component->arResult['roles'] = $roles;
         // выводим таблицу с данными
         $this->component->IncludeComponentTemplate('table');
         $navResult = new \CDBResult();
         $navResult->NavPageCount = ceil($cnt / $onPage);
         $navResult->NavPageNomer = $page;
         $navResult->NavNum = 1;
         $navResult->NavPageSize = $onPage;
         $navResult->NavRecordCount = $cnt;
         $navResult->nPageWindow = 11;
         $context['APPLICATION']->IncludeComponent('ecoplay:system.pagenavigation', '', array('NAV_RESULT' => $navResult, 'NAV_URL' => '/projects/' . $context['project']['projectID'] . '/groups/assess/', 'NAV_QUERY_STRING' => 'sort=' . $sort . '&order=' . $order . ($filterQueryString ? '&' . $filterQueryString : '') . (isset($_GET['checkAll']) ? '&checkAll=1' : '')));
         $sessions = $this->registry->getDbHelper('ProjectsHelper')->getSessionsByIDs(array_keys($userSessions));
         $sessionRoles = array();
         foreach ($sessions as $session) {
             if ($session['param_roles']) {
                 $sessionParams = (array) json_decode($session['~param_roles']);
                 foreach ($sessionParams as $roleID => $param) {
                     if (!array_key_exists($roleID, $sessionRoles)) {
                         $sessionRoles[$roleID] = $param;
                     } else {
                         if ($param->min < $sessionRoles[$roleID]->min) {
                             $sessionRoles[$roleID]->min = $param->min;
                         }
                         if ($param->max > $sessionRoles[$roleID]->max) {
                             $sessionRoles[$roleID]->max = $param->max;
                         }
                     }
                 }
             }
         }
         $this->component->arResult['sessionsRoles'] = $sessionRoles;
     } else {
         $this->component->arResult['assess'] = null;
     }
     $context['APPLICATION']->SetPageProperty('pageMainTitle', 'Оцениваемые');
     $context['APPLICATION']->SetPageProperty('navigation', $viewHelper->generateNavigation(array(0 => array('link' => '/', 'title' => 'Главная'), 1 => array('link' => '/projects/', 'title' => 'Проекты'), 2 => array('link' => '/projects/' . $context['project']['projectID'] . '/continuing/stat/', 'title' => $context['project']['project_name']), 3 => array('link' => '/projects/' . $context['project']['projectID'] . '/settings/groups/', 'title' => 'Группы оцениваемых'), 4 => array('title' => 'Оцениваемые'))));
     $this->component->arResult['canReports'] = $this->registry->getModel('Auth')->checkAccess($_SESSION['accesses'], 'reports', $context['project']['projectID']);
     $this->component->IncludeComponentTemplate();
 }