function checkCompletedCoverscreen(&$respondentorhousehold) { if ($respondentorhousehold->getStatus() != 2) { //not completed yet //HAALSI functionality //change 'present' to 'no' for people that are no longer in the hh $d = new DataRecord(1, $respondentorhousehold->getPrimkey()); $familyR = $this->getDataFromSurvey($d, 'familyR'); $financialR = $this->getDataFromSurvey($d, 'financialR'); $coverscreenR = $this->getDataFromSurvey($d, 'HR009'); //person currently filling out questions //echo '<br/><br/><br/>' . $familyR . '--' . $financialR . '</br>'; $respondents = $respondentorhousehold->getRespondents(); $Rcnt = 1; foreach ($respondents as $respondent) { $present = 1; if (trim($this->getDataFromSurvey($d, 'HHMemberName[' . $Rcnt . ']')) == '') { $present = 0; } $permanent = 1; if (trim($this->getDataFromSurvey($d, 'HR015[' . $Rcnt . ']')) != '') { $permanent = trim($this->getDataFromSurvey($d, 'HR015[' . $Rcnt . ']')); } $movedout = 0; if (trim($this->getDataFromSurvey($d, 'HR011[' . $Rcnt . ']')) != '') { //what happenend $movedout = trim($this->getDataFromSurvey($d, 'HR011[' . $Rcnt . ']')); } //echo '<br/><br/><br/>' . $movedout; $finR = 0; if ($Rcnt == $financialR) { $finR = 1; } $famR = 0; if ($Rcnt == $familyR) { $famR = 1; } $covR = 0; if ($Rcnt == $coverscreenR) { $covR = 1; } $respondent->setPresent($present); $respondent->setFinR($finR); $respondent->setFamR($famR); $respondent->setCovR($covR); $respondent->setPermanent($permanent); $respondent->setMovedOut($movedout); $respondent->setHhOrder($Rcnt); $respondent->saveChanges(); $Rcnt++; } $hhmembers = $this->getDataFromSurvey($d, 'HRcnt'); //get number of people $newmembers = $hhmembers - sizeof($respondents); if ($newmembers > 0) { //add more people! for ($i2 = 0; $i2 < $newmembers; $i2++) { $hhid = $respondentorhousehold->getHhid(); $rtid = $hhid . leadingZeros($Rcnt, 2); $firstname = $this->getDataFromSurvey($d, 'HR002[' . $Rcnt . ']'); $sex = $this->getDataFromSurvey($d, 'HR003[' . $Rcnt . ']'); $age = date('Y') - $this->getDataFromSurvey($d, 'HR004[' . $Rcnt . ']'); $permanent = $this->getDataFromSurvey($d, 'HR015[' . $Rcnt . ']'); $respondentsClass = new Respondents(); $test = $respondentorhousehold->getTest(); //get test mode from household $respondentsClass->insertR($rtid, $firstname, $this->user, $sex, $age, $hhid, 0, 1, $permanent, $Rcnt, $test); //0: not selected! $relationshiphh = ''; if (trim($this->getDataFromSurvey($d, 'HR005[' . $Rcnt . ']')) != '') { //what happenend $relationshiphh = trim($this->getDataFromSurvey($d, 'HR005[' . $Rcnt . ']')); } $respondent = new Respondent($rtid); //aditional info $finR = 0; if ($Rcnt == $financialR) { $finR = 1; } $famR = 0; if ($Rcnt == $familyR) { $famR = 1; } $covR = 0; if ($Rcnt == $coverscreenR) { $covR = 1; } //$birthdate //$schoolingyears //$educationlevel //$occupationalstatus //$relationshiphh // $respondent->setPresent(1); //always 1! set in insertR $respondent->setFinR($finR); $respondent->setFamR($famR); $respondent->setCovR($covR); $respondent->setRelationshipHhHead($relationshiphh); // $respondent->setPermanent($permanent); //set in insertR // $respondent->setHhOrder($Rcnt); //set in insertR //preload from household $respondent->setAddress1($respondentorhousehold->getAddress1()); $respondent->setCity($respondentorhousehold->getCity()); $respondent->setPuid($respondentorhousehold->getPuid()); $respondent->saveChanges(); $Rcnt++; } } //now check if there is anyone eligible.. } }