Exemplo n.º 1
0
 function renderNewForm($username)
 {
     $userToken = new UserToken();
     $userToken->constructUserInfo($username);
     $statement = "INSERT INTO pa_form_data " . "(form_username, survey_uid, staff_name, is_senior, staff_department, staff_position, " . "staff_office, survey_commencement_date, appraiser_name, countersigner_name, survey_period, survey_type, countersigner_1_name, " . "countersigner_2_name) " . "VALUES (:username, :uid, :fullName, :isSenior, :department, :position, :office, :commenceDate, :appraiserFullName, :bothCounter, :survey_period, :survey_type, :counter1, :counter2)";
     $query = $this->dbConnection->prepare($statement);
     $query->bindValue(':username', $userToken->username);
     $query->bindValue(':uid', $this->uid);
     $query->bindValue(':fullName', $userToken->fullName);
     $query->bindValue(':isSenior', $userToken->isSenior);
     $query->bindValue(':department', $userToken->department);
     $query->bindValue(':position', $userToken->position);
     $query->bindValue(':office', $userToken->office);
     $query->bindValue(':commenceDate', $userToken->commenceDate);
     $query->bindValue(':appraiserFullName', $userToken->appraiserFullName);
     $query->bindValue(':counter1', $userToken->countersignerFullName1);
     $query->bindValue(':counter2', $userToken->countersignerFullName2);
     if (!empty($userToken->countersignerFullName1) && !empty($userToken->countersignerFullName2)) {
         $jointString = $userToken->countersignerFullName1 . " & " . $userToken->countersignerFullName2;
     } else {
         $jointString = $userToken->countersignerFullName1 . $userToken->countersignerFullName2;
     }
     $query->bindValue(':bothCounter', $jointString);
     $query->bindValue(':survey_period', $userToken->availiblePeriod['period']);
     //Need to throw an Exception here later if there is not active survey
     $query->bindValue(':survey_type', $userToken->availiblePeriod['type']);
     $query->execute();
     $statement = "INSERT IGNORE INTO pa_part_a SET form_username = :username, survey_uid = :uid, question_no = :no";
     $query = $this->dbConnection->prepare($statement);
     $query->bindValue(':username', $userToken->username);
     $query->bindValue(':uid', $this->uid);
     $query->bindParam(':no', $i);
     for ($i = 1; $i <= 3; $i++) {
         $query->execute();
     }
 }