summaryrefslogtreecommitdiffstats
path: root/application/controllers/SessionController.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/controllers/SessionController.php')
-rw-r--r--application/controllers/SessionController.php50
1 files changed, 40 insertions, 10 deletions
diff --git a/application/controllers/SessionController.php b/application/controllers/SessionController.php
index 21f94fa..09eadc9 100644
--- a/application/controllers/SessionController.php
+++ b/application/controllers/SessionController.php
@@ -16,16 +16,32 @@ class SessionController extends Zend_Controller_Action
public function createsessionAction()
{
+ $cm = new Application_Model_ClientMapper();
+ $clients = $cm->fetchAll();
+
+ $bm = new Application_Model_BootOsMapper();
+ $bootos = $bm->fetchAll();
+
+ $bi = new Application_Model_BootIsoMapper();
+ $bootisos = $bi->fetchAll();
+
if (!isset($_POST["add"])){
- $createsession = new Application_Form_Session();
+ $createsession = new Application_Form_Session(array('clients'=>$clients,'bootos'=>$bootos,'bootisos'=>$bootisos));
$this->view->createsession = $createsession;
}else {
// TODO extend with normal function not only with post
- $createsession = new Application_Form_Session($_POST);
+ $createsession = new Application_Form_Session(array('clients'=>$clients,'bootos'=>$bootos,'bootisos'=>$bootisos),$_POST);
print_a($_POST);
if ($createsession->isValid($_POST)) {
try{
$session = new Application_Model_Session($_POST);
+ $session->setTime(strtotime($_POST['time']));
+ if($session->getClientID() == ''){
+ $session->setClientID(null);
+ }
+ if($session->getBootosID() == ''){
+ $session->setBootosID(null);
+ }
$sessionmapper = new Application_Model_SessionMapper();
$sessionmapper->save($session);
@@ -35,16 +51,22 @@ class SessionController extends Zend_Controller_Action
echo "Error message 2: " . $e->getMessage() . "\n";
}
print_a('saved');
- $this->_redirect('/session');
- }
- else{
- print_a('not saved');
+ #$this->_redirect('/session');
}
+ $this->view->createsession = $createsession;
}
}
public function editsessionAction()
{
+ $cm = new Application_Model_ClientMapper();
+ $clients = $cm->fetchAll();
+
+ $bm = new Application_Model_BootOsMapper();
+ $bootos = $bm->fetchAll();
+
+ $bi = new Application_Model_BootIsoMapper();
+ $bootisos = $bi->fetchAll();
if (!isset($_POST["add"])){
// TODO: ACL implementieren ob er editieren darf
$sessionID = $this->_request->getParam('sessionID');
@@ -52,10 +74,11 @@ class SessionController extends Zend_Controller_Action
$sessionmapper = new Application_Model_SessionMapper();
- $sessionmapper->find($sessionID,$session);
+ $sessionmapper->find($sessionID,$session);
+ $session->setTime(date('d.m.Y H:i',$session->getTime()));
$session2 = $session->toArray();
- $editsession = new Application_Form_Session();
+ $editsession = new Application_Form_Session(array('clients'=>$clients,'bootos'=>$bootos,'bootisos'=>$bootisos));
$editsession->populate($session2);
$this->view->editsession = $editsession;
@@ -63,11 +86,18 @@ class SessionController extends Zend_Controller_Action
try{
$sessionID = $this->_request->getParam('sessionID');
- $editsession = new Application_Form_Session($_POST);
+ $editsession = new Application_Form_Session(array('clients'=>$clients,'bootos'=>$bootos,'bootisos'=>$bootisos),$_POST);
if ($editsession->isValid($_POST)) {
$session = new Application_Model_Session($_POST);
- $session->setID($this->_request->getParam('sessionID'));
+ $session->setID($this->_request->getParam('sessionID'));
+ $session->setTime(strtotime($_POST['time']));
+ if($session->getClientID() == ''){
+ $session->setClientID(null);
+ }
+ if($session->getBootosID() == ''){
+ $session->setBootosID(null);
+ }
$sessionmapper = new Application_Model_SessionMapper();
$sessionmapper->save($session);
echo 'valid';