示例#1
0
 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);
 }
示例#2
0
 function showMetaDataSQLUpdateRes()
 {
     /* update last page */
     $_SESSION['LASTPAGE'] = 'sysadmin.sms.update';
     $displaySms = new DisplaySms();
     $tables = array();
     $updateSql = '';
     if (loadvar('custom') == '1') {
         $updateSql = loadvar('sqlcode');
     }
     if (loadvar('metadata') == '1') {
         //meta data update SQL
         $tables[] = 'settings';
     }
     if (loadvar('users') == '1') {
         //update users
         $tables[] = 'users';
     }
     if (loadvar('psu') == '1') {
         $tables[] = 'psus';
     }
     if (sizeof($tables) > 0 || $updateSql != '') {
         $communication = new Communication();
         if ($updateSql != '') {
             $updateSql .= "\n";
         }
         if (sizeof($tables) > 0) {
             $updateSql .= $communication->exportTables($tables);
         }
         $users = new Users();
         $users = $users->getUsers();
         $selected = loadvar("iwers");
         if (loadvar("iwers") == "") {
             $message = $displaySms->displayInfo(Language::labelSMSLaptopSelectInterviewers());
             return $displaysSms->showMetaDataSQLUpdate($message);
         } else {
             foreach ($users as $user) {
                 if ($user->getUserType() == USER_INTERVIEWER) {
                     //interviewer: get update ready!
                     //this should be per laptop (id on macaddress??), not interviewer
                     if (inArray($user->getUrid(), $selected) || inArray(-1, $selected)) {
                         echo 'ok';
                         //$communication->addSQLToUser($updateSql, $user->getUrid());
                     }
                 }
             }
             $message = $displaySms->displaySuccess(Language::labelSMSLaptopSQLUpdateReady());
         }
     } else {
         $message = $displaySms->displayInfo(Language::labelSMSLaptopSelectItems());
         return $displayssms->showMetaDataSQLUpdate($message);
     }
     return $this->showMetaDataUpdate($message);
 }
示例#3
0
 function showSendReceiveUploadData()
 {
     $displayInterviewer = new DisplayInterviewer();
     $communication = new Communication();
     $data = $communication->exportTables(array('data', 'datarecords', 'states', 'times', 'remarks', 'contacts', 'households', 'respondents'), $this->user->getLastData(), 'primkey not like "999%"');
     //no test data
     if ($communication->sendToServer($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 = $displayInterviewer->displaySuccess(Language::labelDataUploaded());
     } else {
         $message = $displayInterviewer->displayError(Language::labelDataNotUploaded());
     }
     return $displayInterviewer->showSendReceive($message);
 }