Extended attributes of bike (brand, color, equipment).
authorLadislav Láska <laska@kam.mff.cuni.cz>
Tue, 26 Apr 2011 10:24:31 +0000 (12:24 +0200)
committerLadislav Láska <laska@kam.mff.cuni.cz>
Tue, 26 Apr 2011 10:24:31 +0000 (12:24 +0200)
classes/bike.php
controllers/bikedt.php
sql/database.sql
template/bikedt.php
template/bikes_list.inc
template/summary_bikeroom.inc
template/summary_owners.inc

index 51ad8138ce3c3b163444b1bf126ccc37c2795ca4..63628fe83c25f77dd4eaf22ac4f213c56db1867d 100644 (file)
@@ -3,7 +3,8 @@
 require_once "database.php";
 
 class Bike {
-       private $data = array( 'id' => -1, 'user' => -1, 'bikeroom' => -1, 'description' => '');
+       private $data = array( 'id' => -1, 'user' => -1, 'bikeroom' => -1, 'description' => '', 'brand' => '',
+               'color' => '', 'equipment' => '');
        public $lastErrorMessage;
 
        public function __construct($id = null) {
@@ -25,13 +26,16 @@ class Bike {
        public function update() {
                if ($this->id == -1) {
                        /* New bikeroom */
-                       $query = DB::query("INSERT INTO `bikes` (`user`, `bikeroom`, `description`) VALUES (?,?,?);",
-                       array($this->user, $this->bikeroom, $this->description));
+                       $query = DB::query("INSERT INTO `bikes` (`user`, `bikeroom`, `brand`, `color`, `equipment`, `description`) 
+                               VALUES (?,?,?,?,?);",
+                       array($this->user, $this->bikeroom, $this->brand, $this->color, $this->equipment, $this->description));
                        if (!$query->commit()) return false;
                        $this->data['id'] = $query->lastId();
                } else {
-                       $query = DB::query("UPDATE `bikes` SET `user` = ?, `bikeroom` = ?, `description` = ? WHERE `id` = ?;",
-                               array($this->user, $this->bikeroom, $this->description, $this->id));
+                       $query = DB::query("UPDATE `bikes` SET `user` = ?, `bikeroom` = ?, `brand` = ?, 
+                               `color` = ?, `equipment` = ?, `description` = ? WHERE `id` = ?;",
+                               array($this->user, $this->bikeroom, $this->brand, $this->color, $this->equipment, 
+                                       $this->description, $this->id));
                        if (!$query->commit()) return false;
                }
                return true;
@@ -114,6 +118,21 @@ class Bike {
                return true;
        }
 
+       public function setBrand($value) {
+               $this->data['brand'] = $value;
+               return true;
+       }
+
+       public function setColor($value) {
+               $this->data['color'] = $value;
+               return true;
+       }
+
+       public function setEquipment($value) {
+               $this->data['equipment'] = $value;
+               return true;
+       }
+
        public function setDescription($value) {
                $this->data['description'] = $value;
                return true;
index 808b1e0c1b242cdf1be389718937a0c3cfe6abd9..63582bea195d6e429f9ff85f4bef353b4225c0a5 100644 (file)
@@ -14,6 +14,9 @@
                $bike = new Bike($_GET['mod']);
                if ($auth->verify(P_BIKEMOD) || ($auth->id == $bike->user)) {
                        if (isset($_POST['description'])) {
+                               $bike->setBrand($_POST['brand']);
+                               $bike->setColor($_POST['color']);
+                               $bike->setEquipment($_POST['equipment']);
                                $bike->setDescription($_POST['description']);
                                if ($auth->verify(P_BIKEMOD))
                                        $bike->setBikeroom($_POST['bikeroom']);
index 5c163e9c1d68882e700a7be41bcb0478c94d4977..6b564372c85e4bfdfe6adbcf6b0831bf81a4f1be 100644 (file)
@@ -23,6 +23,9 @@ CREATE TABLE `bikes` (
        id int AUTO_INCREMENT,
        user int,
        bikeroom int,
+       brand text,
+       color text,
+       equipment text,
        description text,
        PRIMARY KEY(id)
 );
index aa36d5bf88fd5ec519c36c93da2627ea57a20c05..16b9e5c22c582f3dce215d0c6380a81636961450 100644 (file)
@@ -5,7 +5,10 @@
 <form action="#" method="post">
 <table>
 <?php
-       field("Popis", "text", "description", "validateSomething");
+       field("Značka", "text", "brand", "validateSomething");
+       field("Barva", "text", "color", "validateSomething");
+       field("Vybavení", "text", "equipment");
+       field("Další znaky", "text", "description");
        if ($auth->verify(P_BIKEMOD)) {
                $l = array(-1 => "---");
                foreach (Bikeroom::listAll() as $k) {
index f3533b36c2db371672d0bbb31cc77a2b265bfe99..f685b3d9a2cee0a9bc249b7f3149b7959e87370f 100644 (file)
@@ -1,5 +1,8 @@
 <table class="bikeslist">
        <tr>
+               <th><?=tr("Značka")?></th>
+               <th><?=tr("Barva")?></th>
+               <th><?=tr("Vybavení")?></th>
                <th><?=tr("Popis")?></th>
                <th><?=tr("Vlastník")?></th>
                <th><?=tr("Kolárna")?></th>
@@ -10,6 +13,9 @@
        foreach ($bikes as $bike) {
 ?>
        <tr>
+               <td><?=$bike->brand?></td>
+               <td><?=$bike->color?></td>
+               <td><?=$bike->equipment?></td>
                <td><?=$bike->description?></td>
                <td><?=$bike->userName?></td>
                <td><?php
index 61b40b93ddd968eaac134d6d1c44f5a3bc70686a..7915772159966458b32b62940adbfe7eb1ed04f8 100644 (file)
@@ -1,5 +1,7 @@
 <?php
-       $props = array("userName" => tr("Majitel"), "description" => tr("Popis kola"));
+       $props = array("userName" => tr("Majitel"), 
+       "brand" => tr("Značka"), "color" => tr("Barva"), "equipment" => tr("Vybavení"),
+       "description" => tr("Popis kola"));
 ?>
 <h1><?=tr("List kolárny").' '.$bikeroom->name?></h1>
 <table class="summaries">
index d7e4ce3a28cc3009262bffbddd4a33fc805b1329..0724710cdcc765584c58d1b44d2a076c4e2f4c12 100644 (file)
@@ -1,6 +1,8 @@
 <h1><?=tr("Majitelé kol, kola")?></h1>
 <?php
-       $props = array("userName" => tr("Majitel"), "description" => tr("Popis kola"), "bikeroomName" => tr("Kolárna"));
+       $props = array("userName" => tr("Majitel"),
+               "brand" => tr("Značka"), "color" => tr("Barva"), "equipment" => tr("Vybavení"), 
+               "description" => tr("Popis kola"), "bikeroomName" => tr("Kolárna"),);
 ?>
 <table class="summaries">
 <tr>