NEW FEATURE: Ability to add personal notes for each game
authorArun Persaud <arun@nubati.net>
Wed, 12 Mar 2008 05:21:09 +0000 (22:21 -0700)
committerArun Persaud <arun@nubati.net>
Wed, 12 Mar 2008 05:21:09 +0000 (22:21 -0700)
In case a player is involed in too many games it can get quite confusing with
whom your playing, etc. so now the player can add notes on the side that only
show up on his/her screen.

Signed-off-by: Arun Persaud <arun@nubati.net>
create_database.sql
css/standard.css
db.php
index.php

index e863f538bfc051d546bdcab2cac403c703e758bd..4c7419177fbd98a9065cfc301669213748beb64b 100644 (file)
@@ -62,6 +62,30 @@ LOCK TABLES `Comment` WRITE;
 UNLOCK TABLES;
 /*!40000 ALTER TABLE `Comment` ENABLE KEYS */;
 
 UNLOCK TABLES;
 /*!40000 ALTER TABLE `Comment` ENABLE KEYS */;
 
+--
+-- Table structure for table `Notes`
+--
+
+DROP TABLE IF EXISTS `Notes`;
+CREATE TABLE `Notes` (
+  `mod_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+  `create_date` timestamp NOT NULL default '0000-00-00 00:00:00',
+  `id` int(11) NOT NULL auto_increment,
+  `user_id` int(11) default NULL,
+  `game_id` int(11) default NULL,
+  `comment` text,
+  UNIQUE KEY `id` (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+--
+-- Dumping data for table `Notes`
+--
+
+/*!40000 ALTER TABLE `Notes` DISABLE KEYS */;
+LOCK TABLES `Notes` WRITE;
+UNLOCK TABLES;
+/*!40000 ALTER TABLE `Notes` ENABLE KEYS */;
+
 --
 -- Table structure for table `Game`
 --
 --
 -- Table structure for table `Game`
 --
index 0a0fc10f30c64df80c26ac24e348bd9bf20ef768..1766d6afa9277c82726fc4fea93472a21f4418ef 100644 (file)
@@ -361,6 +361,25 @@ ul.tricks li div div span.comment span{
   background-color: #eee;
 }
 
   background-color: #eee;
 }
 
+.notes {
+  position:absolute;
+  top:27em;
+  left:0;
+  margin:1em;
+  margin-top:0em;
+  margin-left:0em;
+
+  width: 12em;
+
+  border-top:    2px solid gray;
+  border-right:  2px solid gray;
+  border-bottom: 2px solid gray;
+
+  padding:0.3em;
+
+  background-color: #efefef;
+}
+
 .user { margin-left:25%;margin-right:25%; }
 
 .over {
 .user { margin-left:25%;margin-right:25%; }
 
 .over {
diff --git a/db.php b/db.php
index 7b95ae719fed25c02b7f3e8b2eab6b7833605046..7934781e0661bec924da8ba24661badce0447e22 100644 (file)
--- a/db.php
+++ b/db.php
@@ -641,6 +641,27 @@ function DB_insert_comment($comment,$playid,$userid)
   return;
 }
 
   return;
 }
 
+function DB_insert_note($comment,$gameid,$userid)
+{
+  mysql_query("INSERT INTO Notes VALUES (NULL,NULL,NULL,$userid,$gameid, ".DB_quote_smart($comment).")");
+
+  return;
+}
+
+function DB_get_notes_by_userid_and_gameid($userid,$gameid)
+{
+  $notes = array();
+
+  $result = mysql_query("SELECT comment FROM Notes WHERE user_id=".DB_quote_smart($userid) .
+                       " AND game_id=".DB_quote_smart($gameid));
+
+  while($r = mysql_fetch_array($result,MYSQL_NUM))
+    $notes[] = $r[0];
+
+  return $notes;
+}
+
+
 function DB_get_gametype_by_gameid($id)
 {
   $result = mysql_query("SELECT type FROM Game WHERE id=".DB_quote_smart($id));
 function DB_get_gametype_by_gameid($id)
 {
   $result = mysql_query("SELECT type FROM Game WHERE id=".DB_quote_smart($id));
index d0d9eef40362dd39d496864394eacac2b977134b..80a732fa111e85d5ded99f1e8404ad4610335df7 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1179,6 +1179,16 @@ else if(myisset("me"))
              DB_insert_comment($comment,$playid,$myid);
          };
 
              DB_insert_comment($comment,$playid,$myid);
          };
 
+      /* handle notes in case player didn't play a card, allow notes only during a game */
+      if( (!myisset("card") && $mystatus=='play')  )
+       if(myisset("note"))
+         {
+           $note = $_REQUEST["note"];
+
+           if($note != "")
+             DB_insert_note($note,$gameid,$myid);
+         };
+
       /* get everything relevant to display the tricks */
       $result = mysql_query("SELECT Hand_Card.card_id as card,".
                            "       Hand.position as position,".
       /* get everything relevant to display the tricks */
       $result = mysql_query("SELECT Hand_Card.card_id as card,".
                            "       Hand.position as position,".
@@ -1477,6 +1487,14 @@ else if(myisset("me"))
                    DB_insert_comment($comment,$playid,$myid);
                };
 
                    DB_insert_comment($comment,$playid,$myid);
                };
 
+             /* check for note */
+             if(myisset("note"))
+               {
+                 $note = $_REQUEST["note"];
+                 if($note != "")
+                   DB_insert_note($note,$gameid,$myid);
+               };
+
              /* display played card */
              $pos = DB_get_pos_by_hash($me);
              if($sequence==1)
              /* display played card */
              $pos = DB_get_pos_by_hash($me);
              if($sequence==1)
@@ -1837,6 +1855,13 @@ else if(myisset("me"))
 
       echo "</ul>\n"; /* end ul tricks*/
 
 
       echo "</ul>\n"; /* end ul tricks*/
 
+      echo "<div class=\"notes\"> Personal notes: <br />\n";
+      $notes = DB_get_notes_by_userid_and_gameid($myid,$gameid);
+      foreach($notes as $note)
+       echo "$note <hr \>\n";
+      echo "Insert note:<input name=\"note\" type=\"text\" size=\"15\" maxlength=\"100\" />\n";
+      echo "</div> \n";
+      
       $mycards = DB_get_hand($me);
       $mycards = mysort($mycards,$gametype);
       echo "<div class=\"mycards\">\n";
       $mycards = DB_get_hand($me);
       $mycards = mysort($mycards,$gametype);
       echo "<div class=\"mycards\">\n";
@@ -2014,7 +2039,6 @@ else if(myisset("me"))
 
     echo "</div>\n";
 
 
     echo "</div>\n";
 
-
     echo "</form>\n";
     output_footer();
     DB_close();
     echo "</form>\n";
     output_footer();
     DB_close();