summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Zur <tzur@ccwn.org>2012-05-16 18:14:16 +0200
committerTristan Zur <tzur@ccwn.org>2012-05-16 18:14:16 +0200
commit3cb7fbfceae978d2b87ae976bf4536c3461bb868 (patch)
tree36d42842f3dfbc8a9598ea519792933bac99c3f8
parent48f25c5eadd2a82a365b034a59b3cba4536a1e74 (diff)
Initiale Veranstaltungsverwaltung für die Vereine hinzugefügt
-rw-r--r--protected/controllers/MyVeranstaltungController.php13
-rw-r--r--protected/models/Veranstaltung.php6
-rw-r--r--protected/views/myVeranstaltung/_form.php46
-rw-r--r--protected/views/myVeranstaltung/_search.php17
-rw-r--r--protected/views/myVeranstaltung/_view.php38
-rw-r--r--protected/views/myVeranstaltung/admin.php59
-rw-r--r--protected/views/myVeranstaltung/create.php11
-rw-r--r--protected/views/myVeranstaltung/index.php36
-rw-r--r--protected/views/myVeranstaltung/update.php16
-rw-r--r--protected/views/myVeranstaltung/view.php30
-rw-r--r--protected/views/veranstaltung/view.php2
11 files changed, 106 insertions, 168 deletions
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,
)); ?>
- <p class="note">Fields with <span class="required">*</span> are required.</p>
+ <?php $this->renderPartial('/common/_required_fields_text'); ?>
<?php echo $form->errorSummary($model); ?>
<div class="row">
- <?php echo $form->labelEx($model,'verein_id'); ?>
- <?php echo $form->textField($model,'verein_id'); ?>
- <?php echo $form->error($model,'verein_id'); ?>
- </div>
-
- <div class="row">
<?php echo $form->labelEx($model,'titel'); ?>
<?php echo $form->textField($model,'titel',array('size'=>60,'maxlength'=>100)); ?>
<?php echo $form->error($model,'titel'); ?>
@@ -23,13 +17,41 @@
<div class="row">
<?php echo $form->labelEx($model,'startzeit'); ?>
- <?php echo $form->textField($model,'startzeit'); ?>
+ <?php
+ $this->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;'
+ ),
+ ));
+ ?>
<?php echo $form->error($model,'startzeit'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'endzeit'); ?>
- <?php echo $form->textField($model,'endzeit'); ?>
+ <?php
+ $this->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;'
+ ),
+ ));
+ ?>
<?php echo $form->error($model,'endzeit'); ?>
</div>
@@ -41,18 +63,18 @@
<div class="row">
<?php echo $form->labelEx($model,'standort_id'); ?>
- <?php echo $form->textField($model,'standort_id'); ?>
+ <?php echo $form->dropDownList($model, "standort_id", CHtml::listData($standorte, "id", "name"), array('empty' => '-- Bitte Standort wählen --')); ?>
<?php echo $form->error($model,'standort_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'published'); ?>
- <?php echo $form->textField($model,'published'); ?>
+ <?php echo $form->checkbox($model,'published'); ?>
<?php echo $form->error($model,'published'); ?>
</div>
<div class="row buttons">
- <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
+ <?php echo CHtml::submitButton($model->isNewRecord ? 'Erstellen' : 'Speichern'); ?>
</div>
<?php $this->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 @@
)); ?>
<div class="row">
- <?php echo $form->label($model,'id'); ?>
- <?php echo $form->textField($model,'id'); ?>
- </div>
-
- <div class="row">
- <?php echo $form->label($model,'verein_id'); ?>
- <?php echo $form->textField($model,'verein_id'); ?>
- </div>
-
- <div class="row">
<?php echo $form->label($model,'titel'); ?>
<?php echo $form->textField($model,'titel',array('size'=>60,'maxlength'=>100)); ?>
</div>
@@ -37,12 +27,7 @@
<div class="row">
<?php echo $form->label($model,'standort_id'); ?>
- <?php echo $form->textField($model,'standort_id'); ?>
- </div>
-
- <div class="row">
- <?php echo $form->label($model,'published'); ?>
- <?php echo $form->textField($model,'published'); ?>
+ <?php echo $form->dropDownList($model, 'standort_id', CHtml::listData(Standort::model()->findAll(array('condition'=>'type="Bühne"')), 'id', 'name'), array("empty"=>"")); ?>
</div>
<div class="row buttons">
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 @@
-<div class="view">
-
- <b><?php echo CHtml::encode($data->getAttributeLabel('id')); ?>:</b>
- <?php echo CHtml::link(CHtml::encode($data->id), array('view', 'id'=>$data->id)); ?>
- <br />
-
- <b><?php echo CHtml::encode($data->getAttributeLabel('verein_id')); ?>:</b>
- <?php echo CHtml::encode($data->verein_id); ?>
- <br />
-
- <b><?php echo CHtml::encode($data->getAttributeLabel('titel')); ?>:</b>
- <?php echo CHtml::encode($data->titel); ?>
- <br />
-
- <b><?php echo CHtml::encode($data->getAttributeLabel('startzeit')); ?>:</b>
- <?php echo CHtml::encode($data->startzeit); ?>
- <br />
-
- <b><?php echo CHtml::encode($data->getAttributeLabel('endzeit')); ?>:</b>
- <?php echo CHtml::encode($data->endzeit); ?>
- <br />
-
- <b><?php echo CHtml::encode($data->getAttributeLabel('beschreibung')); ?>:</b>
- <?php echo CHtml::encode($data->beschreibung); ?>
- <br />
-
- <b><?php echo CHtml::encode($data->getAttributeLabel('standort_id')); ?>:</b>
- <?php echo CHtml::encode($data->standort_id); ?>
- <br />
-
- <?php /*
- <b><?php echo CHtml::encode($data->getAttributeLabel('published')); ?>:</b>
- <?php echo CHtml::encode($data->published); ?>
- <br />
-
- */ ?>
-
-</div> \ 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 @@
-<?php
-$this->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;
-});
-");
-?>
-
-<h1>Manage Veranstaltungs</h1>
-
-<p>
-You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
-or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
-</p>
-
-<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
-<div class="search-form" style="display:none">
-<?php $this->renderPartial('_search',array(
- 'model'=>$model,
-)); ?>
-</div><!-- search-form -->
-
-<?php $this->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 @@
<?php
$this->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')),
);
?>
-<h1>Create Veranstaltung</h1>
+<h1>Neue Veranstaltung erstellen</h1>
-<?php echo $this->renderPartial('_form', array('model'=>$model)); ?> \ No newline at end of file
+<?php echo $this->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 @@
<?php
$this->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')),
);
?>
-<h1>Veranstaltungs</h1>
+<h1>Unsere Veranstaltungen</h1>
-<?php $this->widget('zii.widgets.CListView', array(
- 'dataProvider'=>$dataProvider,
- 'itemView'=>'_view',
+<?php $this->renderPartial('/common/_comparison_text'); ?>
+
+<?php $this->renderPartial('/common/_advanced_search',array(
+ 'model'=>$model,
+)); ?>
+
+<?php $this->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 @@
<?php
$this->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)),
);
?>
-<h1>Update Veranstaltung <?php echo $model->id; ?></h1>
+<h1>Veranstaltung '<?php echo $model->titel; ?>' bearbeiten</h1>
-<?php echo $this->renderPartial('_form', array('model'=>$model)); ?> \ No newline at end of file
+<?php echo $this->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 @@
<?php
$this->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?')),
);
?>
-<h1>View Veranstaltung #<?php echo $model->id; ?></h1>
+<h1><?php echo $model->titel; ?></h1>
<?php $this->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?')),
);
?>