Пример #1
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;
     $duplicatedRealVoters = AnalyzeManager::getInstance()->getDuplicatedPassportRealVoters($offset, $limit);
     $this->addParam('duplicatedRealVoters', $duplicatedRealVoters);
     $voterIdsArray = $this->getVoterIdsArray($duplicatedRealVoters);
     $voters = [];
     $preVoteData = [];
     if (!empty($voterIdsArray)) {
         $voters = VoterManager::getInstance()->selectByPKs($voterIdsArray, true);
         $voterIdsSqlString = "(" . implode(',', $voterIdsArray) . ")";
         $preVoteData = VoterDataManager::getInstance()->selectAdvance('*', ['voter_id', 'in', $voterIdsSqlString]);
         $preVoteData = $this->MapByVoterId($preVoteData);
     }
     $count = AnalyzeManager::getInstance()->getDuplicatedPassportRealVotersCount();
     $pageCount = ceil($count / $limit);
     if ($count == 0) {
         $pageCount = 1;
     }
     $this->addParam('pageCount', $pageCount);
     $this->addParam('rows', $duplicatedRealVoters);
     $this->addParam('voters', $voters);
     $this->addParam('preVoteData', $preVoteData);
 }
 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);
     }
 }
Пример #3
0
 public function service()
 {
     $validateData = $this->validateData();
     if ($validateData) {
         list($hash, $email, $phone, $will_vote, $will_be_in_arm, $is_death, $ip_address, $country, $browser, $version, $os) = $validateData;
         $rows = VoterDataManager::getInstance()->selectAdvance('*', ['ip_address', '=', "'{$ip_address}'"], ['datetime'], 'DESC');
         if (!empty($rows) && count($rows) > 5) {
             $this->addParam('status', 'error');
             $supportPhoneNumber = $this->getSetting('support_phone_number');
             require_once NGS()->getClassesDir('ngs') . "/lib/captcha/simple-php-captcha.php";
             list($code, $base64Png) = generateCaptcha();
             $_SESSION['captcha_code'] = $code;
             $this->addParam('captcha', 'data:image/png;base64,' . $base64Png);
             $this->addParam('message', 'Sorry, you tried to vote for many peaple, please call us on ' . $supportPhoneNumber, ' for support.');
             return;
         }
         $voter = VoterManager::getInstance()->getByHash($hash);
         if (isset($voter)) {
             $this->addParam('hash', $hash);
             VoterDataManager::getInstance()->addRow($voter->getId(), $email, $phone, $will_vote, $will_be_in_arm, $is_death, $ip_address, $country, $browser, $version, $os);
             /* if (!empty($email)) {
                $mailgunManager = MailgunEmailSenderManager::getInstance();
                $mailgunManager->sendSingleHtmlEmail('*****@*****.**', 'Hi!!!', $this->getEmailHtml(), '*****@*****.**', 'Հանրաքվե');
                } */
         }
     }
 }
 public function service()
 {
     set_time_limit(500000);
     $offset = 0;
     $limit = 5000;
     while (true) {
         $allData = AdditionalVoterManager::getInstance()->selectAdvance('*', [], [], null, $offset, $limit);
         if (empty($allData)) {
             break;
         }
         $offset += $limit;
         foreach ($allData as $row) {
             $birthDate = $row->getBirthDate();
             $firstName = $row->getFirstName();
             $lastName = $row->getLastName();
             $fatherName = $row->getFatherName();
             $voters = VoterManager::getInstance()->selectAdvance('*', ['first_name', '=', "'{$firstName}'", 'and', 'last_name', '=', "'{$lastName}'", 'and', 'father_name', '=', "'{$fatherName}'", 'and', 'birth_date', '=', "'{$birthDate}'"]);
             if (!empty($voters) && is_array($voters) && count($voters) === 1) {
                 $voter = $voters[0];
                 $voter->setCut(1);
                 $additionalVoterId = $row->getId();
                 $voter->setAdditionalVoterId($additionalVoterId);
                 VoterManager::getInstance()->updateByPK($voter);
                 $row->setVoterId($voter->getId());
                 AdditionalVoterManager::getInstance()->updateByPK($row);
             }
         }
     }
     exit;
 }
Пример #5
0
 public function load()
 {
     $limit = 100;
     $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 = [];
     if (!empty(NGS()->args()->firstName)) {
         $firstName = NGS()->args()->firstName;
         $where[] = 'first_name';
         $where[] = 'like';
         $where[] = "'{$firstName}%'";
     }
     if (!empty(NGS()->args()->lastName)) {
         $lastName = NGS()->args()->lastName;
         if (!empty($where)) {
             $where[] = 'and';
         }
         $where[] = 'last_name';
         $where[] = 'like';
         $where[] = "'{$lastName}%'";
     }
     if (!empty(NGS()->args()->ipAddress)) {
         $ipAddress = NGS()->args()->ipAddress;
         if (!empty($where)) {
             $where[] = 'and';
         }
         $where[] = 'ip_address';
         $where[] = 'like';
         $where[] = "'{$ipAddress}%'";
     }
     if (!empty(NGS()->args()->birthYear) && !empty(NGS()->args()->birthMonth) && !empty(NGS()->args()->birthDay)) {
         $birthDate = intval(NGS()->args()->birthYear) . '-' . intval(NGS()->args()->birthMonth) . '-' . intval(NGS()->args()->birthDay);
         if (!empty($where)) {
             $where[] = 'and';
         }
         $where[] = 'birth_date';
         $where[] = '=';
         $where[] = "'{$birthDate}'";
     }
     $rows = VoterDataManager::getInstance()->selectJoinVoters($where, $offset, $limit);
     $count = VoterDataManager::getInstance()->selectJoinVotersCount($where);
     $voterIdsArray = $this->getVoterIdsArray($rows);
     $voters = VoterManager::getInstance()->selectByPKs($voterIdsArray, true);
     $pageCount = ceil($count / $limit);
     if ($count == 0) {
         $pageCount = 1;
     }
     $this->addParam('pageCount', $pageCount);
     $this->addParam('rows', $rows);
     $this->addParam('voters', $voters);
     $this->addParam('total_count', $count);
 }
Пример #6
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;
     $duplicatedOrDeathVoters = VoterDataManager::getInstance()->getDuplicatedOrDeathData($offset, $limit);
     $voterIdsArray = $this->getVoterIdsArray($duplicatedOrDeathVoters);
     $voters = [];
     if (!empty($voterIdsArray)) {
         $voters = VoterManager::getInstance()->selectByPKs($voterIdsArray, true);
     }
     $count = VoterDataManager::getInstance()->getDuplicatedOrDeathDataCount();
     $pageCount = ceil($count / $limit);
     if ($count == 0) {
         $pageCount = 1;
     }
     $this->addParam('pageCount', $pageCount);
     $this->addParam('rows', $duplicatedOrDeathVoters);
     $this->addParam('voters', $voters);
 }
Пример #7
0
 public function load()
 {
     list($minBirthDate, $maxBirthDate) = \hqv\managers\VoterManager::getInstance()->getMaxAndMinBirthDates();
     $this->addJsonParam('minBirthDate', $minBirthDate);
     $this->addJsonParam('maxBirthDate', $maxBirthDate);
     $this->addJsonParam('closeText', $this->getPhrase(50));
     $this->addJsonParam('clearText', $this->getPhrase(52));
 }
Пример #8
0
 public function load()
 {
     if (!isset(NGS()->args()->hash)) {
         return;
     }
     $hash = NGS()->args()->hash;
     $voter = VoterManager::getInstance()->getByHash($hash);
     if (isset($voter)) {
         $this->addParam('voter', $voter);
     }
 }
Пример #9
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);
 }
Пример #10
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));
 }
Пример #11
0
 public function service()
 {
     $validateData = $this->validateData();
     if ($validateData) {
         list($firstName, $lastName, $fatherName, $birthYear, $birthMonth, $birthDay) = $validateData;
         $where = ['first_name', 'like', "'{$firstName}%'", 'and', 'last_name', 'like', "'{$lastName}%'", 'and', 'YEAR(birth_date)', '=', "'{$birthYear}'"];
         if (!empty($fatherName)) {
             $where[] = 'and';
             $where[] = 'father_name';
             $where[] = 'like';
             $where[] = "'{$fatherName}%'";
         }
         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);
         if (!empty($rows) && is_array($rows) && count($rows) === 1) {
             $voter = $rows[0];
             $alreadyExistsRows = VoterDataManager::getInstance()->selectByField('voter_id', $voter->getId());
             if ($alreadyExistsRows) {
                 $alreadyExistsVoter = VoterManager::getInstance()->selectByPK($voter->getId());
                 $this->addParam('status', 'error');
                 $this->addParam('message', 'Already Exists!<br> ' . $alreadyExistsVoter->getFirstName() . ' ' . $alreadyExistsVoter->getLastName() . ' ' . $alreadyExistsVoter->getFatherName() . ' ' . $alreadyExistsVoter->getBirthDate());
                 return;
             }
             VoterDataManager::getInstance()->addRowFromModerator($voter->getId());
             return;
         }
         $this->addParam('status', 'error');
         $message = "";
         if (empty($rows)) {
             $message = "Not Found!";
         } else {
             foreach ($rows as $row) {
                 $message .= $row->getFirstName() . ' ' . $row->getLastName() . ' ' . $row->getFatherName() . ' ' . $row->getBirthDate() . '<br>';
             }
         }
         $this->addParam('message', $message);
     } else {
         $this->addParam('status', 'error');
         $this->addParam('message', "First Name, Last Name, Birth Year is required!");
     }
 }
Пример #12
0
 public function load()
 {
     if (!isset(NGS()->args()->hash)) {
         return;
     }
     $hash = NGS()->args()->hash;
     $voter = VoterManager::getInstance()->getByHash($hash);
     if (isset($voter)) {
         $voterData = VoterDataManager::getInstance()->selectByField('voter_id', $voter->getId());
         $area = AreaManager::getInstance()->selectByPK($voter->getAreaId());
         $this->addParam('voter', $voter);
         $this->addParam('area', $area);
         $this->addParam('voter_data', $voterData);
     }
 }
Пример #13
0
 public function getVoterIdFromOldVoterId($oldVoterId)
 {
     $oldVoter = VoterOldManager::getInstance()->selectByPK($oldVoterId);
     if (!$oldVoter) {
         return 0;
     }
     $firstName = $oldVoter->getFirstName();
     $lastName = $oldVoter->getLastName();
     $fatherName = $oldVoter->getFatherName();
     $birthDate = $oldVoter->getBirthDate();
     $newVoters = VoterManager::getInstance()->selectAdvance('*', ['first_name', '=', "'{$firstName}'", 'and', 'last_name', '=', "'{$lastName}'", 'and', 'father_name', '=', "'{$fatherName}'", 'and', 'birth_date', '=', "'{$birthDate}'"]);
     if (!empty($newVoters) && count($newVoters) === 1) {
         return $newVoters[0]->getId();
     }
     return 0;
 }
Пример #14
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);
 }
 public function addRow($voterNumberInArea, $observerId, $areaId)
 {
     $dto = $this->createDto();
     $dto->setAreaVoterId($voterNumberInArea);
     $dto->setCreateDatetime(date('Y-m-d H:i:s'));
     $dto->setModeratorId(0);
     $dto->setObserverId($observerId);
     $dto->setAreaId($areaId);
     $listVoters = VoterManager::getInstance()->selectAdvance('*', ['area_id', '=', $areaId, 'and', 'number', '=', $voterNumberInArea]);
     if (!empty($listVoters) && count($listVoters) === 1) {
         $voter = $listVoters[0];
         $dto->setVoterId($voter->getId());
     } else {
         $dto->setVoterId(0);
     }
     return $this->insertDto($dto);
 }
Пример #16
0
 public function load()
 {
     $ids = NGS()->args()->ids;
     $duplidatedRows = VoterDataManager::getInstance()->selectAdvance('*', ['id', 'in', "({$ids})"], ['datetime'], 'asc');
     if (!empty($duplidatedRows)) {
         $voterData = $duplidatedRows[0];
         $voterId = $voterData->getVoterId();
         if ($voterId > 0) {
             $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));
         $this->addParam('duplidatedRows', $duplidatedRows);
     }
 }
Пример #17
0
 public function load()
 {
     list($birthDate, $firstName, $lastName, $fatherName) = $this->validateParams();
     $where = [];
     if (!empty($birthDate)) {
         $where[] = 'birth_date';
         $where[] = '=';
         $where[] = "'{$birthDate}'";
     }
     if (!empty($firstName)) {
         if (!empty($where)) {
             $where[] = 'and';
         }
         $where[] = 'first_name';
         $where[] = 'like';
         $where[] = "'{$firstName}%'";
     }
     if (!empty($lastName)) {
         if (!empty($where)) {
             $where[] = 'and';
         }
         $where[] = 'last_name';
         $where[] = 'like';
         $where[] = "'{$lastName}%'";
     }
     if (!empty($fatherName)) {
         if (!empty($where)) {
             $where[] = 'and';
         }
         $where[] = 'father_name';
         $where[] = 'like';
         $where[] = "'{$fatherName}%'";
     }
     $voters = VoterManager::getInstance()->selectAdvance('*', $where, ['first_name', 'last_name', 'father_name'], 'ASC', 0, 100);
     $areaIds = $this->getAreaIds($voters);
     $areas = [];
     if (!empty($areaIds)) {
         $areaIdsString = implode(',', $areaIds);
         $areas = AreaManager::getInstance()->selectAdvance('*', ['id', 'in', "({$areaIdsString})"], null, null, null, null, true);
     }
     $this->addParam('areas', $areas);
     $this->addParam('voters', $voters);
 }
Пример #18
0
 public function service()
 {
     if (!isset(NGS()->args()->number) || empty(NGS()->args()->number) || NGS()->args()->number <= 0) {
         $_SESSION['error_message'] = "Please input positive number";
         $this->redirect('');
     }
     $number = intval(NGS()->args()->getNumber());
     $userId = NGS()->getSessionManager()->getUserId();
     $observerDto = ObserverManager::getInstance()->selectByPK($userId);
     $areaId = $observerDto->getAreaId();
     $rowId = RealVoterNumberTmpManager::getInstance()->addRow($number, $userId, $areaId);
     $dto = RealVoterNumberTmpManager::getInstance()->selectByPK($rowId);
     $voterId = $dto->getVoterId();
     $_SESSION['can_revert'] = 1;
     if ($voterId > 0) {
         $voter = VoterManager::getInstance()->selectByPK($voterId);
         $_SESSION['success_message'] = $number . ' ' . $voter->getFirstName() . ' ' . $voter->getLastName() . ' Successfully added';
     } else {
         $_SESSION['error_message'] = "Number does not exist in list!";
         $this->redirect('');
     }
     $this->redirect('');
 }
Пример #19
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 = VoterDataManager::getInstance()->selectAdvance('*', ['admin_id', '=', $moderatorId], ['datetime'], 'DESC', $offset, $limit);
     $voterIdsArray = $this->getVoterIdsArray($rows);
     $duplicatedInList = [];
     $voters = [];
     $preVoteData = [];
     if (!empty($voterIdsArray)) {
         $voters = VoterManager::getInstance()->selectByPKs($voterIdsArray, true);
         //$duplicatedInList = VoterDataManager::getInstance()->getDuplicatedInListRealVotersRowIds($voterIdsArray);
         $voterIdsSqlString = "(" . implode(',', $voterIdsArray) . ")";
         $preVoteData = VoterDataManager::getInstance()->selectAdvance('*', ['voter_id', 'in', $voterIdsSqlString]);
         $preVoteData = $this->MapByVoterId($preVoteData);
     }
     $count = VoterDataManager::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', $duplicatedInList);
     $this->addParam('preVoteData', $preVoteData);
 }
Пример #20
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);
     }
 }