File: 0.01.1a/mobile/index.php (View as HTML)

  1: <?php
  2: /* -------------------------------------------------------------
  3: This file is part of FreeDESK
  4: 
  5: FreeDESK is (C) Copyright 2012 David Cutting
  6: 
  7: FreeDESK is free software: you can redistribute it and/or modify
  8: it under the terms of the GNU General Public License as published by
  9: the Free Software Foundation, either version 3 of the License, or
 10: (at your option) any later version.
 11: 
 12: FreeDESK is distributed in the hope that it will be useful,
 13: but WITHOUT ANY WARRANTY; without even the implied warranty of
 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15: GNU General Public License for more details.
 16: 
 17: You should have received a copy of the GNU General Public License
 18: along with FreeDESK.  If not, see www.gnu.org/licenses
 19: 
 20: For more information see www.purplepixie.org/freedesk/
 21: -------------------------------------------------------------- */
 22: 
 23: 
 24: if (!isset($_REQUEST['sid']))
 25: {
 26: 	header("Location: login.php");
 27: 	exit();
 28: }
 29: require("../core/FreeDESK.php");
 30: $DESK = new FreeDESK("../");
 31: $DESK->Start();
 32: if (!$DESK->ContextManager->Open(ContextType::User, $_REQUEST['sid']))
 33: {
 34: 	header("Location: login.php?e=expired");
 35: 	exit();
 36: }
 37: 
 38: if (isset($_REQUEST['action']))
 39: {
 40: 	if ($_REQUEST['action'] == "updaterequest")
 41: 	{
 42: 		$req = $DESK->RequestManager->Fetch($_REQUEST['requestid']);
 43: 		if ($req->Get("assignuser") == $DESK->ContextManager->Session->username)
 44: 		{
 45: 			if ($_REQUEST['update'] != "")
 46: 				$req->Update($_REQUEST['update'], true);
 47: 			if ($_REQUEST['status'] != "")
 48: 				$req->Status($_REQUEST['status'], true);
 49: 			if ($_REQUEST['assign'] != "")
 50: 			{
 51: 				$team = 0;
 52: 				$user = "";
 53: 				$assign = $_REQUEST['assign'];
 54: 				
 55: 				if (is_numeric($assign))
 56: 					$team = $assign;
 57: 				else
 58: 				{
 59: 					$parts = explode("/",$assign);
 60: 					$team = $parts[0];
 61: 					if (isset($parts[1]))
 62: 						$user=$parts[1];
 63: 				}
 64: 				$req->Assign($team, $user, true);
 65: 				// If now assigned to someone else we can't view it so redirect
 66: 				if ($user != $DESK->ContextManager->Session->username)
 67: 				{
 68: 					header("Location: ./?sid=".$_REQUEST['sid']);
 69: 					exit();
 70: 				}
 71: 			}
 72: 		}
 73: 	}
 74: }
 75: 
 76: ?>
 77: <!DOCTYPE html>
 78: <html>
 79: <head>
 80: <meta name="viewport" content="width=device-width" />
 81: <link rel="stylesheet" type="text/css" href="mobile.css" />
 82: <title>FreeDESK Mobile Interface</title>
 83: </head>
 84: <body>
 85: 
 86: <div class="header">FreeDESK Mobile</div>
 87: <div class="container">
 88: 
 89: <?php
 90: if (isset($_REQUEST['mode']) && $_REQUEST['mode']=="request")
 91: {
 92: 	echo "<form action=\"./\" method=\"post\">\n";
 93: 	echo "<input type=\"hidden\" name=\"sid\" value=\"".$_REQUEST['sid']."\" />\n";
 94: 	echo "<input type=\"submit\" value=\"&lt;&lt; Back to Request List &lt;&lt;\" class=\"mobLogin\" />\n";
 95: 	echo "</form>\n";
 96: 	echo "<br /><br />\n";
 97: 	
 98: 	$req = $DESK->RequestManager->Fetch($_REQUEST['requestid']);
 99: 	if ($req === false)
100: 	{
101: 		echo "<b>Request not found</b>";
102: 	}
103: 	else if ($req->Get("assignuser") == $DESK->ContextManager->Session->username)
104: 	{
105: 		echo "<b>ID ".$req->ID." for ".$req->Get("customer")."</b><br /><br />\n";
106: 		$req->LoadUpdates();
107: 		$updates = $req->GetUpdates();
108: 		
109: 		foreach($updates as $update)
110: 		{
111: 			echo "<div class=\"update\">\n";
112: 			echo "<div class=\"update_header\">\n";
113: 			echo $update['updatedt'].": ".$update['updateby']."\n";
114: 			echo "</div>\n";
115: 			echo "<div class=\"update_content\">\n";
116: 			echo nl2br($update['update'])."\n";
117: 			echo "</div>\n";
118: 			echo "</div>\n";
119: 		}
120: 		
121: 		echo "<h3>Update Request</h3>\n";
122: 		echo "<form id=\"update_form\" action=\"./\" method=\"post\">\n";
123: 		echo "<input type=\"hidden\" name=\"action\" value=\"updaterequest\" />\n";
124: 		echo "<input type=\"hidden\" name=\"mode\" value=\"request\" />\n";
125: 		echo "<input type=\"hidden\" name=\"requestid\" value=\"".$_REQUEST['requestid']."\" />\n";
126: 		echo "<input type=\"hidden\" name=\"sid\" value=\"".$_REQUEST['sid']."\" />\n";
127: 		echo "<textarea name=\"update\" class=\"update\"></textarea>\n";
128: 		echo "<br /><br />\n";
129: 		
130: 		echo "Assign<br />\n";
131: 		echo "<select name=\"assign\" class=\"update\">\n";
132: 		echo "<option value=\"\" selected>No Change</option>\n";
133: 		$list = $DESK->RequestManager->TeamUserList();
134: 		foreach($list as $teamid => $team)
135: 		{
136: 			$teamname = $team['name'];
137: 			if ($team['assign'])
138: 				echo "<option value=\"".$teamid."\">".$teamname."</option>\n";
139: 			if (is_array($team['items']))
140: 			{
141: 				foreach($team['items'] as $username => $detail)
142: 				{
143: 					if ($team['team'])
144: 						$tid = $teamid;
145: 					else
146: 						$tid = 0;
147: 					if ($detail['assign'])
148: 						echo "<option value=\"".$tid."/".$username."\">".$teamname." &gt; ".$detail['realname']."</option>\n";
149: 				}
150: 			}
151: 		}
152: 		echo "</select>\n";
153: 		
154: 		echo "<br /><br />\n";
155: 		
156: 		echo "Status<br />\n";
157: 		
158: 		$statuses = $DESK->RequestManager->StatusList();
159: 		
160: 		echo "<select name=\"status\" class=\"update\">\n";
161: 		echo "<option value=\"\" selected>No Change</option>\n";
162: 		
163: 		foreach($statuses as $code => $desc)
164: 			echo "<option value=\"".$code."\">".$desc."</option>\n";
165: 		
166: 		echo "</select>\n";
167: 		
168: 		echo "<br /><br />\n";
169: 		
170: 		echo "<input type=\"submit\" class=\"mobLogin\" value=\"Update Request\" />\n";
171: 		
172: 		echo "<br /><br />\n";
173: 		
174: 		echo "</form>\n";
175: 	}
176: 	else
177: 	{
178: 		echo "<b>Sorry access to request denied</b>";
179: 	}
180: 	
181: 	echo "<br /><br />\n";
182: 	echo "<form action=\"./\" method=\"post\">\n";
183: 	echo "<input type=\"hidden\" name=\"sid\" value=\"".$_REQUEST['sid']."\" />\n";
184: 	echo "<input type=\"submit\" value=\"&lt;&lt; Back to Request List &lt;&lt;\" class=\"mobLogin\" />\n";
185: 	echo "</form>\n";
186: 	echo "<br /><br />\n";
187: }
188: else
189: {
190: 	$reqs = $DESK->RequestManager->FetchAssigned(0,
191: 		$DESK->ContextManager->Session->username,
192: 		"requestid");
193: 	//echo sizeof($reqs);
194: 	if (sizeof($reqs)<=0)
195: 	{
196: 		echo "<b>No requests assigned</b>\n";
197: 	}
198: 	
199: 	echo "<table class=\"reqList\">\n";
200: 	$row=0;
201: 	
202: 	foreach($reqs as $req)
203: 	{
204: 		echo "<tr class=\"row".$row."\">\n";
205: 		if ($row==0)
206: 			$row=1;
207: 		else
208: 			$row=0;
209: 		echo "<td><a href=\"./?mode=request&requestid=".$req->ID."&sid=".$_REQUEST['sid']."\">".$req->ID."</a></td>\n";
210: 		echo "<td>".$req->Get("customer")."</td>\n";
211: 		echo "<td>\n";
212: 		echo "<form action=\"./\" method=\"post\">\n";
213: 		echo "<input type=\"hidden\" name=\"mode\" value=\"request\" />\n";
214: 		echo "<input type=\"hidden\" name=\"requestid\" value=\"".$req->ID."\" />\n";
215: 		echo "<input type=\"hidden\" name=\"sid\" value=\"".$_REQUEST['sid']."\" />\n";
216: 		echo "<input type=\"submit\" value=\"Open\" class=\"openButton\" />\n";
217: 		echo "</form>\n";
218: 		echo "</td>\n";
219: 		echo "</tr>\n";
220: 	}
221: 	echo "</table>\n";
222: 	
223: }
224: ?>
225: 
226: <br /><br />
227: <form action="login.php" method="post">
228: <input type="hidden" name="mofr" value="logout" />
229: <input type="hidden" name="sid" value="<?php echo $_REQUEST['sid']; ?>" />
230: <input type="submit" value="Logout" class="mobLogin" />
231: </form>
232: 
233: <br /><br />
234: <form action="../" method="post">
235: <input type="hidden" name="mobileoverride" value="1" />
236: <input type="hidden" name="sid" value="<?php echo $_REQUEST['sid']; ?>" />
237: <input type="submit" value="Use Desktop Interface" class="mobLogin" />
238: </form>
239: </div>
240: 
241: </body>
242: </html>
243: 
244: