function Respondent($rowOrPrimkey) { global $db; $this->remarks = new Remarks(); $this->contacts = new Contacts(); $this->logactions = new LogActions(); if (is_array($rowOrPrimkey)) { $this->respondent = $rowOrPrimkey; } else { $query = 'select *, ' . Respondents::getDeIdentified() . ' from ' . Config::dbSurvey() . '_respondents where primkey = \'' . prepareDatabaseString($rowOrPrimkey) . '\''; $result = $db->selectQuery($query); $this->respondent = $db->getRow($result); } $this->user = new User($this->getUrid()); }
static function getDeIdentified() { $query = 'aes_decrypt(firstname, \'' . Config::smsPersonalInfoKey() . '\') as firstname_dec, '; $query .= 'aes_decrypt(lastname, \'' . Config::smsPersonalInfoKey() . '\') as lastname_dec, '; $query .= 'aes_decrypt(age, \'' . Config::smsPersonalInfoKey() . '\') as age_dec, '; $query .= 'aes_decrypt(sex, \'' . Config::smsPersonalInfoKey() . '\') as sex_dec, '; $query .= 'aes_decrypt(birthdate, \'' . Config::smsPersonalInfoKey() . '\') as birthdate_dec, '; $query .= 'aes_decrypt(address1, \'' . Config::smsPersonalInfoKey() . '\') as address1_dec, '; $query .= 'aes_decrypt(address2, \'' . Config::smsPersonalInfoKey() . '\') as address2_dec, '; $query .= 'aes_decrypt(zip, \'' . Config::smsPersonalInfoKey() . '\') as zip_dec, '; $query .= 'aes_decrypt(city, \'' . Config::smsPersonalInfoKey() . '\') as city_dec, '; $query .= 'aes_decrypt(longitude, \'' . Config::smsPersonalInfoKey() . '\') as longitude_dec, '; $query .= 'aes_decrypt(latitude, \'' . Config::smsPersonalInfoKey() . '\') as latitude_dec, '; $query .= 'aes_decrypt(email, \'' . Config::smsPersonalInfoKey() . '\') as email_dec, '; $query .= 'aes_decrypt(telephone1, \'' . Config::smsPersonalInfoKey() . '\') as telephone1_dec, '; $query .= 'aes_decrypt(telephone2, \'' . Config::smsPersonalInfoKey() . '\') as telephone2_dec, '; $query .= 'aes_decrypt(logincode, \'' . Config::loginCodeKey() . '\') as logincode_dec '; if (dbConfig::defaultSeparateInterviewAddress()) { $query .= Respondents::getExtraDeidentified(); } return $query; }
function showSearchRes() { $displayNurse = new DisplayNurse(); if (trim(loadvar('search')) != '') { $respondents = new Respondents(); $respondentsList = $respondents->getRespondentsSearch($this->user, loadvar('search')); $respondentsList = array_merge($respondentsList, $respondents->getRespondentsByBarcode($this->user, loadvar('search'))); if (sizeof($respondentsList) == 1) { //just one found! foreach ($respondentsList as $respondent) { return $this->showRespondentInfo($respondent->getPrimkey()); } } return $displayNurse->showSearchRes($respondentsList); } else { $message = $displayNurse->displayError(Language::labelNurseEnterSearchTerm()); return $this->mainPage($message); } }
{ global $db; $urid = -1; if ($user != null) { $urid = $user->getUrid(); } $query = 'replace into ' . Config::dbSurvey() . '_households (primkey, urid, name, test) values ("' . $primkey . '", ' . prepareDatabaseString($urid) . ', aes_encrypt("' . $name . '", "' . Config::smsPersonalInfoKey() . '"), ' . $test . ')'; $result = $db->selectQuery($query); // echo $query . '<br/>'; //add respondents return new Household($primkey); } function deleteTestHouseholds($user) { if ($user->isTestMode()) { //only in test mode!! $households = $this->getHouseholdsByUser($user); $respondents = new Respondents(); foreach ($households as $household) { //echo "adadsdsadsa"; $respondents->removeRespondentFromTable($household->getPrimKey(), '_data'); $respondents->removeRespondentFromTable($household->getPrimKey(), '_states'); $respondents->removeRespondentFromTable($household->getPrimKey(), '_actions');
$query .= 'email = AES_ENCRYPT("' . prepareDatabaseString($this->getEmail()) . '", "' . Config::smsPersonalInfoKey() . '"), '; $query .= 'status = ' . prepareDatabaseString($this->getStatus()) . ', '; $query .= 'urid = ' . prepareDatabaseString($this->getUrid()) . ' '; $query .= 'WHERE primkey = "' . prepareDatabaseString($this->getPrimkey()) . '"'; $db->executeQuery($query); return $errorMessage; } function getRespondents() { global $db; if ($this->respondents == null) { $this->respondents = array(); $query = 'select *, ' . Respondents::getDeIdentified() . ' from ' . Config::dbSurvey() . '_respondents where hhid = "' . prepareDatabaseString($this->getHhid()) . '" order by hhorder';
function showAvailableUnassignedHouseholds() { $refpage = 'sysadmin.sms.sample'; $currentUser = new User($_SESSION['URID']); if ($currentUser->getUserType() == USER_SUPERVISOR) { $refpage = 'supervisor.unassignedsample'; } elseif ($currentUser->getUserType() == USER_RESEARCHER) { $refpage = 'researcher.sample'; } $returnStr = ''; //select psu $puid = loadvar('puid', 0); $returnStr .= $this->showActionBar(Language::labelSMSFilterPSU(), $this->displayPsus($puid, true), Language::labelSMSFilterShow(), setSessionParamsPost(array('page' => $refpage))); if (dbConfig::defaultPanel() == PANEL_HOUSEHOLD) { $households = new Households(); $unassignedRespondentOrHouseholds = $households->getUnassigned($puid); } else { $respondents = new Respondents(); $unassignedRespondentOrHouseholds = $respondents->getUnassigned($puid); } if (sizeof($unassignedRespondentOrHouseholds) > 0) { $returnStr .= '<form method="post">'; $returnStr .= setSessionParamsPost(array('page' => $refpage . '.assign')); $returnStr .= '<input type=hidden name=puid value="' . $puid . '">'; $returnStr .= '<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example"> <thead> <tr> <th><label><input type="checkbox" id="checkAll"/> id</label></th> <th>Name</th>'; //echo 'here'; $columns = $this->defaultDisplayOverviewAddressColumns(); foreach ($columns as $column) { $returnStr .= '<th>' . $column . '</th>'; } $returnStr .= ' </tr> </thead> <tbody>'; foreach ($unassignedRespondentOrHouseholds as $respondentOrHousehold) { $returnStr .= '<tr><td>'; $returnStr .= '<label><input type=checkbox name="assignid[]" value="' . $respondentOrHousehold->getPrimkey() . '"> '; $returnStr .= $respondentOrHousehold->getPrimkey() . '</label></td>'; $returnStr .= '<td>' . $respondentOrHousehold->getName() . '</td>'; foreach ($columns as $key => $column) { $returnStr .= '<td>' . $respondentOrHousehold->getDataByField($key) . '</td>'; } $returnStr .= '</tr>'; } $returnStr .= '</table>'; $returnStr .= '<script> $("#checkAll").change(function () { $("input:checkbox").prop("checked", $(this).prop("checked")); }); </script>'; $returnStr .= '<nav class="navbar navbar-default" role="navigation">'; $returnStr .= '<div class="container-fluid"><div class="navbar-header">'; $returnStr .= '<table><tr><td valign=top><img src="images/arrow_ltr.png"></td><td><a class="navbar-brand">assign selected to:</a></td></tr></table>'; $returnStr .= '</div><div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">'; $returnStr .= '<div class="navbar-form navbar-left">'; $returnStr .= '<div class="form-group">'; if ($currentUser->getUserType() == USER_SUPERVISOR) { $returnStr .= $this->displayInterviewerSelect(0, true); } else { $returnStr .= $this->displaySupervisorSelect(); } $returnStr .= '</div>'; $returnStr .= '<button type="submit" class="btn btn-default">' . Language::labelSMSButtonAssign() . '</button>'; $returnStr .= '</div></form></div></div></nav>'; } else { if ($refpage == 'sysadmin.sms.sample') { $returnStr .= $this->displayWarning(Language::labelSMSWarningNoSample()); } else { if (dbConfig::defaultPanel() == PANEL_HOUSEHOLD) { $returnStr .= $this->displayWarning(Language::labelSMSWarningNoUnassignedHouseholds()); } else { $returnStr .= $this->displayWarning(Language::labelSMSWarningNoUnassignedRespondents()); } } } return $returnStr; }
function showResetTestCases() { $respondents = new Respondents(); $respondents->deleteTestRespondents($this->user); $display = new Display(); return $this->mainPage($display->displaySuccess('test cases reset!')); }
function showResetTestCases() { if (dbConfig::defaultPanel() == PANEL_HOUSEHOLD) { //show household level $households = new Households(); $households->deleteTestHouseholds($this->user); } else { $respondents = new Respondents(); $respondents->deleteTestRespondents($this->user); } $display = new Display(); return $this->mainPage($display->displaySuccess(Language::labelInterviewerTestReset())); }