/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
die;
$model = new Customer();
// $jaspers_franchise = JaspersFranchise::model()->findAll();
$jaspers_companies = JaspersCompanies::model()->findAllByAttributes(array('franchise_id' => Yii::app()->user->franchise));
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
$bannerImg = Banner::model()->findByAttributes(array('isactive' => 1, 'loc' => 1));
$curUser = User::model()->findByPk(Yii::app()->user->uid);
if (isset($_POST['Customer'])) {
$model->attributes = $_POST['Customer'];
$model->jaspers_franchise = Yii::app()->user->franchise;
$curUser->name = $model->contact;
$curUser->save();
if (Yii::app()->user->isUser()) {
$model->attendee = Yii::app()->user->uid;
$model->franchise = Yii::app()->user->franchise;
}
if ($model->save()) {
Yii::app()->session['last_created_user'] = $model->attributes;
$istApp = new CustAppoint();
$istApp->app_id = 1;
$istApp->cus_id = getCurCusId();
$istApp->status = 0;
$istApp->save();
if (isset($_GET['back'])) {
$this->redirect(array('site/index'));
}
//$this->redirect(array('site/getstarted', 'id' => getCurCusId()));
$this->redirect(array('workingwell/create', 'id' => getCurCusId()));
}
}
$this->render('create', array('model' => $model, 'bannerImg' => $bannerImg, 'curUser' => $curUser, 'jaspers_companies' => $jaspers_companies));
}