/** * Get company info for users to approve tab */ public function actionGetCompanyInfo() { if (Yii::app()->request->isAjaxRequest && isset($_POST['type'])) { if ($_POST['type'] != '') { $show = false; $view_name = 'users_to_approve_company'; $companyInfo = array(); $id = intval($_POST['userId']); // get user to approve $usersToApprove = UsersToApprove::model()->with('client', 'user')->findByPk($id); $client = $usersToApprove->client; $user = $usersToApprove->user; // get company info $company = $client->company; $adreses = $company->adreses; $adress = $adreses[0]; if ($company && $adress) { $show = true; if ($usersToApprove->New_Client == UsersToApprove::NEW_CLIENT) { $companyInfo['add_text'] = 'Wants to add new company:'; } else { $companyInfo['add_text'] = 'Wants to join existing company:'; } $companyInfo['name'] = $company->Company_Name; $companyInfo['fed_id'] = $company->Company_Fed_ID; $companyInfo['adr'] = $adress->Address1; $companyInfo['city'] = $adress->City; $companyInfo['state'] = $adress->State; $companyInfo['zip'] = $adress->ZIP; $companyInfo['client_admins'] = ''; $companyInfo['come_from'] = ''; $companyInfo['client_active'] = 'Client is not active now'; $companyInfo['company_activated'] = "This company will be automatically activated after user approval"; // check existing of client-admins of company if ($usersToApprove->New_Client == UsersToApprove::OLD_CLIENT && !UsersClientList::checkClientForAdmins($client->Client_ID)) { $companyInfo['client_admins'] = "This company doesn't have Client Admin"; if ($user->User_Pwd == md5('temp100')) { $companyInfo['come_from'] = 'User came from registration form'; } else { $companyInfo['come_from'] = 'User was previously in the system and asks for being added to the company by "Request to join company"'; } } $view_name = 'users_to_approve_company'; } if ( $usersToApprove->client->Client_Type === '2' ){ //single user without company $show = true; $companyInfo['add_text'] = 'Single user without company'; $companyInfo['name'] = 'not defined'; $companyInfo['fed_id'] ='not defined'; $companyInfo['adr'] = 'not defined'; $companyInfo['city'] = 'not defined'; $companyInfo['state'] = 'not defined'; $companyInfo['zip'] = 'not defined'; $companyInfo['client_admins'] = ''; $companyInfo['come_from'] = ''; $companyInfo['client_active'] = 'This is a single user without company'; $companyInfo['company_activated'] = "This company will be automatically activated after user approval"; if ($user->User_Pwd == md5('temp100')) { $companyInfo['come_from'] = 'User came from registration form'; } else { $companyInfo['come_from'] = 'User was previously in the system and asks for being added to the company by "Request to join company"'; } $view_name = 'users_to_approve_without_company'; } $this->renderPartial($view_name , array( 'show' => $show, 'companyInfo' => $companyInfo, 'new_client' => $usersToApprove->New_Client, 'active_client' => $client->Client_Status, )); } die; } }