本文整理汇总了PHP中Planning::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Planning::save方法的具体用法?PHP Planning::save怎么用?PHP Planning::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Planning
的用法示例。
在下文中一共展示了Planning::save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
public function actionCreate()
{
// check permissions
// if (!Yii::app()->user->checkAccess('manageUser')) {
// Helper::authException();
// }
// models
$UserLogin = new UserLogin();
$UserProfile = new UserProfile();
$criteria3 = new CDbCriteria();
$criteria3->condition = '(companyID = :companyID AND IsActive=1)';
$criteria3->params = array(':companyID' => Yii::app()->user->companyID);
$criteria3->order = 'Email';
$userManagers = UserProfile::model()->with('userLogin')->findAllByAttributes(array(), $criteria3);
$managersArray = array();
$managersArray[0] = "Please Select...";
foreach ($userManagers as $UserManager) {
//if ($UserManager->ManagerEmail == '') {
//$managersArray[$UserManager->Email] = $UserManager->Email;
$managersArray[$UserManager->Email] = $UserManager->Email;
//} elseif (Helper::hasRole('lacekAdministrator')) {
// $rolesArray[$UserRole->UserRoleID] = $UserRole->RoleDesc;
// }
}
// add default (empty value) to front of array
$managerArray = $managersArray;
// role array for select
$userRoles = UserRole::model()->findAll();
$rolesArray = array();
foreach ($userRoles as $UserRole) {
if ($UserRole->RoleType != 'lacekAdministrator') {
$rolesArray[$UserRole->UserRoleID] = $UserRole->RoleDesc;
} elseif (Helper::hasRole('lacekAdministrator')) {
$rolesArray[$UserRole->UserRoleID] = $UserRole->RoleDesc;
}
}
// add default (empty value) to front of array
$rolesArray = $rolesArray;
// form processing
if (isset($_POST['UserLogin'], $_POST['UserProfile'])) {
// redirect to the dashboard if 'Cancel' button clicked
if (isset($_POST['button-cancel'])) {
$this->redirect($this->createUrl('user/dashboard'));
}
// set UserLogin attributes and scenario
$UserLogin->attributes = $_POST['UserLogin'];
$UserLogin->IsPasswordReset = 1;
// force password reset on first login
$UserLogin->IsActive = 1;
$UserLogin->scenario = 'create';
$UserLogin->UserRoleID = 1;
// set UserProfile attributes
$UserProfile->attributes = $_POST['UserProfile'];
$UserProfile->CompanyID = Yii::app()->user->companyID;
$UserProfile->Email = $UserLogin->LoginEmail;
// validate form submission
$valid = $UserLogin->validate();
$valid = $UserProfile->validate() && $valid;
if ($valid) {
// save UserLogin
if (!$UserLogin->save(false)) {
throw new CHttpException(400, 'Error when trying to create user.');
}
// save UserProfile
$UserProfile->UserLoginID = $UserLogin->UserLoginID;
// set newly generated EventID
if (!$UserProfile->save(false)) {
throw new CHttpException(400, 'Error when trying to create user.');
}
if ($UserProfile->ManagerEmail) {
$UserProfilex = UserProfile::model()->findByAttributes(array('Email' => $UserProfile->ManagerEmail));
$candidateModel = new Candidate();
$candidateModel->CompanyID = $UserProfile->CompanyID;
$candidateModel->EmployeeID = $UserProfile->EmployeeID;
$candidateModel->FirstName = $UserProfile->FirstName;
$candidateModel->MiddleName = $UserProfile->MiddleName;
$candidateModel->LastName = $UserProfile->LastName;
$candidateModel->Title = $UserProfile->Title;
$candidateModel->Email = $UserProfile->Email;
$candidateModel->CompanyPositionID = 1;
$candidateModel->HireDate = date("Y-m-d");
$candidateModel->PositionDate = date("Y-m-d");
$candidateModel->IsActive = 1;
$candidateModel->UserProfileID = $UserProfilex->UserProfileID;
//$candidateModel->UserProfileId=2;
//print_r($candidateModel);
// die($UserProfilex->UserProfileID);
// if ($candidateModel->validate()) {
// if ($candidateModel->save()) {
$candidateModel->save();
$performanceModel = new Performance();
$ratingModel = new Rating();
$planningModel = new Planning();
$currentYear = date('Y');
// insert new record
$performanceModel->CandidateID = $candidateModel->CandidateID;
$performanceModel->PerformanceYear = $currentYear;
$ratingModel->CandidateID = $candidateModel->CandidateID;
$ratingModel->RatingYear = $currentYear;
$planningModel->CandidateID = $candidateModel->CandidateID;
//.........这里部分代码省略.........
示例2: actionAddcandidate
public function actionAddcandidate()
{
if (!isset(Yii::app()->user->userProfileID)) {
$this->redirect('/user/login');
}
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
$candidateModel = new Candidate();
$performanceModel = new Performance();
$ratingModel = new Rating();
$planningModel = new Planning();
if (isset($_POST['Candidate'])) {
$candidateModel->attributes = $_POST['Candidate'];
$candidateModel->IsActive = 1;
//$candidateModel->UserProfileID = Yii::app()->user->userProfileID;
$candidateModel->CompanyID = Yii::app()->user->companyID;
if ($candidateModel->validate()) {
if ($candidateModel->save()) {
$currentYear = date('Y');
// insert new record
$performanceModel->CandidateID = $candidateModel->CandidateID;
$performanceModel->PerformanceYear = $currentYear;
$ratingModel->CandidateID = $candidateModel->CandidateID;
$ratingModel->RatingYear = $currentYear;
$planningModel->CandidateID = $candidateModel->CandidateID;
$planningModel->PlanningYear = $currentYear;
$planningModel->CurrentPositionLevel = $_POST['Candidate']['CompanyPositionID'];
if ($_POST['Candidate']['CompanyPositionID'] == 5) {
$planningModel->NextStepPositionLevel = 5;
$planningModel->LongTermPositionLevel = 5;
} else {
$planningModel->NextStepPositionLevel = $_POST['Candidate']['CompanyPositionID'];
$planningModel->LongTermPositionLevel = $_POST['Candidate']['CompanyPositionID'];
}
$performanceModel->save();
$ratingModel->save();
$planningModel->save();
$this->redirect(Yii::app()->createUrl('company/candidates'));
}
}
}
$criteria3 = new CDbCriteria();
$criteria3->condition = 'companyID = :companyID';
$criteria3->params = array(':companyID' => Yii::app()->user->companyID);
$criteria3->order = 'Email';
$userManagers = UserProfile::model()->findAllByAttributes(array(), $criteria3);
$managersArray = array();
foreach ($userManagers as $UserManager) {
$managersArray[$UserManager->UserProfileID] = $UserManager->Email;
}
$managerArray = $managersArray;
$companyPositions = Helper::getCompanyPositions(Yii::app()->user->companyID);
$this->render('candidate-form', array('candidateModel' => $candidateModel, 'planningModel' => $planningModel, 'companyPositionSelect' => $companyPositions, 'managerArray' => $managerArray));
}