diff options
Diffstat (limited to 'protected/controllers/MyAngebotController.php')
| -rw-r--r-- | protected/controllers/MyAngebotController.php | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/protected/controllers/MyAngebotController.php b/protected/controllers/MyAngebotController.php index c53da98..a1b6064 100644 --- a/protected/controllers/MyAngebotController.php +++ b/protected/controllers/MyAngebotController.php @@ -30,6 +30,30 @@ class MyAngebotController extends Controller ), ); } + + /** + * Creates a new model. + * If creation is successful, the browser will be redirected to the 'view' page. + */ + public function actionCreate() + { + $model=new AngebotVerein; + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if(isset($_POST['AngebotVerein'])) + { + $model->attributes=$_POST['AngebotVerein']; + if($model->save()) + $this->redirect(array('index')); + } + + $this->render('create',array( + 'model'=>$model, + 'angebote'=>Angebot::model()->findAll(), + )); + } public function actionIndex() { $model=new AngebotVerein('search'); @@ -44,6 +68,47 @@ class MyAngebotController extends Controller )); } + public function actionUpdate($id) { + $model=$this->loadModel($id); + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if(isset($_POST['AngebotVerein'])) + { + $model->attributes=$_POST['AngebotVerein']; + if($model->save()) + $this->redirect(array('index')); + } + $angebot = Angebot::model()->findAll(); + $angebote = array(); + foreach ($angebot as $a) { + $an = array(); + $an["label"] = $a->name; + $an["value"] = $a->id; + $an["einheiten"] = $a->kategorie->einheiten; + array_push($angebote, $an); + } + $this->render('update',array( + 'model'=>$model, + 'angebote'=>$angebote, + 'einheiten'=>$model->angebot->kategorie->einheiten + )); + } + + /** + * Returns the data model based on the primary key given in the GET variable. + * If the data model is not found, an HTTP exception will be raised. + * @param integer the ID of the model to be loaded + */ + public function loadModel($id) + { + $model=AngebotVerein::model()->findByPk($id); + if($model===null) + throw new CHttpException(404,'The requested page does not exist.'); + return $model; + } + // Uncomment the following methods and override them if needed /* public function filters() |
