Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding more features

Signed-off-by: Ciarán Eaton <montyphy@gmail.com>
  • Loading branch information...
commit c01e9a560cf0f3821187b8a2ec8c564d3b3d7efa 1 parent aeeccaf
@montyphy authored
View
31 london.hackspace.org.uk/members/storage.php
@@ -18,12 +18,23 @@
try {
fRequest::validateCSRFToken($_POST['token']);
foreach($user->buildBoxes() as $box) {
- if (isset($_POST['show_' . $box->getId()])) {
+ if (isset($_POST['loc_' . $box->getId()])) {
+ $location = $_POST['location_' . $box->getId()];
+ if ($location == "") {
+ $location = NULL;
+ }
+
+ $box->setLocation($location);
+ $box->store();
+ fURL::redirect('/members/storage.php');
+ }
+ else if (isset($_POST['show_' . $box->getId()])) {
$box_loc = $box->getLocation();
}
else if (isset($_POST['disown' . $box->getId()])) {
$box->setUserId(NULL);
+ $box->setLocation(NULL);
$box->store();
fURL::redirect('/members/storage.php');
}
@@ -31,6 +42,7 @@
//generate label
$label_box_id = $box->getId();
}
+
}
} catch (fValidationException $e) {
echo "<p>" . $e->printMessage() . "</p>";
@@ -73,6 +85,8 @@
<div style="margin:0 auto; text-align:center;">
<img src="/members/storage_image.php?id='.$label_box_id.'" alt="box label" />
</div>';
+ echo '<p style="text-align:center;">Copy this <a href="/members/storage_image.php?id='.$label_box_id.'">link</a>
+ to share this image.</p>';
}
?>
@@ -97,7 +111,8 @@
<tr>
<td><?=$box->getId()?></td>
<td>
- <?=$box->getLocation()?>
+ <input type="text" name="location_<?=$box->getId()?>" value="<?=$box->getLocation()?>" size="6" />
+ <input type="submit" name="loc_<?=$box->getId()?>" value="Save" />
</td>
<td>
<input type="submit" name="show_<?=$box->getId()?>" value="Show" />
@@ -126,6 +141,7 @@
<label for="box_id">Box ID:</label>
<select name="box_id">
+ <option value="" selected="selected"></option>
<? foreach($boxes->getAvailableBoxes() as $box): ?>
<option value="<?=$box->getId()?>"><?=$box->getId()?></option>
<? endforeach ?>
@@ -136,17 +152,6 @@
<? endif; ?>
-<h3>Add a New Box</h3>
-
-<form method="POST">
- <input type="hidden" name="token" value="<?=fRequest::generateCSRFToken()?>" />
- <input type="hidden" name="add_box" value="" />
-
- <label for="add_box_location">Box Loction:</label>
- <input type="text" name="add_box_location" size="10" />
- <input type="submit" name="submit" value="Add box" />
-</form>
-
<h3>Lookup a Box</h3>
<form>
View
132 london.hackspace.org.uk/members/storage_box.php
@@ -37,71 +37,87 @@
trigger_error($e);
}
}
+?>
+
-if (isset($_GET['box_id'])) {
+<h2>Box Management</h2>
+
+<? if (isset($_GET['box_id'])): ?>
+ <?php
$box_id = $_GET['box_id'];
-
- $mem_box = $boxes->getBoxByID($box_id);
-
- if ($mem_box >= 0) {
- //owned box
- echo '
- <div>
- Owned by blah blah
- </div>';
- }
- else if ($mem_box == -1) {
+ $box = new Box(array('id' => $box_id));
+ if ($box->getUserId() != NULL):
+ $owner = new User(array('id' => $box->getUserId()));
+ ?>
+ This box is assigned to:
+ <table>
+ <thead>
+ <tr>
+ <th>Box ID</th>
+ <th>Owner's Member Number</th>
+ <th>Owner's Name</th>
+ <th>Member</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><?=$box->getId()?></td>
+ <td><?=$owner->getMemberNumber()?></td>
+ <td><?=$owner->getFullName()?></td>
+ <td>
+ <?php
+ if ($owner->isMember()) {
+ echo 'True';
+ } else {
+ echo 'False';
+ }
+ ?>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <?php elseif ($mem_box == -1): ?>
//not owned
echo '
<div>
Not owned would you like to take it?
</div>';
- }
- else {
- //unused id
- echo "
- <div>
- This ID hasn't been assigned. Please ensure you entered the correct information.
- </div>";
- }
-}
-
-?>
-
-<h2>Box Management</h2>
-
-<?php
-$boxes = $db->translatedQuery( 'SELECT id FROM boxes ORDER BY id' );
-if ($boxes->countReturnedRows() == 0):
-?>
-<p>No boxes</p>
+ <? endif; ?>
<? else: ?>
-<table>
- <thead>
- <tr>
- <th>ID</th>
- <th>Delete</th>
- </tr>
- </thead>
- <tbody>
- <?php foreach( $boxes as $row ): ?>
- <tr>
- <td><?=$row['id']?></td>
- <td>
- <form method="POST">
- <input type="hidden" name="token" value="<?=fRequest::generateCSRFToken()?>" />
- <input type="hidden" name="box_id" value="<?=$row['id']?>" />
- <input type="submit" name="delete_box" value="Delete Box" />
- </form>
- </td>
- </tr>
- <?php endforeach; ?>
- </tbody>
-</table>
-<? endif; ?>
+ <?php
+ $boxes = $db->translatedQuery( 'SELECT id FROM boxes ORDER BY id' );
+ if ($boxes->countReturnedRows() == 0):
+ ?>
+ <p>No boxes</p>
+ <? else: ?>
+ <table>
+ <thead>
+ <tr>
+ <th>ID</th>
+ <th>Delete</th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php foreach( $boxes as $row ): ?>
+ <tr>
+ <td><?=$row['id']?></td>
+ <td>
+ <form method="POST">
+ <input type="hidden" name="token" value="<?=fRequest::generateCSRFToken()?>" />
+ <input type="hidden" name="box_id" value="<?=$row['id']?>" />
+ <input type="submit" name="delete_box" value="Delete Box" />
+ </form>
+ </td>
+ </tr>
+ <?php endforeach; ?>
+ </tbody>
+ </table>
+ <? endif; ?>
-<form method="POST">
- <input type="hidden" name="token" value="<?=fRequest::generateCSRFToken()?>" />
- <input type="submit" name="create_box" value="Create Box" />
-</form>
+ <form method="POST">
+ <input type="hidden" name="token" value="<?=fRequest::generateCSRFToken()?>" />
+ <input type="submit" name="create_box" value="Create Box" />
+ </form>
+<? endif; ?>
+<? require('footer.php'); ?>
View
8 london.hackspace.org.uk/members/storage_lib.php
@@ -15,8 +15,8 @@ function BoxIdImage($box_id) {
// Segments to create query that gets the QR code
$start_qr_url = "https://chart.googleapis.com/chart?chs=200x200&cht=qr&chl=";
$end_qr_url = "&.png";
- $site = "london.hackspace.org.uk";
- $action = "/members/storage.php?box_id=";
+ $site = "http://london.hackspace.org.uk";
+ $action = "/members/storage_box.php?box_id=";
$this->url = $start_qr_url . $site . $action. $this->box_id . $end_qr_url;
// Fetch QR code
@@ -24,9 +24,9 @@ function BoxIdImage($box_id) {
// modify QR code image to include ID
$font = 2;
- $x = 30;
- $y = 5;
$string = "Box ID: " . $this->box_id;
+ $x = get_string_center_pos($string, $font, imagesx($this->img));
+ $y = 5;
$textcolor = imagecolorallocate($img, 0, 0, 0);
imagestring($this->img, $font, $x, $y, $string, $textcolor);
}
Please sign in to comment.
Something went wrong with that request. Please try again.