From 3cb7fbfceae978d2b87ae976bf4536c3461bb868 Mon Sep 17 00:00:00 2001 From: Tristan Zur Date: Wed, 16 May 2012 18:14:16 +0200 Subject: =?UTF-8?q?Initiale=20Veranstaltungsverwaltung=20f=C3=BCr=20die=20?= =?UTF-8?q?Vereine=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/MyVeranstaltungController.php | 13 +++-- protected/models/Veranstaltung.php | 6 ++- protected/views/myVeranstaltung/_form.php | 46 ++++++++++++----- protected/views/myVeranstaltung/_search.php | 17 +------ protected/views/myVeranstaltung/_view.php | 38 -------------- protected/views/myVeranstaltung/admin.php | 59 ---------------------- protected/views/myVeranstaltung/create.php | 11 ++-- protected/views/myVeranstaltung/index.php | 36 ++++++++++--- protected/views/myVeranstaltung/update.php | 16 +++--- protected/views/myVeranstaltung/view.php | 30 +++++------ protected/views/veranstaltung/view.php | 2 +- 11 files changed, 106 insertions(+), 168 deletions(-) delete mode 100644 protected/views/myVeranstaltung/_view.php delete mode 100644 protected/views/myVeranstaltung/admin.php diff --git a/protected/controllers/MyVeranstaltungController.php b/protected/controllers/MyVeranstaltungController.php index 97efa52..568a93d 100644 --- a/protected/controllers/MyVeranstaltungController.php +++ b/protected/controllers/MyVeranstaltungController.php @@ -65,12 +65,15 @@ class MyVeranstaltungController extends Controller if(isset($_POST['Veranstaltung'])) { $model->attributes=$_POST['Veranstaltung']; + $model->verein_id = Yii::app()->user->vereinId; if($model->save()) $this->redirect(array('view','id'=>$model->id)); } + $standorte = Standort::model()->findAll(array("condition"=>"published = 1 AND (type = 'Bühne' OR (type = 'Stand' AND id = (SELECT standort_id FROM vereine WHERE id = ".Yii::app()->user->vereinId.")))")); $this->render('create',array( 'model'=>$model, + 'standorte'=>$standorte, )); } @@ -93,8 +96,10 @@ class MyVeranstaltungController extends Controller $this->redirect(array('view','id'=>$model->id)); } + $standorte = Standort::model()->findAll(array("condition"=>"published = 1 AND (type = 'Bühne' OR (type = 'Stand' AND id = (SELECT standort_id FROM vereine WHERE id = ".Yii::app()->user->vereinId.")))")); $this->render('update',array( 'model'=>$model, + 'standorte'=>$standorte, )); } @@ -112,7 +117,7 @@ class MyVeranstaltungController extends Controller // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if(!isset($_GET['ajax'])) - $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); + $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index')); } else throw new CHttpException(400,'Invalid request. Please do not repeat this request again.'); @@ -138,8 +143,9 @@ class MyVeranstaltungController extends Controller $model->unsetAttributes(); // clear any default values if(isset($_GET['Veranstaltung'])) $model->attributes=$_GET['Veranstaltung']; + $model->verein_id = Yii::app()->user->vereinId; - $this->render('admin',array( + $this->render('index',array( 'model'=>$model, )); } @@ -151,7 +157,8 @@ class MyVeranstaltungController extends Controller */ public function loadModel($id) { - $model=Veranstaltung::model()->findByPk($id); + $attributes = array("verein_id"=>Yii::app()->user->vereinId, "id"=>$id); + $model=Veranstaltung::model()->findByAttributes($attributes); if($model===null) throw new CHttpException(404,'The requested page does not exist.'); return $model; diff --git a/protected/models/Veranstaltung.php b/protected/models/Veranstaltung.php index 64c7854..496cf30 100644 --- a/protected/models/Veranstaltung.php +++ b/protected/models/Veranstaltung.php @@ -113,7 +113,7 @@ class Veranstaltung extends CActiveRecord )); } - public function beforeSave() { + protected function beforeSave() { $isValid = parent::beforeSave(); if ($isValid) { $this->startzeit = Format::dbDateTime($this->startzeit); @@ -122,6 +122,10 @@ class Veranstaltung extends CActiveRecord return $isValid; } + protected function afterFind() { + parent::afterFind(); + } + public function behaviors() { return array( 'LoggableBehavior'=>'application.modules.auditTrail.behaviors.LoggableBehavior', diff --git a/protected/views/myVeranstaltung/_form.php b/protected/views/myVeranstaltung/_form.php index 588048d..1332b44 100644 --- a/protected/views/myVeranstaltung/_form.php +++ b/protected/views/myVeranstaltung/_form.php @@ -5,17 +5,11 @@ 'enableAjaxValidation'=>false, )); ?> -

Fields with * are required.

+ renderPartial('/common/_required_fields_text'); ?> errorSummary($model); ?>
- labelEx($model,'verein_id'); ?> - textField($model,'verein_id'); ?> - error($model,'verein_id'); ?> -
- -
labelEx($model,'titel'); ?> textField($model,'titel',array('size'=>60,'maxlength'=>100)); ?> error($model,'titel'); ?> @@ -23,13 +17,41 @@
labelEx($model,'startzeit'); ?> - textField($model,'startzeit'); ?> + widget('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker', array( + 'model'=>$model, + 'attribute'=>'startzeit', + 'mode'=>'datetime', + // additional javascript options for the date picker plugin + 'options'=>array( + 'minDate'=>Yii::app()->params["start_date"], + 'maxDate'=>Yii::app()->params["end_date"], + ), + 'htmlOptions'=>array( + 'style'=>'height:20px;' + ), + )); + ?> error($model,'startzeit'); ?>
labelEx($model,'endzeit'); ?> - textField($model,'endzeit'); ?> + widget('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker', array( + 'model'=>$model, + 'attribute'=>'endzeit', + 'mode'=>'datetime', + // additional javascript options for the date picker plugin + 'options'=>array( + 'minDate'=>Yii::app()->params["start_date"], + 'maxDate'=>Yii::app()->params["end_date"], + ), + 'htmlOptions'=>array( + 'style'=>'height:20px;' + ), + )); + ?> error($model,'endzeit'); ?>
@@ -41,18 +63,18 @@
labelEx($model,'standort_id'); ?> - textField($model,'standort_id'); ?> + dropDownList($model, "standort_id", CHtml::listData($standorte, "id", "name"), array('empty' => '-- Bitte Standort wählen --')); ?> error($model,'standort_id'); ?>
labelEx($model,'published'); ?> - textField($model,'published'); ?> + checkbox($model,'published'); ?> error($model,'published'); ?>
- isNewRecord ? 'Create' : 'Save'); ?> + isNewRecord ? 'Erstellen' : 'Speichern'); ?>
endWidget(); ?> diff --git a/protected/views/myVeranstaltung/_search.php b/protected/views/myVeranstaltung/_search.php index b4ec2ed..9fb5b02 100644 --- a/protected/views/myVeranstaltung/_search.php +++ b/protected/views/myVeranstaltung/_search.php @@ -6,16 +6,6 @@ )); ?>
- label($model,'id'); ?> - textField($model,'id'); ?> -
- -
- label($model,'verein_id'); ?> - textField($model,'verein_id'); ?> -
- -
label($model,'titel'); ?> textField($model,'titel',array('size'=>60,'maxlength'=>100)); ?>
@@ -37,12 +27,7 @@
label($model,'standort_id'); ?> - textField($model,'standort_id'); ?> -
- -
- label($model,'published'); ?> - textField($model,'published'); ?> + dropDownList($model, 'standort_id', CHtml::listData(Standort::model()->findAll(array('condition'=>'type="Bühne"')), 'id', 'name'), array("empty"=>"")); ?>
diff --git a/protected/views/myVeranstaltung/_view.php b/protected/views/myVeranstaltung/_view.php deleted file mode 100644 index daa818a..0000000 --- a/protected/views/myVeranstaltung/_view.php +++ /dev/null @@ -1,38 +0,0 @@ -
- - getAttributeLabel('id')); ?>: - id), array('view', 'id'=>$data->id)); ?> -
- - getAttributeLabel('verein_id')); ?>: - verein_id); ?> -
- - getAttributeLabel('titel')); ?>: - titel); ?> -
- - getAttributeLabel('startzeit')); ?>: - startzeit); ?> -
- - getAttributeLabel('endzeit')); ?>: - endzeit); ?> -
- - getAttributeLabel('beschreibung')); ?>: - beschreibung); ?> -
- - getAttributeLabel('standort_id')); ?>: - standort_id); ?> -
- - getAttributeLabel('published')); ?>: - published); ?> -
- - */ ?> - -
\ No newline at end of file diff --git a/protected/views/myVeranstaltung/admin.php b/protected/views/myVeranstaltung/admin.php deleted file mode 100644 index 6e2a1a3..0000000 --- a/protected/views/myVeranstaltung/admin.php +++ /dev/null @@ -1,59 +0,0 @@ -breadcrumbs=array( - 'Veranstaltungs'=>array('index'), - 'Manage', -); - -$this->menu=array( - array('label'=>'List Veranstaltung', 'url'=>array('index')), - array('label'=>'Create Veranstaltung', 'url'=>array('create')), -); - -Yii::app()->clientScript->registerScript('search', " -$('.search-button').click(function(){ - $('.search-form').toggle(); - return false; -}); -$('.search-form form').submit(function(){ - $.fn.yiiGridView.update('veranstaltung-grid', { - data: $(this).serialize() - }); - return false; -}); -"); -?> - -

Manage Veranstaltungs

- -

-You may optionally enter a comparison operator (<, <=, >, >=, <> -or =) at the beginning of each of your search values to specify how the comparison should be done. -

- -'search-button')); ?> - - -widget('zii.widgets.grid.CGridView', array( - 'id'=>'veranstaltung-grid', - 'dataProvider'=>$model->search(), - 'filter'=>$model, - 'columns'=>array( - 'id', - 'verein_id', - 'titel', - 'startzeit', - 'endzeit', - 'beschreibung', - /* - 'standort_id', - 'published', - */ - array( - 'class'=>'CButtonColumn', - ), - ), -)); ?> diff --git a/protected/views/myVeranstaltung/create.php b/protected/views/myVeranstaltung/create.php index 3c7af00..defd84d 100644 --- a/protected/views/myVeranstaltung/create.php +++ b/protected/views/myVeranstaltung/create.php @@ -1,15 +1,14 @@ breadcrumbs=array( - 'Veranstaltungs'=>array('index'), - 'Create', + 'Unsere Veranstaltungen'=>array('index'), + 'Neue Veranstaltung erstellen', ); $this->menu=array( - array('label'=>'List Veranstaltung', 'url'=>array('index')), - array('label'=>'Manage Veranstaltung', 'url'=>array('admin')), + array('label'=>'Unsere Veranstaltungen', 'url'=>array('index')), ); ?> -

Create Veranstaltung

+

Neue Veranstaltung erstellen

-renderPartial('_form', array('model'=>$model)); ?> \ No newline at end of file +renderPartial('_form', array('model'=>$model, 'standorte'=>$standorte)); ?> \ No newline at end of file diff --git a/protected/views/myVeranstaltung/index.php b/protected/views/myVeranstaltung/index.php index 6ff8a23..f5b5893 100644 --- a/protected/views/myVeranstaltung/index.php +++ b/protected/views/myVeranstaltung/index.php @@ -1,17 +1,39 @@ breadcrumbs=array( - 'Veranstaltungs', + 'Unsere Veranstaltungen', ); $this->menu=array( - array('label'=>'Create Veranstaltung', 'url'=>array('create')), - array('label'=>'Manage Veranstaltung', 'url'=>array('admin')), + array('label'=>'Unsere Veranstaltungen', 'url'=>array('index')), + array('label'=>'Neue Veranstaltung erstellen', 'url'=>array('create')), ); ?> -

Veranstaltungs

+

Unsere Veranstaltungen

-widget('zii.widgets.CListView', array( - 'dataProvider'=>$dataProvider, - 'itemView'=>'_view', +renderPartial('/common/_comparison_text'); ?> + +renderPartial('/common/_advanced_search',array( + 'model'=>$model, +)); ?> + +widget('zii.widgets.grid.CGridView', array( + 'id'=>'veranstaltung-grid', + 'dataProvider'=>$model->search(), + 'filter'=>$model, + 'columns'=>array( + //'id', + //'verein_id', + 'titel', + array('value'=>'Format::displayDateTime($data->startzeit)', 'name'=>'startzeit'), + array('value'=>'Format::displayDateTime($data->endzeit)', 'name'=>'endzeit'), + 'beschreibung', + array('name'=>'standort_id', + 'filter'=>CHtml::listData(Standort::model()->findAll(array('condition'=>'type="Bühne"')), 'id', 'name'), + 'value'=>'($data->standort) ? $data->standort->name : "Kein Standort"'), + array('name'=>'published', 'filter'=>'', 'value'=>'CHtml::image($data->published ? "images/ok.png" : "images/nok.png", $data->published ? "ok.png" : "nok.png")', 'type'=>'raw'), + array( + 'class'=>'CButtonColumn', + ), + ), )); ?> diff --git a/protected/views/myVeranstaltung/update.php b/protected/views/myVeranstaltung/update.php index cfeb467..3ee393d 100644 --- a/protected/views/myVeranstaltung/update.php +++ b/protected/views/myVeranstaltung/update.php @@ -1,18 +1,16 @@ breadcrumbs=array( - 'Veranstaltungs'=>array('index'), - $model->id=>array('view','id'=>$model->id), - 'Update', + 'Unsere Veranstaltungen'=>array('index'), + $model->titel.' bearbeiten', ); $this->menu=array( - array('label'=>'List Veranstaltung', 'url'=>array('index')), - array('label'=>'Create Veranstaltung', 'url'=>array('create')), - array('label'=>'View Veranstaltung', 'url'=>array('view', 'id'=>$model->id)), - array('label'=>'Manage Veranstaltung', 'url'=>array('admin')), + array('label'=>'Unsere Veranstaltungen', 'url'=>array('index')), + array('label'=>'Neue Veranstaltung erstellen', 'url'=>array('create')), + array('label'=>'Diese Veranstaltung anzeigen', 'url'=>array('view', 'id'=>$model->id)), ); ?> -

Update Veranstaltung id; ?>

+

Veranstaltung 'titel; ?>' bearbeiten

-renderPartial('_form', array('model'=>$model)); ?> \ No newline at end of file +renderPartial('_form', array('model'=>$model, 'standorte'=>$standorte)); ?> \ No newline at end of file diff --git a/protected/views/myVeranstaltung/view.php b/protected/views/myVeranstaltung/view.php index 12ac308..cb1ab82 100644 --- a/protected/views/myVeranstaltung/view.php +++ b/protected/views/myVeranstaltung/view.php @@ -1,30 +1,28 @@ breadcrumbs=array( - 'Veranstaltungs'=>array('index'), - $model->id, + 'Unsere Veranstaltungen'=>array('index'), + $model->titel, ); $this->menu=array( - array('label'=>'List Veranstaltung', 'url'=>array('index')), - array('label'=>'Create Veranstaltung', 'url'=>array('create')), - array('label'=>'Update Veranstaltung', 'url'=>array('update', 'id'=>$model->id)), - array('label'=>'Delete Veranstaltung', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')), - array('label'=>'Manage Veranstaltung', 'url'=>array('admin')), + array('label'=>'Unsere Veranstaltungen', 'url'=>array('index')), + array('label'=>'Neue Veranstaltung erstellen', 'url'=>array('create')), + array('label'=>'Diese Veranstaltung bearbeiten', 'url'=>array('update', 'id'=>$model->id)), + array('label'=>'Diese Veranstaltung löschen', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Wollen Sie diese Veranstaltung wirklich löschen?')), ); ?> -

View Veranstaltung #id; ?>

+

titel; ?>

widget('zii.widgets.CDetailView', array( 'data'=>$model, 'attributes'=>array( - 'id', - 'verein_id', - 'titel', - 'startzeit', - 'endzeit', - 'beschreibung', - 'standort_id', - 'published', + //'verein_id', + //'titel', + array('label'=>'Startzeit', 'value'=>Format::displayDateTime($model->startzeit)), + array('label'=>'Endzeit', 'value'=>Format::displayDateTime($model->endzeit)), + 'beschreibung:html', + array('label'=>'Standort', 'value'=>($model->standort) ? $model->standort->name : null), + array('label'=>'Öffentlich', 'value'=>CHtml::image($model->published ? "images/ok.png" : "images/nok.png", $model->published ? "ok.png" : "nok.png"), 'type'=>'raw'), ), )); ?> diff --git a/protected/views/veranstaltung/view.php b/protected/views/veranstaltung/view.php index 5840a4e..55444d8 100644 --- a/protected/views/veranstaltung/view.php +++ b/protected/views/veranstaltung/view.php @@ -8,7 +8,7 @@ $this->menu=array( array('label'=>'Veranstaltungen', 'url'=>array('index')), array('label'=>'Veranstaltung erstellen', 'url'=>array('create')), array('label'=>'Veranstaltung bearbeiten', 'url'=>array('update', 'id'=>$model->id)), - array('label'=>'Veranstaltung löschen', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')), + array('label'=>'Veranstaltung löschen', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Willst du diese Veranstaltung wirklich löschen?')), ); ?> -- cgit v1.0-28-g1787