Permalink
Browse files

Initial commit

  • Loading branch information...
Drachenkaetzchen committed Feb 26, 2012
0 parents commit 94ad799ad59e1030e3ce730d96f4e26fda005e4b
Showing with 275 additions and 0 deletions.
  1. +93 −0 Item.php
  2. +36 −0 SizePrice.php
  3. +29 −0 config.php
  4. +33 −0 css/main.css
  5. +4 −0 images/README.md
  6. BIN images/logo.png
  7. BIN images/shirt.gif
  8. +12 −0 index.php
  9. +13 −0 js/check.js
  10. +5 −0 order.php
  11. +50 −0 templates/index.html
@@ -0,0 +1,93 @@
+<?php
+
+class Item {
+ /**
+ * The name of the item
+ * @var string
+ */
+ private $name;
+
+ /**
+ * The description of the item
+ * @var string
+ */
+ private $description;
+
+ /**
+ * The image filename excluding the path
+ * @var string
+ */
+ private $image;
+
+ /**
+ * An array of SizePrice objects which contain the sizes and prices
+ * @var array
+ */
+ private $sizePrices = array();
+
+ /**
+ * Sets the name of the item
+ * @param string $name
+ */
+ public function setName ($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Returns the name of the item
+ *
+ * @return string The item name
+ */
+ public function getName () {
+ return $this->name;
+ }
+
+ /**
+ * Sets the description of the item
+ * @param string $description
+ */
+ public function setDescription ($description) {
+ $this->description = $description;
+ }
+
+ /**
+ * Returns the description of the item
+ * @return string The description
+ */
+ public function getDescription () {
+ return $this->description;
+ }
+
+ /**
+ * Sets the image name
+ * @param string $image
+ */
+ public function setImage ($image) {
+ $this->image = $image;
+ }
+
+ /**
+ * Returns the image name
+ * @return string The image name
+ */
+ public function getImage () {
+ return $this->image;
+ }
+
+ /**
+ * Adds a SizePrice
+ * @param SizePrice $sizePrice
+ */
+ public function addSizePrice (SizePrice $sizePrice) {
+ $this->sizePrices[] = $sizePrice;
+ }
+
+ /**
+ * Returns all SizePrice objects
+ * @return array an array of SizePrice objects
+ */
+ public function getSizePrices () {
+ return $this->sizePrices;
+ }
+
+}
@@ -0,0 +1,36 @@
+<?php
+
+class SizePrice {
+ /**
+ * Holds the size
+ * @var string
+ */
+ private $size;
+
+ /**
+ * Holds the price
+ * @var float
+ */
+ private $price;
+
+ public function __construct ($size, $price) {
+ $this->size = $size;
+ $this->price = $price;
+ }
+
+ /**
+ * Returns the size
+ * @return string
+ */
+ public function getSize () {
+ return $this->size;
+ }
+
+ /**
+ * Returns the price
+ * @return float
+ */
+ public function getPrice () {
+ return $this->price;
+ }
+}
@@ -0,0 +1,29 @@
+<?php
+$items = array();
+
+$item = new Item();
+$item->setName("RaumZeitLabor T-Shirt");
+$item->setDescription("Das Super RZL Shirt");
+$item->setImage("shirt.gif");
+$item->addSizePrice(new SizePrice("XXL", 15.90));
+$item->addSizePrice(new SizePrice("XL", 14.90));
+$item->addSizePrice(new SizePrice("L", 13.90));
+$item->addSizePrice(new SizePrice("M", 12.90));
+$item->addSizePrice(new SizePrice("S", 11.90));
+
+$items[] = $item;
+
+
+$item = new Item();
+$item->setName("RZL LabCoat");
+$item->setDescription( "Das Pflichtprogramm für jeden Laboraten! Ein bestickter Labcoat, der auch " .
+ "wunderbar für Ätzsessions geeignet ist. Die Bestickung wird von Unicorn oder Inte ".
+ "mittels unserer Stickmaschine vorgenommen." );
+$item->setImage("shirt.gif");
+$item->addSizePrice(new SizePrice("XXL", 15.90));
+$item->addSizePrice(new SizePrice("XL", 14.90));
+$item->addSizePrice(new SizePrice("L", 13.90));
+$item->addSizePrice(new SizePrice("M", 12.90));
+$item->addSizePrice(new SizePrice("S", 11.90));
+
+$items[] = $item;
@@ -0,0 +1,33 @@
+.size {
+ display: block;
+ width: 40px;
+}
+
+.price {
+ display: block;
+ width: 80px;
+}
+
+table.sizeprice {
+ margin-top: 20px;
+}
+
+div.item {
+ overflow: auto;
+ margin-bottom: 10px;
+}
+
+input.textfield {
+ width: 300px;
+}
+
+.textarea {
+ width: 300px;
+ height: 100px;
+}
+
+label {
+ width: 180px;
+ vertical-align: top;
+ display: inline-block;
+}
@@ -0,0 +1,4 @@
+This file contains all item images.
+
+Put the full size image into "full" and the thumbnail (300px width) into the thumb directory. Each item needs to
+have the same name.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,12 @@
+<?php
+require_once 'Twig/Autoloader.php';
+Twig_Autoloader::register();
+
+$loader = new Twig_Loader_Filesystem('templates');
+$twig = new Twig_Environment($loader);
+
+require_once("SizePrice.php");
+require_once("Item.php");
+require_once("config.php");
+
+$twig->display('index.html', array("items" => $items));
@@ -0,0 +1,13 @@
+function checkForm () {
+ if (document.getElementById("name").value.length < 5) {
+ alert("Bitte gib deinen Namen an");
+ return false;
+ }
+
+ if (document.getElementById("email").value.length < 5) {
+ alert("Bitte gib deine E-Mail an");
+ return false;
+ }
+
+ return true;
+}
@@ -0,0 +1,5 @@
+<?php
+
+echo "<pre>";
+print_r($_REQUEST);
+
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <script type="text/javascript" src="js/check.js"></script>
+ <title>RaumZeitLabor Merchandise</title>
+ <link href="css/main.css" rel="stylesheet" type="text/css" />
+ </head>
+ <body>
+ <img src="images/logo.png" style="float: right;"/><h1>RaumZeitLabor Merchandise</h1><br/>
+ <form method="POST" action="order.php">
+ {% for item in items %}
+ <div class="item">
+ <img src="images/{{ item.getImage() }}" style="float: left;"/>
+ <h1>{{ item.getName() }}</h1><br/>
+ {{ item.getDescription() }}<br/>
+
+ <table class="sizeprice">
+ <tr>
+ <th>Größe</th>
+ <th>Preis</th>
+ <th>Anzahl</th>
+ </tr>
+ {% for sizeprice in item.getSizePrices() %}
+ <tr>
+ <td>{{ sizeprice.getSize() }}</td>
+ <td>{{ sizeprice.getPrice() }} &euro;</td>
+ <td><input type="text" size="3" name="item[{{ item.getName() }}-{{ sizeprice.getSize() }}]"/></td>
+ </tr>
+ {% endfor %}
+ </table>
+ </div>
+ {% endfor %}
+
+ <div class="order">
+ <h1>Bestelldaten</h1>
+ <label for="name">Dein Name</label>
+ <input class="textfield" type="text" id="name" name="name" size="32" maxlength="255"/><br/>
+
+ <label for="email">Deine E-Mail</label>
+ <input class="textfield" type="text" id="email" name="email" size="32" maxlength="255"/><br/>
+
+ <label for="comments">Bemerkungen, Kommentare</label>
+ <textarea class="textarea" name="comments" id="comments"></textarea>
+ </div>
+
+ <input type="submit" onclick="return checkForm()" value="Bestellung los!"/>
+ </form>
+ </body>
+</html>

0 comments on commit 94ad799

Please sign in to comment.