summaryrefslogblamecommitdiffstats
path: root/application/controllers/BootisoController.php
blob: c49cdf394403094c98dde5ddf78e9d157ce7ca51 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                                               



                                                                     
                                                              





                                                                                                                                                                                           



                                         

                                                                   
                                                     
                                                                                                                        




























                                                                                      
                                                           









                                                                          
                                                                                                                       



















































                                                                                
<?php

class BootisoController extends Zend_Controller_Action
{

    public function init()
    {
   		$db = Zend_Db_Table::getDefaultAdapter();
    }

    public function indexAction()
    {
    	$bootisomapper = new Application_Model_BootIsoMapper();
    	$groupmapper = new Application_Model_GroupMapper();
    	$membershipmapper = new Application_Model_MembershipMapper();
    	$personmapper = new Application_Model_PersonMapper();
    	
    	$this->view->bootisolist = $bootisomapper->fetchAll();
    	    
    	foreach ($this->view->bootisolist as $bootiso){
    		  $bootiso->setGroupID("[".$bootiso->getGroupID()."] ".$groupmapper->find($bootiso->getGroupID())->getTitle());
    		  $bootiso->setMembershipID("[".$bootiso->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootiso->getMembershipID())->getPersonID())->getFirstname());
    	}
    
    }

    public function createbootisoAction()
    {
    		$groupmapper = new Application_Model_GroupMapper();
    	
           	if (!isset($_POST["createbootiso"])){
    	        $createbootisoForm = new Application_Form_BootisoCreate(array('grouplist' => $groupmapper->fetchAll()));
    		} else {
    			
    	        $createbootisoForm = new Application_Form_BootisoCreate($_POST);
    			    			
    		    if ($createbootisoForm->isValid($_POST)) {

    		    	$bootiso = new Application_Model_BootIso($_POST);
    		    	$bootiso->setMembershipID('1');
    		        $bootisomapper = new Application_Model_BootIsoMapper();
    		        $bootiso->setCreated(time()); 
    		        
    		    	try {  
    		            $bootisomapper->save($bootiso);
    		        }catch(Zend_Exception $e)
    		        {
    		            echo "Caught exception: " . get_class($e) . "<br/>";
    					echo "Message: " . $e->getMessage() . "<br/>";
    					
    		        }
					$this->_redirect('/bootiso');
    		     }
    		}
    
            $this->view->createbootisoForm = $createbootisoForm;
    }

    public function editbootisoAction()
    {
    	$bootisoID = $this->_request->getParam('bootisoID');
    	$groupmapper = new Application_Model_GroupMapper();
    	
    	if (!isset($_POST["editbootiso"])){
    		$bootisoID = $this->_request->getParam('bootisoID');
     		if (!isset($bootisoID) || !is_numeric($bootisoID)){
   				$this->_redirect('/bootiso');
    		} else {
    		   $bootiso = new Application_Model_BootIso();
    		   $bootisomapper = new Application_Model_BootIsoMapper();
    		   $bootisomapper->find($bootisoID, $bootiso);
    		   
    		   $editbootisoForm = new Application_Form_BootisoEdit(array('grouplist' => $groupmapper->fetchAll()));
    		   $editbootisoForm->populate($bootiso->toArray()); 
    		}
    	}else{
    		$editbootisoForm = new Application_Form_BootisoEdit($_POST);
    			    			
    		if ($editbootisoForm->isValid($_POST)) {

    			$bootiso = new Application_Model_BootIso($_POST);
    			$bootiso->setMembershipID('1');
    		    $bootisomapper = new Application_Model_BootIsoMapper();
    		    $bootiso->setCreated(time());
    		    $bootiso->setID($bootisoID);
    		        
    		   	try {  
    		       	$bootisomapper->save($bootiso);
    		    }catch(Zend_Exception $e)
    		    {
    		    	echo "Caught exception: " . get_class($e) . "<br/>";
    				echo "Message: " . $e->getMessage() . "<br/>";	
    		    }
    		    
				$this->_redirect('/bootiso');
    		}
    			
    	}
    	
    	$this->view->editbootisoForm = $editbootisoForm;
    }

    public function deletebootisoAction()
    {
   		$bootisoID = $this->_request->getParam('bootisoID');
     	if (!isset($bootisoID)){
   			$this->_redirect('/bootiso');
    	} else {
    		   $bootiso = new Application_Model_BootIso();
    		   $bootiso->setID($bootisoID);
    		   $bootisomapper = new Application_Model_BootIsoMapper();
    		   $bootisomapper->delete($bootiso);
    	}
    	$this->_redirect('/bootiso');
    }


}