summaryrefslogtreecommitdiffstats
path: root/application/controllers
diff options
context:
space:
mode:
authorSimon2011-03-07 15:51:56 +0100
committerSimon2011-03-07 15:51:56 +0100
commit8dcde51a354a3308017564a64ef69e794f430974 (patch)
tree970a98ce6aa23cc2dcf789bdea65c9875391bcad /application/controllers
parentMerge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2 (diff)
downloadpbs2-8dcde51a354a3308017564a64ef69e794f430974.tar.gz
pbs2-8dcde51a354a3308017564a64ef69e794f430974.tar.xz
pbs2-8dcde51a354a3308017564a64ef69e794f430974.zip
Alle mapper mit findBy(criteria, value) ausgestattet && clients zu pool hinzufügen
Diffstat (limited to 'application/controllers')
-rw-r--r--application/controllers/PoolController.php49
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()
{