From b363e50d5500044499ba08208433fd8b736b5430 Mon Sep 17 00:00:00 2001
From: Patrick Seeger <pseeger@ccwn.org>
Date: Wed, 18 Jun 2014 23:55:12 +0200
Subject: =?UTF-8?q?Programmpunkt=20pro=20B=C3=BChne=20eingebaut?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 protected/controllers/VeranstaltungController.php |   4 +
 protected/models/Veranstaltung.php                |  21 +++-
 protected/views/standort/_buehne.php              |   7 +-
 protected/views/standort/_standort.php            |   7 +-
 protected/views/veranstaltung/_ultrashort.php     |   1 +
 protected/views/veranstaltung/stage.php           | 112 ++++++++++++++++++----
 6 files changed, 125 insertions(+), 27 deletions(-)
 create mode 100644 protected/views/veranstaltung/_ultrashort.php

diff --git a/protected/controllers/VeranstaltungController.php b/protected/controllers/VeranstaltungController.php
index 6333702..d047f1d 100644
--- a/protected/controllers/VeranstaltungController.php
+++ b/protected/controllers/VeranstaltungController.php
@@ -84,12 +84,16 @@ class VeranstaltungController extends Controller
 	 */
 	public function actionStage($id)
 	{
+		$buehnen = new Standort();
+		$buehnen->type="Bühne";
+		
 		$model = Standort::model()->findByPk($id);
 		if($model===null)
 			throw new CHttpException(404,'The requested page does not exist.');
 		
 		$this->render('stage',array(
 				'model'=>$model,
+				//'buehnen'=>$buehnen->search(),
 		));
 	}
 	
diff --git a/protected/models/Veranstaltung.php b/protected/models/Veranstaltung.php
index 843d430..f8d3e01 100644
--- a/protected/models/Veranstaltung.php
+++ b/protected/models/Veranstaltung.php
@@ -106,7 +106,7 @@ class Veranstaltung extends CActiveRecord
 		$criteria->compare('endzeit',$this->endzeit,true);
 		$criteria->compare('beschreibung',$this->beschreibung,true);
 		$criteria->compare('standort_id',$this->standort_id);
-		$criteria->compare('published',true);
+		$criteria->compare('published',$this->published);
 
 
 		return new CActiveDataProvider($this, array(
@@ -148,6 +148,14 @@ class Veranstaltung extends CActiveRecord
 			//	'LoggableBehavior'=>'application.modules.auditTrail.behaviors.LoggableBehavior',
 		);
 	}
+	public function parentStage($stageid=56)
+	{
+		$this->getDbCriteria()->mergeWith(array(
+				'condition'=>"standort_id = $stageid",
+		));
+		return $this;
+	}
+	
 	public function scopes()
 	{
 		return array(
@@ -158,9 +166,18 @@ class Veranstaltung extends CActiveRecord
 						'order'=>'startzeit ASC',
 				),
 				'thisYear'=>array(
-						'condition'=>"startzeit > STR_TO_DATE('".Yii::app()->params['start_date']."',GET_FORMAT(DATE,'EUR'))",
+						'condition'=>"startzeit >= STR_TO_DATE('".Yii::app()->params['start_date']."',GET_FORMAT(DATE,'EUR'))",
 				
 				),
+				'freitag'=>array(
+						'condition'=>"dayofweek(startzeit)=6",
+				),
+				'samstag'=>array(
+						'condition'=>"dayofweek(startzeit)=7",	
+				),
+				'sonntag'=>array(
+						'condition'=>"dayofweek(startzeit)=1",
+				),
 		);
 	}
 }
\ No newline at end of file
diff --git a/protected/views/standort/_buehne.php b/protected/views/standort/_buehne.php
index bfaa34a..0dc0870 100644
--- a/protected/views/standort/_buehne.php
+++ b/protected/views/standort/_buehne.php
@@ -1,5 +1,5 @@
 <h6>Folgende Veranstaltungen finden <?php echo $data->name?> statt</h6>
-<?php
+<?php /*
 $dataProvider=new CActiveDataProvider('Veranstaltung', array(
 		'criteria'=>array(
 				'condition'=>'standort_id='.$data->id." and published=1",
@@ -8,9 +8,10 @@ $dataProvider=new CActiveDataProvider('Veranstaltung', array(
 				'pageSize'=>20,
 		),
 		
-));
+));*/
 $this->widget('zii.widgets.CListView', array(
-		'dataProvider'=>$dataProvider,
+		//'dataProvider'=>$dataProvider,
+		'dataProvider'=>Veranstaltung::model('Veranstaltung')->published()->thisYear()->parentStage($data->id)->sorted()->search(),
 		'itemView'=>'/veranstaltung/_short',
 		'sortableAttributes'=>array(
 				'name'
diff --git a/protected/views/standort/_standort.php b/protected/views/standort/_standort.php
index 126417f..2c8ef4c 100644
--- a/protected/views/standort/_standort.php
+++ b/protected/views/standort/_standort.php
@@ -1,5 +1,5 @@
 <h6>Folgende Vereine finden sich <?php echo $data->name?></h6>
-<?php
+<?php /*
 $dataProvider=new CActiveDataProvider('Verein', array(
 		'criteria'=>array(
 				'condition'=>'standort_id='.$data->id." and published = 1",
@@ -8,9 +8,10 @@ $dataProvider=new CActiveDataProvider('Verein', array(
 				'pageSize'=>20,
 		),
 		
-));
+));*/
 $this->widget('zii.widgets.CListView', array(
-		'dataProvider'=>$dataProvider,
+		//'dataProvider'=>$dataProvider,
+		'dataProvider'=>Veranstaltung::model('Veranstaltung')->published()->thisYear()->parentStage($data->id)->sorted()->search(),
 		'itemView'=>'/verein/_short',
 		'sortableAttributes'=>array(
 				'name'
diff --git a/protected/views/veranstaltung/_ultrashort.php b/protected/views/veranstaltung/_ultrashort.php
new file mode 100644
index 0000000..9532ca9
--- /dev/null
+++ b/protected/views/veranstaltung/_ultrashort.php
@@ -0,0 +1 @@
+<div class="ym-g25 ym-gl"><div class="ym-gbox"><?php echo Yii::app()->dateFormatter->format('HH:mm',$data->startzeit)?> Uhr </div></div><div class="ym-g75 ym-gr"><div class="ym-gbox"><?php echo CHTML::link("<strong>".$data->titel."</strong>",array("veranstaltung/view","id"=>$data->id)); ?></div>	</div>
\ No newline at end of file
diff --git a/protected/views/veranstaltung/stage.php b/protected/views/veranstaltung/stage.php
index a38d1de..02e811f 100644
--- a/protected/views/veranstaltung/stage.php
+++ b/protected/views/veranstaltung/stage.php
@@ -6,14 +6,26 @@ $this->pageTitle = 'Programmpunkte auf der Bühne '.$model->name.' - ' . Yii::ap
 
 $this->menu=array(
 		array('label'=>'Jetzt auf dem Fest', 'url'=>array('now')),
+		//array('label'=>'Zellerplatz', 'url'=>array('stage','id'=>45)),
 		//array('label'=>'Veranstaltung suchen', 'url'=>array('search')),
-);?>
-
+);
+$buehnen = new CActiveDataProvider('Standort', array(
+    'criteria'=>array(
+        'condition'=>"type='Bühne'",
+        
+    ),
+));
+$mymenu = array();
+foreach ($buehnen->getData() as $buehne) {
+	$mymenu = array_merge( $mymenu , array(array('label' => 'Bühnenprogramm '.$buehne->name, 'url'=>array('stage','id'=>$buehne->id))));
+}
+$this->menu = array_merge($this->menu, $mymenu);
+?>
 <h3>Bühnenprogramm <?php echo $model->name?> </h3>
-<?php
+<?php /*
 $freitag=new CActiveDataProvider('Veranstaltung', array(
 		'criteria'=>array(
-				'condition'=>'standort_id='.$model->id." and published=1 and dayofweek(startzeit)=6",
+				'condition'=>'standort_id='.$model->id." and  dayofweek(startzeit)=6",
 		),
 ));
 $samstag=new CActiveDataProvider('Veranstaltung', array(
@@ -25,26 +37,88 @@ $sonntag=new CActiveDataProvider('Veranstaltung', array(
 		'criteria'=>array(
 				'condition'=>'standort_id='.$model->id." and published=1 and dayofweek(startzeit)=1",
 		),
-));
+));*/
 ?>
-<h4>Freitag</h4>
+
+<h5>Freitag</h5>
 <?php
-$this->widget('zii.widgets.CListView', array(
-		'dataProvider'=>$freitag,
-		'itemView'=>'/veranstaltung/_short',
+$veranstaltung = new Veranstaltung();
+$this->widget('zii.widgets.grid.CGridView', array(
 		
-  ));?>
-<h4>Samstag</h4>
+		'dataProvider'=>$veranstaltung->published()->thisYear()->freitag()->parentStage($model->id)->sorted()->search(),
+		'columns'=>array(
+				array(            // display 'create_time' using an expression
+            		'name'=>'Startzeit',
+            		'value'=>'Yii::app()->dateFormatter->format(\'HH:mm\',$data->startzeit)." Uhr"',
+					'htmlOptions' => array('style'=>"width:20%;"),
+				),
+				array(
+						'name'=> 'Titel',
+						'type' => 'Raw',
+						'value' => 'CHTML::link($data->titel,array("veranstaltung/view","id"=>$data->id))',
+						),
+						
+				),
+		'blankDisplay' => "Heute keine Termine bekannt",
+		'enableSorting' => false,
+		'enablePagination' => false,
+		'hideHeader' => true,
+		'template' => '{items}',
+		'htmlOptions' => array('class'=>''),
+
+  ));
+?>
+
+<h5>Samstag</h5>
 <?php
-$this->widget('zii.widgets.CListView', array(
-		'dataProvider'=>$samstag,
-		'itemView'=>'/veranstaltung/_short',
-		
+$veranstaltung = new Veranstaltung(); 
+$this->widget('zii.widgets.grid.CGridView', array(
+		'dataProvider'=>$veranstaltung->published()->thisYear()->samstag()->parentStage($model->id)->sorted()->search(),
+		'columns'=>array(
+				array(            // display 'create_time' using an expression
+            		'name'=>'Startzeit',
+            		'value'=>'Yii::app()->dateFormatter->format(\'HH:mm\',$data->startzeit)." Uhr"',
+						'htmlOptions' => array('style'=>"width:20%;"),
+				),
+								array(
+						'name'=> 'Titel',
+						'type' => 'Raw',
+						'value' => 'CHTML::link($data->titel,array("veranstaltung/view","id"=>$data->id))',
+						),
+						
+				),
+		'blankDisplay' => "Heute keine Termine bekannt",
+		'enableSorting' => false,
+		'enablePagination' => false,
+		'hideHeader' => true,
+		'template' => '{items}',
+		'htmlOptions' => array('class'=>''),
+
   ));?>
-<h4>Sonntag</h4>
+<h5>Sonntag</h5>
 <?php
-$this->widget('zii.widgets.CListView', array(
-		'dataProvider'=>$sonntag,
-		'itemView'=>'/veranstaltung/_short',
+$veranstaltung = new Veranstaltung();
+$this->widget('zii.widgets.grid.CGridView', array(
+		'dataProvider'=>$veranstaltung->published()->thisYear()->sonntag()->parentStage($model->id)->sorted()->search(),
+		'columns'=>array(
+				array(            // display 'create_time' using an expression
+            		'name'=>'Startzeit',
+            		'value'=>'Yii::app()->dateFormatter->format(\'HH:mm\',$data->startzeit)." Uhr"',
+						'htmlOptions' => array('style'=>"width:20%;"),
+				),
+								array(
+						'name'=> 'Titel',
+						'type' => 'Raw',
+						'value' => 'CHTML::link($data->titel,array("veranstaltung/view","id"=>$data->id))',
+						),
+						
+				),
+		'blankDisplay' => "Heute keine Termine bekannt",
+		'enableSorting' => false,
+		'enablePagination' => false,
+		'hideHeader' => true,
+		'template' => '{items}',
+		'htmlOptions' => array('class'=>''),
   ));?>
 
+
-- 
cgit v1.0-28-g1787

