function showSendReceiveUploadData() { $displayNurse = new DisplayNurse(); $communication = new Communication(); if ($this->user->getLastData() != '' && $this->user->getLastData() != '0000-00-00 00:00:00') { $tables = array('data', 'datarecords', 'states', 'times', 'remarks', 'contacts', 'observations'); } else { $tables = array('data', 'datarecords', 'times', 'remarks', 'contacts', 'observations'); } $data = $communication->exportTables($tables, $this->user->getLastData(), 'primkey not like "999%"'); //no test data // $data = $communication->exportTables(array('data'), $this->user->getLastData(), 'primkey not like "999%"'); //no test data // $data = $communication->exportTables(array('remarks'), $this->user->getLastData(), 'primkey not like "999%"'); //no test data //update lab! $respondents = new Respondents(); $respondents = $respondents->getRespondentsByUrid($_SESSION['URID']); foreach ($respondents as $respondent) { $data = 'UPDATE ' . Config::dbSurveyData() . '_lab set status = ' . $respondent->getStatus() . ' where primkey = \'' . prepareDatabaseString($respondent->getPrimkey()) . '\'' . ";\n"; } if ($communication->sendToServerAsFile($data, $this->user->getUrid())) { //success sending data to server //update lastdate! $this->user->setLastData(date('Y-m-d H:i:s')); $this->user->saveChanges(); $message = $displayNurse->displaySuccess(Language::labelDataUploaded()); } else { $message = $displayNurse->displayError(Language::labelDataNotUploaded()); } return $this->mainPage($message); }