aboutsummaryrefslogtreecommitdiff
path: root/modules/rudi/admin
diff options
context:
space:
mode:
Diffstat (limited to 'modules/rudi/admin')
-rw-r--r--modules/rudi/admin/includes/admin.class.php121
-rw-r--r--modules/rudi/admin/index.php21
-rw-r--r--modules/rudi/admin/views/view.addsoldier.php3
-rw-r--r--modules/rudi/admin/views/view.admin.php20
-rw-r--r--modules/rudi/admin/views/view.deletesoldier.php3
-rw-r--r--modules/rudi/admin/views/view.modifysoldier.php35
6 files changed, 203 insertions, 0 deletions
diff --git a/modules/rudi/admin/includes/admin.class.php b/modules/rudi/admin/includes/admin.class.php
new file mode 100644
index 0000000..fee79c9
--- /dev/null
+++ b/modules/rudi/admin/includes/admin.class.php
@@ -0,0 +1,121 @@
+<?php
+/*
+class Rank
+{
+ public function __toString()
+ {
+ return $this->longname;
+ }
+}
+
+class Award
+{
+ public function __toString()
+ {
+ return $this->name;
+ }
+}
+*/
+
+class AdminCommon extends RUDI_Common
+{
+ public function __construct()
+ {
+ parent::__construct();
+ $this->Update();
+ }
+
+ public function getRanks()
+ {
+ $result = $this->db->Query("SELECT * FROM rudi_ranks");
+ while(($row = $this->db->FetchObject($result,'Rank'))!=false)
+ {
+ $ranks[] = $row;
+ }
+
+ return $ranks;
+ }
+
+ public function getAwards()
+ {
+ $result = $this->db->Query("SELECT * FROM rudi_awards");
+ while(($row = $this->db->FetchObject($result,'Award'))!=false)
+ {
+ $awards[] = $row;
+ }
+
+ return $awards;
+ }
+}
+
+class AdminAdd
+{
+ protected $db, $link, $id;
+ public $data;
+
+ public function __construct()
+ {
+ if(is_null($id))
+ {
+ decho("No ID");
+ return;
+ }
+ $this->id = $id;
+
+ $this->db = new RUDI_SQL();
+ $this->link = $this->db->Connect('localhost','hunkeler','proball');
+ $this->db->Select_db('rudi');
+
+ //$result = $this->db->Query("INSERT INTO rudi_unit_members VALUES()");
+ //$name = $this->db->FetchArray($result);
+
+ echo "Current soldier selected: '{$name['last_name']}, {$name['first_name']}'";
+ }
+
+ public function __set($var, $val)
+ {
+ //echo "UPDATE rudi_unit_members SET $var = '$val';";
+ //mysql_query("UPDATE rudi_unit_members SET $var = '$val';");
+ $this->id = addslashes($this->id);
+ $this->db->Query("UPDATE rudi_unit_members SET $var = '$val' WHERE member_id = '{$this->id}';");
+ }
+}
+
+class AdminModify
+{
+ protected $db, $link, $id;
+ public $data;
+
+ public function __construct($id)
+ {
+ if(is_null($id))
+ {
+ decho("No ID");
+ return;
+ }
+ else
+ {
+ decho(get_class($this) . "received: $id" );
+ }
+ $this->id = $id;
+
+ $this->db = new RUDI_SQL();
+ $this->link = $this->db->Connect('localhost','hunkeler','proball');
+ $this->db->Select_db('rudi');
+
+ $result = $this->db->Query("SELECT last_name, first_name FROM rudi_unit_members WHERE member_id = '$id'");
+ $name = $this->db->FetchArray($result);
+
+ echo "Current soldier selected: '{$name['last_name']}, {$name['first_name']}'";
+ }
+
+ public function __set($var, $val)
+ {
+ //echo "UPDATE rudi_unit_members SET $var = '$val';";
+ //mysql_query("UPDATE rudi_unit_members SET $var = '$val';");
+ $this->id = addslashes($this->id);
+ $this->db->Query("UPDATE rudi_unit_members SET $var = '$val' WHERE member_id = '{$this->id}';");
+ }
+}
+
+?> \ No newline at end of file
diff --git a/modules/rudi/admin/index.php b/modules/rudi/admin/index.php
new file mode 100644
index 0000000..33d9cd1
--- /dev/null
+++ b/modules/rudi/admin/index.php
@@ -0,0 +1,21 @@
+<?php
+
+//include '../includes/debug.php';
+//include '../includes/sql.class.php';
+//include '../includes/common.class.php';
+include 'includes/admin.class.php';
+//include '../header.php';
+
+ob_start();
+$common = new AdminCommon();
+include 'views/view.admin.php';
+
+if(isset($_GET['soldier']) && $_GET['soldier'] == 'modify')
+{
+ include 'views/view.modifysoldier.php';
+
+}
+
+//include '../footer.php';
+ob_flush();
+?> \ No newline at end of file
diff --git a/modules/rudi/admin/views/view.addsoldier.php b/modules/rudi/admin/views/view.addsoldier.php
new file mode 100644
index 0000000..370b232
--- /dev/null
+++ b/modules/rudi/admin/views/view.addsoldier.php
@@ -0,0 +1,3 @@
+<?php
+
+?> \ No newline at end of file
diff --git a/modules/rudi/admin/views/view.admin.php b/modules/rudi/admin/views/view.admin.php
new file mode 100644
index 0000000..d05e5b1
--- /dev/null
+++ b/modules/rudi/admin/views/view.admin.php
@@ -0,0 +1,20 @@
+<?php
+
+?>
+<html>
+<head>
+<title>RUDI Administration</title>
+</head>
+
+<body>
+ <table>
+ <tr><th>RUDI Administration</th></tr>
+ <table cellpadding="5">
+ <tr><th>Soldiers</th><th>Awards</th><th>Ranks</th></tr>
+ <tr><td><a href="?load=rudi&admin&soldier=add">Add</a></td><td><a href="?load=rudi&admin&award=add">Add</a></td><td><a href="?load=rudi&admin&rank=add">Add</a></td></tr>
+ <tr><td>Modify</td><td>Modify</td><td>Modify</td></tr>
+ <tr><td>Delete</td><td>Delete</td><td>Delete</td></tr>
+ </table>
+ </table>
+</body>
+</html>
diff --git a/modules/rudi/admin/views/view.deletesoldier.php b/modules/rudi/admin/views/view.deletesoldier.php
new file mode 100644
index 0000000..370b232
--- /dev/null
+++ b/modules/rudi/admin/views/view.deletesoldier.php
@@ -0,0 +1,3 @@
+<?php
+
+?> \ No newline at end of file
diff --git a/modules/rudi/admin/views/view.modifysoldier.php b/modules/rudi/admin/views/view.modifysoldier.php
new file mode 100644
index 0000000..83449b8
--- /dev/null
+++ b/modules/rudi/admin/views/view.modifysoldier.php
@@ -0,0 +1,35 @@
+
+<?php
+if(isset($_POST['id']))
+{
+ $id = $_POST['id'];
+ //unset($_POST);
+ $modify = new AdminModify((int)$id);
+ $edit =& $common->data[(int)$id];
+}
+?>
+
+<form method="POST">
+<select name="id">
+<?php foreach($common->data as $member):?>
+ <option value="<?php echo $member->member_id ?>" <?php if(!is_null($id) && $id == $member->member_id) echo ' selected '; ?>><?php echo $member->name ?></option>
+<?php endforeach; ?>
+</select>
+<button value="Select">Select</button>
+</form>
+
+<form action="" method="GET">
+<table>
+<tr><th>Modify Soldier</th></tr>
+<tr><th>Last Name</th><td><input type="text" name="last" value="<?php echo $edit->last_name ?>" /></td></tr>
+<tr><th>First Name</th><td><input type="text" value="<?php echo $edit->first_name ?>" /></td></tr>
+<tr><th>Rank</th><td><select name="rank">
+<?php foreach($common->getRanks() as $ranks): ?>
+ <option value="<?php echo $ranks->rank_id ?>"><?php echo $ranks ?></option>
+<?php endforeach; ?>
+</select></td></tr>
+<tr><th colspan="2"><input type="submit" value="submit"/></th></tr>
+</table>
+</form>
+
+<?php decho($_POST); decho($common->data[$id]); //decho($common->getRanks())?> \ No newline at end of file