/**
	 * Creates a new model.
	 * If creation is successful, the browser will be redirected to the 'view' page.
	 */
	public function actionCreate()
	{
		$model=new EmployeeExperienceTrans;
		$emp_exp=new EmployeeExperience;
		$this->layout='no-portlet';

		// Uncomment the following line if AJAX validation is needed
		$this->performAjaxValidation(array($model,$emp_exp));

		if(isset($_POST['EmployeeExperience']))
		{
			$emp_exp->attributes=$_POST['EmployeeExperience'];
			$todate = $_POST['EmployeeExperience']['employee_experience_to'];
			$fromdate = $_POST['EmployeeExperience']['employee_experience_from'];
			$from_date = date("Y-m-d", strtotime($fromdate));
			$to_date = date("Y-m-d", strtotime($todate));
			$valid = $emp_exp->validate();

			if($valid)
			{
				
				$datetime1 = date_create($to_date);
				$datetime2 = date_create($from_date);
				$total_exp = date_diff($datetime1,$datetime2);
				$diffday = $total_exp->format('%d');
				$diffmonth = $total_exp->format('%m');
				$diffyear = $total_exp->format('%y');
				$experince = $diffyear.'Y '.$diffmonth.'M '.$diffday.'D';
				$emp_exp->employee_experience = $experince;
				$emp_exp->employee_experience_to = $to_date;
				$emp_exp->employee_experience_from = $from_date;
				$emp_exp->save();
				$model->employee_experience_trans_user_id = $_REQUEST['id'];
				$model->employee_experience_trans_emp_experience_id = $emp_exp->employee_experience_id;
				$model->employee_experience_trans_organization_id=Yii::app()->user->getState('org_id');
				$model->save();
				
				$this->redirect(array('employeeTransaction/employeeExperience','id'=>$model->employee_experience_trans_user_id));
			}
			
		}

		$this->render('create',array(
			'model'=>$model,'emp_exp'=>$emp_exp,
		));
	}