summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Zur <tzur@ccwn.org>2012-04-28 13:42:41 +0200
committerTristan Zur <tzur@ccwn.org>2012-04-28 13:42:41 +0200
commit2d4bddcbf7b816f86db6f308a4d11bc9787c1f99 (patch)
treecb19c5a13d6fcf87c8a9a3eb5dbba4920ca1969f
parentc98745edd2c7b2f48bc3493c4dd9a061376c4720 (diff)
- Veranstaltungen CRUD Basisimplementierung
- Extension "CJuiDateTimePicker" hinzugefügt - Modul "AuditTrail" hinzugefügt
-rw-r--r--.gitignore8
-rw-r--r--protected/components/Html.php2
-rw-r--r--protected/config/console.php8
-rw-r--r--protected/config/maincfg.php14
-rw-r--r--protected/controllers/VeranstaltungController.php167
-rw-r--r--protected/data/testdrive.dbbin0 -> 14336 bytes
-rw-r--r--protected/extensions/CJuiDateTimePicker/CJuiDateTimePicker.php62
-rw-r--r--protected/extensions/CJuiDateTimePicker/assets/jquery-ui-timepicker-addon.css5
-rw-r--r--protected/extensions/CJuiDateTimePicker/assets/jquery-ui-timepicker-addon.js981
-rw-r--r--protected/models/Angebot.php6
-rw-r--r--protected/models/AngebotVerein.php6
-rw-r--r--protected/models/Kategorie.php6
-rw-r--r--protected/models/Standort.php6
-rw-r--r--protected/models/Veranstaltung.php118
-rw-r--r--protected/models/Verein.php6
-rw-r--r--protected/modules/auditTrail/.DS_Storebin0 -> 12292 bytes
-rw-r--r--protected/modules/auditTrail/AuditTrailModule.php74
-rw-r--r--protected/modules/auditTrail/README.txt19
-rw-r--r--protected/modules/auditTrail/behaviors/LoggableBehavior.php133
-rw-r--r--protected/modules/auditTrail/controllers/AdminController.php19
-rw-r--r--protected/modules/auditTrail/controllers/DefaultController.php9
-rw-r--r--protected/modules/auditTrail/migrations/m110517_155003_create_tables_audit_trail.php66
-rw-r--r--protected/modules/auditTrail/models/.DS_Storebin0 -> 6148 bytes
-rw-r--r--protected/modules/auditTrail/models/AuditTrail.php125
-rw-r--r--protected/modules/auditTrail/views/.DS_Storebin0 -> 6148 bytes
-rw-r--r--protected/modules/auditTrail/views/admin/_search.php59
-rw-r--r--protected/modules/auditTrail/views/admin/admin.php58
-rw-r--r--protected/modules/auditTrail/views/default/.DS_Storebin0 -> 6148 bytes
-rw-r--r--protected/modules/auditTrail/views/default/index.php95
-rw-r--r--protected/modules/auditTrail/widgets/.DS_Storebin0 -> 6148 bytes
-rw-r--r--protected/modules/auditTrail/widgets/portlets/.DS_Storebin0 -> 6148 bytes
-rw-r--r--protected/modules/auditTrail/widgets/portlets/ShowAuditTrail.php157
-rw-r--r--protected/runtime/application.log226
-rw-r--r--protected/tests/functional/SiteTest.php6
-rw-r--r--protected/views/veranstaltung/_form.php98
-rw-r--r--protected/views/veranstaltung/_search.php54
-rw-r--r--protected/views/veranstaltung/_view.php38
-rw-r--r--protected/views/veranstaltung/create.php16
-rw-r--r--protected/views/veranstaltung/index.php35
-rw-r--r--protected/views/veranstaltung/update.php18
-rw-r--r--protected/views/veranstaltung/view.php28
41 files changed, 2715 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..fddbf02
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+
+/assets/17a1de59
+/assets/3940d2b
+/assets/505bb103
+/assets/b6d35603
+/assets/e5f37766
+/assets/e7e1ddad
+/assets/fc6ef99b \ No newline at end of file
diff --git a/protected/components/Html.php b/protected/components/Html.php
index 08fc6d9..6c7df3c 100644
--- a/protected/components/Html.php
+++ b/protected/components/Html.php
@@ -34,7 +34,5 @@ class Html extends CHtml {
public static function enumDropDownList($model, $attribute, $htmlOptions = array()) {
return CHtml::activeDropDownList($model, $attribute, Html::enumItem($model, $attribute), $htmlOptions);
}
-
-
}
?> \ No newline at end of file
diff --git a/protected/config/console.php b/protected/config/console.php
index 15c9353..2df2b24 100644
--- a/protected/config/console.php
+++ b/protected/config/console.php
@@ -7,18 +7,16 @@ return array(
'name'=>'My Console Application',
// application components
'components'=>array(
- 'db'=>array(
+ /*'db'=>array(
'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
- ),
+ ),*/
// uncomment the following to use a MySQL database
- /*
'db'=>array(
- 'connectionString' => 'mysql:host=localhost;dbname=testdrive',
+ 'connectionString' => 'mysql:host=localhost;dbname=astaf',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
),
- */
),
); \ No newline at end of file
diff --git a/protected/config/maincfg.php b/protected/config/maincfg.php
index 78c3c6a..c1443ba 100644
--- a/protected/config/maincfg.php
+++ b/protected/config/maincfg.php
@@ -16,7 +16,8 @@ return array(
'import'=>array(
'application.models.*',
'application.components.*',
- 'application.extensions.egmap.*'
+ 'application.extensions.egmap.*',
+ 'application.modules.auditTrail.models.AuditTrail',
),
'modules'=>array(
@@ -27,6 +28,11 @@ return array(
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
+ 'auditTrail'=>array(
+ 'userClass' => 'User', // the class name for the user object
+ 'userIdColumn' => 'id', // the column name of the primary key for the user
+ 'userNameColumn' => 'username', // the column name of the primary key for the user
+ ),
),
// application components
@@ -86,6 +92,10 @@ return array(
'pos_lat'=>48.8323934983,
'pos_long'=>9.31750059128,
'map_api_key'=>'ABQIAAAAzwMJRVnIOel5nqTjdUcPrRTSNOUR83EeIVShY4aBvXxHJx0DexSUFNGH3KQhtFhfSNHxkECqL5rQBA',
- 'map_api_domain'=>'www.astaf.de'
+ 'map_api_domain'=>'www.astaf.de',
+ 'start_date'=>'01.07.2012',
+ 'end_date'=>'03.07.2012',
+ 'start_time'=>'19:00',
+ 'end_time'=>'23:00',
),
); \ No newline at end of file
diff --git a/protected/controllers/VeranstaltungController.php b/protected/controllers/VeranstaltungController.php
new file mode 100644
index 0000000..d4471b7
--- /dev/null
+++ b/protected/controllers/VeranstaltungController.php
@@ -0,0 +1,167 @@
+<?php
+
+class VeranstaltungController extends Controller
+{
+ /**
+ * @var string the default layout for the views. Defaults to '//layouts/column2', meaning
+ * using two-column layout. See 'protected/views/layouts/column2.php'.
+ */
+ public $layout='//layouts/column2';
+
+ /**
+ * @return array action filters
+ */
+ public function filters()
+ {
+ return array(
+ 'accessControl', // perform access control for CRUD operations
+ );
+ }
+
+ /**
+ * Specifies the access control rules.
+ * This method is used by the 'accessControl' filter.
+ * @return array access control rules
+ */
+ public function accessRules()
+ {
+ return array(
+ array('allow', // allow admin user to perform 'admin' and 'delete' actions
+ 'actions'=>array('create','update','index','view','delete'),
+ 'users'=>array('admin'),
+ ),
+ array('deny', // deny all users
+ 'users'=>array('*'),
+ ),
+ );
+ }
+
+ /**
+ * Displays a particular model.
+ * @param integer $id the ID of the model to be displayed
+ */
+ public function actionView($id)
+ {
+ $this->render('view',array(
+ 'model'=>$this->loadModel($id),
+ ));
+ }
+
+ /**
+ * Creates a new model.
+ * If creation is successful, the browser will be redirected to the 'view' page.
+ */
+ public function actionCreate()
+ {
+ $model=new Veranstaltung;
+
+ // Uncomment the following line if AJAX validation is needed
+ // $this->performAjaxValidation($model);
+
+ if(isset($_POST['Veranstaltung']))
+ {
+ $model->attributes=$_POST['Veranstaltung'];
+ if($model->save())
+ $this->redirect(array('view','id'=>$model->id));
+ }
+
+ $standorte = Standort::model()->findAll(array("condition"=>"published=1 and type='Bühne'"));
+ $vereine = Verein::model()->findAll(array("condition"=>"published=1"));
+
+ $this->render('create',array(
+ 'model'=>$model,
+ 'vereine'=>$vereine,
+ 'standorte'=>$standorte
+ ));
+ }
+
+ /**
+ * Updates a particular model.
+ * If update is successful, the browser will be redirected to the 'view' page.
+ * @param integer $id the ID of the model to be updated
+ */
+ public function actionUpdate($id)
+ {
+ $model=$this->loadModel($id);
+
+ // Uncomment the following line if AJAX validation is needed
+ // $this->performAjaxValidation($model);
+
+ if(isset($_POST['Veranstaltung']))
+ {
+ $model->attributes=$_POST['Veranstaltung'];
+ if($model->save())
+ $this->redirect(array('view','id'=>$model->id));
+ }
+
+ $standorte = Standort::model()->findAll(array("condition"=>"published=1 and type='Bühne'"));
+ $vereine = Verein::model()->findAll(array("condition"=>"published=1"));
+
+ $this->render('update',array(
+ 'model'=>$model,
+ 'vereine'=>$vereine,
+ 'standorte'=>$standorte
+ ));
+ }
+
+ /**
+ * Deletes a particular model.
+ * If deletion is successful, the browser will be redirected to the 'admin' page.
+ * @param integer $id the ID of the model to be deleted
+ */
+ public function actionDelete($id)
+ {
+ if(Yii::app()->request->isPostRequest)
+ {
+ // we only allow deletion via POST request
+ $this->loadModel($id)->delete();
+
+ // 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'));
+ }
+ else
+ throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
+ }
+
+ /**
+ * Lists all models.
+ */
+ public function actionIndex()
+ {
+ $model=new Veranstaltung('search');
+ $model->unsetAttributes(); // clear any default values
+ if(isset($_GET['Veranstaltung']))
+ $model->attributes=$_GET['Veranstaltung'];
+
+ $this->render('index',array(
+ 'model'=>$model,
+ ));
+ }
+
+ /**
+ * 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=Veranstaltung::model()->findByPk($id);
+ if($model===null)
+ throw new CHttpException(404,'The requested page does not exist.');
+ return $model;
+ }
+
+ /**
+ * Performs the AJAX validation.
+ * @param CModel the model to be validated
+ */
+ protected function performAjaxValidation($model)
+ {
+ if(isset($_POST['ajax']) && $_POST['ajax']==='veranstaltung-form')
+ {
+ echo CActiveForm::validate($model);
+ Yii::app()->end();
+ }
+ }
+}
diff --git a/protected/data/testdrive.db b/protected/data/testdrive.db
new file mode 100644
index 0000000..e335767
--- /dev/null
+++ b/protected/data/testdrive.db
Binary files differ
diff --git a/protected/extensions/CJuiDateTimePicker/CJuiDateTimePicker.php b/protected/extensions/CJuiDateTimePicker/CJuiDateTimePicker.php
new file mode 100644
index 0000000..3a73cb6
--- /dev/null
+++ b/protected/extensions/CJuiDateTimePicker/CJuiDateTimePicker.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * CJuiDateTimePicker class file.
+ *
+ * @author Anatoly Ivanchin <van4in@gmail.com>
+ */
+
+Yii::import('zii.widgets.jui.CJuiDatePicker');
+class CJuiDateTimePicker extends CJuiDatePicker
+{
+ const ASSETS_NAME='/jquery-ui-timepicker-addon';
+
+ public $mode='datetime';
+
+ public function init()
+ {
+ if(!in_array($this->mode, array('date','time','datetime')))
+ throw new CException('unknow mode "'.$this->mode.'"');
+ if(!isset($this->language))
+ $this->language=Yii::app()->getLanguage();
+ return parent::init();
+ }
+
+ public function run()
+ {
+ list($name,$id)=$this->resolveNameID();
+
+ if(isset($this->htmlOptions['id']))
+ $id=$this->htmlOptions['id'];
+ else
+ $this->htmlOptions['id']=$id;
+ if(isset($this->htmlOptions['name']))
+ $name=$this->htmlOptions['name'];
+ else
+ $this->htmlOptions['name']=$name;
+
+ if($this->hasModel())
+ echo CHtml::activeTextField($this->model,$this->attribute,$this->htmlOptions);
+ else
+ echo CHtml::textField($name,$this->value,$this->htmlOptions);
+
+
+ $options=CJavaScript::encode($this->options);
+
+ $js = "jQuery('#{$id}').{$this->mode}picker($options);";
+
+ if (isset($this->language)){
+ $this->registerScriptFile($this->i18nScriptFile);
+ $js = "jQuery('#{$id}').{$this->mode}picker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));";
+ }
+
+ $cs = Yii::app()->getClientScript();
+
+ $assets = Yii::app()->getAssetManager()->publish(dirname(__FILE__).DIRECTORY_SEPARATOR.'assets');
+ $cs->registerCssFile($assets.self::ASSETS_NAME.'.css');
+ $cs->registerScriptFile($assets.self::ASSETS_NAME.'.js',CClientScript::POS_END);
+
+ $cs->registerScript(__CLASS__, $this->defaultOptions?'jQuery.{$this->mode}picker.setDefaults('.CJavaScript::encode($this->defaultOptions).');':'');
+ $cs->registerScript(__CLASS__.'#'.$id, $js);
+
+ }
+} \ No newline at end of file
diff --git a/protected/extensions/CJuiDateTimePicker/assets/jquery-ui-timepicker-addon.css b/protected/extensions/CJuiDateTimePicker/assets/jquery-ui-timepicker-addon.css
new file mode 100644
index 0000000..2cdb20f
--- /dev/null
+++ b/protected/extensions/CJuiDateTimePicker/assets/jquery-ui-timepicker-addon.css
@@ -0,0 +1,5 @@
+.ui-timepicker-div .ui-widget-header{ margin-bottom: 8px; }
+.ui-timepicker-div dl{ text-align: left; }
+.ui-timepicker-div dl dt{ height: 25px; }
+.ui-timepicker-div dl dd{ margin: -25px 0 10px 65px; }
+.ui-timepicker-div td { font-size: 90%; } \ No newline at end of file
diff --git a/protected/extensions/CJuiDateTimePicker/assets/jquery-ui-timepicker-addon.js b/protected/extensions/CJuiDateTimePicker/assets/jquery-ui-timepicker-addon.js
new file mode 100644
index 0000000..215e43a
--- /dev/null
+++ b/protected/extensions/CJuiDateTimePicker/assets/jquery-ui-timepicker-addon.js
@@ -0,0 +1,981 @@
+/*
+* jQuery timepicker addon
+* By: Trent Richardson [http://trentrichardson.com]
+* Version 0.9.4-dev
+* Last Modified: 03/02/2011
+*
+* Copyright 2011 Trent Richardson
+* Dual licensed under the MIT and GPL licenses.
+* http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
+* http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
+*
+* HERES THE CSS:
+* .ui-timepicker-div .ui-widget-header{ margin-bottom: 8px; }
+* .ui-timepicker-div dl{ text-align: left; }
+* .ui-timepicker-div dl dt{ height: 25px; }
+* .ui-timepicker-div dl dd{ margin: -25px 0 10px 65px; }
+* .ui-timepicker-div td { font-size: 90%; }
+*/
+
+(function($) {
+
+$.extend($.ui, { timepicker: { version: "0.9.4" } });
+
+/* Time picker manager.
+ Use the singleton instance of this class, $.timepicker, to interact with the time picker.
+ Settings for (groups of) time pickers are maintained in an instance object,
+ allowing multiple different settings on the same page. */
+
+function Timepicker() {
+ this.regional = []; // Available regional settings, indexed by language code
+ this.regional[''] = { // Default regional settings
+ currentText: 'Now',
+ closeText: 'Done',
+ ampm: false,
+ timeFormat: 'hh:mm tt',
+ timeOnlyTitle: 'Choose Time',
+ timeText: 'Time',
+ hourText: 'Hour',
+ minuteText: 'Minute',
+ secondText: 'Second',
+ timezoneText: 'Time Zone'
+ };
+ this._defaults = { // Global defaults for all the datetime picker instances
+ showButtonPanel: true,
+ timeOnly: false,
+ showHour: true,
+ showMinute: true,
+ showSecond: false,
+ showTimezone: false,
+ showTime: true,
+ stepHour: 0.05,
+ stepMinute: 0.05,
+ stepSecond: 0.05,
+ hour: 0,
+ minute: 0,
+ second: 0,
+ timezone: '+0000',
+ hourMin: 0,
+ minuteMin: 0,
+ secondMin: 0,
+ hourMax: 23,
+ minuteMax: 59,
+ secondMax: 59,
+ minDateTime: null,
+ maxDateTime: null,
+ hourGrid: 0,
+ minuteGrid: 0,
+ secondGrid: 0,
+ alwaysSetTime: true,
+ separator: ' ',
+ altFieldTimeOnly: true,
+ showTimepicker: true,
+ timezoneList: ["-1100", "-1000", "-0900", "-0800", "-0700", "-0600",
+ "-0500", "-0400", "-0300", "-0200", "-0100", "+0000",
+ "+0100", "+0200", "+0300", "+0400", "+0500", "+0600",
+ "+0700", "+0800", "+0900", "+1000", "+1100", "+1200"]
+ };
+ $.extend(this._defaults, this.regional['']);
+}
+
+$.extend(Timepicker.prototype, {
+ $input: null,
+ $altInput: null,
+ $timeObj: null,
+ inst: null,
+ hour_slider: null,
+ minute_slider: null,
+ second_slider: null,
+ timezone_select: null,
+ hour: 0,
+ minute: 0,
+ second: 0,
+ timezone: '+0000',
+ hourMinOriginal: null,
+ minuteMinOriginal: null,
+ secondMinOriginal: null,
+ hourMaxOriginal: null,
+ minuteMaxOriginal: null,
+ secondMaxOriginal: null,
+ ampm: '',
+ formattedDate: '',
+ formattedTime: '',
+ formattedDateTime: '',
+ timezoneList: ["-1100", "-1000", "-0900", "-0800", "-0700", "-0600",
+ "-0500", "-0400", "-0300", "-0200", "-0100", "+0000",
+ "+0100", "+0200", "+0300", "+0400", "+0500", "+0600",
+ "+0700", "+0800", "+0900", "+1000", "+1100", "+1200"],
+
+ /* Override the default settings for all instances of the time picker.
+ @param settings object - the new settings to use as defaults (anonymous object)
+ @return the manager object */
+ setDefaults: function(settings) {
+ extendRemove(this._defaults, settings || {});
+ return this;
+ },
+
+ //########################################################################
+ // Create a new Timepicker instance
+ //########################################################################
+ _newInst: function($input, o) {
+ var tp_inst = new Timepicker(),
+ inlineSettings = {};
+
+ for (var attrName in this._defaults) {
+ var attrValue = $input.attr('time:' + attrName);
+ if (attrValue) {
+ try {
+ inlineSettings[attrName] = eval(attrValue);
+ } catch (err) {
+ inlineSettings[attrName] = attrValue;
+ }
+ }
+ }
+ tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, {
+ beforeShow: function(input, dp_inst) {
+ if ($.isFunction(o.beforeShow))
+ o.beforeShow(input, dp_inst, tp_inst);
+ },
+ onChangeMonthYear: function(year, month, dp_inst) {
+ // Update the time as well : this prevents the time from disappearing from the $input field.
+ tp_inst._updateDateTime(dp_inst);
+ if ($.isFunction(o.onChangeMonthYear))
+ o.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
+ },
+ onClose: function(dateText, dp_inst) {
+ if (tp_inst.timeDefined === true && $input.val() != '')
+ tp_inst._updateDateTime(dp_inst);
+ if ($.isFunction(o.onClose))
+ o.onClose.call($input[0], dateText, dp_inst, tp_inst);
+ },
+ timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
+ });
+
+ tp_inst.hour = tp_inst._defaults.hour;
+ tp_inst.minute = tp_inst._defaults.minute;
+ tp_inst.second = tp_inst._defaults.second;
+ tp_inst.ampm = '';
+ tp_inst.$input = $input;
+
+ if (o.altField)
+ tp_inst.$altInput = $(o.altField)
+ .css({ cursor: 'pointer' })
+ .focus(function(){ $input.trigger("focus"); });
+
+ // datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
+ if(tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date)
+ tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime());
+ if(tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date)
+ tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime());
+ if(tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date)
+ tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime());
+ if(tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date)
+ tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime());
+
+ return tp_inst;
+ },
+
+ //########################################################################
+ // add our sliders to the calendar
+ //########################################################################
+ _addTimePicker: function(dp_inst) {
+ var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ?
+ this.$input.val() + ' ' + this.$altInput.val() :
+ this.$input.val();
+
+ this.timeDefined = this._parseTime(currDT);
+ this._limitMinMaxDateTime(dp_inst, false);
+ this._injectTimePicker();
+ },
+
+ //########################################################################
+ // parse the time string from input value or _setTime
+ //########################################################################
+ _parseTime: function(timeString, withDate) {
+ var regstr = this._defaults.timeFormat.toString()
+ .replace(/h{1,2}/ig, '(\\d?\\d)')
+ .replace(/m{1,2}/ig, '(\\d?\\d)')
+ .replace(/s{1,2}/ig, '(\\d?\\d)')
+ .replace(/t{1,2}/ig, '(am|pm|a|p)?')
+ .replace(/z{1}/ig, '((\\+|-)\\d\\d\\d\\d)?')
+ .replace(/\s/g, '\\s?') + '$',
+ order = this._getFormatPositions(),
+ treg;
+
+ if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]);
+
+ if (withDate || !this._defaults.timeOnly) {
+ // the time should come after x number of characters and a space.
+ // x = at least the length of text specified by the date format
+ var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
+ // escape special regex characters in the seperator
+ var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g");
+ regstr = '.{' + dp_dateFormat.length + ',}' + this._defaults.separator.replace(specials, "\\$&") + regstr;
+ }
+
+ treg = timeString.match(new RegExp(regstr, 'i'));
+
+ if (treg) {
+ if (order.t !== -1)
+ this.ampm = ((treg[order.t] === undefined || treg[order.t].length === 0) ?
+ '' :
+ (treg[order.t].charAt(0).toUpperCase() == 'A') ? 'AM' : 'PM').toUpperCase();
+
+ if (order.h !== -1) {
+ if (this.ampm == 'AM' && treg[order.h] == '12')
+ this.hour = 0; // 12am = 0 hour
+ else if (this.ampm == 'PM' && treg[order.h] != '12')
+ this.hour = (parseFloat(treg[order.h]) + 12).toFixed(0); // 12pm = 12 hour, any other pm = hour + 12
+ else this.hour = Number(treg[order.h]);
+ }
+
+ if (order.m !== -1) this.minute = Number(treg[order.m]);
+ if (order.s !== -1) this.second = Number(treg[order.s]);
+ if (order.z !== -1) this.timezone = treg[order.z];
+
+ return true;
+
+ }
+ return false;
+ },
+
+ //########################################################################
+ // figure out position of time elements.. cause js cant do named captures
+ //########################################################################
+ _getFormatPositions: function() {
+ var finds = this._defaults.timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|t{1,2}|z)/g),
+ orders = { h: -1, m: -1, s: -1, t: -1, z: -1 };
+
+ if (finds)
+ for (var i = 0; i < finds.length; i++)
+ if (orders[finds[i].toString().charAt(0)] == -1)
+ orders[finds[i].toString().charAt(0)] = i + 1;
+
+ return orders;
+ },
+
+ //########################################################################
+ // generate and inject html for timepicker into ui datepicker
+ //########################################################################
+ _injectTimePicker: function() {
+ var $dp = this.inst.dpDiv,
+ o = this._defaults,
+ tp_inst = this,
+ // Added by Peter Medeiros:
+ // - Figure out what the hour/minute/second max should be based on the step values.
+ // - Example: if stepMinute is 15, then minMax is 45.
+ hourMax = (o.hourMax - (o.hourMax % o.stepHour)).toFixed(0),
+ minMax = (o.minuteMax - (o.minuteMax % o.stepMinute)).toFixed(0),
+ secMax = (o.secondMax - (o.secondMax % o.stepSecond)).toFixed(0),
+ dp_id = this.inst.id.toString().replace(/([^A-Za-z0-9_])/g, '');
+
+ // Prevent displaying twice
+ //if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0) {
+ if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0 && o.showTimepicker) {
+ var noDisplay = ' style="display:none;"',
+ html = '<div class="ui-timepicker-div" id="ui-timepicker-div-' + dp_id + '"><dl>' +
+ '<dt class="ui_tpicker_time_label" id="ui_tpicker_time_label_' + dp_id + '"' +
+ ((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
+ '<dd class="ui_tpicker_time" id="ui_tpicker_time_' + dp_id + '"' +
+ ((o.showTime) ? '' : noDisplay) + '></dd>' +
+ '<dt class="ui_tpicker_hour_label" id="ui_tpicker_hour_label_' + dp_id + '"' +
+ ((o.showHour) ? '' : noDisplay) + '>' + o.hourText + '</dt>',
+ hourGridSize = 0,
+ minuteGridSize = 0,
+ secondGridSize = 0,
+ size;
+
+ if (o.showHour && o.hourGrid > 0) {
+ html += '<dd class="ui_tpicker_hour">' +
+ '<div id="ui_tpicker_hour_' + dp_id + '"' + ((o.showHour) ? '' : noDisplay) + '></div>' +
+ '<div style="padding-left: 1px"><table><tr>';
+
+ for (var h = o.hourMin; h < hourMax; h += o.hourGrid) {
+ hourGridSize++;
+ var tmph = (o.ampm && h > 12) ? h-12 : h;
+ if (tmph < 10) tmph = '0' + tmph;
+ if (o.ampm) {
+ if (h == 0) tmph = 12 +'a';
+ else if (h < 12) tmph += 'a';
+ else tmph += 'p';
+ }
+ html += '<td>' + tmph + '</td>';
+ }
+
+ html += '</tr></table></div>' +
+ '</dd>';
+ } else html += '<dd class="ui_tpicker_hour" id="ui_tpicker_hour_' + dp_id + '"' +
+ ((o.showHour) ? '' : noDisplay) + '></dd>';
+
+ html += '<dt class="ui_tpicker_minute_label" id="ui_tpicker_minute_label_' + dp_id + '"' +
+ ((o.showMinute) ? '' : noDisplay) + '>' + o.minuteText + '</dt>';
+
+ if (o.showMinute && o.minuteGrid > 0) {
+ html += '<dd class="ui_tpicker_minute ui_tpicker_minute_' + o.minuteGrid + '">' +
+ '<div id="ui_tpicker_minute_' + dp_id + '"' +
+ ((o.showMinute) ? '' : noDisplay) + '></div>' +
+ '<div style="padding-left: 1px"><table><tr>';
+
+ for (var m = o.minuteMin; m < minMax; m += o.minuteGrid) {
+ minuteGridSize++;
+ html += '<td>' + ((m < 10) ? '0' : '') + m + '</td>';
+ }
+
+ html += '</tr></table></div>' +
+ '</dd>';
+ } else html += '<dd class="ui_tpicker_minute" id="ui_tpicker_minute_' + dp_id + '"' +
+ ((o.showMinute) ? '' : noDisplay) + '></dd>';
+
+ html += '<dt class="ui_tpicker_second_label" id="ui_tpicker_second_label_' + dp_id + '"' +
+ ((o.showSecond) ? '' : noDisplay) + '>' + o.secondText + '</dt>';
+
+ if (o.showSecond && o.secondGrid > 0) {
+ html += '<dd class="ui_tpicker_second ui_tpicker_second_' + o.secondGrid + '">' +
+ '<div id="ui_tpicker_second_' + dp_id + '"' +
+ ((o.showSecond) ? '' : noDisplay) + '></div>' +
+ '<div style="padding-left: 1px"><table><tr>';
+
+ for (var s = o.secondMin; s < secMax; s += o.secondGrid) {
+ secondGridSize++;
+ html += '<td>' + ((s < 10) ? '0' : '') + s + '</td>';
+ }
+
+ html += '</tr></table></div>' +
+ '</dd>';
+ } else html += '<dd class="ui_tpicker_second" id="ui_tpicker_second_' + dp_id + '"' +
+ ((o.showSecond) ? '' : noDisplay) + '></dd>';
+
+ html += '<dt class="ui_tpicker_timezone_label" id="ui_tpicker_timezone_label_' + dp_id + '"' +
+ ((o.showTimezone) ? '' : noDisplay) + '>' + o.timezoneText + '</dt>';
+ html += '<dd class="ui_tpicker_timezone" id="ui_tpicker_timezone_' + dp_id + '"' +
+ ((o.showTimezone) ? '' : noDisplay) + '></dd>';
+
+ html += '</dl></div>';
+ $tp = $(html);
+
+ // if we only want time picker...
+ if (o.timeOnly === true) {
+ $tp.prepend(
+ '<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' +
+ '<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' +
+ '</div>');
+ $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
+ }
+
+ this.hour_slider = $tp.find('#ui_tpicker_hour_'+ dp_id).slider({
+ orientation: "horizontal",
+ value: this.hour,
+ min: o.hourMin,
+ max: hourMax,
+ step: o.stepHour,
+ slide: function(event, ui) {
+ tp_inst.hour_slider.slider( "option", "value", ui.value);
+ tp_inst._onTimeChange();
+ }
+ });
+
+ // Updated by Peter Medeiros:
+ // - Pass in Event and UI instance into slide function
+ this.minute_slider = $tp.find('#ui_tpicker_minute_'+ dp_id).slider({
+ orientation: "horizontal",
+ value: this.minute,
+ min: o.minuteMin,
+ max: minMax,
+ step: o.stepMinute,
+ slide: function(event, ui) {
+ // update the global minute slider instance value with the current slider value
+ tp_inst.minute_slider.slider( "option", "value", ui.value);
+ tp_inst._onTimeChange();
+ }
+ });
+
+ this.second_slider = $tp.find('#ui_tpicker_second_'+ dp_id).slider({
+ orientation: "horizontal",
+ value: this.second,
+ min: o.secondMin,
+ max: secMax,
+ step: o.stepSecond,
+ slide: function(event, ui) {
+ tp_inst.second_slider.slider( "option", "value", ui.value);
+ tp_inst._onTimeChange();
+ }
+ });
+
+
+ this.timezone_select = $tp.find('#ui_tpicker_timezone_'+ dp_id).append('<select></select>').find("select");
+ $.fn.append.apply(this.timezone_select,
+ $.map(o.timezoneList, function(val, idx) {
+ return $("<option />")
+ .val(typeof val == "object" ? val.value : val)
+ .text(typeof val == "object" ? val.label : val);
+ })
+ );
+ this.timezone_select.val((typeof this.timezone != "undefined" && this.timezone != null && this.timezone != "") ? this.timezone : o.timezone);
+ this.timezone_select.change(function() {
+ tp_inst._onTimeChange();
+ });
+
+ // Add grid functionality
+ if (o.showHour && o.hourGrid > 0) {
+ size = 100 * hourGridSize * o.hourGrid / (hourMax - o.hourMin);
+
+ $tp.find(".ui_tpicker_hour table").css({
+ width: size + "%",
+ marginLeft: (size / (-2 * hourGridSize)) + "%",
+ borderCollapse: 'collapse'
+ }).find("td").each( function(index) {
+ $(this).click(function() {
+ var h = $(this).html();
+ if(o.ampm) {
+ var ap = h.substring(2).toLowerCase(),
+ aph = parseInt(h.substring(0,2));
+ if (ap == 'a') {
+ if (aph == 12) h = 0;
+ else h = aph;
+ } else if (aph == 12) h = 12;
+ else h = aph + 12;
+ }
+ tp_inst.hour_slider.slider("option", "value", h);
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ }).css({
+ cursor: 'pointer',
+ width: (100 / hourGridSize) + '%',
+ textAlign: 'center',
+ overflow: 'hidden'
+ });
+ });
+ }
+
+ if (o.showMinute && o.minuteGrid > 0) {
+ size = 100 * minuteGridSize * o.minuteGrid / (minMax - o.minuteMin);
+ $tp.find(".ui_tpicker_minute table").css({
+ width: size + "%",
+ marginLeft: (size / (-2 * minuteGridSize)) + "%",
+ borderCollapse: 'collapse'
+ }).find("td").each(function(index) {
+ $(this).click(function() {
+ tp_inst.minute_slider.slider("option", "value", $(this).html());
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ }).css({
+ cursor: 'pointer',
+ width: (100 / minuteGridSize) + '%',
+ textAlign: 'center',
+ overflow: 'hidden'
+ });
+ });
+ }
+
+ if (o.showSecond && o.secondGrid > 0) {
+ $tp.find(".ui_tpicker_second table").css({
+ width: size + "%",
+ marginLeft: (size / (-2 * secondGridSize)) + "%",
+ borderCollapse: 'collapse'
+ }).find("td").each(function(index) {
+ $(this).click(function() {
+ tp_inst.second_slider.slider("option", "value", $(this).html());
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ }).css({
+ cursor: 'pointer',
+ width: (100 / secondGridSize) + '%',
+ textAlign: 'center',
+ overflow: 'hidden'
+ });
+ });
+ }
+
+ var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
+ if ($buttonPanel.length) $buttonPanel.before($tp);
+ else $dp.append($tp);
+
+ this.$timeObj = $tp.find('#ui_tpicker_time_'+ dp_id);
+
+ if (this.inst !== null) {
+ var timeDefined = this.timeDefined;
+ this._onTimeChange();
+ this.timeDefined = timeDefined;
+ }
+
+ //Emulate datepicker onSelect behavior. Call on slidestop.
+ var onSelectDelegate = function() {
+ tp_inst._onSelectHandler();
+ }
+ this.hour_slider.bind('slidestop',onSelectDelegate);
+ this.minute_slider.bind('slidestop',onSelectDelegate);
+ this.second_slider.bind('slidestop',onSelectDelegate);
+ }
+ },
+
+ //########################################################################
+ // This function tries to limit the ability to go outside the
+ // min/max date range
+ //########################################################################
+ _limitMinMaxDateTime: function(dp_inst, adjustSliders){
+ var o = this._defaults,
+ dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay);
+
+ if(!this._defaults.showTimepicker) return; // No time so nothing to check here
+
+ if(this._defaults.minDateTime !== null && dp_date){
+ var minDateTime = this._defaults.minDateTime,
+ minDateTimeDate = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), 0, 0, 0, 0);
+
+ if(this.hourMinOriginal === null || this.minuteMinOriginal === null || this.secondMinOriginal === null){
+ this.hourMinOriginal = o.hourMin;
+ this.minuteMinOriginal = o.minuteMin;
+ this.secondMinOriginal = o.secondMin;
+ }
+
+ if(dp_inst.settings.timeOnly || minDateTimeDate.getTime() == dp_date.getTime()) {
+ this._defaults.hourMin = minDateTime.getHours();
+ if (this.hour <= this._defaults.hourMin) {
+ this.hour = this._defaults.hourMin;
+ this._defaults.minuteMin = minDateTime.getMinutes();
+ if (this.minute <= this._defaults.minuteMin) {
+ this.minute = this._defaults.minuteMin;
+ this._defaults.secondMin = minDateTime.getSeconds();
+ } else {
+ if(this.second < this._defaults.secondMin) this.second = this._defaults.secondMin;
+ this._defaults.secondMin = this.secondMinOriginal;
+ }
+ } else {
+ this._defaults.minuteMin = this.minuteMinOriginal;
+ this._defaults.secondMin = this.secondMinOriginal;
+ }
+ }else{
+ this._defaults.hourMin = this.hourMinOriginal;
+ this._defaults.minuteMin = this.minuteMinOriginal;
+ this._defaults.secondMin = this.secondMinOriginal;
+ }
+ }
+
+ if(this._defaults.maxDateTime !== null && dp_date){
+ var maxDateTime = this._defaults.maxDateTime,
+ maxDateTimeDate = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), 0, 0, 0, 0);
+
+ if(this.hourMaxOriginal === null || this.minuteMaxOriginal === null || this.secondMaxOriginal === null){
+ this.hourMaxOriginal = o.hourMax;
+ this.minuteMaxOriginal = o.minuteMax;
+ this.secondMaxOriginal = o.secondMax;
+ }
+
+ if(dp_inst.settings.timeOnly || maxDateTimeDate.getTime() == dp_date.getTime()){
+ this._defaults.hourMax = maxDateTime.getHours();
+ if (this.hour >= this._defaults.hourMax) {
+ this.hour = this._defaults.hourMax;
+ this._defaults.minuteMax = maxDateTime.getMinutes();
+ if (this.minute >= this._defaults.minuteMax) {
+ this.minute = this._defaults.minuteMax;
+ this._defaults.secondMin = maxDateTime.getSeconds();
+ } else {
+ if(this.second > this._defaults.secondMax) this.second = this._defaults.secondMax;
+ this._defaults.secondMax = this.secondMaxOriginal;
+ }
+ } else {
+ this._defaults.minuteMax = this.minuteMaxOriginal;
+ this._defaults.secondMax = this.secondMaxOriginal;
+ }
+ }else{
+ this._defaults.hourMax = this.hourMaxOriginal;
+ this._defaults.minuteMax = this.minuteMaxOriginal;
+ this._defaults.secondMax = this.secondMaxOriginal;
+ }
+ }
+
+ if(adjustSliders !== undefined && adjustSliders === true){
+ this.hour_slider.slider("option", { min: this._defaults.hourMin, max: this._defaults.hourMax }).slider('value', this.hour);
+ this.minute_slider.slider("option", { min: this._defaults.minuteMin, max: this._defaults.minuteMax }).slider('value', this.minute);
+ this.second_slider.slider("option", { min: this._defaults.secondMin, max: this._defaults.secondMax }).slider('value', this.second);
+ }
+
+ },
+
+
+ //########################################################################
+ // when a slider moves, set the internal time...
+ // on time change is also called when the time is updated in the text field
+ //########################################################################
+ _onTimeChange: function() {
+ var hour = (this.hour_slider) ? this.hour_slider.slider('value') : false,
+ minute = (this.minute_slider) ? this.minute_slider.slider('value') : false,
+ second = (this.second_slider) ? this.second_slider.slider('value') : false,
+ timezone = (this.timezone_select) ? this.timezone_select.val() : false
+
+ if (hour !== false) hour = parseInt(hour,10);
+ if (minute !== false) minute = parseInt(minute,10);
+ if (second !== false) second = parseInt(second,10);
+
+ var ampm = (hour < 12) ? 'AM' : 'PM';
+
+ // If the update was done in the input field, the input field should not be updated.
+ // If the update was done using the sliders, update the input field.
+ var hasChanged = (hour != this.hour || minute != this.minute || second != this.second || (this.ampm.length > 0 && this.ampm != ampm) || timezone != this.timezone);
+
+ if (hasChanged) {
+
+ if (hour !== false)this.hour = hour;
+ if (minute !== false) this.minute = minute;
+ if (second !== false) this.second = second;
+ if (timezone !== false) this.timezone = timezone;
+ this._limitMinMaxDateTime(this.inst, true);
+ }
+ if (this._defaults.ampm) this.ampm = ampm;
+
+ this._formatTime();
+ if (this.$timeObj) this.$timeObj.text(this.formattedTime);
+ this.timeDefined = true;
+ if (hasChanged) this._updateDateTime();
+ },
+
+ //########################################################################
+ // call custom onSelect.
+ // bind to sliders slidestop, and grid click.
+ //########################################################################
+ _onSelectHandler: function() {
+ var onSelect = this._defaults['onSelect'];
+ var inputEl = this.$input ? this.$input[0] : null;
+ if (onSelect && inputEl) {
+ onSelect.apply(inputEl, [this.formattedDateTime, this]);
+ }
+ },
+
+ //########################################################################
+ // format the time all pretty...
+ //########################################################################
+ _formatTime: function(time, format, ampm) {
+ if (ampm == undefined) ampm = this._defaults.ampm;
+ time = time || { hour: this.hour, minute: this.minute, second: this.second, ampm: this.ampm, timezone: this.timezone };
+ var tmptime = format || this._defaults.timeFormat.toString();
+
+ if (ampm) {
+ var hour12 = ((time.ampm == 'AM') ? (time.hour) : (time.hour % 12));
+ hour12 = (Number(hour12) === 0) ? 12 : hour12;
+ tmptime = tmptime.toString()
+ .replace(/hh/g, ((hour12 < 10) ? '0' : '') + hour12)
+ .replace(/h/g, hour12)
+ .replace(/mm/g, ((time.minute < 10) ? '0' : '') + time.minute)
+ .replace(/m/g, time.minute)
+ .replace(/ss/g, ((time.second < 10) ? '0' : '') + time.second)
+ .replace(/s/g, time.second)
+ .replace(/TT/g, time.ampm.toUpperCase())
+ .replace(/tt/g, time.ampm.toLowerCase())
+ .replace(/T/g, time.ampm.charAt(0).toUpperCase())
+ .replace(/t/g, time.ampm.charAt(0).toLowerCase())
+ .replace(/z/g, time.timezone);
+ } else {
+ tmptime = tmptime.toString()
+ .replace(/hh/g, ((time.hour < 10) ? '0' : '') + time.hour)
+ .replace(/h/g, time.hour)
+ .replace(/mm/g, ((time.minute < 10) ? '0' : '') + time.minute)
+ .replace(/m/g, time.minute)
+ .replace(/ss/g, ((time.second < 10) ? '0' : '') + time.second)
+ .replace(/s/g, time.second)
+ .replace(/z/g, time.timezone);
+ tmptime = $.trim(tmptime.replace(/t/gi, ''));
+ }
+
+ if (arguments.length) return tmptime;
+ else this.formattedTime = tmptime;
+ },
+
+ //########################################################################
+ // update our input with the new date time..
+ //########################################################################
+ _updateDateTime: function(dp_inst) {
+ dp_inst = this.inst || dp_inst,
+ dt = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay),
+ dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
+ formatCfg = $.datepicker._getFormatConfig(dp_inst),
+ timeAvailable = dt !== null && this.timeDefined;
+ this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
+ var formattedDateTime = this.formattedDate;
+ if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0))
+ return;
+
+ if (this._defaults.timeOnly === true) {
+ formattedDateTime = this.formattedTime;
+ } else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
+ formattedDateTime += this._defaults.separator + this.formattedTime;
+ }
+
+ this.formattedDateTime = formattedDateTime;
+
+ if(!this._defaults.showTimepicker) {
+ this.$input.val(this.formattedDate);
+ } else if (this.$altInput && this._defaults.altFieldTimeOnly === true) {
+ this.$altInput.val(this.formattedTime);
+ this.$input.val(this.formattedDate);
+ } else if(this.$altInput) {
+ this.$altInput.val(formattedDateTime);
+ this.$input.val(formattedDateTime);
+ } else {
+ this.$input.val(formattedDateTime);
+ }
+
+ this.$input.trigger("change");
+ }
+
+});
+
+$.fn.extend({
+ //########################################################################
+ // shorthand just to use timepicker..
+ //########################################################################
+ timepicker: function(o) {
+ o = o || {};
+ var tmp_args = arguments;
+
+ if (typeof o == 'object') tmp_args[0] = $.extend(o, { timeOnly: true });
+
+ return $(this).each(function() {
+ $.fn.datetimepicker.apply($(this), tmp_args);
+ });
+ },
+
+ //########################################################################
+ // extend timepicker to datepicker
+ //########################################################################
+ datetimepicker: function(o) {
+ o = o || {};
+ var $input = this,
+ tmp_args = arguments;
+
+ if (typeof(o) == 'string'){
+ if(o == 'getDate')
+ return $.fn.datepicker.apply($(this[0]), tmp_args);
+ else
+ return this.each(function() {
+ var $t = $(this);
+ $t.datepicker.apply($t, tmp_args);
+ });
+ }
+ else
+ return this.each(function() {
+ var $t = $(this);
+ $t.datepicker($.timepicker._newInst($t, o)._defaults);
+ });
+ }
+});
+
+//########################################################################
+// the bad hack :/ override datepicker so it doesnt close on select
+// inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
+//########################################################################
+$.datepicker._base_selectDate = $.datepicker._selectDate;
+$.datepicker._selectDate = function (id, dateStr) {
+ var inst = this._getInst($(id)[0]),
+ tp_inst = this._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ tp_inst._limitMinMaxDateTime(inst, true);
+ inst.inline = inst.stay_open = true;
+ //This way the onSelect handler called from calendarpicker get the full dateTime
+ this._base_selectDate(id, dateStr + tp_inst._defaults.separator + tp_inst.formattedTime);
+ inst.inline = inst.stay_open = false;
+ this._notifyChange(inst);
+ this._updateDatepicker(inst);
+ }
+ else this._base_selectDate(id, dateStr);
+};
+
+//#############################################################################################
+// second bad hack :/ override datepicker so it triggers an event when changing the input field
+// and does not redraw the datepicker on every selectDate event
+//#############################################################################################
+$.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
+$.datepicker._updateDatepicker = function(inst) {
+ if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
+
+ this._base_updateDatepicker(inst);
+
+ // Reload the time control when changing something in the input text field.
+ var tp_inst = this._get(inst, 'timepicker');
+ if(tp_inst) tp_inst._addTimePicker(inst);
+ }
+};
+
+//#######################################################################################
+// third bad hack :/ override datepicker so it allows spaces and colan in the input field
+//#######################################################################################
+$.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
+$.datepicker._doKeyPress = function(event) {
+ var inst = $.datepicker._getInst(event.target),
+ tp_inst = $.datepicker._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ if ($.datepicker._get(inst, 'constrainInput')) {
+ var ampm = tp_inst._defaults.ampm,
+ datetimeChars = tp_inst._defaults.timeFormat.toString()
+ .replace(/[hms]/g, '')
+ .replace(/TT/g, ampm ? 'APM' : '')
+ .replace(/T/g, ampm ? 'AP' : '')
+ .replace(/tt/g, ampm ? 'apm' : '')
+ .replace(/t/g, ampm ? 'ap' : '') +
+ " " +
+ tp_inst._defaults.separator +
+ $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
+ chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
+ return event.ctrlKey || (chr < ' ' || !datetimeChars || datetimeChars.indexOf(chr) > -1);
+ }
+ }
+
+ return $.datepicker._base_doKeyPress(event);
+};
+
+//#######################################################################################
+// Override key up event to sync manual input changes.
+//#######################################################################################
+$.datepicker._base_doKeyUp = $.datepicker._doKeyUp;
+$.datepicker._doKeyUp = function (event) {
+ var inst = $.datepicker._getInst(event.target),
+ tp_inst = $.datepicker._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
+ try {
+ $.datepicker._updateDatepicker(inst);
+ }
+ catch (err) {
+ $.datepicker.log(err);
+ }
+ }
+ }
+
+ return $.datepicker._base_doKeyUp(event);
+};
+
+//#######################################################################################
+// override "Today" button to also grab the time.
+//#######################################################################################
+$.datepicker._base_gotoToday = $.datepicker._gotoToday;
+$.datepicker._gotoToday = function(id) {
+ this._base_gotoToday(id);
+ this._setTime(this._getInst($(id)[0]), new Date());
+};
+
+//#######################################################################################
+// Disable & enable the Time in the datetimepicker
+//#######################################################################################
+$.datepicker._disableTimepickerDatepicker = function(target, date, withDate) {
+ var inst = this._getInst(target),
+ tp_inst = this._get(inst, 'timepicker');
+ $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
+ if (tp_inst) {
+ tp_inst._defaults.showTimepicker = false;
+ tp_inst._updateDateTime(inst);
+ }
+};
+
+$.datepicker._enableTimepickerDatepicker = function(target, date, withDate) {
+ var inst = this._getInst(target),
+ tp_inst = this._get(inst, 'timepicker');
+ $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
+ if (tp_inst) {
+ tp_inst._defaults.showTimepicker = true;
+ tp_inst._addTimePicker(inst); // Could be disabled on page load
+ tp_inst._updateDateTime(inst);
+ }
+};
+
+//#######################################################################################
+// Create our own set time function
+//#######################################################################################
+$.datepicker._setTime = function(inst, date) {
+ var tp_inst = this._get(inst, 'timepicker');
+ if (tp_inst) {
+ var defaults = tp_inst._defaults,
+ // calling _setTime with no date sets time to defaults
+ hour = date ? date.getHours() : defaults.hour,
+ minute = date ? date.getMinutes() : defaults.minute,
+ second = date ? date.getSeconds() : defaults.second;
+
+ //check if within min/max times..
+ if ((hour < defaults.hourMin || hour > defaults.hourMax) || (minute < defaults.minuteMin || minute > defaults.minuteMax) || (second < defaults.secondMin || second > defaults.secondMax)) {
+ hour = defaults.hourMin;
+ minute = defaults.minuteMin;
+ second = defaults.secondMin;
+ }
+
+ if (tp_inst.hour_slider) tp_inst.hour_slider.slider('value', hour);
+ else tp_inst.hour = hour;
+ if (tp_inst.minute_slider) tp_inst.minute_slider.slider('value', minute);
+ else tp_inst.minute = minute;
+ if (tp_inst.second_slider) tp_inst.second_slider.slider('value', second);
+ else tp_inst.second = second;
+
+ tp_inst._onTimeChange();
+ tp_inst._updateDateTime(inst);
+ }
+};
+
+//#######################################################################################
+// Create new public method to set only time, callable as $().datepicker('setTime', date)
+//#######################################################################################
+$.datepicker._setTimeDatepicker = function(target, date, withDate) {
+ var inst = this._getInst(target),
+ tp_inst = this._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ this._setDateFromField(inst);
+ var tp_date;
+ if (date) {
+ if (typeof date == "string") {
+ tp_inst._parseTime(date, withDate);
+ tp_date = new Date();
+ tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second);
+ }
+ else tp_date = new Date(date.getTime());
+ if (tp_date.toString() == 'Invalid Date') tp_date = undefined;
+ this._setTime(inst, tp_date);
+ }
+ }
+
+};
+
+//#######################################################################################
+// override setDate() to allow setting time too within Date object
+//#######################################################################################
+$.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
+$.datepicker._setDateDatepicker = function(target, date) {
+ var inst = this._getInst(target),
+ tp_date = (date instanceof Date) ? new Date(date.getTime()) : date;
+
+ this._updateDatepicker(inst);
+ this._base_setDateDatepicker.apply(this, arguments);
+ this._setTimeDatepicker(target, tp_date, true);
+};
+
+//#######################################################################################
+// override getDate() to allow getting time too within Date object
+//#######################################################################################
+$.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
+$.datepicker._getDateDatepicker = function(target, noDefault) {
+ var inst = this._getInst(target),
+ tp_inst = this._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ this._setDateFromField(inst, noDefault);
+ var date = this._getDate(inst);
+ if (date && tp_inst._parseTime($(target).val(), true)) date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second);
+ return date;
+ }
+ return this._base_getDateDatepicker(target, noDefault);
+};
+
+//#######################################################################################
+// jQuery extend now ignores nulls!
+//#######################################################################################
+function extendRemove(target, props) {
+ $.extend(target, props);
+ for (var name in props)
+ if (props[name] === null || props[name] === undefined)
+ target[name] = props[name];
+ return target;
+}
+
+$.timepicker = new Timepicker(); // singleton instance
+$.timepicker.version = "0.9.4";
+
+})(jQuery);
diff --git a/protected/models/Angebot.php b/protected/models/Angebot.php
index 9561687..8a16fd8 100644
--- a/protected/models/Angebot.php
+++ b/protected/models/Angebot.php
@@ -97,4 +97,10 @@ class Angebot extends CActiveRecord
'criteria'=>$criteria,
));
}
+
+ public function behaviors() {
+ return array(
+ 'LoggableBehavior'=>'application.modules.auditTrail.behaviors.LoggableBehavior',
+ );
+ }
} \ No newline at end of file
diff --git a/protected/models/AngebotVerein.php b/protected/models/AngebotVerein.php
index 65339ed..26c6dab 100644
--- a/protected/models/AngebotVerein.php
+++ b/protected/models/AngebotVerein.php
@@ -99,4 +99,10 @@ class AngebotVerein extends CActiveRecord
'criteria'=>$criteria,
));
}
+
+ public function behaviors() {
+ return array(
+ 'LoggableBehavior'=>'application.modules.auditTrail.behaviors.LoggableBehavior',
+ );
+ }
} \ No newline at end of file
diff --git a/protected/models/Kategorie.php b/protected/models/Kategorie.php
index 4e39910..a9d8db6 100644
--- a/protected/models/Kategorie.php
+++ b/protected/models/Kategorie.php
@@ -98,4 +98,10 @@ class Kategorie extends CActiveRecord
'criteria'=>$criteria,
));
}
+
+ public function behaviors() {
+ return array(
+ 'LoggableBehavior'=>'application.modules.auditTrail.behaviors.LoggableBehavior',
+ );
+ }
} \ No newline at end of file
diff --git a/protected/models/Standort.php b/protected/models/Standort.php
index b7eddcf..8d71707 100644
--- a/protected/models/Standort.php
+++ b/protected/models/Standort.php
@@ -103,4 +103,10 @@ class Standort extends CActiveRecord
'criteria'=>$criteria,
));
}
+
+ public function behaviors() {
+ return array(
+ 'LoggableBehavior'=>'application.modules.auditTrail.behaviors.LoggableBehavior',
+ );
+ }
} \ No newline at end of file
diff --git a/protected/models/Veranstaltung.php b/protected/models/Veranstaltung.php
new file mode 100644
index 0000000..fedd79f
--- /dev/null
+++ b/protected/models/Veranstaltung.php
@@ -0,0 +1,118 @@
+<?php
+
+/**
+ * This is the model class for table "termin".
+ *
+ * The followings are the available columns in table 'termin':
+ * @property integer $id
+ * @property integer $verein_id
+ * @property string $titel
+ * @property string $startzeit
+ * @property string $endzeit
+ * @property string $beschreibung
+ * @property integer $standort_id
+ * @property integer $published
+ *
+ * The followings are the available model relations:
+ * @property Standort $standort
+ * @property Verein $verein
+ */
+class Veranstaltung extends CActiveRecord
+{
+ /**
+ * Returns the static model of the specified AR class.
+ * @param string $className active record class name.
+ * @return Veranstaltung the static model class
+ */
+ public static function model($className=__CLASS__)
+ {
+ return parent::model($className);
+ }
+
+ /**
+ * @return string the associated database table name
+ */
+ public function tableName()
+ {
+ return 'termin';
+ }
+
+ /**
+ * @return array validation rules for model attributes.
+ */
+ public function rules()
+ {
+ // NOTE: you should only define rules for those attributes that
+ // will receive user inputs.
+ return array(
+ array('verein_id, standort_id, published', 'numerical', 'integerOnly'=>true),
+ array('titel', 'length', 'max'=>100),
+ array('startzeit, endzeit, beschreibung', 'safe'),
+ array('verein_id, standort_id, titel, startzeit, endzeit', 'required'),
+ // The following rule is used by search().
+ // Please remove those attributes that should not be searched.
+ array('id, verein_id, titel, startzeit, endzeit, beschreibung, standort_id, published', 'safe', 'on'=>'search'),
+ );
+ }
+
+ /**
+ * @return array relational rules.
+ */
+ public function relations()
+ {
+ // NOTE: you may need to adjust the relation name and the related
+ // class name for the relations automatically generated below.
+ return array(
+ 'standort' => array(self::BELONGS_TO, 'Standort', 'standort_id'),
+ 'verein' => array(self::BELONGS_TO, 'Verein', 'verein_id'),
+ );
+ }
+
+ /**
+ * @return array customized attribute labels (name=>label)
+ */
+ public function attributeLabels()
+ {
+ return array(
+ 'id' => 'ID',
+ 'verein_id' => 'Verein',
+ 'titel' => 'Titel',
+ 'startzeit' => 'Startzeit',
+ 'endzeit' => 'Endzeit',
+ 'beschreibung' => 'Beschreibung',
+ 'standort_id' => 'Standort',
+ 'published' => 'Published',
+ );
+ }
+
+ /**
+ * Retrieves a list of models based on the current search/filter conditions.
+ * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
+ */
+ public function search()
+ {
+ // Warning: Please modify the following code to remove attributes that
+ // should not be searched.
+
+ $criteria=new CDbCriteria;
+
+ $criteria->compare('id',$this->id);
+ $criteria->compare('verein_id',$this->verein_id);
+ $criteria->compare('titel',$this->titel,true);
+ $criteria->compare('startzeit',$this->startzeit,true);
+ $criteria->compare('endzeit',$this->endzeit,true);
+ $criteria->compare('beschreibung',$this->beschreibung,true);
+ $criteria->compare('standort_id',$this->standort_id);
+ $criteria->compare('published',$this->published);
+
+ return new CActiveDataProvider($this, array(
+ 'criteria'=>$criteria,
+ ));
+ }
+
+ public function behaviors() {
+ return array(
+ 'LoggableBehavior'=>'application.modules.auditTrail.behaviors.LoggableBehavior',
+ );
+ }
+} \ No newline at end of file
diff --git a/protected/models/Verein.php b/protected/models/Verein.php
index d740c8a..c40404c 100644
--- a/protected/models/Verein.php
+++ b/protected/models/Verein.php
@@ -116,4 +116,10 @@ class Verein extends CActiveRecord
'criteria'=>$criteria,
));
}
+
+ public function behaviors() {
+ return array(
+ 'LoggableBehavior'=>'application.modules.auditTrail.behaviors.LoggableBehavior',
+ );
+ }
} \ No newline at end of file
diff --git a/protected/modules/auditTrail/.DS_Store b/protected/modules/auditTrail/.DS_Store
new file mode 100644
index 0000000..dd74794
--- /dev/null
+++ b/protected/modules/auditTrail/.DS_Store
Binary files differ
diff --git a/protected/modules/auditTrail/AuditTrailModule.php b/protected/modules/auditTrail/AuditTrailModule.php
new file mode 100644
index 0000000..56d2d25
--- /dev/null
+++ b/protected/modules/auditTrail/AuditTrailModule.php
@@ -0,0 +1,74 @@
+<?php
+
+class AuditTrailModule extends CWebModule
+{
+ /**
+ * @var string the name of the User class. Defaults to "User"
+ */
+ public $userClass = "User";
+
+ /**
+ * @var string the name of the column of the user class that is the primary key. Defaults to "id"
+ */
+ public $userIdColumn = "id";
+
+ /**
+ * @var string the name of the column of the user class that is the username. Defaults to "username"
+ */
+ public $userNameColumn = "username";
+
+ /**
+ * @var AuditTrailModule static variable to hold the module so we don't have to instantiate it a million times to get config values
+ */
+ private static $__auditTrailModule;
+
+ public function init()
+ {
+ // this method is called when the module is being created
+ // you may place code here to customize the module or the application
+
+ // import the module-level models and components
+ $this->setImport(array(
+ 'auditTrail.models.*',
+ 'auditTrail.components.*',
+ ));
+ }
+
+ public function beforeControllerAction($controller, $action)
+ {
+ if(parent::beforeControllerAction($controller, $action))
+ {
+ // this method is called before any module controller action is performed
+ // you may place customized code here
+ return true;
+ }
+ else
+ return false;
+ }
+
+
+ /**
+ * Returns the value you want to look up, either from the config file or a user's override
+ * @var value The name of the value you would like to look up
+ * @return the config value you need
+ */
+ public static function getFromConfigOrObject($value) {
+ $at = Yii::app()->modules['auditTrail'];
+
+ //If we can get the value from the config, do that to save overhead
+ if( isset( $at[$value]) && !empty($at[$value] ) ) {
+ return $at[$value];
+ }
+
+ //If we cannot get the config value from the config file, get it from the
+ //instantiated object. Only instantiate it once though, its probably
+ //expensive to do. PS I feel this is a dirty trick and I don't like it
+ //but I don't know a better way
+ if(!is_object(self::$__auditTrailModule)) {
+ self::$__auditTrailModule = new AuditTrailModule(microtime(), null);
+ }
+
+ return self::$__auditTrailModule->$value;
+ }
+
+} \ No newline at end of file
diff --git a/protected/modules/auditTrail/README.txt b/protected/modules/auditTrail/README.txt
new file mode 100644
index 0000000..0ebb757
--- /dev/null
+++ b/protected/modules/auditTrail/README.txt
@@ -0,0 +1,19 @@
+In your main.php config file, add the follow line in your modules section:
+
+
+ 'modules'=>array(
+ ..
+ 'auditTrail'=>array(),
+ ..
+
+
+Then go to
+
+http://myapp.com/index.php?r=auditTrail
+
+
+and view the instructions for setup!
+
+For a more detailed walkthrough, please see the instructions at
+
+http://www.yiiframework.com/extension/audittrail \ No newline at end of file
diff --git a/protected/modules/auditTrail/behaviors/LoggableBehavior.php b/protected/modules/auditTrail/behaviors/LoggableBehavior.php
new file mode 100644
index 0000000..ff28507
--- /dev/null
+++ b/protected/modules/auditTrail/behaviors/LoggableBehavior.php
@@ -0,0 +1,133 @@
+<?php
+class LoggableBehavior extends CActiveRecordBehavior
+{
+ private $_oldattributes = array();
+
+ public function afterSave($event)
+ {
+ try {
+ $username = Yii::app()->user->Name;
+ $userid = Yii::app()->user->id;
+ } catch(Exception $e) { //If we have no user object, this must be a command line program
+ $username = "NO_USER";
+ $userid = null;
+ }
+
+ if(empty($username)) {
+ $username = "NO_USER";
+ }
+
+ if(empty($userid)) {
+ $userid = null;
+ }
+
+ $newattributes = $this->Owner->getAttributes();
+ $oldattributes = $this->getOldAttributes();
+
+ if (!$this->Owner->isNewRecord) {
+ // compare old and new
+ foreach ($newattributes as $name => $value) {
+ if (!empty($oldattributes)) {
+ $old = $oldattributes[$name];
+ } else {
+ $old = '';
+ }
+
+ if ($value != $old) {
+ $log=new AuditTrail();
+ $log->old_value = $old;
+ $log->new_value = $value;
+ $log->action = 'CHANGE';
+ $log->model = get_class($this->Owner);
+ $log->model_id = $this->Owner->getPrimaryKey();
+ $log->field = $name;
+ $log->stamp = date('Y-m-d H:i:s');
+ $log->user_id = $userid;
+
+ $log->save();
+ }
+ }
+ } else {
+ $log=new AuditTrail();
+ $log->old_value = '';
+ $log->new_value = '';
+ $log->action= 'CREATE';
+ $log->model= get_class($this->Owner);
+ $log->model_id= $this->Owner->getPrimaryKey();
+ $log->field= 'N/A';
+ $log->stamp= date('Y-m-d H:i:s');
+ $log->user_id= $userid;
+
+ $log->save();
+
+
+ foreach ($newattributes as $name => $value) {
+ $log=new AuditTrail();
+ $log->old_value = '';
+ $log->new_value = $value;
+ $log->action= 'SET';
+ $log->model= get_class($this->Owner);
+ $log->model_id= $this->Owner->getPrimaryKey();
+ $log->field= $name;
+ $log->stamp= date('Y-m-d H:i:s');
+ $log->user_id= $userid;
+ $log->save();
+ }
+
+
+
+ }
+ return parent::afterSave($event);
+ }
+
+ public function afterDelete($event)
+ {
+
+ try {
+ $username = Yii::app()->user->Name;
+ $userid = Yii::app()->user->id;
+ } catch(Exception $e) {
+ $username = "NO_USER";
+ $userid = null;
+ }
+
+ if(empty($username)) {
+ $username = "NO_USER";
+ }
+
+ if(empty($userid)) {
+ $userid = null;
+ }
+
+ $log=new AuditTrail();
+ $log->old_value = '';
+ $log->new_value = '';
+ $log->action= 'DELETE';
+ $log->model= get_class($this->Owner);
+ $log->model_id= $this->Owner->getPrimaryKey();
+ $log->field= 'N/A';
+ $log->stamp= date('Y-m-d H:i:s');
+ $log->user_id= $userid;
+ $log->save();
+ return parent::afterDelete($event);
+ }
+
+ public function afterFind($event)
+ {
+ // Save old values
+ $this->setOldAttributes($this->Owner->getAttributes());
+
+ return parent::afterFind($event);
+ }
+
+ public function getOldAttributes()
+ {
+ return $this->_oldattributes;
+ }
+
+ public function setOldAttributes($value)
+ {
+ $this->_oldattributes=$value;
+ }
+}
+?> \ No newline at end of file
diff --git a/protected/modules/auditTrail/controllers/AdminController.php b/protected/modules/auditTrail/controllers/AdminController.php
new file mode 100644
index 0000000..12d9841
--- /dev/null
+++ b/protected/modules/auditTrail/controllers/AdminController.php
@@ -0,0 +1,19 @@
+<?php
+
+class AdminController extends Controller
+{
+ public $defaultAction = "admin";
+ public $layout='//layouts/column1';
+
+ public function actionAdmin()
+ {
+ $model=new AuditTrail('search');
+ $model->unsetAttributes(); // clear any default values
+ if(isset($_GET['AuditTrail'])) {
+ $model->attributes=$_GET['AuditTrail'];
+ }
+ $this->render('admin',array(
+ 'model'=>$model,
+ ));
+ }
+} \ No newline at end of file
diff --git a/protected/modules/auditTrail/controllers/DefaultController.php b/protected/modules/auditTrail/controllers/DefaultController.php
new file mode 100644
index 0000000..957551e
--- /dev/null
+++ b/protected/modules/auditTrail/controllers/DefaultController.php
@@ -0,0 +1,9 @@
+<?php
+
+class DefaultController extends Controller
+{
+ public function actionIndex()
+ {
+ $this->render('index');
+ }
+} \ No newline at end of file
diff --git a/protected/modules/auditTrail/migrations/m110517_155003_create_tables_audit_trail.php b/protected/modules/auditTrail/migrations/m110517_155003_create_tables_audit_trail.php
new file mode 100644
index 0000000..e4a2428
--- /dev/null
+++ b/protected/modules/auditTrail/migrations/m110517_155003_create_tables_audit_trail.php
@@ -0,0 +1,66 @@
+<?php
+
+class m110517_155003_create_tables_audit_trail extends CDbMigration
+{
+
+ /**
+ * Creates initial version of the audit trail table
+ */
+ public function up()
+ {
+
+ //Create our first version of the audittrail table
+ //Please note that this matches the original creation of the
+ //table from version 1 of the extension. Other migrations will
+ //upgrade it from here if we ever need to. This was done so
+ //that older versions can still use migrate functionality to upgrade.
+ $this->createTable( 'tbl_audit_trail',
+ array(
+ 'id' => 'pk',
+ 'old_value' => 'string',
+ 'new_value' => 'string',
+ 'action' => 'string NOT NULL',
+ 'model' => 'string NOT NULL',
+ 'field' => 'string NOT NULL',
+ 'stamp' => 'datetime NOT NULL',
+ 'user_id' => 'string',
+ 'model_id' => 'string NOT NULL',
+ )
+ );
+
+ //Index these bad boys for speedy lookups
+ $this->createIndex( 'idx_audit_trail_user_id', 'tbl_audit_trail', 'user_id');
+ $this->createIndex( 'idx_audit_trail_model_id', 'tbl_audit_trail', 'model_id');
+ $this->createIndex( 'idx_audit_trail_model', 'tbl_audit_trail', 'model');
+ $this->createIndex( 'idx_audit_trail_field', 'tbl_audit_trail', 'field');
+ $this->createIndex( 'idx_audit_trail_old_value', 'tbl_audit_trail', 'old_value');
+ $this->createIndex( 'idx_audit_trail_new_value', 'tbl_audit_trail', 'new_value');
+ $this->createIndex( 'idx_audit_trail_action', 'tbl_audit_trail', 'action');
+ }
+
+ /**
+ * Drops the audit trail table
+ */
+ public function down()
+ {
+ $this->dropTable( 'tbl_audit_trail' );
+ }
+
+ /**
+ * Creates initial version of the audit trail table in a transaction-safe way.
+ * Uses $this->up to not duplicate code.
+ */
+ public function safeUp()
+ {
+ $this->up();
+ }
+
+ /**
+ * Drops the audit trail table in a transaction-safe way.
+ * Uses $this->down to not duplicate code.
+ */
+ public function safeDown()
+ {
+ $this->down();
+ }
+} \ No newline at end of file
diff --git a/protected/modules/auditTrail/models/.DS_Store b/protected/modules/auditTrail/models/.DS_Store
new file mode 100644
index 0000000..5008ddf
--- /dev/null
+++ b/protected/modules/auditTrail/models/.DS_Store
Binary files differ
diff --git a/protected/modules/auditTrail/models/AuditTrail.php b/protected/modules/auditTrail/models/AuditTrail.php
new file mode 100644
index 0000000..e21a283
--- /dev/null
+++ b/protected/modules/auditTrail/models/AuditTrail.php
@@ -0,0 +1,125 @@
+<?php
+
+/**
+ * This is the model class for table "tbl_audit_trail".
+ */
+class AuditTrail extends CActiveRecord
+{
+ /**
+ * The followings are the available columns in table 'tbl_audit_trail':
+ * @var integer $id
+ * @var string $new_value
+ * @var string $old_value
+ * @var string $action
+ * @var string $model
+ * @var string $field
+ * @var string $stamp
+ * @var integer $user_id
+ * @var string $model_id
+ */
+
+ /**
+ * Returns the static model of the specified AR class.
+ * @return AuditTrail the static model class
+ */
+ public static function model($className=__CLASS__)
+ {
+ return parent::model($className);
+ }
+
+ /**
+ * @return string the associated database table name
+ */
+ public function tableName()
+ {
+ return 'tbl_audit_trail';
+ }
+
+ /**
+ * @return array validation rules for model attributes.
+ */
+ public function rules()
+ {
+ // NOTE: you should only define rules for those attributes that
+ // will receive user inputs.
+ return array(
+ array('action, model, field, stamp, model_id', 'required'),
+ array('action', 'length', 'max'=>255),
+ array('model', 'length', 'max'=>255),
+ array('field', 'length', 'max'=>255),
+ array('model_id', 'length', 'max'=>255),
+ array('user_id', 'length', 'max'=>255),
+ // The following rule is used by search().
+ // Please remove those attributes that should not be searched.
+ array('id, new_value, old_value, action, model, field, stamp, user_id, model_id', 'safe', 'on'=>'search'),
+ );
+ }
+
+ /**
+ * @return array relational rules.
+ */
+ public function relations()
+ {
+ // NOTE: you may need to adjust the relation name and the related
+ // class name for the relations automatically generated below.
+ return array(
+ );
+ }
+
+ /**
+ * @return array customized attribute labels (name=>label)
+ */
+ public function attributeLabels()
+ {
+ return array(
+ 'id' => 'ID',
+ 'old_value' => 'Old Value',
+ 'new_value' => 'New Value',
+ 'action' => 'Action',
+ 'model' => 'Model',
+ 'field' => 'Field',
+ 'stamp' => 'Stamp',
+ 'user_id' => 'User',
+ 'model_id' => 'Model',
+ );
+ }
+
+ /**
+ * Retrieves a list of models based on the current search/filter conditions.
+ * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
+ */
+ public function search($options = array())
+ {
+ // Warning: Please modify the following code to remove attributes that
+ // should not be searched.
+ $criteria=new CDbCriteria;
+ $criteria->compare('id',$this->id);
+ $criteria->compare('old_value',$this->old_value,true);
+ $criteria->compare('new_value',$this->new_value,true);
+ $criteria->compare('action',$this->action,true);
+ $criteria->compare('model',$this->model);
+ $criteria->compare('field',$this->field,true);
+ $criteria->compare('stamp',$this->stamp,true);
+ $criteria->compare('user_id',$this->user_id);
+ $criteria->compare('model_id',$this->model_id);
+ $criteria->mergeWith($this->getDbCriteria());
+ return new CActiveDataProvider(
+ get_class($this),
+ array_merge(
+ array(
+ 'criteria'=>$criteria,
+ ),
+ $options
+ )
+ );
+ }
+
+ public function scopes() {
+ return array(
+ 'recently' => array(
+ 'order' => ' t.stamp DESC ',
+ ),
+
+ );
+ }
+} \ No newline at end of file
diff --git a/protected/modules/auditTrail/views/.DS_Store b/protected/modules/auditTrail/views/.DS_Store
new file mode 100644
index 0000000..6f1c5a1
--- /dev/null
+++ b/protected/modules/auditTrail/views/.DS_Store
Binary files differ
diff --git a/protected/modules/auditTrail/views/admin/_search.php b/protected/modules/auditTrail/views/admin/_search.php
new file mode 100644
index 0000000..f7d4571
--- /dev/null
+++ b/protected/modules/auditTrail/views/admin/_search.php
@@ -0,0 +1,59 @@
+<div class="wide form">
+
+<?php $form=$this->beginWidget('CActiveForm', array(
+ 'action'=>Yii::app()->createUrl($this->route),
+ 'method'=>'get',
+)); ?>
+
+ <div class="row">
+ <?php echo $form->label($model,'id'); ?>
+ <?php echo $form->textField($model,'id',array('size'=>11,'maxlength'=>11)); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->label($model,'old_value'); ?>
+ <?php echo $form->textArea($model,'old_value',array('rows'=>6, 'cols'=>50)); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->label($model,'new_value'); ?>
+ <?php echo $form->textArea($model,'new_value',array('rows'=>6, 'cols'=>50)); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->label($model,'action'); ?>
+ <?php echo $form->textField($model,'action',array('size'=>20,'maxlength'=>20)); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->label($model,'model'); ?>
+ <?php echo $form->textField($model,'model',array('size'=>60,'maxlength'=>255)); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->label($model,'field'); ?>
+ <?php echo $form->textField($model,'field',array('size'=>60,'maxlength'=>64)); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->label($model,'stamp'); ?>
+ <?php echo $form->textField($model,'stamp'); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->label($model,'user_id'); ?>
+ <?php echo $form->textField($model,'user_id'); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->label($model,'model_id'); ?>
+ <?php echo $form->textField($model,'model_id',array('size'=>60,'maxlength'=>65)); ?>
+ </div>
+
+ <div class="row buttons">
+ <?php echo CHtml::submitButton('Search'); ?>
+ </div>
+
+<?php $this->endWidget(); ?>
+
+</div><!-- search-form --> \ No newline at end of file
diff --git a/protected/modules/auditTrail/views/admin/admin.php b/protected/modules/auditTrail/views/admin/admin.php
new file mode 100644
index 0000000..2536b1a
--- /dev/null
+++ b/protected/modules/auditTrail/views/admin/admin.php
@@ -0,0 +1,58 @@
+<?php
+$this->breadcrumbs=array(
+ 'Audit Trails'=>array('/auditTrail'),
+ 'Manage',
+);
+/*
+$this->menu=array(
+ array('label'=>'List AuditTrail', 'url'=>array('index')),
+ array('label'=>'Create AuditTrail', '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('audit-trail-grid', {
+ data: $(this).serialize()
+ });
+ return false;
+});
+");
+?>
+
+<h1>Manage Audit Trails</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'=>'audit-trail-grid',
+ 'dataProvider'=>$model->search(),
+ 'filter'=>$model,
+ 'columns'=>array(
+ 'id',
+ 'old_value',
+ 'new_value',
+ 'action',
+ 'model',
+ 'field',
+ 'stamp',
+ 'user_id',
+ 'model_id',
+// array(
+// 'class'=>'CButtonColumn',
+// ),
+ ),
+)); ?> \ No newline at end of file
diff --git a/protected/modules/auditTrail/views/default/.DS_Store b/protected/modules/auditTrail/views/default/.DS_Store
new file mode 100644
index 0000000..5008ddf
--- /dev/null
+++ b/protected/modules/auditTrail/views/default/.DS_Store
Binary files differ
diff --git a/protected/modules/auditTrail/views/default/index.php b/protected/modules/auditTrail/views/default/index.php
new file mode 100644
index 0000000..f9a114f
--- /dev/null
+++ b/protected/modules/auditTrail/views/default/index.php
@@ -0,0 +1,95 @@
+<?php
+$this->breadcrumbs=array(
+ $this->module->id,
+);
+?>
+<h1>Welcome to Audit Trail!</h1>
+<h2>Introduction</h2>
+<p>
+ This is the audit trail module. This module provides basic access to any changes performed via active record through any class that has the LoggableBehavior assigned. It is based off of <?php echo CHtml::link('this cookbook article', 'http://www.yiiframework.com/wiki/9/how-to-log-changes-of-activerecords'); ?>. I've noticed I always do the same things with it, and I hoped to help others who probably do the same thing.
+</p>
+<h2>Changes</h2>
+<p>
+ <ul>
+ <li><b><em>The widget now uses the zii Cportlet widget</em></b> and does not need the <?php echo CHtml::link('xportlet widget', 'http://www.yiiframework.com/extension/portlet/'); ?> any longer</li>
+ <li>This extension now uses migrations, so the db schema files are no longer necessary.</li>
+ </ul>
+</p>
+<h2>Requirements</h2>
+<p>
+ This module requires:
+ <ul>
+ <li>Yii 1.1.6 or higher</li>
+ <li>command line access to use database migrations</li>
+ <li>a database connection. So far this has only been tested on MySQL, but it should work on any DB as long as the initDb script is properly modified to create tables in the syntax of your RDBMS. Any RDBMS translations would be very much appreciated!</li>
+ <li>a user object with an id and a username field. The name of the class, the id field, and the username field can be overridden in the config file.</li>
+ </ul>
+</p>
+<h2>Installation</h2>
+<p>
+ If you are looking at this page, you at least enabled the module in your main.php config. Good job! Now we can continue with the installation:
+ <ol>
+ <li>Make sure your components->db is configured in protected/config/main.php</li>
+ <li>Make sure the rest of this module is set up in your protected/config/main.php. See <a href="#config">configuration</a> for help with this.</li>
+ <li>
+ Run the database migrations to create the tables for audit trail. Keep in mind that you will have to use the --migrationPath flag to tell the yiic tool where the migrations are. It should look something like this:
+ <blockquote><code>prompt:> php ./yiic.php migrate up --migrationPath=application.modules.auditTrail.migrations</code></blockquote>
+ Keep in mind that you may have to change the mirgrationPath to match where you installed the extension. My examples assumes you put it in MyWebApp/protected/modules
+ </li>
+ <li>Make sure any active record objects you want to log are using the <a href="#loggable">loggable behavior</a></li>
+ <li>
+ Add the <a href="#widget">audit trail widget</a> to any admin pages you want (optional)
+ </li>
+ <li>
+ Build in RBAC rules if using RBAC (optional). This controllers in this module automatically extend the Controller class of the current web app, so any logic you built into your app for RBAC should work fine. You may need to adjust settings in your RBAC management interface, but specific instructions depend on which implementation you are using. If you need a recommendation, I really like <a href="http://www.yiiframework.com/extension/rights/">Rights</a> by Chris83.
+ </li>
+ <li>Use the <a href="#manager">Audit Trail Manager</a> to manage your audit trail!</li>
+ </ol>
+</p>
+<h2>Parts</h2>
+<a name="config"><h3>main.php Configuration</h3></a>
+<p>
+ Please add the AuditTrail model to the import section of your main.php config file so that all models that need it can find the AR model:
+<blockquote><code><pre>
+ 'import'=>array(
+ 'application.models.*',
+ 'application.components.*',
+ 'application.modules.auditTrail.models.AuditTrail',
+ .....
+ ),
+</pre></code></blockquote>
+ Here are the following options for your main.php configurations (the defaults for all of them should work, so you may not need to use any of them, but if you need to override them you can)
+<blockquote><code><pre>
+ 'modules'=>array(
+ 'auditTrail'=>array(
+ 'userClass' => 'User', // the class name for the user object
+ 'userIdColumn' => 'id', // the column name of the primary key for the user
+ 'userNameColumn' => 'username', // the column name of the primary key for the user
+ ),
+ .......
+</pre></code></blockquote>
+</p>
+
+<a name="loggable"><h3>Loggable Behavior</h3></a>
+<p>
+ You should make sure your ActiveRecord objects use the LoggableBehavior. If you installed AuditTrail to your modules directory, this would typically be referenced by adding this function to your AR model:
+<code>public function behaviors()
+{
+ return array(
+ 'LoggableBehavior'=>
+ 'application.modules.auditTrail.behaviors.LoggableBehavior',
+ );
+}</code>
+</p>
+<a name="widget"><h3>Audit Trail Widget</h3></a>
+<p>
+ You can easily add the audit trail widget to any page that is specifcally about one row of one thing (ie: one instance of one model, like an update or view page, not like an admin or list page), and it will give you insight into changes for just that object.
+<code>$this->widget(
+ 'application.modules.auditTrail.widgets.portlets.ShowAuditTrail',
+ array(
+ 'model' => $model,
+ )
+);</code>
+</p>
+<a name="manager"><h3>Audit Trail Manager</h3></a>
+<p>The manager is just a searchable table of all audits. You can find it here: <?php echo Chtml::link('Audit Trail Manager', array('/auditTrail/admin')); ?></p>
diff --git a/protected/modules/auditTrail/widgets/.DS_Store b/protected/modules/auditTrail/widgets/.DS_Store
new file mode 100644
index 0000000..e2f4aeb
--- /dev/null
+++ b/protected/modules/auditTrail/widgets/.DS_Store
Binary files differ
diff --git a/protected/modules/auditTrail/widgets/portlets/.DS_Store b/protected/modules/auditTrail/widgets/portlets/.DS_Store
new file mode 100644
index 0000000..1e58340
--- /dev/null
+++ b/protected/modules/auditTrail/widgets/portlets/.DS_Store
Binary files differ
diff --git a/protected/modules/auditTrail/widgets/portlets/ShowAuditTrail.php b/protected/modules/auditTrail/widgets/portlets/ShowAuditTrail.php
new file mode 100644
index 0000000..eb5a94f
--- /dev/null
+++ b/protected/modules/auditTrail/widgets/portlets/ShowAuditTrail.php
@@ -0,0 +1,157 @@
+<?php
+/**
+ * ShowAuditTrail shows the audit trail for the current item
+ */
+
+Yii::import('zii.widgets.CPortlet');
+require_once(realpath(dirname(__FILE__) . '/../../AuditTrailModule.php'));
+
+class ShowAuditTrail extends CPortlet
+{
+ /**
+ * @var CActiveRecord the model you want to use with this field
+ */
+ public $model;
+
+ /**
+ * @var boolean whether or not to show the widget
+ */
+ public $visible = true;
+
+ /**
+ * @var this allows you to override individual columns' display properties in the datagrid.
+ * Column definitions should be indexed by column name, and the value should match the column
+ * format of CDataGrid. For example:
+ *
+ * 'dataGridColumnsOverride' => array(
+ * 'old_value' => array(
+ * 'name' => 'old_value',
+ * 'filter' => '',
+ * ),
+ * 'new_value' => array(
+ * 'name' => 'new_value',
+ * 'filter' => '',
+ * ),
+ * )
+ *
+ * Please do not specify a column if you do not wish to override the defaults of that column.
+ * Also, please be careful when specifying a format for user_id, as special handling exists
+ * to format the user name
+ */
+ public $dataGridColumnsOverride = array( );
+
+ /**
+ * @var AuditTrailModule static variable to hold the module so we don't have to instantiate it a million times to get config values
+ */
+ private static $__auditTrailModule;
+
+ /**
+ * Sets the title of the portlet
+ */
+ public function init() {
+ $this->title = "Audit Trail For " . get_class($this->model) . " " . $this->model->id;
+ parent::init();
+ }
+
+ /**
+ * generates content of widget the widget.
+ * This renders the widget, if it is visible.
+ */
+ public function renderContent()
+ {
+ if($this->visible) {
+ $auditTrail = AuditTrail::model()->recently();
+ $auditTrail->model = get_class($this->model);
+ $auditTrail->model_id = $this->model->primaryKey;
+ $columnFormat = $this->getColumnFormat();
+ $this->widget('zii.widgets.grid.CGridView', array(
+ 'id'=>'audit-trail-grid',
+ 'dataProvider'=>$auditTrail->search(),
+ 'columns'=> $this->getColumnFormat(),
+ ));
+ }
+ }
+
+ /**
+ * Builds the label code we need to display usernames correctly
+ * @return The code to be evaled to display the user info correctly
+ */
+ protected function getEvalUserLabelCode() {
+ $userClass = $this->getFromConfigOrObject('userClass');
+ $userNameColumn = $this->getFromConfigOrObject('userNameColumn');
+ $userEvalLabel = ' ( ($t = '
+ . $userClass
+ . '::model()->findByPk($data->user_id)) == null ? "": $t->'
+ . $userNameColumn
+ . ' ) ';
+ return $userEvalLabel;
+ }
+
+ /**
+ * Returns the value you want to look up, either from the config file or a user's override
+ * @var value The name of the value you would like to look up
+ * @return the config value you need
+ */
+ protected function getFromConfigOrObject($value) {
+ $at = Yii::app()->modules['auditTrail'];
+
+ //If we can get the value from the config, do that to save overhead
+ if( isset( $at[$value]) && !empty($at[$value] ) ) {
+ return $at[$value];
+ }
+
+ //If we cannot get the config value from the config file, get it from the
+ //instantiated object. Only instantiate it once though, its probably
+ //expensive to do. PS I feel this is a dirty trick and I don't like it
+ //but I don't know a better way
+ if(!is_object(self::$__auditTrailModule)) {
+ self::$__auditTrailModule = new AuditTrailModule(microtime(), null);
+ }
+
+ return self::$__auditTrailModule->$value;
+ }
+
+ /**
+ * Gets final column format. Starts with default column format (specified in this method
+ * and checks $this->dataGridColumnsOverride array to see if any columns need to use a
+ * user specified format.
+ * @return array The final format array, with any user specified formats taking precedent over defaults
+ */
+ protected function getColumnFormat() {
+ $evalUserLabel = $this->getEvalUserLabelCode();
+ $columnFormat = array();
+ $defaultColumnFormat = array(
+ 'old_value' => array(
+ 'name' => 'old_value',
+ 'filter' => '',
+ ),
+ 'new_value' => array(
+ 'name' => 'new_value',
+ 'filter' => '',
+ ),
+ 'action' => array(
+ 'name' => 'action',
+ 'filter'=> '',
+ ),
+ 'field' => array(
+ 'name' => 'field',
+ 'filter' => '',
+ ),
+ 'stamp' => array(
+ 'name' => 'stamp',
+ 'filter' => '',
+ ),
+ 'user_id' => array(
+ 'name' => 'user_id',
+ 'value'=>$evalUserLabel,
+ 'filter'=> '',
+ ),
+ );
+
+ foreach($defaultColumnFormat as $key => $format) {
+ $columnFormat[] = isset($this->dataGridColumnsOverride[$key]) ? $this->dataGridColumnsOverride[$key] : $defaultColumnFormat[$key];
+ }
+
+ return $columnFormat;
+ }
+} \ No newline at end of file
diff --git a/protected/runtime/application.log b/protected/runtime/application.log
index b25ea6a..ba3b632 100644
--- a/protected/runtime/application.log
+++ b/protected/runtime/application.log
@@ -4282,3 +4282,229 @@ Stack trace:
REQUEST_URI=/admin.astaf.de/index.php?r=verein/admin
HTTP_REFERER=http://dev.astaf.de:90/admin.astaf.de/index.php?r=site/login
---
+2012/04/28 12:09:15 [error] [exception.CException] exception 'CException' with message 'CrudCode and its behaviors do not have a method or closure named "renderPartial".' in D:\Projects\Astaf\workspace\yii\framework\base\CComponent.php:266
+Stack trace:
+#0 D:\Projects\Astaf\workspace\yii\framework\gii\generators\crud\templates\astaf\_form.php(14): CComponent->__call('renderPartial', Array)
+#1 D:\Projects\Astaf\workspace\yii\framework\gii\generators\crud\templates\astaf\_form.php(14): CrudCode->renderPartial('/common/_requir...')
+#2 D:\Projects\Astaf\workspace\yii\framework\gii\CCodeModel.php(320): require('D:\Projects\Ast...')
+#3 D:\Projects\Astaf\workspace\yii\framework\gii\generators\crud\CrudCode.php(97): CCodeModel->render('D:\Projects\Ast...')
+#4 D:\Projects\Astaf\workspace\yii\framework\gii\CCodeGenerator.php(161): CrudCode->prepare()
+#5 D:\Projects\Astaf\workspace\yii\framework\gii\CCodeGenerator.php(64): CCodeGenerator->prepare()
+#6 D:\Projects\Astaf\workspace\yii\framework\web\actions\CInlineAction.php(50): CCodeGenerator->actionIndex()
+#7 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(309): CInlineAction->runWithParams(Array)
+#8 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(287): CController->runAction(Object(CInlineAction))
+#9 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(266): CController->runActionWithFilters(Object(CInlineAction), Array)
+#10 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(276): CController->run('')
+#11 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(135): CWebApplication->runController('gii/crud')
+#12 D:\Projects\Astaf\workspace\yii\framework\base\CApplication.php(162): CWebApplication->processRequest()
+#13 D:\Projects\Astaf\workspace\admin.astaf.de\index.php(13): CApplication->run()
+#14 {main}
+REQUEST_URI=/admin.astaf.de/index.php?r=gii/crud
+HTTP_REFERER=http://dev.astaf.de:90/admin.astaf.de/index.php?r=gii/crud
+---
+2012/04/28 12:09:39 [error] [exception.CException] exception 'CException' with message 'CrudCode and its behaviors do not have a method or closure named "renderPartial".' in D:\Projects\Astaf\workspace\yii\framework\base\CComponent.php:266
+Stack trace:
+#0 D:\Projects\Astaf\workspace\yii\framework\gii\generators\crud\templates\astaf\_form.php(14): CComponent->__call('renderPartial', Array)
+#1 D:\Projects\Astaf\workspace\yii\framework\gii\generators\crud\templates\astaf\_form.php(14): CrudCode->renderPartial('/common/_requir...')
+#2 D:\Projects\Astaf\workspace\yii\framework\gii\CCodeModel.php(320): require('D:\Projects\Ast...')
+#3 D:\Projects\Astaf\workspace\yii\framework\gii\generators\crud\CrudCode.php(97): CCodeModel->render('D:\Projects\Ast...')
+#4 D:\Projects\Astaf\workspace\yii\framework\gii\CCodeGenerator.php(161): CrudCode->prepare()
+#5 D:\Projects\Astaf\workspace\yii\framework\gii\CCodeGenerator.php(64): CCodeGenerator->prepare()
+#6 D:\Projects\Astaf\workspace\yii\framework\web\actions\CInlineAction.php(50): CCodeGenerator->actionIndex()
+#7 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(309): CInlineAction->runWithParams(Array)
+#8 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(287): CController->runAction(Object(CInlineAction))
+#9 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(266): CController->runActionWithFilters(Object(CInlineAction), Array)
+#10 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(276): CController->run('')
+#11 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(135): CWebApplication->runController('gii/crud')
+#12 D:\Projects\Astaf\workspace\yii\framework\base\CApplication.php(162): CWebApplication->processRequest()
+#13 D:\Projects\Astaf\workspace\admin.astaf.de\index.php(13): CApplication->run()
+#14 {main}
+REQUEST_URI=/admin.astaf.de/index.php?r=gii/crud
+HTTP_REFERER=http://dev.astaf.de:90/admin.astaf.de/index.php?r=gii/crud
+---
+2012/04/28 12:09:46 [error] [exception.CException] exception 'CException' with message 'CrudCode and its behaviors do not have a method or closure named "renderPartial".' in D:\Projects\Astaf\workspace\yii\framework\base\CComponent.php:266
+Stack trace:
+#0 D:\Projects\Astaf\workspace\yii\framework\gii\generators\crud\templates\astaf\_form.php(14): CComponent->__call('renderPartial', Array)
+#1 D:\Projects\Astaf\workspace\yii\framework\gii\generators\crud\templates\astaf\_form.php(14): CrudCode->renderPartial('/common/_requir...')
+#2 D:\Projects\Astaf\workspace\yii\framework\gii\CCodeModel.php(320): require('D:\Projects\Ast...')
+#3 D:\Projects\Astaf\workspace\yii\framework\gii\generators\crud\CrudCode.php(97): CCodeModel->render('D:\Projects\Ast...')
+#4 D:\Projects\Astaf\workspace\yii\framework\gii\CCodeGenerator.php(161): CrudCode->prepare()
+#5 D:\Projects\Astaf\workspace\yii\framework\gii\CCodeGenerator.php(64): CCodeGenerator->prepare()
+#6 D:\Projects\Astaf\workspace\yii\framework\web\actions\CInlineAction.php(50): CCodeGenerator->actionIndex()
+#7 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(309): CInlineAction->runWithParams(Array)
+#8 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(287): CController->runAction(Object(CInlineAction))
+#9 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(266): CController->runActionWithFilters(Object(CInlineAction), Array)
+#10 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(276): CController->run('')
+#11 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(135): CWebApplication->runController('gii/crud')
+#12 D:\Projects\Astaf\workspace\yii\framework\base\CApplication.php(162): CWebApplication->processRequest()
+#13 D:\Projects\Astaf\workspace\admin.astaf.de\index.php(13): CApplication->run()
+#14 {main}
+REQUEST_URI=/admin.astaf.de/index.php?r=gii/crud
+HTTP_REFERER=http://dev.astaf.de:90/admin.astaf.de/index.php?r=gii/crud
+---
+2012/04/28 12:11:38 [error] [exception.CHttpException.404] exception 'CHttpException' with message 'The system is unable to find the requested action "admin".' in D:\Projects\Astaf\workspace\yii\framework\web\CController.php:484
+Stack trace:
+#0 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(271): CController->missingAction('admin')
+#1 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(276): CController->run('admin')
+#2 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(135): CWebApplication->runController('verein/admin')
+#3 D:\Projects\Astaf\workspace\yii\framework\base\CApplication.php(162): CWebApplication->processRequest()
+#4 D:\Projects\Astaf\workspace\admin.astaf.de\index.php(13): CApplication->run()
+#5 {main}
+REQUEST_URI=/admin.astaf.de/index.php?r=verein/admin
+HTTP_REFERER=http://dev.astaf.de:90/admin.astaf.de/index.php?r=site/login
+---
+2012/04/28 12:14:35 [error] [php] Undefined variable: model (D:\Projects\Astaf\workspace\admin.astaf.de\protected\views\veranstaltung\index.php:15)
+Stack trace:
+#0 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(870): VeranstaltungController->renderFile()
+#1 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(783): VeranstaltungController->renderPartial()
+#2 D:\Projects\Astaf\workspace\admin.astaf.de\protected\controllers\VeranstaltungController.php(125): VeranstaltungController->render()
+#3 D:\Projects\Astaf\workspace\yii\framework\web\actions\CInlineAction.php(50): VeranstaltungController->actionIndex()
+#4 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(309): CInlineAction->runWithParams()
+#5 D:\Projects\Astaf\workspace\yii\framework\web\filters\CFilterChain.php(134): VeranstaltungController->runAction()
+#6 D:\Projects\Astaf\workspace\yii\framework\web\filters\CFilter.php(41): CFilterChain->run()
+#7 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(1146): CAccessControlFilter->filter()
+#8 D:\Projects\Astaf\workspace\yii\framework\web\filters\CInlineFilter.php(59): VeranstaltungController->filterAccessControl()
+#9 D:\Projects\Astaf\workspace\yii\framework\web\filters\CFilterChain.php(131): CInlineFilter->filter()
+#10 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(292): CFilterChain->run()
+#11 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(266): VeranstaltungController->runActionWithFilters()
+#12 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(276): VeranstaltungController->run()
+#13 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(135): CWebApplication->runController()
+#14 D:\Projects\Astaf\workspace\yii\framework\base\CApplication.php(162): CWebApplication->processRequest()
+#15 D:\Projects\Astaf\workspace\admin.astaf.de\index.php(13): CWebApplication->run()
+REQUEST_URI=/admin.astaf.de/index.php?r=veranstaltung/index
+in D:\Projects\Astaf\workspace\admin.astaf.de\protected\views\veranstaltung\index.php (15)
+in D:\Projects\Astaf\workspace\admin.astaf.de\protected\controllers\VeranstaltungController.php (125)
+in D:\Projects\Astaf\workspace\admin.astaf.de\index.php (13)
+2012/04/28 12:16:07 [error] [php] Trying to get property of non-object (D:\Projects\Astaf\workspace\yii\framework\base\CComponent.php(607) : eval()'d code:1)
+Stack trace:
+#0 D:\Projects\Astaf\workspace\yii\framework\zii\widgets\grid\CGridColumn.php(138): CDataColumn->renderDataCellContent()
+#1 D:\Projects\Astaf\workspace\yii\framework\zii\widgets\grid\CGridView.php(517): CDataColumn->renderDataCell()
+#2 D:\Projects\Astaf\workspace\yii\framework\zii\widgets\grid\CGridView.php(490): CGridView->renderTableRow()
+#3 D:\Projects\Astaf\workspace\yii\framework\zii\widgets\grid\CGridView.php(400): CGridView->renderTableBody()
+#4 D:\Projects\Astaf\workspace\yii\framework\zii\widgets\CBaseListView.php(158): CGridView->renderItems()
+#5 unknown(0): CGridView->renderSection()
+#6 D:\Projects\Astaf\workspace\yii\framework\zii\widgets\CBaseListView.php(141): preg_replace_callback()
+#7 D:\Projects\Astaf\workspace\yii\framework\zii\widgets\CBaseListView.php(126): CGridView->renderContent()
+#8 D:\Projects\Astaf\workspace\yii\framework\web\CBaseController.php(174): CGridView->run()
+#9 D:\Projects\Astaf\workspace\admin.astaf.de\protected\views\veranstaltung\index.php(34): VeranstaltungController->widget()
+#10 D:\Projects\Astaf\workspace\yii\framework\web\CBaseController.php(127): require()
+#11 D:\Projects\Astaf\workspace\yii\framework\web\CBaseController.php(96): VeranstaltungController->renderInternal()
+#12 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(870): VeranstaltungController->renderFile()
+#13 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(783): VeranstaltungController->renderPartial()
+#14 D:\Projects\Astaf\workspace\admin.astaf.de\protected\controllers\VeranstaltungController.php(129): VeranstaltungController->render()
+#15 D:\Projects\Astaf\workspace\yii\framework\web\actions\CInlineAction.php(50): VeranstaltungController->actionIndex()
+#16 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(309): CInlineAction->runWithParams()
+#17 D:\Projects\Astaf\workspace\yii\framework\web\filters\CFilterChain.php(134): VeranstaltungController->runAction()
+#18 D:\Projects\Astaf\workspace\yii\framework\web\filters\CFilter.php(41): CFilterChain->run()
+#19 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(1146): CAccessControlFilter->filter()
+#20 D:\Projects\Astaf\workspace\yii\framework\web\filters\CInlineFilter.php(59): VeranstaltungController->filterAccessControl()
+#21 D:\Projects\Astaf\workspace\yii\framework\web\filters\CFilterChain.php(131): CInlineFilter->filter()
+#22 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(292): CFilterChain->run()
+#23 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(266): VeranstaltungController->runActionWithFilters()
+#24 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(276): VeranstaltungController->run()
+#25 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(135): CWebApplication->runController()
+#26 D:\Projects\Astaf\workspace\yii\framework\base\CApplication.php(162): CWebApplication->processRequest()
+#27 D:\Projects\Astaf\workspace\admin.astaf.de\index.php(13): CWebApplication->run()
+REQUEST_URI=/admin.astaf.de/index.php?r=veranstaltung/index
+in D:\Projects\Astaf\workspace\admin.astaf.de\protected\views\veranstaltung\index.php (34)
+in D:\Projects\Astaf\workspace\admin.astaf.de\protected\controllers\VeranstaltungController.php (129)
+in D:\Projects\Astaf\workspace\admin.astaf.de\index.php (13)
+2012/04/28 12:18:59 [error] [exception.CException] exception 'CException' with message 'Eigenschaft "Veranstaltung.name ist nicht definiert.' in D:\Projects\Astaf\workspace\yii\framework\base\CComponent.php:131
+Stack trace:
+#0 D:\Projects\Astaf\workspace\yii\framework\db\ar\CActiveRecord.php(144): CComponent->__get('name')
+#1 D:\Projects\Astaf\workspace\admin.astaf.de\protected\views\veranstaltung\view.php(4): CActiveRecord->__get('name')
+#2 D:\Projects\Astaf\workspace\yii\framework\web\CBaseController.php(127): require('D:\Projects\Ast...')
+#3 D:\Projects\Astaf\workspace\yii\framework\web\CBaseController.php(96): CBaseController->renderInternal('D:\Projects\Ast...', Array, true)
+#4 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(870): CBaseController->renderFile('D:\Projects\Ast...', Array, true)
+#5 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(783): CController->renderPartial('view', Array, true)
+#6 D:\Projects\Astaf\workspace\admin.astaf.de\protected\controllers\VeranstaltungController.php(47): CController->render('view', Array)
+#7 [internal function]: VeranstaltungController->actionView('1')
+#8 D:\Projects\Astaf\workspace\yii\framework\web\actions\CAction.php(107): ReflectionMethod->invokeArgs(Object(VeranstaltungController), Array)
+#9 D:\Projects\Astaf\workspace\yii\framework\web\actions\CInlineAction.php(48): CAction->runWithParamsInternal(Object(VeranstaltungController), Object(ReflectionMethod), Array)
+#10 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(309): CInlineAction->runWithParams(Array)
+#11 D:\Projects\Astaf\workspace\yii\framework\web\filters\CFilterChain.php(134): CController->runAction(Object(CInlineAction))
+#12 D:\Projects\Astaf\workspace\yii\framework\web\filters\CFilter.php(41): CFilterChain->run()
+#13 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(1146): CFilter->filter(Object(CFilterChain))
+#14 D:\Projects\Astaf\workspace\yii\framework\web\filters\CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))
+#15 D:\Projects\Astaf\workspace\yii\framework\web\filters\CFilterChain.php(131): CInlineFilter->filter(Object(CFilterChain))
+#16 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(292): CFilterChain->run()
+#17 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(266): CController->runActionWithFilters(Object(CInlineAction), Array)
+#18 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(276): CController->run('view')
+#19 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(135): CWebApplication->runController('veranstaltung/v...')
+#20 D:\Projects\Astaf\workspace\yii\framework\base\CApplication.php(162): CWebApplication->processRequest()
+#21 D:\Projects\Astaf\workspace\admin.astaf.de\index.php(13): CApplication->run()
+#22 {main}
+REQUEST_URI=/admin.astaf.de/index.php?r=veranstaltung/view&id=1
+HTTP_REFERER=http://dev.astaf.de:90/admin.astaf.de/index.php?r=veranstaltung/index
+---
+2012/04/28 12:19:04 [error] [exception.CException] exception 'CException' with message 'Eigenschaft "Veranstaltung.title ist nicht definiert.' in D:\Projects\Astaf\workspace\yii\framework\base\CComponent.php:131
+Stack trace:
+#0 D:\Projects\Astaf\workspace\yii\framework\db\ar\CActiveRecord.php(144): CComponent->__get('title')
+#1 D:\Projects\Astaf\workspace\admin.astaf.de\protected\views\veranstaltung\view.php(4): CActiveRecord->__get('title')
+#2 D:\Projects\Astaf\workspace\yii\framework\web\CBaseController.php(127): require('D:\Projects\Ast...')
+#3 D:\Projects\Astaf\workspace\yii\framework\web\CBaseController.php(96): CBaseController->renderInternal('D:\Projects\Ast...', Array, true)
+#4 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(870): CBaseController->renderFile('D:\Projects\Ast...', Array, true)
+#5 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(783): CController->renderPartial('view', Array, true)
+#6 D:\Projects\Astaf\workspace\admin.astaf.de\protected\controllers\VeranstaltungController.php(47): CController->render('view', Array)
+#7 [internal function]: VeranstaltungController->actionView('1')
+#8 D:\Projects\Astaf\workspace\yii\framework\web\actions\CAction.php(107): ReflectionMethod->invokeArgs(Object(VeranstaltungController), Array)
+#9 D:\Projects\Astaf\workspace\yii\framework\web\actions\CInlineAction.php(48): CAction->runWithParamsInternal(Object(VeranstaltungController), Object(ReflectionMethod), Array)
+#10 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(309): CInlineAction->runWithParams(Array)
+#11 D:\Projects\Astaf\workspace\yii\framework\web\filters\CFilterChain.php(134): CController->runAction(Object(CInlineAction))
+#12 D:\Projects\Astaf\workspace\yii\framework\web\filters\CFilter.php(41): CFilterChain->run()
+#13 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(1146): CFilter->filter(Object(CFilterChain))
+#14 D:\Projects\Astaf\workspace\yii\framework\web\filters\CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))
+#15 D:\Projects\Astaf\workspace\yii\framework\web\filters\CFilterChain.php(131): CInlineFilter->filter(Object(CFilterChain))
+#16 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(292): CFilterChain->run()
+#17 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(266): CController->runActionWithFilters(Object(CInlineAction), Array)
+#18 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(276): CController->run('view')
+#19 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(135): CWebApplication->runController('veranstaltung/v...')
+#20 D:\Projects\Astaf\workspace\yii\framework\base\CApplication.php(162): CWebApplication->processRequest()
+#21 D:\Projects\Astaf\workspace\admin.astaf.de\index.php(13): CApplication->run()
+#22 {main}
+REQUEST_URI=/admin.astaf.de/index.php?r=veranstaltung/view&id=1
+HTTP_REFERER=http://dev.astaf.de:90/admin.astaf.de/index.php?r=veranstaltung/index
+---
+2012/04/28 12:32:33 [error] [php] Undefined variable: vereine (D:\Projects\Astaf\workspace\admin.astaf.de\protected\views\veranstaltung\create.php:16)
+Stack trace:
+#0 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(870): VeranstaltungController->renderFile()
+#1 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(783): VeranstaltungController->renderPartial()
+#2 D:\Projects\Astaf\workspace\admin.astaf.de\protected\controllers\VeranstaltungController.php(70): VeranstaltungController->render()
+#3 D:\Projects\Astaf\workspace\yii\framework\web\actions\CInlineAction.php(50): VeranstaltungController->actionCreate()
+#4 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(309): CInlineAction->runWithParams()
+#5 D:\Projects\Astaf\workspace\yii\framework\web\filters\CFilterChain.php(134): VeranstaltungController->runAction()
+#6 D:\Projects\Astaf\workspace\yii\framework\web\filters\CFilter.php(41): CFilterChain->run()
+#7 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(1146): CAccessControlFilter->filter()
+#8 D:\Projects\Astaf\workspace\yii\framework\web\filters\CInlineFilter.php(59): VeranstaltungController->filterAccessControl()
+#9 D:\Projects\Astaf\workspace\yii\framework\web\filters\CFilterChain.php(131): CInlineFilter->filter()
+#10 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(292): CFilterChain->run()
+#11 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(266): VeranstaltungController->runActionWithFilters()
+#12 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(276): VeranstaltungController->run()
+#13 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(135): CWebApplication->runController()
+#14 D:\Projects\Astaf\workspace\yii\framework\base\CApplication.php(162): CWebApplication->processRequest()
+#15 D:\Projects\Astaf\workspace\admin.astaf.de\index.php(13): CWebApplication->run()
+REQUEST_URI=/admin.astaf.de/index.php?r=veranstaltung/create
+in D:\Projects\Astaf\workspace\admin.astaf.de\protected\views\veranstaltung\create.php (16)
+in D:\Projects\Astaf\workspace\admin.astaf.de\protected\controllers\VeranstaltungController.php (70)
+in D:\Projects\Astaf\workspace\admin.astaf.de\index.php (13)
+2012/04/28 13:22:31 [error] [system.db.CDbCommand] CDbCommand::fetchAll fehlgeschlagen: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'astaf.tbl_audit_trail' doesn't exist. Der SQL-Ausdruck war: SHOW COLUMNS FROM `tbl_audit_trail`.
+in D:\Projects\Astaf\workspace\admin.astaf.de\protected\modules\auditTrail\controllers\AdminController.php (10)
+in D:\Projects\Astaf\workspace\admin.astaf.de\index.php (13)
+2012/04/28 13:22:31 [error] [exception.CDbException] exception 'CDbException' with message 'Die Tabelle "tbl_audit_trail" für die ActiveRecord-Klasse "AuditTrail" kann nicht in der Datenbank gefunden werden.' in D:\Projects\Astaf\workspace\yii\framework\db\ar\CActiveRecord.php:2264
+Stack trace:
+#0 D:\Projects\Astaf\workspace\yii\framework\db\ar\CActiveRecord.php(379): CActiveRecordMetaData->__construct(Object(AuditTrail))
+#1 D:\Projects\Astaf\workspace\yii\framework\db\ar\CActiveRecord.php(394): CActiveRecord::model('AuditTrail')
+#2 D:\Projects\Astaf\workspace\yii\framework\db\ar\CActiveRecord.php(78): CActiveRecord->getMetaData()
+#3 D:\Projects\Astaf\workspace\admin.astaf.de\protected\modules\auditTrail\controllers\AdminController.php(10): CActiveRecord->__construct('search')
+#4 D:\Projects\Astaf\workspace\yii\framework\web\actions\CInlineAction.php(50): AdminController->actionAdmin()
+#5 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(309): CInlineAction->runWithParams(Array)
+#6 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(287): CController->runAction(Object(CInlineAction))
+#7 D:\Projects\Astaf\workspace\yii\framework\web\CController.php(266): CController->runActionWithFilters(Object(CInlineAction), Array)
+#8 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(276): CController->run('')
+#9 D:\Projects\Astaf\workspace\yii\framework\web\CWebApplication.php(135): CWebApplication->runController('auditTrail/admi...')
+#10 D:\Projects\Astaf\workspace\yii\framework\base\CApplication.php(162): CWebApplication->processRequest()
+#11 D:\Projects\Astaf\workspace\admin.astaf.de\index.php(13): CApplication->run()
+#12 {main}
+REQUEST_URI=/admin.astaf.de/index.php?r=auditTrail/admin
+HTTP_REFERER=http://dev.astaf.de:90/admin.astaf.de/index.php?r=auditTrail
+---
diff --git a/protected/tests/functional/SiteTest.php b/protected/tests/functional/SiteTest.php
index cb9727c..a7e2996 100644
--- a/protected/tests/functional/SiteTest.php
+++ b/protected/tests/functional/SiteTest.php
@@ -1,9 +1,7 @@
<?php
-class SiteTest extends WebTestCase
-{
- public function testIndex()
- {
+class SiteTest extends WebTestCase {
+ public function testIndex() {
$this->open('');
$this->assertTextPresent('Welcome');
}
diff --git a/protected/views/veranstaltung/_form.php b/protected/views/veranstaltung/_form.php
new file mode 100644
index 0000000..10eb6c9
--- /dev/null
+++ b/protected/views/veranstaltung/_form.php
@@ -0,0 +1,98 @@
+<div class="form">
+
+<?php $form=$this->beginWidget('CActiveForm', array(
+ 'id'=>'veranstaltung-form',
+ 'enableAjaxValidation'=>false,
+)); ?>
+
+ <?php $this->renderPartial('/common/_required_fields_text'); ?>
+
+ <?php echo $form->errorSummary($model); ?>
+<?php echo Yii::app()->params["start_datetime"]?>
+ <div class="row">
+ <?php echo $form->labelEx($model,'verein_id'); ?>
+ <?php echo $form->dropDownList($model, "verein_id", CHtml::listData($vereine, "id", "name"), array('empty' => '-- Bitte Verein wählen --')); ?>
+ <?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'); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->labelEx($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_datetime"],
+ 'maxDate'=>Yii::app()->params["end_datetime"]
+ ),
+ 'htmlOptions'=>array(
+ 'style'=>'height:20px;'
+ ),
+ ));
+ ?>
+ <?php echo $form->error($model,'startzeit'); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->labelEx($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_datetime"],
+ 'maxDate'=>Yii::app()->params["end_datetime"]
+ ),
+ 'htmlOptions'=>array(
+ 'style'=>'height:20px;'
+ ),
+ ));
+ ?>
+ <?php echo $form->error($model,'endzeit'); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->labelEx($model,'beschreibung'); ?>
+ <?php $this->widget('application.extensions.tinymce.ETinyMce',
+ array(
+ 'name'=>'beschreibung',
+ "value"=>$model->beschreibung,
+ 'useSwitch' => false,
+ 'editorTemplate'=>'simple',
+ "language"=>"de",
+ "height"=>"200px",
+ )
+ );
+ ?>
+ <?php echo $form->error($model,'beschreibung'); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->labelEx($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->checkbox($model,'published'); ?>
+ <?php echo $form->error($model,'published'); ?>
+ </div>
+
+ <div class="row buttons">
+ <?php echo CHtml::submitButton($model->isNewRecord ? 'Erstellen' : 'Speichern'); ?>
+ </div>
+
+<?php $this->endWidget(); ?>
+
+</div><!-- form --> \ No newline at end of file
diff --git a/protected/views/veranstaltung/_search.php b/protected/views/veranstaltung/_search.php
new file mode 100644
index 0000000..b4ec2ed
--- /dev/null
+++ b/protected/views/veranstaltung/_search.php
@@ -0,0 +1,54 @@
+<div class="wide form">
+
+<?php $form=$this->beginWidget('CActiveForm', array(
+ 'action'=>Yii::app()->createUrl($this->route),
+ 'method'=>'get',
+)); ?>
+
+ <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>
+
+ <div class="row">
+ <?php echo $form->label($model,'startzeit'); ?>
+ <?php echo $form->textField($model,'startzeit'); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->label($model,'endzeit'); ?>
+ <?php echo $form->textField($model,'endzeit'); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->label($model,'beschreibung'); ?>
+ <?php echo $form->textArea($model,'beschreibung',array('rows'=>6, 'cols'=>50)); ?>
+ </div>
+
+ <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'); ?>
+ </div>
+
+ <div class="row buttons">
+ <?php echo CHtml::submitButton('Search'); ?>
+ </div>
+
+<?php $this->endWidget(); ?>
+
+</div><!-- search-form --> \ No newline at end of file
diff --git a/protected/views/veranstaltung/_view.php b/protected/views/veranstaltung/_view.php
new file mode 100644
index 0000000..daa818a
--- /dev/null
+++ b/protected/views/veranstaltung/_view.php
@@ -0,0 +1,38 @@
+<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/veranstaltung/create.php b/protected/views/veranstaltung/create.php
new file mode 100644
index 0000000..ea42d4c
--- /dev/null
+++ b/protected/views/veranstaltung/create.php
@@ -0,0 +1,16 @@
+<?php
+$this->breadcrumbs=array(
+ 'Veranstaltungen'=>array('index'),
+ 'Veranstaltung erstellen',
+);
+
+$this->menu=array(
+ array('label'=>'Veranstaltungen', 'url'=>array('index')),
+);
+?>
+
+<h1>Veranstaltung erstellen</h1>
+
+<?php echo $this->renderPartial('_form', array('model'=>$model,
+ 'vereine'=>$vereine,
+ 'standorte'=>$standorte)); ?> \ No newline at end of file
diff --git a/protected/views/veranstaltung/index.php b/protected/views/veranstaltung/index.php
new file mode 100644
index 0000000..f058e2e
--- /dev/null
+++ b/protected/views/veranstaltung/index.php
@@ -0,0 +1,35 @@
+<?php
+$this->breadcrumbs=array(
+ 'Veranstaltungen',
+);
+
+$this->menu=array(
+ array('label'=>'Veranstaltung erstellen', 'url'=>array('create')),
+);?>
+
+<h1>Veranstaltungen</h1>
+
+<?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',
+ array('header'=>'Verein', 'value'=>'$data->verein->name'),
+ 'titel',
+ 'startzeit',
+ 'endzeit',
+ array('header'=>'Standort', 'value'=>'($data->standort) ? $data->standort->name : "Kein Standort"'),
+ array('header'=>'Öffentlich',
+ '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/veranstaltung/update.php b/protected/views/veranstaltung/update.php
new file mode 100644
index 0000000..8813aae
--- /dev/null
+++ b/protected/views/veranstaltung/update.php
@@ -0,0 +1,18 @@
+<?php
+$this->breadcrumbs=array(
+ 'Veranstaltungen'=>array('index'),
+ '"'.$model->titel.'" bearbeiten'
+);
+
+$this->menu=array(
+ array('label'=>'Veranstaltungen', 'url'=>array('index')),
+ array('label'=>'Veranstaltung erstellen', 'url'=>array('create')),
+ array('label'=>'Veranstaltung anzeigen', 'url'=>array('view', 'id'=>$model->id)),
+);
+?>
+
+<h1>"<?php echo $model->titel; ?>" bearbeiten</h1>
+
+<?php echo $this->renderPartial('_form', array('model'=>$model,
+ 'vereine'=>$vereine,
+ 'standorte'=>$standorte)); ?> \ No newline at end of file
diff --git a/protected/views/veranstaltung/view.php b/protected/views/veranstaltung/view.php
new file mode 100644
index 0000000..aa48d41
--- /dev/null
+++ b/protected/views/veranstaltung/view.php
@@ -0,0 +1,28 @@
+<?php
+$this->breadcrumbs=array(
+ 'Veranstaltungen'=>array('index'),
+ $model->titel,
+);
+
+$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?')),
+ );
+?>
+
+<h1><?php echo $model->titel; ?></h1>
+
+<?php $this->widget('zii.widgets.CDetailView', array(
+ 'data'=>$model,
+ 'attributes'=>array(
+ array('label'=>'Verein', 'value'=>($model->verein) ? $model->verein->name : "-"),
+ 'titel',
+ 'startzeit',
+ 'endzeit',
+ 'beschreibung:html',
+ array('label'=>'Standort', 'value'=>($model->standort) ? $model->standort->name : "-"),
+ array('label'=>'Öfentlich', 'value'=>CHtml::image($model->published ? "images/ok.png" : "images/nok.png", $model->published ? "ok.png" : "nok.png"), 'type'=>'raw'),
+ ),
+)); ?>