summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/controllers/PoolController.php28
-rw-r--r--application/views/scripts/filter/index.phtml3
-rw-r--r--application/views/scripts/pool/index.phtml28
3 files changed, 52 insertions, 7 deletions
diff --git a/application/controllers/PoolController.php b/application/controllers/PoolController.php
index 28bde8e..cb38a80 100644
--- a/application/controllers/PoolController.php
+++ b/application/controllers/PoolController.php
@@ -13,8 +13,21 @@ 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));
+ $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);
+ #print_a($freeclients);
+
+ $this->view->freeclients = $freeclients;
}
@@ -84,12 +97,15 @@ class PoolController extends Zend_Controller_Action
public function linkclientAction()
{
- if(!isset($_POST['clientID'])){
+ $clientID = $this->_request->getParam('clientID');
+ $poolID = $this->_request->getParam('poolID');
+ print_a($clientID,$poolID);
+
+ if(!isset($_POST['clientID']) && ($clientID == '' && $poolID == '')){
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();
@@ -108,7 +124,9 @@ class PoolController extends Zend_Controller_Action
try{
$pool = new Application_Model_PoolEntries($_POST);
$pool->setPoolID($this->_request->getParam('poolID'));
-
+ if($pool->getClientID() == ''){
+ $pool->setClientID($this->_request->getParam('clientID'));
+ }
$poolmapper = new Application_Model_PoolEntriesMapper();
$poolmapper->save($pool);
$this->_redirect('/pool');
diff --git a/application/views/scripts/filter/index.phtml b/application/views/scripts/filter/index.phtml
index a3e6f25..eb459a7 100644
--- a/application/views/scripts/filter/index.phtml
+++ b/application/views/scripts/filter/index.phtml
@@ -103,7 +103,8 @@ tr.filter{background-color:#DDD;}
</tr>
<?php endforeach ?>
</table>
-
+
+
<?php else: ?>
<p>There are no filters to display.</p>
diff --git a/application/views/scripts/pool/index.phtml b/application/views/scripts/pool/index.phtml
index 25f1528..c3a6be9 100644
--- a/application/views/scripts/pool/index.phtml
+++ b/application/views/scripts/pool/index.phtml
@@ -79,7 +79,33 @@
</table>
<?php endforeach ?>
</table>
-
+<h2>Free clients</h2>
+<table border=1 >
+<tr><th>ClientID</th><th>MacAdress</th><th>Hardwarehash</th>
+<?php foreach ($this->pools as $pool): ?>
+ <th><?php echo $this->escape($pool->getTitle()) ?></th>
+ <?php endforeach ?>
+</tr>
+<?php
+foreach ($this->freeclients as $client): ?>
+ <tr>
+ <td><?php echo $client['clientID']; ?></td>
+ <td><?php echo $client['macadress']; ?></td>
+ <td><?php echo $client['hardwarehash']; ?></td>
+ <?php foreach ($this->pools as $pool): ?>
+ <td><a href='<?php echo $this->url(
+ array(
+ 'controller' => 'pool',
+ 'action' => 'linkclient',
+ 'clientID' => $client['clientID'],
+ 'poolID' => $pool->getID(),
+ ),
+ 'default',
+ true) ?>'>link</a></td>
+ <?php endforeach ?>
+ </tr>
+<?php endforeach ?>
+</table>
<?php else: ?>