function defaultAction($param = NULL)
 {
     $userOperator = new UserBatchOperator();
     $data = new ReportData();
     $periodIndex = $data->getAvailablePeriod();
     $accessRight = $userOperator->getUserAccessRight($this->user->username);
     $userList = $accessRight["accessable_user"];
     $this->header = 'surveyHeader.php';
     $this->extraCSS = 'report/report.css';
     $this->content = 'report.php';
     $this->extraCSS = array("report/report.css", "jquery-ui.css");
     $this->extraJS = array("jquery-2.1.3.js", "jquery-ui.js", "report.js");
     $param['periodIndex'] = $periodIndex;
     if (!empty($param['uid'])) {
         $param['data'] = $data->getFormSummary($param['uid'], $userList);
     }
     foreach ($userOperator->getEmptyUserData($param['uid']) as $emptyUserData) {
         if (in_array($emptyUserData["username"], $userList)) {
             $param['empty_survey'][] = $emptyUserData;
         }
     }
     $this->view($param);
 }
 private function populateEmptydata($emptySurveyData)
 {
     $userOperator = new UserBatchOperator();
     $returnArray = array();
     foreach ($emptySurveyData as $data) {
         $temp["form_username"] = $data["username"];
         $temp["staff_name"] = $data["user_full_name"];
         $temp["is_senior"] = $data["is_senior"];
         $temp["staff_position"] = $data["user_position"];
         $temp["staff_department"] = $data["user_department"];
         $temp["staff_office"] = $data["user_office"];
         $temp["appraiser_name"] = $userOperator->getFullNameByUsername($data["appraiser_username"]);
         $temp["countersigner_1_name"] = $userOperator->getFullNameByUsername($data["countersigner_username_1"]);
         $temp["countersigner_name"] = $temp["countersigner_1_name"];
         if (!empty($data["countersigner_username_2"])) {
             $temp["countersigner_2_name"] = $userOperator->getFullNameByUsername($data["countersigner_username_2"]);
             $temp["countersigner_name"] .= " & " . $temp["countersigner_2_name"];
         }
         $temp["part_a_b_total"] = null;
         $temp["part_a_overall_score"] = null;
         $temp["part_b1_overall_score"] = null;
         $temp["part_b2_overall_score"] = null;
         $temp["part_a_total"] = null;
         $temp["part_b_total"] = null;
         $temp["function_training_0_to_1_year"] = null;
         $temp["function_training_1_to_2_year"] = null;
         $temp["function_training_2_to_3_year"] = null;
         $temp["generic_training_0_to_1_year"] = null;
         $temp["generic_training_1_to_2_year"] = null;
         $temp["generic_training_2_to_3_year"] = null;
         $temp["survey_overall_comment"] = null;
         $temp["survey_commencement_date"] = $data["commence_date"];
         $returnArray[$data["username"]] = $temp;
     }
     return $returnArray;
 }
 function ajaxToggleStatus($param = NULL)
 {
     try {
         if (!$this->user->isAdmin) {
             throw new Exception("Access Denied");
         }
         $userOperator = new UserBatchOperator();
         $userOperator->toggleStatus($param["userId"]);
         $result["error"] = "0";
         $result["msg"] = "Account is toggled.";
     } catch (Exception $ex) {
         $result["error"] = "1";
         $result["msg"] = $ex->getMessage();
     }
     echo json_encode($result);
 }
 function constructUserInfo($username)
 {
     //maybe merge fullname and username with asso array
     $statement = "SELECT * FROM pa_user WHERE username = :username";
     $query = $this->dbConnection->prepare($statement);
     $query->bindValue(':username', $username);
     $query->execute();
     $result = $query->fetch(PDO::FETCH_ASSOC);
     if (!empty($result)) {
         $this->username = $username;
         $this->fullName = $result['user_full_name'];
         $this->department = $result['user_department'];
         $this->position = $result['user_position'];
         $this->office = $result['user_office'];
         $this->commenceDate = $result['commence_date'];
         $this->appraiser = $result['appraiser_username'];
         $this->isSenior = $result['is_senior'];
         $this->isActive = $result['is_active'];
         $this->isAdmin = $result['is_admin'];
         $this->countersigner1 = $result['countersigner_username_1'];
         $this->countersigner2 = $result['countersigner_username_2'];
         $this->isReportUser = $result['is_report_user'];
         $this->isFlaggedForPwReset = $result["is_flagged_for_pw_reset"];
         $userOperator = new UserBatchOperator();
         $right = $userOperator->getUserAccessRight($username);
         $this->accessRight = $right["accessable_user"];
         unset($result);
         $statement = "SELECT user_full_name FROM pa_user WHERE username = :username";
         $query = $this->dbConnection->prepare($statement);
         $query->bindValue(':username', $this->appraiser);
         $query->execute();
         $result = $query->fetchAll(PDO::FETCH_ASSOC);
         if (!empty($result)) {
             foreach ($result as $val) {
                 $this->appraiserFullName = $val['user_full_name'];
             }
         }
         unset($result);
         $statement = "SELECT username, user_full_name FROM pa_user WHERE appraiser_username = :username";
         $query = $this->dbConnection->prepare($statement);
         $query->bindValue(':username', $this->username);
         $query->execute();
         $result = $query->fetchAll(PDO::FETCH_ASSOC);
         if (!empty($result)) {
             foreach ($result as $val) {
                 $this->appraisee[$val['username']] = $val['user_full_name'];
             }
         }
         unset($result);
         $statement = "SELECT * FROM pa_form_period WHERE is_active = True";
         $query = $this->dbConnection->prepare($statement);
         $query->execute();
         $result = $query->fetch(PDO::FETCH_ASSOC);
         if (!empty($result)) {
             $this->availiblePeriod['uid'] = $result['uid'];
             $this->availiblePeriod['period'] = $result['survey_period'];
             $this->availiblePeriod['type'] = $result['survey_type'];
         } else {
             return false;
         }
         unset($result);
         $statement = "SELECT user_full_name FROM pa_user WHERE username = :username";
         $query = $this->dbConnection->prepare($statement);
         $query->bindValue(':username', $this->countersigner1);
         $query->execute();
         $result = $query->fetchAll(PDO::FETCH_ASSOC);
         if (!empty($result)) {
             foreach ($result as $val) {
                 $this->countersignerFullName1 = $val['user_full_name'];
             }
         }
         unset($result);
         $statement = "SELECT user_full_name FROM pa_user WHERE username = :username";
         $query = $this->dbConnection->prepare($statement);
         $query->bindValue(':username', $this->countersigner2);
         $query->execute();
         $result = $query->fetchAll(PDO::FETCH_ASSOC);
         if (!empty($result)) {
             foreach ($result as $val) {
                 $this->countersignerFullName2 = $val['user_full_name'];
             }
         }
         unset($result);
         $statement = "SELECT username, user_full_name FROM pa_user WHERE (countersigner_username_1 = :username)";
         $query = $this->dbConnection->prepare($statement);
         $query->bindValue(':username', $username);
         $query->execute();
         $result = $query->fetchAll(PDO::FETCH_ASSOC);
         if (!empty($result)) {
             foreach ($result as $val) {
                 $this->countersignee[$val['username']] = 'counter1';
                 $this->countersigneeFullName[$val['username']] = $val['user_full_name'];
             }
         }
         unset($result);
         $statement = "SELECT username, user_full_name FROM pa_user WHERE (countersigner_username_2 = :username)";
         $query = $this->dbConnection->prepare($statement);
         $query->bindValue(':username', $username);
         $query->execute();
         $result = $query->fetchAll(PDO::FETCH_ASSOC);
         if (!empty($result)) {
             foreach ($result as $val) {
                 $this->countersignee[$val['username']] = 'counter2';
                 $this->countersigneeFullName[$val['username']] = $val['user_full_name'];
             }
         }
         unset($result);
         $statement = "SELECT uid FROM pa_form_period WHERE is_active = 1";
         $query = $this->dbConnection->prepare($statement);
         $query->execute();
         $result = $query->fetch(PDO::FETCH_ASSOC);
         if (!empty($result)) {
             $this->activeUid = 2;
         }
     } else {
         throw new Exception('Cannot construct user token. Maybe username does not exist? Check the query string.');
     }
 }