Example #1
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);
 }
Example #2
0
 public function load()
 {
     $firstName = "";
     $lastName = "";
     $fatherName = "";
     $birthYear = 1950;
     $birthMonth = 0;
     $birthDay = 0;
     if (isset(NGS()->args()->rowId)) {
         $realVoter = RealVoterPassportManager::getInstance()->selectByPK(NGS()->args()->rowId);
         if (isset($realVoter)) {
             $firstName = $realVoter->getFirstName();
             $lastName = $realVoter->getLastName();
             $fatherName = $realVoter->getFatherName();
             $birthDate = $realVoter->getBirthDate();
             if (!empty($birthDate)) {
                 $dateParts = explode('-', $birthDate);
                 $birthYear = $dateParts[0];
                 $birthMonth = $dateParts[1];
                 $birthDay = $dateParts[2];
             }
             $this->addParam('edit', 1);
             $this->addParam('row_id', NGS()->args()->rowId);
         }
     } else {
         $this->addParam('edit', 0);
     }
     $this->addParam('first_name', $firstName);
     $this->addParam('last_name', $lastName);
     $this->addParam('father_name', $fatherName);
     $this->addParam('birth_year', $birthYear);
     $this->addParam('birth_month', $birthMonth);
     $this->addParam('birth_day', $birthDay);
 }
 public function load()
 {
     $ids = NGS()->args()->ids;
     $duplidatedRows = RealVoterPassportManager::getInstance()->selectAdvance('*', ['id', 'in', "({$ids})"], ['create_datetime'], 'asc');
     if (!empty($duplidatedRows)) {
         $passVoter = $duplidatedRows[0];
         $voterId = $passVoter->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 #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);
     RealVoterPassportManager::getInstance()->deleteByPK($rowId);
 }
 public function load()
 {
     if (isset(NGS()->args()->areaId)) {
         $areaId = intval(NGS()->args()->areaId);
         $area = AreaManager::getInstance()->selectByPK($areaId);
         if (isset($area)) {
             $areaPassportVoters = RealVoterPassportManager::getInstance()->selectAdvance('*', ['area_id', '=', $areaId]);
             $this->addParam('areaPassportVotersCount', count($areaPassportVoters));
         }
     }
 }
Example #6
0
 public function load()
 {
     $willVoteVoters = VoterDataManager::getInstance()->selectAdvance('*', ['will_vote', '=', 1]);
     $voterIdsArray = $this->getVoterIdsArray($willVoteVoters);
     $voterIdsArraySql = "(" . implode(',', $voterIdsArray) . ")";
     $realVotersPassport = RealVoterPassportManager::getInstance()->selectAdvance('*', ['voter_id', '>', '0', 'and', 'voter_id', 'in', $voterIdsArraySql]);
     $gnacacneriVoterIds = $this->getVoterIdsArray($realVotersPassport);
     $retVoterIds = array_diff($voterIdsArray, $gnacacneriVoterIds);
     $rows = VoterManager::getInstance()->selectByPKs($retVoterIds);
     $this->addParam("rows", $rows);
     $this->addParam("count", count($rows));
 }
 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);
     RealVoterPassportManager::getInstance()->updateField($rowId, 'invalid', $invalid);
     if (NGS()->args()->note) {
         RealVoterPassportManager::getInstance()->updateField($rowId, 'invalid_note', NGS()->args()->note);
     }
 }
Example #8
0
 public function load()
 {
     if (isset(NGS()->args()->rowId)) {
         $row = RealVoterPassportManager::getInstance()->selectByPK(NGS()->args()->rowId);
         if (isset($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 = NGS()->args()->selectedRegion;
         }
     }
     $regionCommunities = AreaManager::getInstance()->getRegionCommunitiesArray($selectedRegion);
     if (!isset($selectedRegionCommunity)) {
         $selectedRegionCommunity = $regionCommunities[0];
         if (isset(NGS()->args()->selectedRegionCommunity)) {
             $selectedRegionCommunity = 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;
         }
     }
     $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);
 }
Example #9
0
 public function load()
 {
     $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;
     $rows = RealVoterPassportManager::getInstance()->selectAdvance('*', ['moderator_id', '=', $moderatorId], ['create_datetime'], 'DESC', $offset, $limit);
     $voterIdsArray = $this->getVoterIdsArray($rows);
     $duplicatedInListRealVoters = [];
     $voters = [];
     $preVoteData = [];
     if (!empty($voterIdsArray)) {
         $voters = VoterManager::getInstance()->selectByPKs($voterIdsArray, true);
         $duplicatedInListRealVoters = RealVoterPassportManager::getInstance()->getDuplicatedInListRealVotersRowIds($voterIdsArray);
         $voterIdsSqlString = "(" . implode(',', $voterIdsArray) . ")";
         $preVoteData = \hqv\managers\VoterDataManager::getInstance()->selectAdvance('*', ['voter_id', 'in', $voterIdsSqlString]);
         $preVoteData = $this->MapByVoterId($preVoteData);
     }
     $count = RealVoterPassportManager::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('duplicatedInListMappedById', $duplicatedInListRealVoters);
     $this->addParam('preVoteData', $preVoteData);
 }
Example #10
0
 public function service()
 {
     $validateFields = $this->validateFields();
     if (!is_array($validateFields)) {
         $this->addParam('status', 'error');
         $this->addParam('message', $validateFields);
         return;
     }
     list($firstName, $lastName, $fatherName, $birthYear, $birthMonth, $birthDay, $rowId, $areaId, $passportType) = $validateFields;
     $where = ['first_name', 'like', "'{$firstName}%'", 'and', 'last_name', 'like', "'{$lastName}%'", 'and', 'area_id', '=', $areaId];
     if (!empty($fatherName)) {
         $where[] = 'and';
         $where[] = 'father_name';
         $where[] = 'like';
         $where[] = "'{$fatherName}%'";
     }
     if (!empty($birthYear)) {
         $where[] = 'and';
         $where[] = 'YEAR(birth_date)';
         $where[] = '=';
         $where[] = "'{$birthYear}'";
     }
     if (!empty($birthMonth)) {
         $where[] = 'and';
         $where[] = 'MONTH(birth_date)';
         $where[] = '=';
         $where[] = "'{$birthMonth}'";
     }
     if (!empty($birthDay)) {
         $where[] = 'and';
         $where[] = 'DAY(birth_date)';
         $where[] = '=';
         $where[] = "'{$birthDay}'";
     }
     $moderatorId = NGS()->getSessionManager()->getUserId();
     $rows = VoterManager::getInstance()->selectAdvance('*', $where);
     $voter = false;
     if (!empty($rows)) {
         $voter = $rows[0];
     }
     if ($voter) {
         if ($rowId == 0) {
             RealVoterPassportManager::getInstance()->addRow($voter->getId(), 1, $voter->getFirstName(), $voter->getLastName(), $voter->getFatherName(), $voter->getBirthDate(), $moderatorId, $areaId, $passportType);
         } else {
             RealVoterPassportManager::getInstance()->editRow($voter->getId(), 1, $rowId, $voter->getFirstName(), $voter->getLastName(), $voter->getFatherName(), $voter->getBirthDate(), $moderatorId, $areaId, $passportType);
         }
         return;
     }
     $where = ['first_name', '=', "'{$firstName}'", 'and', 'last_name', '=', "'{$lastName}'"];
     if (!empty($fatherName)) {
         $where[] = 'and';
         $where[] = 'father_name';
         $where[] = 'like';
         $where[] = "'{$fatherName}%'";
     }
     if (!empty($birthYear)) {
         $where[] = 'and';
         $where[] = 'YEAR(birth_date)';
         $where[] = '=';
         $where[] = "'{$birthYear}'";
     }
     if (!empty($birthMonth)) {
         $where[] = 'and';
         $where[] = 'MONTH(birth_date)';
         $where[] = '=';
         $where[] = "'{$birthMonth}'";
     }
     if (!empty($birthDay)) {
         $where[] = 'and';
         $where[] = 'DAY(birth_date)';
         $where[] = '=';
         $where[] = "'{$birthDay}'";
     }
     $rows = VoterManager::getInstance()->selectAdvance('*', $where);
     $voter = false;
     if (!empty($rows) && count($rows) === 1) {
         $voter = $rows[0];
     }
     if ($voter) {
         $birthDate = $voter->getBirthData();
         if ($rowId == 0) {
             RealVoterPassportManager::getInstance()->addRow($voter->getId(), 0, $voter->getFirstName(), $voter->getLastName(), $voter->getFatherName(), $voter->getBirthDate(), $moderatorId, $areaId, $passportType);
         } else {
             RealVoterPassportManager::getInstance()->editRow($voter->getId(), 0, $rowId, $voter->getFirstName(), $voter->getLastName(), $voter->getFatherName(), $voter->getBirthDate(), $moderatorId, $areaId, $passportType);
         }
         return;
     }
     $birthYear = !empty($birthYear) ? $birthYear : 1900;
     $birthMonth = !empty($birthMonth) ? $birthMonth : 1;
     $birthDay = !empty($birthDay) ? $birthDay : 1;
     $birthDate = $birthYear . '-' . $birthMonth . '-' . $birthDay;
     if ($rowId == 0) {
         RealVoterPassportManager::getInstance()->addRow(0, 0, $firstName, $lastName, $fatherName, $birthDate, $moderatorId, $areaId, $passportType);
     } else {
         RealVoterPassportManager::getInstance()->editRow(0, 0, $rowId, $firstName, $lastName, $fatherName, $birthDate, $moderatorId, $areaId, $passportType);
     }
 }