public function load()
 {
     $ids = NGS()->args()->ids;
     $duplidatedRows = RealVoterNumberManager::getInstance()->selectAdvance('*', ['id', 'in', "({$ids})"], ['create_datetime'], 'asc');
     if (!empty($duplidatedRows)) {
         $numVoter = $duplidatedRows[0];
         $voterId = $numVoter->getVoterId();
         if ($voterId > 0) {
             $prevoteData = VoterDataManager::getInstance()->selectByField('voter_id', $voterId);
             if (!empty($prevoteData)) {
                 $this->addParam('prevoteData', $prevoteData);
             }
             $voter = VoterManager::getInstance()->selectByPK($voterId);
             $areaId = $voter->getAreaId();
             $area = AreaManager::getInstance()->selectByPK($areaId);
             $this->addParam('area', $area);
             $this->addParam('voter', $voter);
         }
         $this->addParam('voter_id', $voterId);
         $this->addParam('vote_count', count($duplidatedRows));
         $areaIdsArray = $this->getAreaIdsArray($duplidatedRows);
         $areasMappedById = AreaManager::getInstance()->selectbyPKs($areaIdsArray, true);
         $this->addParam('duplidatedRows', $duplidatedRows);
         $this->addParam('areasMappedById', $areasMappedById);
     }
 }
Example #2
0
 public function load()
 {
     $dataCountGroupByVoter = VoterDataManager::getInstance()->getDataCountGroupByVoterId();
     $nonParticipantCounts = VoterDataManager::getInstance()->getNonParticipantCounts();
     $participantCounts = VoterDataManager::getInstance()->getParticipantCounts();
     $totalPassportDuplicationVotes = AnalyzeManager::getInstance()->getTotalPassportDuplicationVotes();
     $totalValidPassportVotesCount = RealVoterPassportManager::getInstance()->getTotalValidVotesCount();
     $totalNumberDuplicationVotes = AnalyzeManager::getInstance()->getTotalNumberDuplicationVotes();
     $totalValidNumberVotesCount = RealVoterNumberManager::getInstance()->getTotalValidVotesCount();
     $allAreaIdsMappedByTerritoryId = \hqv\managers\AreaManager::getInstance()->getAllAreaIdsMappedByTerritoryId();
     $allTerritoriesIds = array_keys($allAreaIdsMappedByTerritoryId);
     asort($allTerritoriesIds);
     $this->addJsonParam('allTerritoryIds', array_values($allTerritoriesIds));
     $passportTotalVotersCountByTerritoryId = [];
     $numberTotalVotersCountByTerritoryId = [];
     foreach ($allAreaIdsMappedByTerritoryId as $territoryId => $areaIdsArray) {
         $passportTotalVotersCountByTerritoryId['t' . $territoryId] = RealVoterPassportManager::getInstance()->getTotalValidVotesCountInAreaIds($areaIdsArray);
         $numberTotalVotersCountByTerritoryId['t' . $territoryId] = RealVoterNumberManager::getInstance()->getTotalValidVotesCountInAreaIds($areaIdsArray);
     }
     $this->addJsonParam('passportTotalVotersCountByTerritoryId', $passportTotalVotersCountByTerritoryId);
     $this->addJsonParam('numberTotalVotersCountByTerritoryId', $numberTotalVotersCountByTerritoryId);
     $this->addJsonParam("passportFake", $totalPassportDuplicationVotes);
     $this->addJsonParam("passportTotal", $totalValidPassportVotesCount);
     $this->addJsonParam("numberFake", $totalNumberDuplicationVotes);
     $this->addJsonParam("numberTotal", $totalValidNumberVotesCount);
     $this->addParam('countGroupByVoter', $dataCountGroupByVoter);
     $this->addParam('participantCounts', $participantCounts);
     $this->addParam('nonParticipantCounts', $nonParticipantCounts);
 }
 public function service()
 {
     set_time_limit(1000);
     $t = microtime(true);
     while (true) {
         $tmpRows = RealVoterNumberTmpManager::getInstance()->selectAdvance('*', ['synced', '=', '0', 'and', 'create_datetime', '<', "'" . date('Y-m-d H:i:s', strtotime('-16 seconds')) . "'"]);
         foreach ($tmpRows as $tmpRow) {
             $areaVoterId = $tmpRow->getAreaVoterId();
             $voterId = $tmpRow->getVoterId();
             $areaId = $tmpRow->getAreaId();
             $observerId = $tmpRow->getObserverId();
             $datetime = $tmpRow->getCreateDatetime();
             $rows = RealVoterNumberManager::getInstance()->selectAdvance('*', ['moderator_id', '=', 0, 'and', 'area_id', '=', $areaId, 'and', 'area_voter_id', '=', $areaVoterId, 'and', 'NOT', "FIND_IN_SET('{$observerId}',`observers_ids`)"]);
             if (!empty($rows)) {
                 $row = $rows[0];
                 $observersIds = $row->getObserversIds();
                 $observersIdsArray = explode(',', $observersIds);
                 $observersIdsArray[] = $observerId;
                 $row->setObserversIds(implode(',', $observersIdsArray));
                 RealVoterNumberManager::getInstance()->updateByPK($row);
             } else {
                 RealVoterNumberManager::getInstance()->addRowForObserver($areaVoterId, $voterId, $areaId, $observerId, $datetime);
             }
             RealVoterNumberTmpManager::getInstance()->updateField($tmpRow->getId(), 'synced', 1);
         }
         sleep(1);
         $deltaSeconds = microtime(true) - $t;
         if ($deltaSeconds > 58) {
             break;
         }
     }
 }
Example #4
0
 public function service()
 {
     if (!isset(NGS()->args()->rowId)) {
         $this->addParam('status', 'error');
         $this->addParam('message', "Missing ID");
         return;
     }
     $rowId = intval(NGS()->args()->rowId);
     RealVoterNumberManager::getInstance()->deleteByPK($rowId);
 }
Example #5
0
 public function load()
 {
     global $numberAreaId;
     if (isset(NGS()->args()->areaId)) {
         $numberAreaId = NGS()->args()->areaId;
     }
     $userType = NGS()->getSessionManager()->getUserType();
     $moderatorId = NGS()->getSessionManager()->getUserId();
     $limit = 20;
     $page = 1;
     if (isset(NGS()->args()->page)) {
         $page = intval(NGS()->args()->page);
     }
     if (isset(NGS()->args()->limit)) {
         $limit = intval(NGS()->args()->limit);
     }
     $this->addParam('page', $page);
     $this->addParam('limit', $limit);
     $offset = ($page - 1) * $limit;
     $where = ['area_id', '=', $numberAreaId];
     if ($userType == \admin\security\UserGroups::$MODERATOR) {
         $where[] = 'and';
         $where[] = 'moderator_id';
         $where[] = '=';
         $where[] = $moderatorId;
     }
     $rows = RealVoterNumberManager::getInstance()->selectAdvance('*', $where, ['create_datetime'], 'DESC', $offset, $limit);
     $voterIdsArray = $this->getVoterIdsArray($rows);
     $areaIdsArray = $this->getAreaIdsArray($rows);
     $duplicatedInListRealVoters = [];
     $voters = [];
     $areas = [];
     $preVoteData = [];
     if (!empty($voterIdsArray)) {
         $voters = VoterManager::getInstance()->selectByPKs($voterIdsArray, true);
         $areas = AreaManager::getInstance()->selectByPKs($areaIdsArray, true);
         $duplicatedInListRealVoters = RealVoterNumberManager::getInstance()->getDuplicatedInListRealVotersRowIds($voterIdsArray);
         $voterIdsSqlString = "(" . implode(',', $voterIdsArray) . ")";
         $preVoteData = VoterDataManager::getInstance()->selectAdvance('*', ['voter_id', 'in', $voterIdsSqlString]);
         $preVoteData = $this->MapByVoterId($preVoteData);
     }
     $count = RealVoterNumberManager::getInstance()->getLastSelectAdvanceRowsCount();
     $pageCount = ceil($count / $limit);
     if ($count == 0) {
         $pageCount = 1;
     }
     $this->addParam('pageCount', $pageCount);
     $this->addParam('rows', $rows);
     $this->addParam('voters', $voters);
     $this->addParam('areas', $areas);
     $this->addParam('duplicatedInListMappedById', $duplicatedInListRealVoters);
     $this->addParam('preVoteData', $preVoteData);
 }
 public function service()
 {
     if (!isset(NGS()->args()->rowId)) {
         $this->addParam('status', 'error');
         $this->addParam('message', "Missing ID");
         return;
     }
     $rowId = intval(NGS()->args()->rowId);
     $invalid = intval(NGS()->args()->invalid);
     RealVoterNumberManager::getInstance()->updateField($rowId, 'invalid', $invalid);
     if (NGS()->args()->note) {
         RealVoterNumberManager::getInstance()->updateField($rowId, 'invalid_note', NGS()->args()->note);
     }
 }
Example #7
0
 public function load()
 {
     $voterNumber = "";
     if (isset(NGS()->args()->rowId)) {
         $realVoter = RealVoterNumberManager::getInstance()->selectByPK(NGS()->args()->rowId);
         if (!empty($realVoter)) {
             $voterNumber = $realVoter->getAreaVoterId();
             $this->addParam('edit', 1);
             $this->addParam('row_id', NGS()->args()->rowId);
         }
     } else {
         $this->addParam('edit', 0);
     }
     $this->addParam('voterNumber', $voterNumber);
 }
Example #8
0
 public function load()
 {
     global $numberAreaId;
     if (isset(NGS()->args()->rowId)) {
         $row = RealVoterNumberManager::getInstance()->selectByPK(NGS()->args()->rowId);
         if (!empty($row)) {
             $areaId = $row->getAreaId();
             if (intval($areaId) > 0) {
                 $area = AreaManager::getInstance()->selectByPK($areaId);
                 $selectedRegion = $area->getRegion();
                 $selectedRegionCommunity = $area->getCommunity();
                 $selectedAreaId = $area->getId();
             }
         }
     }
     $regionNamesArray = AreaManager::getInstance()->getRegionNamesArray();
     if (!isset($selectedRegion)) {
         $selectedRegion = $regionNamesArray[0];
         if (isset(NGS()->args()->selectedRegion)) {
             $selectedRegion = trim(NGS()->args()->selectedRegion);
         }
     }
     $regionCommunities = AreaManager::getInstance()->getRegionCommunitiesArray($selectedRegion);
     if (!isset($selectedRegionCommunity)) {
         $selectedRegionCommunity = $regionCommunities[0];
         if (isset(NGS()->args()->selectedRegionCommunity)) {
             $selectedRegionCommunity = trim(NGS()->args()->selectedRegionCommunity);
         }
     }
     $areasMappedById = AreaManager::getInstance()->getByRegionAndCommunity($selectedRegion, $selectedRegionCommunity);
     if (!isset($selectedAreaId)) {
         $areaIds = array_keys($areasMappedById);
         reset($areaIds);
         $selectedAreaId = current($areaIds);
         if (isset(NGS()->args()->selectedAreaId)) {
             $selectedAreaId = NGS()->args()->selectedAreaId;
         }
     }
     $numberAreaId = $selectedAreaId;
     $allAreas = AreaManager::getInstance()->selectAll();
     $this->addParam('all_areas', $allAreas);
     $this->addParam('selectedRegion', $selectedRegion);
     $this->addParam('selectedRegionCommunity', $selectedRegionCommunity);
     $this->addParam('selectedAreaId', $selectedAreaId);
     $this->addParam('regions', $regionNamesArray);
     $this->addParam('regionCommunities', $regionCommunities);
     $this->addParam('areas', $areasMappedById);
 }
 public function service()
 {
     $validateFields = $this->validateFields();
     if (!is_array($validateFields)) {
         $this->addParam('status', 'error');
         $this->addParam('message', $validateFields);
         return;
     }
     list($voterNumber, $rowId, $areaId) = $validateFields;
     $moderatorId = NGS()->getSessionManager()->getUserId();
     if ($rowId == 0) {
         RealVoterNumberManager::getInstance()->addRow($voterNumber, $moderatorId, $areaId);
     } else {
         RealVoterNumberManager::getInstance()->editRow($rowId, $voterNumber, $moderatorId, $areaId);
     }
 }
Example #10
0
 public function load()
 {
     $willNotVoteVoters = VoterDataManager::getInstance()->selectAdvance('*', ['is_death', '=', 1]);
     $voterIdsArray = $this->getVoterIdsArray($willNotVoteVoters);
     $voterIdsArraySql = "(" . implode(',', $voterIdsArray) . ")";
     $realVoters = RealVoterNumberManager::getInstance()->selectAdvance('*', ['voter_id', '>', 0, 'and', 'voter_id', 'in', $voterIdsArraySql]);
     $voterIdsArray = $this->getVoterIdsArray($realVoters);
     $voters = VoterManager::getInstance()->selectByPKs($voterIdsArray, true);
     $prevotDatas = [];
     array_unique($voterIdsArray);
     foreach ($voterIdsArray as $voterId) {
         $prevotDatas[$voterId] = VoterDataManager::getInstance()->selectAdvance('*', ['voter_id', '=', $voterId]);
     }
     $this->addParam("rows", $realVoters);
     $this->addParam("voters", $voters);
     $this->addParam("prevotDatas", $prevotDatas);
 }