public function actionSearchaccounts() { $session = Yii::$app->session; if ($session->has('accountTypeID')) { $sessionAccountTypeID = (int) $session->get('accountTypeID'); $request = Yii::$app->request; if ($request->isAjax) { $get = $request->get(); $accountType = $get['accountType']; $status = $get['status']; $ID = $get['ID']; $lastName = $get['lastName']; $firstName = $get['firstName']; $page = $get['page']; $limit = $get['rows']; $sidx = $get['sidx']; $rows = array(); $accountAdminDetails = array(); $accountStudentDetails = array(); $accountRegisteredUserDetails = array(); $_AccountAdminDetailsForm = new AccountAdminDetailsForm(); $_AccountStudentDetailsForm = new AccountStudentDetailsForm(); $_AccountRegisteredUserDetailsForm = new AccountRegisteredUserDetailsForm(); if ($ID == "") { if ($accountType == "0" || $accountType == "") { if ($status == "") { if ($sessionAccountTypeID == DefaultForm::ACCOUNT_TYPE_SUPERUSER || $sessionAccountTypeID == DefaultForm::ACCOUNT_TYPE_ADMINISTRATOR) { $accountAdminDetails = $_AccountAdminDetailsForm->getAllAdminDataByLastnameAndFirstNameExceptAccountType($lastName, $firstName, $sessionAccountTypeID); } else { $accountAdminDetails = array(); } $accountStudentDetails = $_AccountStudentDetailsForm->getAllStudentDataByLastnameAndFirstName($lastName, $firstName); $accountRegisteredUserDetails = $_AccountRegisteredUserDetailsForm->getAllRegisteredUserDataByLastnameAndFirstName($lastName, $firstName); } else { if ($status == 0 || $status == "0") { if ($sessionAccountTypeID == DefaultForm::ACCOUNT_TYPE_SUPERUSER || $sessionAccountTypeID == DefaultForm::ACCOUNT_TYPE_ADMINISTRATOR) { $accountAdminDetails = $_AccountAdminDetailsForm->getAllAdminDataByStatusAndLastNameAndFirstNameExceptAccountType($status, $lastName, $firstName, $sessionAccountTypeID); } else { $accountAdminDetails = array(); } $accountStudentDetails = $_AccountStudentDetailsForm->getAllStudentDataByStatusAndLastNameAndFirstName($status, $lastName, $firstName); $accountRegisteredUserDetails = $_AccountRegisteredUserDetailsForm->getAllRegisteredUserDataByStatusAndLastNameAndFirstName($status, $lastName, $firstName); } } } else { if ($status == "") { if ($sessionAccountTypeID == DefaultForm::ACCOUNT_TYPE_SUPERUSER || $sessionAccountTypeID == DefaultForm::ACCOUNT_TYPE_ADMINISTRATOR) { $accountAdminDetails = $_AccountAdminDetailsForm->getAllAdminDataByAccountTypeAndLastNameAndFirstNameExceptAccountType($accountType, $lastName, $firstName, $sessionAccountTypeID); } else { $accountAdminDetails = array(); } $accountStudentDetails = $_AccountStudentDetailsForm->getAllStudentDataByAccountTypeAndLastNameAndFirstName($accountType, $lastName, $firstName); $accountRegisteredUserDetails = $_AccountRegisteredUserDetailsForm->getAllRegisteredUserDataByAccountTypeAndLastNameAndFirstName($accountType, $lastName, $firstName); } else { if ($sessionAccountTypeID == DefaultForm::ACCOUNT_TYPE_SUPERUSER || $sessionAccountTypeID == DefaultForm::ACCOUNT_TYPE_ADMINISTRATOR) { $accountAdminDetails = $_AccountAdminDetailsForm->getAllAdminDataByAccountTypeAndStatusAndLastNameAndFirstNameExceptAccountType($accountType, $status, $lastName, $firstName, $sessionAccountTypeID); } else { $accountAdminDetails = array(); } $accountStudentDetails = $_AccountStudentDetailsForm->getAllStudentDataByAccountTypeAndStatusAndLastNameAndFirstName($accountType, $status, $lastName, $firstName); $accountRegisteredUserDetails = $_AccountRegisteredUserDetailsForm->getAllRegisteredUserDataByAccountTypeAndStatusAndLastNameAndFirstName($accountType, $status, $lastName, $firstName); } } } else { if ($accountType == DefaultForm::ACCOUNT_TYPE_SUPERUSER || $accountType == "1" || ($accountType == DefaultForm::ACCOUNT_TYPE_ADMINISTRATOR || $accountType == "2") || ($accountType == DefaultForm::ACCOUNT_TYPE_REGISTRAR || $accountType == "3") || ($accountType == DefaultForm::ACCOUNT_TYPE_BACK_OFFICE || $accountType == "4") || ($accountType == DefaultForm::ACCOUNT_TYPE_INSTRUCTOR || $accountType == "5") || ($accountType == DefaultForm::ACCOUNT_TYPE_SECURITY || $accountType == "6")) { if ($sessionAccountTypeID == DefaultForm::ACCOUNT_TYPE_SUPERUSER || $sessionAccountTypeID == DefaultForm::ACCOUNT_TYPE_ADMINISTRATOR) { $accountAdminDetails = $_AccountAdminDetailsForm->getAdminDataByIDAndLastNameAndFirstNameExceptAccountType($ID, $lastName, $firstName, $sessionAccountTypeID); } else { $accountAdminDetails = array(); } $accountStudentDetails = array(); $accountRegisteredUserDetails = array(); } else { if ($accountType == DefaultForm::ACCOUNT_TYPE_STUDENT || $accountType == "7") { $accountAdminDetails = array(); $accountStudentDetails = $_AccountStudentDetailsForm->getStudentDataByIDAndLastNameAndFirstName($ID, $lastName, $firstName); $accountRegisteredUserDetails = array(); } else { if ($accountType == DefaultForm::ACCOUNT_TYPE_REGISTERED_USER || $accountType == "7") { $accountAdminDetails = array(); $accountStudentDetails = array(); $accountRegisteredUserDetails = $_AccountRegisteredUserDetailsForm->getRegisteredUserDataByIDAndLastNameAndFirstName($ID, $lastName, $firstName); } else { if ($sessionAccountTypeID == DefaultForm::ACCOUNT_TYPE_SUPERUSER || $sessionAccountTypeID == DefaultForm::ACCOUNT_TYPE_ADMINISTRATOR) { $accountAdminDetails = $_AccountAdminDetailsForm->getAdminDataByIDAndLastNameAndFirstNameExceptAccountType($ID, $lastName, $firstName, $sessionAccountTypeID); } else { $accountAdminDetails = array(); } $accountStudentDetails = $_AccountStudentDetailsForm->getStudentDataByIDAndLastNameAndFirstName($ID, $lastName, $firstName); $accountRegisteredUserDetails = $_AccountRegisteredUserDetailsForm->getRegisteredUserDataByIDAndLastNameAndFirstName($ID, $lastName, $firstName); } } } } if (!$sidx) { $sidx = 1; } $accountAdminDetailsCount = count($accountAdminDetails); $accountStudentDetailsCount = count($accountStudentDetails); $accountRegisteredUserDetailsCount = count($accountRegisteredUserDetails); $count = $accountAdminDetailsCount + $accountStudentDetailsCount + $accountRegisteredUserDetailsCount; if ($count > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 1; } if ($page > $total_pages) { $page = $total_pages; } if (!empty($accountAdminDetailsCount) && $count > 0) { foreach ($accountAdminDetails as $value) { $ID = $value["ID"]; $lastName = $value["LastName"]; $firstName = $value["FirstName"]; $accountTypeID = $value["AccountTypeID"]; if ($accountTypeID == DefaultForm::ACCOUNT_TYPE_SUPERUSER || $accountTypeID == '1') { $accountType = 'Superuser'; } else { if ($accountTypeID == DefaultForm::ACCOUNT_TYPE_ADMINISTRATOR || $accountTypeID == '2') { $accountType = 'Administrator'; } else { if ($accountTypeID == DefaultForm::ACCOUNT_TYPE_REGISTRAR || $accountTypeID == '3') { $accountType = 'Registrar'; } else { if ($accountTypeID == DefaultForm::ACCOUNT_TYPE_BACK_OFFICE || $accountTypeID == '4') { $accountType = 'Back Office'; } else { if ($accountTypeID == DefaultForm::ACCOUNT_TYPE_INSTRUCTOR || $accountTypeID == '5') { $accountType = 'Instructor'; } else { if ($accountTypeID == DefaultForm::ACCOUNT_TYPE_SECURITY || $accountTypeID == '6') { $accountType = 'Security'; } else { if ($accountTypeID == DefaultForm::ACCOUNT_TYPE_STUDENT || $accountTypeID == '7') { $accountType = 'Student'; } else { if ($accountTypeID == DefaultForm::ACCOUNT_TYPE_REGISTERED_USER || $accountTypeID == '8') { $accountType = 'Registered User'; } else { $accountType = 'Undefined'; } } } } } } } } $statusValue = $value["Status"]; if ($statusValue == DefaultForm::ACCOUNT_STATUS_ADMIN_INACTIVE) { $adminStatus = 'Inactive'; } else { if ($statusValue == DefaultForm::ACCOUNT_STATUS_ADMIN_ACTIVE) { $adminStatus = 'Active'; } else { if ($statusValue == DefaultForm::ACCOUNT_STATUS_ADMIN_DEACTIVATED) { $adminStatus = 'Deactivated'; } else { if ($statusValue == DefaultForm::ACCOUNT_STATUS_ADMIN_LOCKED_BY_SELF) { $adminStatus = 'Locked By Self'; } else { if ($statusValue == DefaultForm::ACCOUNT_STATUS_ADMIN_LOCKED_BY_THE_ADMINISTRATOR) { $adminStatus = 'Locked By The Administrator'; } else { if ($statusValue == DefaultForm::ACCOUNT_STATUS_ADMIN_DELETED) { $adminStatus = 'Deleted'; } else { $adminStatus = 'Undefined'; } } } } } } $url = "accounts/adminprofile?adminID=" . $ID; $accountAdminDetails = array('ID' => $ID, 'LastName' => $lastName, 'FirstName' => $firstName, 'AccountType' => $accountType, 'Status' => $adminStatus, 'Action' => "<a href='#' onclick=\"window.open('" . $url . "', '_blank'); return false;\">View <span class='glyphicon glyphicon-eye-open'></span></a>"); array_push($rows, $accountAdminDetails); } } if (!empty($accountStudentDetailsCount) && $count > 0) { foreach ($accountStudentDetails as $value) { $ID = $value["ID"]; $lastName = $value["LastName"]; $firstName = $value["FirstName"]; $accountTypeID = $value["AccountTypeID"]; if ($accountTypeID == DefaultForm::ACCOUNT_TYPE_STUDENT || $accountTypeID == '7') { $accountType = 'Student'; } else { $accountType = 'Undefined'; } $statusValue = $value["Status"]; if ($statusValue == DefaultForm::ACCOUNT_STATUS_STUDENT_INACTIVE) { $studentStatus = 'Inactive'; } else { if ($statusValue == DefaultForm::ACCOUNT_STATUS_STUDENT_ACTIVE) { $studentStatus = 'Active'; } else { if ($statusValue == DefaultForm::ACCOUNT_STATUS_STUDENT_DEACTIVATED) { $studentStatus = 'Deactivated'; } else { if ($statusValue == DefaultForm::ACCOUNT_STATUS_STUDENT_LOCKED_BY_SELF) { $studentStatus = 'Locked By Self'; } else { if ($statusValue == DefaultForm::ACCOUNT_STATUS_STUDENT_LOCKED_BY_THE_ADMINISTRATOR) { $studentStatus = 'Locked By The Administrator'; } else { if ($statusValue == DefaultForm::ACCOUNT_STATUS_STUDENT_DELETED) { $studentStatus = 'Deleted'; } else { $studentStatus = 'Undefined'; } } } } } } $url = "accounts/studentprofile?studentID=" . $ID; $accountStudentDetails = array('ID' => $ID, 'LastName' => $lastName, 'FirstName' => $firstName, 'AccountType' => $accountType, 'Status' => $studentStatus, 'Action' => "<a href='#' onclick=\"window.open('" . $url . "', '_blank'); return false;\">View <span class='glyphicon glyphicon-eye-open'></span></a>"); array_push($rows, $accountStudentDetails); } } if (!empty($accountRegisteredUserDetailsCount) && $count > 0) { foreach ($accountRegisteredUserDetails as $value) { $ID = $value["ID"]; $lastName = $value["LastName"]; $firstName = $value["FirstName"]; $accountTypeID = $value["AccountTypeID"]; if ($accountTypeID == DefaultForm::ACCOUNT_TYPE_REGISTERED_USER || $accountTypeID == '8') { $accountType = 'Registered User'; } else { $accountType = 'Undefined'; } $statusValue = $value["Status"]; if ($statusValue == DefaultForm::ACCOUNT_STATUS_REGISTERED_USER_INACTIVE) { $registeredUserStatus = 'Inactive'; } else { if ($statusValue == DefaultForm::ACCOUNT_STATUS_REGISTERED_USER_ACTIVE) { $registeredUserStatus = 'Active'; } else { if ($statusValue == DefaultForm::ACCOUNT_STATUS_REGISTERED_USER_DEACTIVATED) { $registeredUserStatus = 'Deactivated'; } else { if ($statusValue == DefaultForm::ACCOUNT_STATUS_REGISTERED_USER_LOCKED_BY_SELF) { $registeredUserStatus = 'Locked By Self'; } else { if ($statusValue == DefaultForm::ACCOUNT_STATUS_REGISTERED_USER_LOCKED_BY_THE_ADMINISTRATOR) { $registeredUserStatus = 'Locked By The Administrator'; } else { if ($statusValue == DefaultForm::ACCOUNT_STATUS_REGISTERED_USER_DELETED) { $registeredUserStatus = 'Deleted'; } else { $registeredUserStatus = 'Undefined'; } } } } } } $url = "accounts/registereduserprofile?registeredUserID=" . $ID; $accountRegisteredUserDetails = array('ID' => $ID, 'LastName' => $lastName, 'FirstName' => $firstName, 'AccountType' => $accountType, 'Status' => $registeredUserStatus, 'Action' => "<a href='#' onclick=\"window.open('" . $url . "', '_blank'); return false;\">View <span class='glyphicon glyphicon-eye-open'></span></a>"); array_push($rows, $accountRegisteredUserDetails); } } echo json_encode($rows); } } else { return DefaultController::redirectToLogOut(); } }