public function actionCreateUser() { $this->layout = 'select_company_main'; $model = new User(); $ass_comp = new assignCompanyUserTable(); //$model->setScenario('create'); $auth_assign = new AuthAssignment(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['User'])) { $model->attributes = $_POST['User']; $model->user_password = md5($model->user_password . $model->user_password); $model->user_type = 'admin'; $model->user_created_by = 1; $model->user_creation_date = new CDbExpression('NOW()'); $model->user_organization_id = $_REQUEST['id']; if ($model->save()) { $ass_comp->assign_user_id = $model->user_id; $ass_comp->assign_org_id = $_REQUEST['id']; $ass_comp->assign_created_by = $model->user_id; $ass_comp->assign_creation_date = new CDbExpression('NOW()'); $ass_comp->save(); $auth_assign->itemname = 'SuperAdmin'; $auth_assign->userid = $model->user_id; $auth_assign->save(false); $this->redirect(array('site/redirectLogin')); } } $this->render('create_user', array('model' => $model)); }
/** * Manages all models. */ public function actionTransferemployee() { $model=new EmployeeTransaction('transferemployee'); $info=new EmployeeInfo; $user =new User; $photo =new EmployeePhotos; $address=new EmployeeAddress; $lang=new LanguagesKnown; $ass_comp = new assignCompanyUserTable; $auth_assign = new AuthAssignment; $this->performAjaxValidation(array($info,$model,$user)); if(!empty($_POST['user_id1'])) { $model->attributes=$_POST['EmployeeTransaction']; $info->attributes=$_POST['EmployeeInfo']; $trans_id = $_POST['user_id1']; $old_model = EmployeeTransaction::model()->resetScope()->findByPk($trans_id); $old_info = EmployeeInfo::model()->findByPk($old_model->employee_transaction_employee_id); $old_info->transfer_left_remarks= $_POST['EmployeeTransaction']['transfer_left_remarks']; $old_info->employee_left_transfer_date = new CDbExpression('NOW()'); $old_info->save(false); $old_model->employee_status = 1; $old_model->save(); $user = User::model()->findByPk($old_model->employee_transaction_user_id); $user->user_created_by = Yii::app()->user->id; $user->user_creation_date = new CDbExpression('NOW()'); $user->user_organization_id = $_POST['EmployeeTransaction']['employee_transaction_organization_id']; if($user->save()) { $org_data = Organization::model()->findByPk($_POST['EmployeeTransaction']['employee_transaction_organization_id']); $org_name = $org_data->organization_name; $org_arr = explode(' ',$org_name); $bizrule = 'return Yii::app()->user->getState("org_id")=='.$_POST['EmployeeTransaction']['employee_transaction_organization_id'].";"; $var_data = serialize($_POST['EmployeeTransaction']['employee_transaction_organization_id']); $suffix_lab = ''; foreach($org_arr as $list) $suffix_lab .= $list[0]; $auth_assign->itemname = 'Employee of '.$suffix_lab; $check = AuthAssignment::model()->findByAttributes(array('itemname'=>$auth_assign->itemname,'userid' => $user->user_id,'data' =>$var_data)); if(empty($check)){ $auth_assign->userid = $user->user_id; $auth_assign->bizrule = $bizrule; $auth_assign->data = $var_data; $auth_assign->save(); } $ass_comp->assign_user_id = $user->user_id; $ass_comp->assign_role_id = 3; $ass_comp->assign_org_id = $_POST['EmployeeTransaction']['employee_transaction_organization_id']; $ass_comp->assign_created_by = Yii::app()->user->id; $ass_comp->assign_creation_date = new CDbExpression('NOW()'); $ass_comp->save(); $info = $old_info; $info->employee_joining_date = new CDbExpression('NOW()'); $info->employee_type = $_POST['EmployeeInfo']['employee_type']; $info->employee_attendance_card_id = ''; $info->employee_created_by = Yii::app()->user->id; $info->employee_creation_date = new CDbExpression('NOW()'); $info->employee_left_transfer_date = NULL; $info->employee_id = null; $info->setIsNewRecord(true); $info->save(false); $model = $old_model; $model->employee_transaction_id = null; $model->setIsNewRecord(true); $model->employee_transaction_user_id = $user->user_id; $model->employee_transaction_employee_id = $info->employee_id; $model->employee_transaction_shift_id = $_POST['EmployeeTransaction']['employee_transaction_shift_id']; $model->employee_transaction_designation_id = $_POST['EmployeeTransaction']['employee_transaction_designation_id']; $model->employee_transaction_department_id = $_POST['EmployeeTransaction']['employee_transaction_department_id']; $model->employee_transaction_organization_id = $_POST['EmployeeTransaction']['employee_transaction_organization_id']; $model->employee_status = 0; $model->save(false); EmployeeInfo::model()->updateByPk($model->employee_transaction_employee_id, array('employee_info_transaction_id'=>$model->employee_transaction_id)); Yii::app()->user->setFlash('success',"Transfer of ".$info->employee_first_name.' to '.$org_name.' successfully.!'); $this->redirect(array('employeeTransaction/admin')); } } $this->render('transfer_employee',array( 'model'=>$model,'info'=>$info,'user'=>$user, )); }
public function actionAprove($id) { $model= StudentRegistrationInfo::model()->findByPk($id); $info = new StudentInfo; $stud_trans = new StudentTransaction; $user =new User; $photo =new StudentPhotos; $address=new StudentAddress; $lang=new LanguagesKnown; $ass_comp = new assignCompanyUserTable; $auth_assign = new AuthAssignment; $qualification=new StudentAcademicRecordTrans; if(isset($_REQUEST['StudentRegistrationInfo'])) { $org_id = $model->organization_id; if($model->student_status==1){ $acd = Yii::app()->db->createCommand() ->select("academic_term_id,academic_term_name,academic_term_period_id") ->from('academic_term') ->where('current_sem=1 and academic_term_name =1 and academic_term_organization_id='.$org_id) ->queryAll(); if(!$acd){ Yii::app()->user->setFlash('notice','Semester-1 is not an Active semester'); $this->redirect(array('admin')); } $info->student_dtod_regular_status = 'Regular'; } elseif($model->student_status==2){ $acd = Yii::app()->db->createCommand() ->select("academic_term_id,academic_term_name,academic_term_period_id") ->from('academic_term') ->where('current_sem=1 and academic_term_name =3 and academic_term_organization_id='.$org_id) ->queryAll(); if(!$acd){ Yii::app()->user->setFlash('notice','Semester-3 is not an Active semester'); $this->redirect(array('admin')); } $info->student_dtod_regular_status = 'DTOD'; } $info->title = $model->student_title; $info->student_merit_no = $model->student_merit_no; $info->student_first_name = $model->student_first_name; $info->student_middle_name =$model->student_middle_name; $info->student_last_name = $model->student_last_name; $info->student_father_name = $model->student_father_name; $info->student_mother_name = $model->student_mother_name; $info->student_dob = $model->student_dob; $info->student_adm_date = new CDbExpression('NOW()'); $info->student_birthplace = $model->student_place_of_birth; $info->student_gender = $model->student_gender; $info->student_email_id_1 = $model->student_email_id; $info->student_mobile_no = $model->student_mobile; $info->student_created_by = Yii::app()->user->id; $info->student_creation_date = new CDbExpression('NOW()'); $user->user_organization_email_id = strtolower($info->student_email_id_1); $user->user_password = md5($info->student_email_id_1.$info->student_email_id_1); $user->user_created_by = Yii::app()->user->id; $user->user_creation_date = new CDbExpression('NOW()'); $user->user_organization_id = $org_id; $user->user_type = "student"; $photo->student_photos_path = $model->student_photo; $address->student_address_c_line1 = $model->student_address_c_line1; $address->student_address_c_line2 = $model->student_address_c_line2; $address->student_address_c_taluka = $model->student_address_c_taluka; $address->student_address_c_district = $model->student_address_c_district; $address->student_address_c_country = $model->student_address_c_country; $address->student_address_c_city = $model->student_address_c_city; $address->student_address_c_pin = $model->student_address_c_pin ; $address->student_address_c_state = $model->student_address_c_state; $address->student_address_p_line1 = $model->student_address_p_line1; $address->student_address_p_line2 = $model->student_address_p_line2; $address->student_address_p_taluka = $model->student_address_p_taluka; $address->student_address_p_district = $model->student_address_p_district; $address->student_address_p_country = $model->student_address_p_country; $address->student_address_p_city = $model->student_address_p_city; $address->student_address_p_pin = $model->student_address_p_pin ; $address->student_address_p_state = $model->student_address_p_state; $address->student_address_phone = $model->student_phoneno; $address->student_address_mobile = $model->student_mobile; if($info->save(false)){ $user->save(false); $photo->save(false); $address->save(false); $lang->save(false); $stud_trans->student_transaction_user_id = $user->user_id; $stud_trans->student_transaction_student_id = $info->student_id; //$stud_trans->student_transaction_branch_id = $model->student_branch_id; if(!empty($model->student_category_id)) $stud_trans->student_transaction_category_id = $model->student_category_id; $stud_trans->student_transaction_organization_id = $org_id; $stud_trans->student_transaction_student_address_id = $address->student_address_id; $stud_trans->student_transaction_languages_known_id= $lang->languages_known_id; $stud_trans->student_transaction_detain_student_flag='5'; $stud_trans->student_transaction_student_photos_id = $photo->student_photos_id; $stud_trans->student_transaction_branch_id=$_POST['StudentRegistrationInfo']['student_branch_id']; $stud_trans->student_academic_term_period_tran_id = $acd[0]['academic_term_period_id']; $stud_trans->student_academic_term_name_id = $acd[0]['academic_term_id']; $stud_trans->save(false); StudentInfo::model()->updateByPk($stud_trans->student_transaction_student_id, array('student_info_transaction_id'=>$stud_trans->student_transaction_id)); $org_data = Organization::model()->findByPk($org_id); $org_name = $org_data->organization_name; $org_arr = explode(' ',$org_name); $suffix_lab = ''; foreach($org_arr as $list) $suffix_lab .= $list[0]; $bizrule = 'return Yii::app()->user->getState("org_id")=='.$org_id.";"; $var_data = serialize(Yii::app()->user->getState('org_id')); $auth_assign->itemname = 'Student of '.$suffix_lab; $auth_assign->userid = $user->user_id; $auth_assign->bizrule = $bizrule; $auth_assign->data = $var_data; $auth_assign->save(); $ass_comp->assign_user_id = $user->user_id; $ass_comp->assign_org_id = $org_id; $ass_comp->assign_created_by = Yii::app()->user->id; $ass_comp->assign_creation_date = new CDbExpression('NOW()'); $ass_comp->save(); StudentRegistrationInfo::model()->updateByPk($id, array( 'student_aproved'=>'1', )); $this->redirect(array('admin')); } } $this->render('aprove',array('model'=>$model)); }