diff options
Diffstat (limited to 'application/controllers/PoolController.php')
| -rw-r--r-- | application/controllers/PoolController.php | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/application/controllers/PoolController.php b/application/controllers/PoolController.php index 27e81a3..f4287cb 100644 --- a/application/controllers/PoolController.php +++ b/application/controllers/PoolController.php @@ -12,6 +12,10 @@ class PoolController extends Zend_Controller_Action { $poolMapper = new Application_Model_PoolMapper(); $this->view->pools = $poolMapper->fetchAll(); + + $poolentriesMapper = new Application_Model_PoolEntriesMapper(); + print_a($poolentriesMapper->findBy('poolID',1)); + } public function createpoolAction() @@ -80,8 +84,51 @@ class PoolController extends Zend_Controller_Action public function linkclientAction() { - // action body + if(!isset($_POST['clientID'])){ + print_a($_POST); + $clientmapper = new Application_Model_ClientMapper(); + $clients = $clientmapper->fetchAll(); + foreach($clients as $c){ + #$client = new Application_Model_Client($c); + $clientsArray[] = $c->toArray(); + } + $assignedclientmapper = new Application_Model_PoolEntriesMapper(); + $assignedclients = $assignedclientmapper->fetchAll(); + foreach($assignedclients as $c){ + $assignedclientsArray[] = $c->toArray(); + } + $freeclients = $this->arrayDiff($clientsArray,$assignedclientsArray); + + $poolclient = new Application_Form_PoolClient(array('clients'=> $freeclients)); + $this->view->poolclient = $poolclient; + }else { + #$_POST['poolID'] = $this->_request->getParam('poolID'); + $poolclientform = new Application_Form_PoolClient($_POST); + + try{ + $pool = new Application_Model_PoolEntries($_POST); + $pool->setPoolID($this->_request->getParam('poolID')); + + $poolmapper = new Application_Model_PoolEntriesMapper(); + $poolmapper->save($pool); + $this->_redirect('/pool'); + }catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + + } } + private function arrayDiff($a, $b){ + foreach($a as $k1 => $i1){ + foreach($b as $k2 => $i2){ + if($i1['clientID'] == $i2['clientID']){ + unset($a[$k1]); + } + } + } + return $a; + } + public function unlinkclientAction() { |
