summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Geiger2011-09-22 17:56:43 +0200
committerBjörn Geiger2011-09-22 17:56:43 +0200
commit54da4fa07b925badf406c8fae8daa48d26224d41 (patch)
treee311d0719496a09762267bcec56629e502b57d47
parentweitere Korrektur (diff)
downloadpoolctrl-54da4fa07b925badf406c8fae8daa48d26224d41.tar.gz
poolctrl-54da4fa07b925badf406c8fae8daa48d26224d41.tar.xz
poolctrl-54da4fa07b925badf406c8fae8daa48d26224d41.zip
Repeat Optionen werden nun in der DB gespeichert, achtung DB Update
-rwxr-xr-xapplication/controllers/EventController.php119
-rwxr-xr-xapplication/forms/EventAdd.php89
-rwxr-xr-xapplication/forms/EventEdit.php105
-rwxr-xr-xapplication/models/DbTable/Repeatend.php (renamed from application/models/DbTable/Eventtype.php)4
-rwxr-xr-xapplication/models/DbTable/Repeattype.php20
-rwxr-xr-xapplication/models/DbTable/Runningtype.php20
-rwxr-xr-xapplication/models/Event.php47
-rwxr-xr-xapplication/models/EventMapper.php12
-rwxr-xr-xapplication/models/Repeatend.php (renamed from application/models/Eventtype.php)17
-rwxr-xr-xapplication/models/RepeatendMapper.php (renamed from application/models/EventtypeMapper.php)50
-rwxr-xr-xapplication/models/Repeattype.php110
-rwxr-xr-xapplication/models/RepeattypeMapper.php138
-rwxr-xr-xapplication/models/Runningtype.php111
-rwxr-xr-xapplication/models/RunningtypeMapper.php138
-rwxr-xr-xpublic/media/js/script.js57
-rwxr-xr-xsetup/poolctrl.sql54
-rwxr-xr-xsetup/poolctrl_data.sql12
17 files changed, 890 insertions, 213 deletions
diff --git a/application/controllers/EventController.php b/application/controllers/EventController.php
index ce115c5..5e3901b 100755
--- a/application/controllers/EventController.php
+++ b/application/controllers/EventController.php
@@ -123,7 +123,10 @@ class EventController extends Zend_Controller_Action
}
}
}
-
+ $repeatendMapper = new Application_Model_RepeatendMapper();
+ $repeatendlist = $repeatendMapper->fetchAll();
+ $repeattypeMapper = new Application_Model_RepeattypeMapper();
+ $repeattypelist = $repeattypeMapper->fetchAll();
$add = $this->getRequest()->getParam("add");
if($this->getRequest()->getParam('start')) {
$start = date ('m/d/Y H:i', strtotime($this->getRequest()->getParam('start')));
@@ -144,12 +147,12 @@ class EventController extends Zend_Controller_Action
}
}
if(isset($this->userIDsNamespace['poolID'])) {
- $addForm = new Application_Form_EventAdd(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'start' => $start, 'end' => $end, 'defaultEventCategoryID' => $defaultEventCategoryID, 'poolID' => $this->userIDsNamespace['poolID']));
+ $addForm = new Application_Form_EventAdd(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'repeatendlist' => $repeatendlist, 'repeattypelist' => $repeattypelist, 'start' => $start, 'end' => $end, 'defaultEventCategoryID' => $defaultEventCategoryID, 'poolID' => $this->userIDsNamespace['poolID']));
} else {
- $addForm = new Application_Form_EventAdd(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'poollist' => $poollist, 'start' => $start, 'end' => $end, 'defaultEventCategoryID' => $defaultEventCategoryID));
+ $addForm = new Application_Form_EventAdd(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'repeatendlist' => $repeatendlist, 'repeattypelist' => $repeattypelist, 'poollist' => $poollist, 'start' => $start, 'end' => $end, 'defaultEventCategoryID' => $defaultEventCategoryID));
}
} else {
- $addForm = new Application_Form_EventAdd(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'start' => $start, 'end' => $end, $this->getRequest()->getParams()));
+ $addForm = new Application_Form_EventAdd(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'repeatendlist' => $repeatendlist, 'repeattypelist' => $repeattypelist, 'start' => $start, 'end' => $end, $this->getRequest()->getParams()));
$params = $this->getRequest()->getParams();
if(!isset($params['pbs_poolID'])) {
$params['pbs_poolID'] = $this->userIDsNamespace['poolID'];
@@ -167,10 +170,10 @@ class EventController extends Zend_Controller_Action
} else {
unset($params['end']);
}
- if($params['repeatEnd']) {
- $params['repeatEnd'] = date ('Y-m-d H:i', strtotime($this->getRequest()->getParam('repeatEnd')));
+ if($params['repeatdate']) {
+ $params['repeatdate'] = date ('Y-m-d H:i', strtotime($this->getRequest()->getParam('repeatdate')));
} else {
- unset($params['repeatEnd']);
+ unset($params['repeatdate']);
$params['repeat'] = 0;
}
}
@@ -232,10 +235,10 @@ class EventController extends Zend_Controller_Action
$eventcategories[$category->getID()] = $category->getTitle();
}
$eventCategory = $eventcategories[$event->getCategory()];
- $eventtypeMapper = new Application_Model_EventtypeMapper();
- $eventtype = $eventtypeMapper->findBy(array("title" => $eventCategory));
+ $runningtypeMapper = new Application_Model_RunningtypeMapper();
+ $runningtype = $runningtypeMapper->findBy(array("title" => $eventCategory));
$event->setRunning(true);
- $event->setRunningtype($eventtype[0]->getID());
+ $event->setRunningtype($runningtype[0]->getID());
} else {
$event->setRunning(false);
}
@@ -252,6 +255,9 @@ class EventController extends Zend_Controller_Action
if($event->getImmediate()) {
$this->runEvent($event, $this->userIDsNamespace['apikey']);
}
+ if($event->repeat) {
+ repeatEvent($event);
+ }
$this->_redirect('/event/');
}
}
@@ -355,10 +361,14 @@ class EventController extends Zend_Controller_Action
$this->_redirect('/');
}
}
+ $repeatendMapper = new Application_Model_RepeatendMapper();
+ $repeatendlist = $repeatendMapper->fetchAll();
+ $repeattypeMapper = new Application_Model_RepeattypeMapper();
+ $repeattypelist = $repeattypeMapper->fetchAll();
$save = $this->getRequest()->getParam("save");
if (isset($save)){
$params = $this->getRequest()->getParams();
- $editForm = new Application_Form_EventEdit(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'poollist' => $poollist, 'params' => $params));
+ $editForm = new Application_Form_EventEdit(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'poollist' => $poollist, 'repeattypelist' => $repeattypelist, 'repeatendlist' => $repeatendlist, 'params' => $params));
if ($editForm->isValid($params)) {
$params['start'] = date ('Y-m-d H:i', strtotime($this->getRequest()->getParam('start')));
if($params['end']) {
@@ -366,10 +376,10 @@ class EventController extends Zend_Controller_Action
} else {
unset($params['end']);
}
- if($params['repeatEnd']) {
- $params['repeatEnd'] = date ('Y-m-d H:i', strtotime($this->getRequest()->getParam('repeatEnd')));
+ if($params['repeatdate']) {
+ $params['repeatdate'] = date ('Y-m-d H:i', strtotime($this->getRequest()->getParam('repeatdate')));
} else {
- unset($params['repeatEnd']);
+ unset($params['repeatdate']);
$params['repeat'] = 0;
}
if($event->getPbs_bootmenuID()) {
@@ -449,8 +459,17 @@ class EventController extends Zend_Controller_Action
$this->getRequest()->setParam('end', $event->getEnd());
}
$this->getRequest()->setParam('repeat', $event->getRepeat());
- if($event->getRepeatEnd()) {
- $this->getRequest()->setParam('repeatEnd', $event->getRepeatEnd());
+ if($event->getRepeattype()) {
+ $this->getRequest()->setParam('repeattype', $event->getRepeattype());
+ }
+ if($event->getRepeatend()) {
+ $this->getRequest()->setParam('repeatend', $event->getRepeatend());
+ }
+ if($event->getRepeatdate()) {
+ $this->getRequest()->setParam('repeatdate', $event->getRepeatdate());
+ }
+ if($event->getRepeatings()) {
+ $this->getRequest()->setParam('repeatings', $event->getRepeatings());
}
$this->getRequest()->setParam('participants', $event->getParticipants());
$this->getRequest()->setParam('category', $event->getCategory());
@@ -459,7 +478,7 @@ class EventController extends Zend_Controller_Action
$this->getRequest()->setParam('pbs_bootosID', $event->getPbs_bootosID());
$this->getRequest()->setParam('pbs_membershipID', $event->getPbs_membershipID());
$params = $this->getRequest()->getParams();
- $editForm = new Application_Form_EventEdit(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'poollist' => $poollist , 'params' => $params));
+ $editForm = new Application_Form_EventEdit(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'poollist' => $poollist, 'repeattypelist' => $repeattypelist, 'repeatendlist' => $repeatendlist, 'params' => $params));
}
$this->view->editForm = $editForm;
$this->view->params = $params;
@@ -685,7 +704,7 @@ class EventController extends Zend_Controller_Action
} else {
$apikey = $this->_request->getParam('apikey');
}
- $eventtypeMapper = new Application_Model_EventtypeMapper();
+ $runningtypeMapper = new Application_Model_RunningtypeMapper();
$results = array();
foreach($eventlist as $event) {
$run = false;
@@ -797,10 +816,10 @@ class EventController extends Zend_Controller_Action
exit;
}
$results[$event->getTitle()] = $result;
- $result = $eventtypeMapper->findBy(array("title" => "boot"));
- $eventtypeBoot = $result[0];
+ $result = $runningtypeMapper->findBy(array("title" => "boot"));
+ $runningtypeBoot = $result[0];
$event->setRunning(true);
- $event->setRunningtype($eventtypeBoot->getID());
+ $event->setRunningtype($runningtypeBoot->getID());
try {
$this->eventMapper->save($event);
} catch(Zend_Exception $e)
@@ -818,10 +837,10 @@ class EventController extends Zend_Controller_Action
exit;
}
$results[$event->getTitle()] = $result;
- $result = $eventtypeMapper->findBy(array("title" => "shutdown"));
- $eventtypeShutdown = $result[0];
+ $result = $runningtypeMapper->findBy(array("title" => "shutdown"));
+ $runningtypeShutdown = $result[0];
$event->setRunning(true);
- $event->setRunningtype($eventtypeShutdown->getID());
+ $event->setRunningtype($runningtypeShutdown->getID());
try {
$this->eventMapper->save($event);
} catch(Zend_Exception $e)
@@ -853,22 +872,22 @@ class EventController extends Zend_Controller_Action
$this->_helper->viewRenderer->setNoRender();
$eventreportMapper = new Application_Model_EventreportMapper();
- $eventtypeMapper = new Application_Model_EventtypeMapper();
+ $runningtypeMapper = new Application_Model_RunningtypeMapper();
$eventBootNames = array();
$eventShutdownNames = array();
$results = array();
- $result1 = $eventtypeMapper->findBy(array("title" => "boot"));
- $result2 = $eventtypeMapper->findBy(array("title" => "shutdown"));
- $eventtypeBoot = $result1[0];
- $eventtypeShutdown = $result2[0];
+ $result1 = $runningtypeMapper->findBy(array("title" => "boot"));
+ $result2 = $runningtypeMapper->findBy(array("title" => "shutdown"));
+ $runningtypeBoot = $result1[0];
+ $runningtypeShutdown = $result2[0];
$resultShortcutName = 'result shortcut';
$errorsName = 'clients errors';
$events = $this->eventMapper->findBy(array('running' => 1));
foreach($events as $event) {
- if($event->getRunningtype() == $eventtypeBoot->getID()) {
+ if($event->getRunningtype() == $runningtypeBoot->getID()) {
$eventBootNames[] = $event->getTitle();
- } else if($event->getRunningtype() == $eventtypeShutdown->getID()) {
+ } else if($event->getRunningtype() == $runningtypeShutdown->getID()) {
$eventShutdownNames[] = $event->getTitle();
}
}
@@ -916,7 +935,7 @@ class EventController extends Zend_Controller_Action
if($eventResult->$resultShortcutName == "failed") {
$eventreport->setErrors(json_encode($eventResult->$errorsName));
}
- $eventreport->setType($eventtypeBoot->getID());
+ $eventreport->setType($runningtypeBoot->getID());
try {
$eventreportMapper->save($eventreport);
} catch(Zend_Exception $e)
@@ -979,7 +998,7 @@ class EventController extends Zend_Controller_Action
if($eventResult->$resultShortcutName == "failed") {
$eventreport->setErrors(json_encode($eventResult->$errorsName));
}
- $eventreport->setType($eventtypeShutdown->getID());
+ $eventreport->setType($runningtypeShutdown->getID());
try {
$eventreportMapper->save($eventreport);
} catch(Zend_Exception $e)
@@ -1022,16 +1041,16 @@ class EventController extends Zend_Controller_Action
$this->eventMapper->find($eventID, $event);
$eventreportMapper = new Application_Model_EventreportMapper();
$reportlist = $eventreportMapper->findBy(array("eventID" => $eventID), false, array('created' => 'DESC'));
- $eventtypeMapper = new Application_Model_EventtypeMapper();
- $eventtypes = array();
- $result = $eventtypeMapper->fetchAll();
+ $runningtypeMapper = new Application_Model_RunningtypeMapper();
+ $runningtypes = array();
+ $result = $runningtypeMapper->fetchAll();
if(count($result) > 0) {
foreach($result as $type) {
- $eventtypes[$type->getID()] = $type->getTitle();
+ $runningtypes[$type->getID()] = $type->getTitle();
}
}
for($i = 0; $i < count($reportlist); $i++) {
- $reportType = $eventtypes[$reportlist[$i]->getType()];
+ $reportType = $runningtypes[$reportlist[$i]->getType()];
$reportlist[$i]->setType($reportType);
}
@@ -1152,7 +1171,7 @@ class EventController extends Zend_Controller_Action
break;
}
- $eventtypeMapper = new Application_Model_EventtypeMapper();
+ $runningtypeMapper = new Application_Model_RunningtypeMapper();
if($boot) {
$bootOsRequest = "bootosid=" . $event->getPbs_bootosID();
$bootOsApiResult = PostToHost($this->pbs2host, $this->config['pbs2']['getbootoss'] . $apikey, 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'poolctrl', $bootOsRequest);
@@ -1186,10 +1205,10 @@ class EventController extends Zend_Controller_Action
exit;
}
$results[$event->getTitle()] = $result;
- $result = $eventtypeMapper->findBy(array("title" => "boot"));
- $eventtypeBoot = $result[0];
+ $result = $runningtypeMapper->findBy(array("title" => "boot"));
+ $runningtypeBoot = $result[0];
$event->setRunning(true);
- $event->setRunningtype($eventtypeBoot->getID());
+ $event->setRunningtype($runningtypeBoot->getID());
try {
$this->eventMapper->save($event);
} catch(Zend_Exception $e)
@@ -1207,10 +1226,10 @@ class EventController extends Zend_Controller_Action
exit;
}
$results[$event->getTitle()] = $result;
- $result = $eventtypeMapper->findBy(array("title" => "shutdown"));
- $eventtypeShutdown = $result[0];
+ $result = $runningtypeMapper->findBy(array("title" => "shutdown"));
+ $runningtypeShutdown = $result[0];
$event->setRunning(true);
- $event->setRunningtype($eventtypeShutdown->getID());
+ $event->setRunningtype($runningtypeShutdown->getID());
try {
$this->eventMapper->save($event);
} catch(Zend_Exception $e)
@@ -1237,7 +1256,7 @@ class EventController extends Zend_Controller_Action
break;
}
$eventreportMapper = new Application_Model_EventreportMapper();
- $eventtypeMapper = new Application_Model_EventtypeMapper();
+ $runningtypeMapper = new Application_Model_RunningtypeMapper();
if($boot) {
$data = array(
'type' => 'getBootState',
@@ -1276,7 +1295,7 @@ class EventController extends Zend_Controller_Action
if($eventResult->$resultShortcutName == "failed") {
$eventreport->setErrors(json_encode($eventResult->$errorsName));
}
- $eventreport->setType($eventtypeBoot->getID());
+ $eventreport->setType($runningtypeBoot->getID());
try {
$eventreportMapper->save($eventreport);
} catch(Zend_Exception $e)
@@ -1333,7 +1352,7 @@ class EventController extends Zend_Controller_Action
if($eventResult->$resultShortcutName == "failed") {
$eventreport->setErrors(json_encode($eventResult->$errorsName));
}
- $eventreport->setType($eventtypeShutdown->getID());
+ $eventreport->setType($runningtypeShutdown->getID());
try {
$eventreportMapper->save($eventreport);
} catch(Zend_Exception $e)
@@ -1354,4 +1373,8 @@ class EventController extends Zend_Controller_Action
}
}
}
+
+ private function repeatEvent(Application_Model_Event $event) {
+ switch($event->getR)
+ }
} \ No newline at end of file
diff --git a/application/forms/EventAdd.php b/application/forms/EventAdd.php
index a2719bf..14e5e18 100755
--- a/application/forms/EventAdd.php
+++ b/application/forms/EventAdd.php
@@ -5,6 +5,8 @@ class Application_Form_EventAdd extends Zend_Form
private $membershiplist;
private $bootoslist;
private $poollist;
+ private $repeattypelist;
+ private $repeatendlist;
private $eventcategorylist;
private $start;
private $end;
@@ -41,6 +43,25 @@ class Application_Form_EventAdd extends Zend_Form
return $this->poollist;
}
+ public function setRepeattypelist($repeattypelist){
+ $this->repeattypelist = $repeattypelist;
+ return $this;
+
+ }
+
+ public function getRepeattypelist(){
+ return $this->repeattypelist;
+ }
+
+ public function setRepeatendlist($repeatendlist){
+ $this->repeatendlist = $repeatendlist;
+ return $this;
+ }
+
+ public function getRepeatendlist(){
+ return $this->repeatendlist;
+ }
+
public function getEventcategorylist()
{
return $this->eventcategorylist;
@@ -168,50 +189,36 @@ class Application_Form_EventAdd extends Zend_Form
'value'=>array(0,1),
));
- $this->addElement('select', 'repeatType', array(
- 'multioptions' => array(
- 'day' => 'Daily',
- 'week' => 'Once a week',
- 'week2' => 'Every couple of weeks',
- 'month' => 'Every month',
- ),
- 'required' => false,
- 'label' => 'Repeat Type:',
- ));
+ $repeattypefield = $this->createElement('select','repeattype');
+ $repeattypefield ->setLabel('Repeat Type:');
- /*
- * This is the multiCheckbox to select special days.
- * To do: create a css-file...
- *
- $this->addElement('multiCheckbox', 'repeatDays', array(
- 'multiOptions' => array(
- 'mon' => 'Monday',
- 'tue' => 'Thuestay',
- 'wed' => 'Wednesday',
- 'thu' => 'Thursday',
- 'fri' => 'Friday',
- 'sat' => 'Saturday',
- 'sun' => 'Sunday',
- ),
- 'onchange' => '',
- 'required' => false,
- 'label' => 'Repeat days:',
- 'value'=>array(0,1),
- ));
- */
-
+ if(count($this->repeattypelist)>0){
+ foreach($this->repeattypelist as $type => $t){
+ $title = $t->getTitle();
+ $id = $t->getID();
+ $repeattypefield->addMultiOption($id, $title);
+ }
+ }
- $this->addElement('select', 'repeatOption', array(
- 'multioptions' => array(
- 'after' => 'After',
- 'date' => 'Date',
- ),
- 'required' => false,
- 'label' => 'Repeat End:',
- 'onchange' => 'repeatOptionChanged("repeatOption");',
- ));
+ $repeattypefield->setRegisterInArrayValidator(false);
+ $this->addElement($repeattypefield);
+
+ $repeatendfield = $this->createElement('select','repeatend');
+ $repeatendfield ->setLabel('Repeat End:');
+
+ if(count($this->$repeatendlist)>0){
+ foreach($this->$repeatendlist as $end => $e){
+ $title = $e->getTitle();
+ $id = $e->getID();
+ $repeatendfield->addMultiOption($id, $title);
+ }
+ }
+
+ $repeatendfield->setRegisterInArrayValidator(false);
+ $repeatendfield->setAttrib('onchange', 'repeatendChanged("repeatend");');
+ $this->addElement($repeattypefield);
- $this->addElement('text', 'repeatEnd', array(
+ $this->addElement('text', 'repeatdate', array(
'filters' => array('StringTrim'),
'validators' => array(
array('StringLength', false, array(0, 16)),
diff --git a/application/forms/EventEdit.php b/application/forms/EventEdit.php
index fcacf9a..300d766 100755
--- a/application/forms/EventEdit.php
+++ b/application/forms/EventEdit.php
@@ -5,6 +5,8 @@ class Application_Form_EventEdit extends Zend_Form
private $membershiplist;
private $bootoslist;
private $poollist;
+ private $repeattypelist;
+ private $repeatendlist;
private $eventcategorylist;
private $params;
@@ -35,6 +37,25 @@ class Application_Form_EventEdit extends Zend_Form
return $this->poollist;
}
+ public function setRepeattypelist($repeattypelist){
+ $this->repeattypelist = $repeattypelist;
+ return $this;
+
+ }
+
+ public function getRepeattypelist(){
+ return $this->repeattypelist;
+ }
+
+ public function setRepeatendlist($repeatendlist){
+ $this->repeatendlist = $repeatendlist;
+ return $this;
+ }
+
+ public function getRepeatendlist(){
+ return $this->repeatendlist;
+ }
+
public function getEventcategorylist()
{
return $this->eventcategorylist;
@@ -142,66 +163,76 @@ class Application_Form_EventEdit extends Zend_Form
));
}
- if(isset($this->params['repeatType'])) {
- $this->addElement('select', 'repeatType', array(
- 'multioptions' => array(
- 'day' => 'Daily',
- 'week' => 'Once a week',
- 'week2' => 'Every couple of weeks',
- 'month' => 'Every month',
- ),
- 'required' => false,
- 'value' => $this->params['repeatType'],
- 'label' => 'Repeat Type:',
- ));
- } else {
- $this->addElement('select', 'repeatType', array(
- 'multioptions' => array(
- 'day' => 'Daily',
- 'week' => 'Once a week',
- 'week2' => 'Every couple of weeks',
- 'month' => 'Every month',
- ),
- 'required' => false,
- 'label' => 'Repeat Type:',
- ));
+ $repeattypefield = $this->createElement('select','repeattype');
+ $repeattypefield ->setLabel('Repeat Type:');
+
+ if(count($this->repeattypelist)>0){
+ foreach($this->repeattypelist as $type => $t){
+ $title = $t->getTitle();
+ $id = $t->getID();
+ $repeattypefield->addMultiOption($id, $title);
+ }
+ }
+
+ $repeattypefield->setRegisterInArrayValidator(false);
+ if(isset($this->params['repeattype'])) {
+ $repeattypefield->setValue($this->params['repeattype']);
+ }
+ $this->addElement($repeattypefield);
+
+ $repeatendfield = $this->createElement('select','repeatend');
+ $repeatendfield ->setLabel('Repeat End:');
+
+ if(count($this->$repeatendlist)>0){
+ foreach($this->$repeatendlist as $end => $e){
+ $title = $e->getTitle();
+ $id = $e->getID();
+ $repeatendfield->addMultiOption($id, $title);
+ }
+ }
+
+ $repeatendfield->setRegisterInArrayValidator(false);
+ $repeatendfield->setAttrib('onchange', 'repeatendChanged("repeatend");');
+ if(isset($this->params['repeatend'])) {
+ $repeatendfield->setValue($this->params['repeatend']);
}
+ $this->addElement($repeattypefield);
- if(isset($this->params['repeatOption'])) {
- $this->addElement('select', 'repeatOption', array(
+ if(isset($this->params['repeatend'])) {
+ $this->addElement('select', 'repeatend', array(
'multioptions' => array(
- 'after' => 'After',
- 'date' => 'Date',
+ '1' => 'After',
+ '2' => 'Date',
),
'required' => false,
'label' => 'Repeat End:',
- 'value' => $this->params['repeatOption'],
- 'onchange' => 'repeatOptionChanged("repeatOption");',
+ 'value' => $this->params['repeatend'],
+ 'onchange' => 'repeatendChanged("repeatend");',
));
} else {
- $this->addElement('select', 'repeatOption', array(
+ $this->addElement('select', 'repeatend', array(
'multioptions' => array(
- 'after' => 'After',
- 'date' => 'Date',
+ '1' => 'After',
+ '2' => 'Date',
),
'required' => false,
'label' => 'Repeat End:',
- 'onchange' => 'repeatOptionChanged("repeatOption");',
+ 'onchange' => 'repeatendChanged("repeatend");',
));
}
- if(isset($this->params['repeatEnd'])) {
- $this->addElement('text', 'repeatEnd', array(
+ if(isset($this->params['repeatdate'])) {
+ $this->addElement('text', 'repeatdate', array(
'filters' => array('StringTrim'),
'validators' => array(
array('StringLength', false, array(0, 16)),
),
'required' => false,
'label' => 'Repeat End Date:',
- 'value' => $this->params['repeatEnd'],
+ 'value' => $this->params['repeatdate'],
));
} else {
- $this->addElement('text', 'repeatEnd', array(
+ $this->addElement('text', 'repeatdate', array(
'filters' => array('StringTrim'),
'validators' => array(
array('StringLength', false, array(0, 16)),
diff --git a/application/models/DbTable/Eventtype.php b/application/models/DbTable/Repeatend.php
index 6c54913..d39a481 100755
--- a/application/models/DbTable/Eventtype.php
+++ b/application/models/DbTable/Repeatend.php
@@ -10,10 +10,10 @@
* General information about OpenSLX can be found at http://openslx.org/
*/
-class Application_Model_DbTable_Eventtype extends Zend_Db_Table_Abstract
+class Application_Model_DbTable_Repeatend extends Zend_Db_Table_Abstract
{
- protected $_name = 'poolctrl_eventtype';
+ protected $_name = 'poolctrl_repeatend';
}
diff --git a/application/models/DbTable/Repeattype.php b/application/models/DbTable/Repeattype.php
new file mode 100755
index 0000000..7c3e7b3
--- /dev/null
+++ b/application/models/DbTable/Repeattype.php
@@ -0,0 +1,20 @@
+<?php
+/*
+ * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
+ * This program is free software distributed under the GPL version 2.
+ * See http://gpl.openslx.org/
+ *
+ * If you have any feedback please consult http://feedback.openslx.org/ and
+ * send your suggestions, praise, or complaints to feedback@openslx.org
+ *
+ * General information about OpenSLX can be found at http://openslx.org/
+ */
+
+class Application_Model_DbTable_Repeattype extends Zend_Db_Table_Abstract
+{
+
+ protected $_name = 'poolctrl_repeattype';
+
+
+}
+
diff --git a/application/models/DbTable/Runningtype.php b/application/models/DbTable/Runningtype.php
new file mode 100755
index 0000000..0ed5638
--- /dev/null
+++ b/application/models/DbTable/Runningtype.php
@@ -0,0 +1,20 @@
+<?php
+/*
+ * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
+ * This program is free software distributed under the GPL version 2.
+ * See http://gpl.openslx.org/
+ *
+ * If you have any feedback please consult http://feedback.openslx.org/ and
+ * send your suggestions, praise, or complaints to feedback@openslx.org
+ *
+ * General information about OpenSLX can be found at http://openslx.org/
+ */
+
+class Application_Model_DbTable_Runningtype extends Zend_Db_Table_Abstract
+{
+
+ protected $_name = 'poolctrl_runningtype';
+
+
+}
+
diff --git a/application/models/Event.php b/application/models/Event.php
index 76bb2dc..0b472ea 100755
--- a/application/models/Event.php
+++ b/application/models/Event.php
@@ -25,7 +25,10 @@ class Application_Model_Event
protected $_pbs_bootmenuID;
protected $_pbs_filterID;
protected $_repeat;
- protected $_repeatEnd;
+ protected $_repeattype;
+ protected $_repeatend;
+ protected $_repeatdate;
+ protected $_repeatings;
protected $_immediate;
protected $_running;
protected $_runningtype;
@@ -225,14 +228,48 @@ class Application_Model_Event
return $this;
}
- public function getRepeatEnd()
+ public function getRepeattype()
{
- return $this->_repeatEnd;
+ return $this->_repeattype;
}
- public function setRepeatEnd($_repeatEnd)
+ public function setRepeattype($_repeattype)
{
- $this->_repeatEnd = $_repeatEnd;
+ $this->_repeattype = $__repeattype;
+ return $this;
+ }
+
+
+ public function getRepeatend()
+ {
+ return $this->_repeatend;
+ }
+
+ public function setRepeatend($_repeatend)
+ {
+ $this->_repeatend = $_repeatend;
+ return $this;
+ }
+
+ public function getRepeatdate()
+ {
+ return $this->_repeatdate;
+ }
+
+ public function setRepeatdate($_repeatdate)
+ {
+ $this->_repeatdate = $_repeatdate;
+ return $this;
+ }
+
+ public function getRepeatings()
+ {
+ return $this->_repeatings;
+ }
+
+ public function setRepeatings($_repeatings)
+ {
+ $this->_repeatings = $_repeatings;
return $this;
}
diff --git a/application/models/EventMapper.php b/application/models/EventMapper.php
index 418bab8..864353c 100755
--- a/application/models/EventMapper.php
+++ b/application/models/EventMapper.php
@@ -85,7 +85,7 @@ class Application_Model_EventMapper
public function save(Application_Model_Event $event)
{
- $data = array('eventID'=> $event->getID() ,'category'=> $event->getCategory() ,'title'=> $event->getTitle(), 'pbs_membershipID'=> $event->getPbs_membershipID(),'end'=> $event->getEnd() ,'immediate'=> $event->getImmediate() ,'note'=> $event->getNote() ,'participants'=> $event->getParticipants() ,'pbs_bootosID'=> $event->getPbs_bootosID(),'pbs_poolID'=> $event->getPbs_poolID(),'repeat'=> $event->getRepeat(),'repeatEnd'=> $event->getRepeatEnd(),'start'=> $event->getStart(),'pbs_bootmenuID'=> $event->getPbs_bootmenuID(),'pbs_filterID'=> $event->getPbs_filterID(), 'running' => $event->getRunning(), 'runningtype' => $event->getRunningtype(), 'created' => $event->getCreated() );
+ $data = array('eventID'=> $event->getID() ,'category'=> $event->getCategory() ,'title'=> $event->getTitle(), 'pbs_membershipID'=> $event->getPbs_membershipID(),'end'=> $event->getEnd() ,'immediate'=> $event->getImmediate() ,'note'=> $event->getNote() ,'participants'=> $event->getParticipants() ,'pbs_bootosID'=> $event->getPbs_bootosID(),'pbs_poolID'=> $event->getPbs_poolID(),'repeat'=> $event->getRepeat(),'repeattype'=> $event->getRepeattype(),'repeatend'=> $event->getRepeatend(),'repeatdate'=> $event->getRepeatdate(),'repeatings'=> $event->getRepeatings(),'start'=> $event->getStart(),'pbs_bootmenuID'=> $event->getPbs_bootmenuID(),'pbs_filterID'=> $event->getPbs_filterID(), 'running' => $event->getRunning(), 'runningtype' => $event->getRunningtype(), 'created' => $event->getCreated() );
if (null === ($id = $event->getID()) ) {
unset($data['eventID']);
return $this->getDbTable()->insert($data);
@@ -130,7 +130,10 @@ class Application_Model_EventMapper
->setPbs_filterID($row->pbs_filterID)
->setPbs_bootmenuID($row->pbs_bootmenuID)
->setRepeat($row->repeat)
- ->setRepeatEnd($row->repeatEnd)
+ ->setRepeattype($row->repeattype)
+ ->setRepeatend($row->repeatend)
+ ->setRepeatdate($row->repeatdate)
+ ->setRepeatings($row->repeatings)
->setStart($row->start)
->setRunning($row->running)
->setCreated($row->created)
@@ -159,7 +162,10 @@ class Application_Model_EventMapper
->setPbs_filterID($row->pbs_filterID)
->setPbs_bootmenuID($row->pbs_bootmenuID)
->setRepeat($row->repeat)
- ->setRepeatEnd($row->repeatEnd)
+ ->setRepeattype($row->repeattype)
+ ->setRepeatend($row->repeatend)
+ ->setRepeatdate($row->repeatdate)
+ ->setRepeatings($row->repeatings)
->setStart($row->start)
->setRunning($row->running)
->setCreated($row->created)
diff --git a/application/models/Eventtype.php b/application/models/Repeatend.php
index fe21eeb..cabff52 100755
--- a/application/models/Eventtype.php
+++ b/application/models/Repeatend.php
@@ -10,9 +10,9 @@
* General information about OpenSLX can be found at http://openslx.org/
*/
-class Application_Model_Eventtype
+class Application_Model_Repeatend
{
- protected $_eventtypeID;
+ protected $_repeatendID;
protected $_title;
public function __construct(array $options = null)
@@ -26,7 +26,7 @@ class Application_Model_Eventtype
{
$method = 'set' . $name;
if (('mapper' == $name) || !method_exists($this, $method)) {
- throw new Exception('Invalid eventtype property');
+ throw new Exception('Invalid repeatend property');
}
$this->$method($value);
}
@@ -35,7 +35,7 @@ class Application_Model_Eventtype
{
$method = 'get' . $name;
if (('mapper' == $name) || !method_exists($this, $method)) {
- throw new Exception('Invalid eventtype property');
+ throw new Exception('Invalid repeatend property');
}
return $this->$method();
}
@@ -89,11 +89,11 @@ class Application_Model_Eventtype
public function getID()
{
- return $this->_eventtypeID;
+ return $this->_repeatendID;
}
- public function setID($_eventtypeID)
+ public function setID($_repeatendID)
{
- $this->_eventtypeID = $_eventtypeID;
+ $this->_repeatendID = $_repeatendID;
return $this;
}
@@ -107,5 +107,4 @@ class Application_Model_Eventtype
$this->_title = $_title;
return $this;
}
-}
-
+} \ No newline at end of file
diff --git a/application/models/EventtypeMapper.php b/application/models/RepeatendMapper.php
index 7116975..3af42f2 100755
--- a/application/models/EventtypeMapper.php
+++ b/application/models/RepeatendMapper.php
@@ -1,6 +1,6 @@
<?php
-class Application_Model_EventtypeMapper
+class Application_Model_RepeatendMapper
{
protected $_dbTable;
@@ -33,8 +33,8 @@ class Application_Model_EventtypeMapper
$entries = array();
if(count($result) > 0) {
foreach ($result as $row) {
- $entry = new Application_Model_Eventtype($row);
- $entry->setID($row['eventtypeID']);
+ $entry = new Application_Model_Repeatend($row);
+ $entry->setID($row['repeatendID']);
$entries[] = $entry;
}
}
@@ -66,56 +66,56 @@ class Application_Model_EventtypeMapper
public function getDbTable()
{
if (null === $this->_dbTable) {
- $this->setDbTable('Application_Model_DbTable_Eventtype');
+ $this->setDbTable('Application_Model_DbTable_Repeatend');
}
return $this->_dbTable;
}
- public function save(Application_Model_Eventtype $eventtype)
+ public function save(Application_Model_Repeatend $repeatend)
{
- $data = array('eventtypeID'=> $eventtype->getID() ,'title'=> $eventtype->getTitle() );
+ $data = array('repeatendID'=> $repeatend->getID() ,'title'=> $repeatend->getTitle() );
- if (null === ($id = $eventtype->getID()) ) {
- unset($data['eventtypeID']);
+ if (null === ($id = $repeatend->getID()) ) {
+ unset($data['repeatendID']);
$this->getDbTable()->insert($data);
} else {
- $this->getDbTable()->update($data, array('eventtypeID = ?' => $id));
+ $this->getDbTable()->update($data, array('repeatendID = ?' => $id));
}
}
- public function delete(Application_Model_Eventtype $eventtype)
+ public function delete(Application_Model_Repeatend $repeatend)
{
- if (null === ($id = $eventtype->getID()) ) {
+ if (null === ($id = $repeatend->getID()) ) {
return;
} else {
- $this->getDbTable()->delete(array('eventtypeID = ?' => $id));
+ $this->getDbTable()->delete(array('repeatendID = ?' => $id));
}
}
- public function find($id, Application_Model_Eventtype $eventtype = null)
+ public function find($id, Application_Model_Repeatend $repeatend = null)
{
$result = $this->getDbTable()->find($id);
if (0 == count($result)) {
return;
}
- if($eventtype == null) {
+ if($repeatend == null) {
$return = true;
}
$row = $result->current();
if($return) {
- $eventtype = new Application_Model_Eventtype();
- $eventtype
- ->setID($row->eventtypeID)
+ $repeatend = new Application_Model_Repeatend();
+ $repeatend
+ ->setID($row->repeatendID)
->setTitle($row->title);
- return $eventtype;
+ return $repeatend;
} else {
- $eventtype
- ->setID($row->eventtypeID)
+ $repeatend
+ ->setID($row->repeatendID)
->setTitle($row->title);
}
}
@@ -125,18 +125,14 @@ class Application_Model_EventtypeMapper
$resultSet = $this->getDbTable()->fetchAll();
$entries = array();
foreach ($resultSet as $row) {
- $entry = new Application_Model_Eventtype();
+ $entry = new Application_Model_Repeatend();
$entry
- ->setID($row->eventtypeID)
+ ->setID($row->repeatendID)
->setTitle($row->title);
$entries[] = $entry;
}
return $entries;
}
-
-
-
-}
-
+} \ No newline at end of file
diff --git a/application/models/Repeattype.php b/application/models/Repeattype.php
new file mode 100755
index 0000000..43ad949
--- /dev/null
+++ b/application/models/Repeattype.php
@@ -0,0 +1,110 @@
+<?php
+/*
+ * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
+ * This program is free software distributed under the GPL version 2.
+ * See http://gpl.openslx.org/
+ *
+ * If you have any feedback please consult http://feedback.openslx.org/ and
+ * send your suggestions, praise, or complaints to feedback@openslx.org
+ *
+ * General information about OpenSLX can be found at http://openslx.org/
+ */
+
+class Application_Model_Repeattype
+{
+ protected $_repeattypeID;
+ protected $_title;
+
+ public function __construct(array $options = null)
+ {
+ if (is_array($options)) {
+ $this->setOptions($options);
+ }
+ }
+
+ public function __set($name, $value)
+ {
+ $method = 'set' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid repeattype property');
+ }
+ $this->$method($value);
+ }
+
+ public function __get($name)
+ {
+ $method = 'get' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid repeattype property');
+ }
+ return $this->$method();
+ }
+
+ public function setOptions(array $options)
+ {
+ $methods = get_class_methods($this);
+ foreach ($options as $key => $value) {
+ $method = 'set' . ucfirst($key);
+ if (in_array($method, $methods)) {
+ $this->$method($value);
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Returns current data as associative array using ReflectionClass
+ *
+ * @return array Returns associative array containing model data
+ * If "get"-method not available (our primary keys) the function getID() is called
+ */
+ public function toArray()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $properties = $reflectionClass->getProperties();
+ $result = array();
+ foreach ($properties as $property) {
+ $key = $property->name;
+ if (substr($key, 0, 1) != '_' && $this->$key !== null) {
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ } else {
+ $result[$key] = $this->$key;
+ }
+ }
+ elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
+ $key = substr($key, 1);
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ }else{
+ $result[$key] = $this->getID();
+ }
+
+ }
+ }
+ return $result;
+ }
+
+ public function getID()
+ {
+ return $this->_repeattypeID;
+ }
+ public function setID($_repeattypeID)
+ {
+ $this->_repeattypeID = $_repeattypeID;
+ return $this;
+ }
+
+ public function getTitle()
+ {
+ return $this->_title;
+ }
+
+ public function setTitle($_title)
+ {
+ $this->_title = $_title;
+ return $this;
+ }
+} \ No newline at end of file
diff --git a/application/models/RepeattypeMapper.php b/application/models/RepeattypeMapper.php
new file mode 100755
index 0000000..015c4e2
--- /dev/null
+++ b/application/models/RepeattypeMapper.php
@@ -0,0 +1,138 @@
+<?php
+
+class Application_Model_RepeattypeMapper
+{
+ protected $_dbTable;
+
+ public function findBy($where, $array=false, $order=false)
+ {
+ foreach($where as $k => $v){
+ if($v != null)
+ $where2[] = "$k = '$v'";
+ else
+ $where2[] = "$k IS NULL";
+ }
+ $where = implode(" AND " ,$where2);
+
+ try{
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $select = $this->getDbTable()->select()
+ ->from($this->_dbTable)
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
+ $stmt = $select->query();
+ $result = $stmt->fetchAll();
+
+ if(!$array){
+ $entries = array();
+ if(count($result) > 0) {
+ foreach ($result as $row) {
+ $entry = new Application_Model_Repeattype($row);
+ $entry->setID($row['repeattypeID']);
+ $entries[] = $entry;
+ }
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
+ }
+ }
+
+ public function setDbTable($dbTable)
+ {
+ if (is_string($dbTable)) {
+ $dbTable = new $dbTable();
+ }
+
+ if (!$dbTable instanceof Zend_Db_Table_Abstract) {
+ throw new Exception('Invalid table data gateway provided');
+ }
+
+ $this->_dbTable = $dbTable;
+
+ return $this;
+ }
+
+ public function getDbTable()
+ {
+ if (null === $this->_dbTable) {
+ $this->setDbTable('Application_Model_DbTable_Repeattype');
+ }
+
+ return $this->_dbTable;
+ }
+
+ public function save(Application_Model_Repeattype $repeattype)
+ {
+
+ $data = array('repeattypeID'=> $repeattype->getID() ,'title'=> $repeattype->getTitle() );
+
+ if (null === ($id = $repeattype->getID()) ) {
+ unset($data['repeattypeID']);
+ $this->getDbTable()->insert($data);
+ } else {
+ $this->getDbTable()->update($data, array('repeattypeID = ?' => $id));
+ }
+ }
+
+ public function delete(Application_Model_Repeattype $repeattype)
+ {
+ if (null === ($id = $repeattype->getID()) ) {
+ return;
+ } else {
+ $this->getDbTable()->delete(array('repeattypeID = ?' => $id));
+ }
+ }
+
+ public function find($id, Application_Model_Repeattype $repeattype = null)
+ {
+ $result = $this->getDbTable()->find($id);
+ if (0 == count($result)) {
+ return;
+ }
+
+ if($repeattype == null) {
+ $return = true;
+ }
+
+ $row = $result->current();
+
+ if($return) {
+ $repeattype = new Application_Model_Repeattype();
+ $repeattype
+ ->setID($row->repeattypeID)
+ ->setTitle($row->title);
+ return $repeattype;
+ } else {
+ $repeattype
+ ->setID($row->repeattypeID)
+ ->setTitle($row->title);
+ }
+ }
+
+ public function fetchAll()
+ {
+ $resultSet = $this->getDbTable()->fetchAll();
+ $entries = array();
+ foreach ($resultSet as $row) {
+ $entry = new Application_Model_Repeattype();
+
+ $entry
+ ->setID($row->repeattypeID)
+ ->setTitle($row->title);
+
+ $entries[] = $entry;
+ }
+ return $entries;
+ }
+} \ No newline at end of file
diff --git a/application/models/Runningtype.php b/application/models/Runningtype.php
new file mode 100755
index 0000000..d08222d
--- /dev/null
+++ b/application/models/Runningtype.php
@@ -0,0 +1,111 @@
+<?php
+/*
+ * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
+ * This program is free software distributed under the GPL version 2.
+ * See http://gpl.openslx.org/
+ *
+ * If you have any feedback please consult http://feedback.openslx.org/ and
+ * send your suggestions, praise, or complaints to feedback@openslx.org
+ *
+ * General information about OpenSLX can be found at http://openslx.org/
+ */
+
+class Application_Model_Runningtype
+{
+ protected $_runningtypeID;
+ protected $_title;
+
+ public function __construct(array $options = null)
+ {
+ if (is_array($options)) {
+ $this->setOptions($options);
+ }
+ }
+
+ public function __set($name, $value)
+ {
+ $method = 'set' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid runningtype property');
+ }
+ $this->$method($value);
+ }
+
+ public function __get($name)
+ {
+ $method = 'get' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid runningtype property');
+ }
+ return $this->$method();
+ }
+
+ public function setOptions(array $options)
+ {
+ $methods = get_class_methods($this);
+ foreach ($options as $key => $value) {
+ $method = 'set' . ucfirst($key);
+ if (in_array($method, $methods)) {
+ $this->$method($value);
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Returns current data as associative array using ReflectionClass
+ *
+ * @return array Returns associative array containing model data
+ * If "get"-method not available (our primary keys) the function getID() is called
+ */
+ public function toArray()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $properties = $reflectionClass->getProperties();
+ $result = array();
+ foreach ($properties as $property) {
+ $key = $property->name;
+ if (substr($key, 0, 1) != '_' && $this->$key !== null) {
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ } else {
+ $result[$key] = $this->$key;
+ }
+ }
+ elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
+ $key = substr($key, 1);
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ }else{
+ $result[$key] = $this->getID();
+ }
+
+ }
+ }
+ return $result;
+ }
+
+ public function getID()
+ {
+ return $this->_runningtypeID;
+ }
+ public function setID($_runningtypeID)
+ {
+ $this->_runningtypeID = $_runningtypeID;
+ return $this;
+ }
+
+ public function getTitle()
+ {
+ return $this->_title;
+ }
+
+ public function setTitle($_title)
+ {
+ $this->_title = $_title;
+ return $this;
+ }
+}
+
diff --git a/application/models/RunningtypeMapper.php b/application/models/RunningtypeMapper.php
new file mode 100755
index 0000000..621405a
--- /dev/null
+++ b/application/models/RunningtypeMapper.php
@@ -0,0 +1,138 @@
+<?php
+
+class Application_Model_RunningtypeMapper
+{
+ protected $_dbTable;
+
+ public function findBy($where, $array=false, $order=false)
+ {
+ foreach($where as $k => $v){
+ if($v != null)
+ $where2[] = "$k = '$v'";
+ else
+ $where2[] = "$k IS NULL";
+ }
+ $where = implode(" AND " ,$where2);
+
+ try{
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $select = $this->getDbTable()->select()
+ ->from($this->_dbTable)
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
+ $stmt = $select->query();
+ $result = $stmt->fetchAll();
+
+ if(!$array){
+ $entries = array();
+ if(count($result) > 0) {
+ foreach ($result as $row) {
+ $entry = new Application_Model_Runningtype($row);
+ $entry->setID($row['runningtypeID']);
+ $entries[] = $entry;
+ }
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
+ }
+ }
+
+ public function setDbTable($dbTable)
+ {
+ if (is_string($dbTable)) {
+ $dbTable = new $dbTable();
+ }
+
+ if (!$dbTable instanceof Zend_Db_Table_Abstract) {
+ throw new Exception('Invalid table data gateway provided');
+ }
+
+ $this->_dbTable = $dbTable;
+
+ return $this;
+ }
+
+ public function getDbTable()
+ {
+ if (null === $this->_dbTable) {
+ $this->setDbTable('Application_Model_DbTable_Runningtype');
+ }
+
+ return $this->_dbTable;
+ }
+
+ public function save(Application_Model_Runningtype $runningtype)
+ {
+
+ $data = array('runningtypeID'=> $runningtype->getID() ,'title'=> $runningtype->getTitle() );
+
+ if (null === ($id = $runningtype->getID()) ) {
+ unset($data['runningtypeID']);
+ $this->getDbTable()->insert($data);
+ } else {
+ $this->getDbTable()->update($data, array('runningtypeID = ?' => $id));
+ }
+ }
+
+ public function delete(Application_Model_Runningtype $runningtype)
+ {
+ if (null === ($id = $runningtype->getID()) ) {
+ return;
+ } else {
+ $this->getDbTable()->delete(array('runningtypeID = ?' => $id));
+ }
+ }
+
+ public function find($id, Application_Model_Runningtype $runningtype = null)
+ {
+ $result = $this->getDbTable()->find($id);
+ if (0 == count($result)) {
+ return;
+ }
+
+ if($runningtype == null) {
+ $return = true;
+ }
+
+ $row = $result->current();
+
+ if($return) {
+ $runningtype = new Application_Model_Runningtype();
+ $runningtype
+ ->setID($row->runningtypeID)
+ ->setTitle($row->title);
+ return $runningtype;
+ } else {
+ $runningtype
+ ->setID($row->runningtypeID)
+ ->setTitle($row->title);
+ }
+ }
+
+ public function fetchAll()
+ {
+ $resultSet = $this->getDbTable()->fetchAll();
+ $entries = array();
+ foreach ($resultSet as $row) {
+ $entry = new Application_Model_Runningtype();
+
+ $entry
+ ->setID($row->runningtypeID)
+ ->setTitle($row->title);
+
+ $entries[] = $entry;
+ }
+ return $entries;
+ }
+} \ No newline at end of file
diff --git a/public/media/js/script.js b/public/media/js/script.js
index 77b5789..048011a 100755
--- a/public/media/js/script.js
+++ b/public/media/js/script.js
@@ -95,23 +95,23 @@ function enableElement(name) {
function repeatChanged(name) {
if (getElementAttribute(name, 'checked')) {
- setElementVisible("repeatType-label");
- setElementVisible("repeatType-element");
- enableElement('repeatType');
- setElementVisible("repeatOption-label");
- setElementVisible("repeatOption-element");
- enableElement('repeatOption');
- repeatOptionChanged('repeatOption');
+ setElementVisible("repeattype-label");
+ setElementVisible("repeattype-element");
+ enableElement('repeattype');
+ setElementVisible("repeatend-label");
+ setElementVisible("repeatend-element");
+ enableElement('repeatend');
+ repeatendChanged('repeatend');
} else {
- setElementInvisible("repeatEnd-label");
- setElementInvisible("repeatEnd-element");
+ setElementInvisible("repeatdate-label");
+ setElementInvisible("repeatdate-element");
disableElement('repeatEnd');
- setElementInvisible("repeatType-label");
- setElementInvisible("repeatType-element");
+ setElementInvisible("repeattype-label");
+ setElementInvisible("repeattype-element");
disableElement('repeatType');
- setElementInvisible("repeatOption-label");
- setElementInvisible("repeatOption-element");
- disableElement('repeatOption');
+ setElementInvisible("repeatend-label");
+ setElementInvisible("repeatend-element");
+ disableElement('repeatend');
setElementInvisible("repeatings-label");
setElementInvisible("repeatings-element");
disableElement('repeatings');
@@ -126,8 +126,14 @@ function immediateChanged(name) {
setElementInvisible("end-element");
setElementInvisible("repeat-label");
setElementInvisible("repeat-element");
- setElementInvisible("repeatEnd-label");
- setElementInvisible("repeatEnd-element");
+ setElementInvisible("repeattype-label");
+ setElementInvisible("repeattype-element");
+ setElementInvisible("repeatend-label");
+ setElementInvisible("repeatend-element");
+ setElementInvisible("repeatdate-label");
+ setElementInvisible("repeatdate-element");
+ setElementInvisible("repeatings-label");
+ setElementInvisible("repeatings-element");
setElementInvisible("note-label");
setElementInvisible("note-element");
setElementInvisible("participants-label");
@@ -139,7 +145,10 @@ function immediateChanged(name) {
setElementValue('start', start);
disableElement('end');
disableElement('repeat');
- disableElement('repeatEnd');
+ disableElement('repeattype');
+ disableElement('repeatend');
+ disableElement('repeatdate');
+ disableElement('repeatings');
disableElement('note');
disableElement('participants');
} else {
@@ -222,19 +231,19 @@ function editeventcategoryfieldChanged(name) {
repeatChanged('repeat');
}
-function repeatOptionChanged(name) {
+function repeatendChanged(name) {
value = getElementValue(name);
if (value == 'after') {
- setElementInvisible("repeatEnd-label");
- setElementInvisible("repeatEnd-element");
- disableElement('repeatEnd');
+ setElementInvisible("repeatdate-label");
+ setElementInvisible("repeatdate-element");
+ disableElement('repeatdate');
setElementVisible("repeatings-label");
setElementVisible("repeatings-element");
enableElement('repeatings');
} else if (value == 'date') {
- setElementVisible("repeatEnd-label");
- setElementVisible("repeatEnd-element");
- enableElement('repeatEnd');
+ setElementVisible("repeatdate-label");
+ setElementVisible("repeatdate-element");
+ enableElement('repeatdate');
setElementInvisible("repeatings-label");
setElementInvisible("repeatings-element");
disableElement('repeatings');
diff --git a/setup/poolctrl.sql b/setup/poolctrl.sql
index c50d266..5d9a75f 100755
--- a/setup/poolctrl.sql
+++ b/setup/poolctrl.sql
@@ -18,7 +18,10 @@ CREATE TABLE IF NOT EXISTS `poolctrl_event` (
`pbs_bootmenuID` int(11) NOT NULL,
`pbs_filterID` int(11) NOT NULL,
`repeat` bool NOT NULL DEFAULT false,
- `repeatEnd` timestamp COLLATE utf8_unicode_ci NULL,
+ `repeattype` int(11) NULL,
+ `repeatend` int(11) NULL,
+ `repeatdate` timestamp COLLATE utf8_unicode_ci NULL,
+ `repeatings` int(4) NULL,
`immediate` bool NOT NULL DEFAULT false,
`running` bool NOT NULL DEFAULT false,
`runningtype` int(11) DEFAULT NULL,
@@ -31,12 +34,26 @@ CREATE TABLE IF NOT EXISTS `poolctrl_event` (
KEY `pbs_filterID` (`pbs_filterID`),
KEY `category` (`category`),
KEY `runningtype` (`runningtype`)
+ KEY `repeattype` (`repeattype`)
+ KEY `repeatend` (`repeatend`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
-CREATE TABLE IF NOT EXISTS `poolctrl_eventtype` (
+CREATE TABLE IF NOT EXISTS `poolctrl_runningtype` (
`eventtypeID` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(30) COLLATE utf8_unicode_ci NOT NULL UNIQUE,
- PRIMARY KEY (`eventtypeID`)
+ PRIMARY KEY (`runningtypeID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
+
+CREATE TABLE IF NOT EXISTS `poolctrl_repeattype` (
+ `repeattypeID` int(11) NOT NULL AUTO_INCREMENT,
+ `title` varchar(30) COLLATE utf8_unicode_ci NOT NULL UNIQUE,
+ PRIMARY KEY (`repeattypeID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
+
+CREATE TABLE IF NOT EXISTS `poolctrl_repeatend` (
+ `repeatendID` int(11) NOT NULL AUTO_INCREMENT,
+ `title` varchar(30) COLLATE utf8_unicode_ci NOT NULL UNIQUE,
+ PRIMARY KEY (`repeatendID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS `poolctrl_eventcategory` (
@@ -135,10 +152,37 @@ ALTER TABLE `pbs_poolentries`
ALTER TABLE `poolctrl_eventreport`
ADD CONSTRAINT `pbs_eventreport_eventidC` FOREIGN KEY (`eventID`) REFERENCES `poolctrl_event` (`eventID`) ON DELETE CASCADE,
- ADD CONSTRAINT `pbs_eventreport_typeidC` FOREIGN KEY (`type`) REFERENCES `poolctrl_eventtype` (`eventtypeID`) ON DELETE CASCADE;
+ ADD CONSTRAINT `pbs_eventreport_typeidC` FOREIGN KEY (`type`) REFERENCES `poolctrl_runningtype` (`runningtypeID`) ON DELETE CASCADE;
ALTER TABLE `poolctrl_event`
ADD CONSTRAINT `poolctrl_event_categoryC` FOREIGN KEY (`category`) REFERENCES `poolctrl_eventcategory` (`eventcategoryID`) ON DELETE CASCADE,
- ADD CONSTRAINT `poolctrl_event_runningtypeC` FOREIGN KEY (`runningtype`) REFERENCES `poolctrl_eventtype` (`eventtypeID`) ON DELETE SET NULL,
+ ADD CONSTRAINT `poolctrl_event_repeattypeC` FOREIGN KEY (`repeattype`) REFERENCES `poolctrl_repeattype` (`repeattypeID`) ON DELETE SET NULL,
+ ADD CONSTRAINT `poolctrl_event_runningtypeC` FOREIGN KEY (`runningtype`) REFERENCES `poolctrl_runningtype` (`runningtypeID`) ON DELETE SET NULL,
+ ADD CONSTRAINT `poolctrl_event_repeatendC` FOREIGN KEY (`repeatend`) REFERENCES `poolctrl_repeatend` (`repeatendID`) ON DELETE SET NULL,
ADD CONSTRAINT `poolctrl_event_startC` CHECK (start > CURRENT_TIMESTAMP()),
ADD CONSTRAINT `poolctrl_event_endC` CHECK (end > start);
+
+--Adding Data
+-- Adding eventcategories
+INSERT INTO `poolctrl_eventcategory` (`eventcategoryID`, `title`) VALUES
+(1, 'Lecture'),
+(2, 'Maintenance'),
+(3, 'Boot'),
+(4, 'Shutdown');
+
+-- Adding runningtypes
+INSERT INTO `poolctrl_runningtype` (`eventtypeID`, `title`) VALUES
+(1, 'Boot'),
+(2, 'Shutdown');
+
+-- Adding repeattypes
+INSERT INTO `poolctrl_repeattype` (`repeattypeID`, `title`) VALUES
+(1, 'Daily'),
+(2, 'Once a week'),
+(3, 'Every couple of weeks'),
+(4, 'Every month');
+
+-- Adding repeatend
+INSERT INTO `poolctrl_repeatend` (`repeatendID`, `title`) VALUES
+(1, 'After'),
+(2, 'Date');
diff --git a/setup/poolctrl_data.sql b/setup/poolctrl_data.sql
index 5715ec9..079b53d 100755
--- a/setup/poolctrl_data.sql
+++ b/setup/poolctrl_data.sql
@@ -56,18 +56,6 @@ INSERT INTO `pbs_poolentries` (`poolentriesID`, `poolID`, `clientID`) VALUES
(9, 4, 9),
(10, 4, 10);
--- Adding eventcategories
-INSERT INTO `poolctrl_eventcategory` (`eventcategoryID`, `title`) VALUES
-(1, 'Lecture'),
-(2, 'Maintenance'),
-(3, 'Boot'),
-(4, 'Shutdown');
-
--- Adding eventtypes
-INSERT INTO `poolctrl_eventtype` (`eventtypeID`, `title`) VALUES
-(1, 'Boot'),
-(2, 'Shutdown');
-
-- Adding events
INSERT INTO `poolctrl_event` (`eventID`, `title`, `start`, `end`, `category`, `pbs_poolID`, `pbs_membershipID`, `pbs_bootosID`, `note`, `pbs_bootmenuID`, `pbs_filterID`, `created`) VALUES
(1, 'Systeme I', '2011-06-24 12:10:00', '2011-06-24 14:00:00', '1', 1, 1, 1, 'Systeme I Vorlesung', 1, 1, 1308583320),