Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function addAction() {
- $this->view->headScript()->appendFile( '/js/jquery.autotab.js' );
- $this->view->form = new Forms_Newuser();
- $this->setDefault('sitekey', $this->_session->user['sitekey_phrase']);;
- $this->view->sitekey_img_path = Instacare_Sitekey::getImgPath();
- $this->view->sitekeySet = true;
- $this->view->sitekey_img_path = Instacare_Sitekey::getImgPath();
- if( $this->_request->isPost() ) {
- if( $this->view->form->isValid( $this->_request->getParams() ) ) {
- $query = Doctrine_Query::create()->from( 'Instacare_User u' )->where( "id = ?", $this->_session->user[ 'id' ] );
- $user = $query->fetchOne();
- if( $user ) {
- $user->sitekey_id = $this->_request->getParam( 'sitekey' );
- $user->sitekey_phrase = $this->_request->getParam( 'phrase' );
- $user->save();
- //Update user session
- $this->_session->user[ 'sitekey_id' ] = $this->_request->getParam( 'sitekey' );
- $this->_session->user[ 'sitekey_phrase' ] = $this->_request->getParam( 'phrase' );
- //Redirect to password authentication
- //$this->_redirect( '/identity/auth/' );
- if(!$this->view->sitekeySet)
- {
- if( $this->_request->isPost() ) {
- if( $this->view->form->isValid( $this->_request->getParams() ) ) {
- // @todo: add sitekey, etc. to form
- $created = date( 'Y-m-d H:i:s' );
- $person = new People_Person( );
- $person->prefix = $this->_request->getParam( 'prefix' ) == 'None' ? NULL : $this->_request->getParam( 'prefix' );
- $person->first = $this->_request->getParam( 'firstName' );
- $person->last = $this->_request->getParam( 'lastName' );
- $person->suffix = $this->_request->getParam( 'suffix' ) == 'None' ? NULL : $this->_request->getParam( 'suffix' );
- $person->dob = $this->_request->getParam( 'dobYear' ) . "-" . $this->_request->getParam( 'dobMonth' ) . "-" . $this->_request->getParam( 'dobDay' );
- $person->gender = $this->_request->getParam( 'gender' );
- $person->created = $created;
- $person->save();
- $user = new Instacare_User( );
- $user->username = $this->_request->getParam( 'email' );
- $user->password = Auth_User::get_hashed_password( $this->_request->getParam( 'password' ), $created );
- $user->person_id = $person->id;
- $user->role_id = $this->_request->getParam( 'role' );
- $user->created = $created;
- $user->sitekey_id = $this->_request->getParam( 'sitekey' );
- $user->sitekey_phrase = $this->_request->getParam( 'phrase' );
- $user->verified = 1;
- $user->save();
- $location = new Locations_Location( );
- $location->label = 'Current Residence';
- $location->street1 = $this->_request->getParam( 'address' );
- $location->city = $this->_request->getParam( 'city' );
- $location->state_id = $this->_request->getParam( 'state' );
- $location->zip = $this->_request->getParam( 'zip' );
- $location->country_id = '1';
- $location->save();
- $phone = new Contacts_Phone( );
- $phone->type_id = '1';
- $phone->number = $this->_request->getParam( 'primaryPhone1' ) . $this->_request->getParam( 'primaryPhone2' ) . $this->_request->getParam( 'primaryPhone3' );
- $phone->save();
- $email = new Contacts_Email( );
- $email->address = $this->_request->getParam( 'email' );
- $email->save();
- $pLocation = new People_PersonsLocations( );
- $pLocation->person_id = $person->id;
- $pLocation->location_id = $location->id;
- $pLocation->label = 'Current Residence';
- $pLocation->save();
- $pPhone = new People_PersonsPhones( );
- $pPhone->person_id = $person->id;
- $pPhone->phone_id = $phone->id;
- $pPhone->label = 'Primary';
- $pPhone->save();
- $pEmail = new People_PersonsEmails( );
- $pEmail->person_id = $person->id;
- $pEmail->email_id = $email->id;
- $pEmail->label = 'Primary';
- $pEmail->save();
- if ($this->_request->getParam('role') == '1') {
- $patient = new Instacare_Patient( );
- $patient->person_id = $person->id;
- $patient->default_location_id = $location->id;
- $patient->default_phone_id = $phone->id;
- $patient->save();
- $record = new Records_Record( );
- $record->person_id = $person->id;
- $record->save();
- } else {
- $employee = new Businesses_Employee();
- $employee->person_id = $person->id;
- $employee->business_id = Doctrine_Query::create()
- ->select('id')
- ->from('Businesses_Business')
- ->where('name LIKE ?', '%Summerlin Health%')
- ->fetchOne()
- ->id;
- $employee->save();
- // @todo: add new roles
- switch ($this->_request->getParam('role')) {
- case '2': $iEmployee = new Instacare_Nurse();
- $iEmployee->npi = $this->_request->getParam('npi');
- $phoneUserType = 2;
- break;
- case '3': $iEmployee = new Instacare_Doctor();
- $iEmployee->npi = $this->_request->getParam('npi');
- $phoneUserType = 3;
- break;
- case '4': $iEmployee = new Instacare_Scheduler();
- $phoneUserType = 4;
- break;
- case '5': $iEmployee = new Instacare_Admissions();
- $phoneUserType = 1;
- break;
- case '6': $iEmployee = new Instacare_Admin();
- break;
- case '10': $iEmployee = new Instacare_Manager();
- break;
- case '11': $iEmployee = new Instacare_Executive();
- break;
- case '12': $iEmployee = new Instacare_Accounting();
- break;
- case '9': $iEmployee = new Instacare_Cmo();
- break;
- }
- $iEmployee->title = $this->_request->getParam('title');
- $iEmployee->employee_id = $employee->id;
- $iEmployee->save();
- if (isset($phoneUserType)) {
- $phoneUser = new Instacare_phone_IcpUsers();
- $phoneUser->user_id = $user->id;
- $phoneUser->type = $phoneUserType;
- switch ($person->default_language) {
- case 'en': $phoneUser->language = 1;
- break;
- case 'es': $phoneUser->language = 2;
- }
- $phoneUser->save();
- }
- }
- $this->_helper->FlashMessenger('User '.$user->username.'successfully created');
- $this->_redirect('/user/index/add');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement