Viewing File customer/index.php of 0.00.1a
|
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::Customer, $_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: $rid = $_REQUEST['requestid']; 43: $req = $DESK->RequestManager->Fetch($rid); 44: if ($rid !== false && $req->Get("customerid")==$DESK->ContextManager->Session->username) 45: { 46: $req->Update($_REQUEST['update']); 47: } 48: } 49: else if ($_REQUEST['action'] == "createrequest") 50: { 51: $req = $DESK->RequestManager->CreateById(""); 52: $rid=$req->Create($DESK->ContextManager->Session->username, 53: $_REQUEST['update'], 54: "", 55: 1 ); 56: $loc="./?mode=request&requestid=".$rid."&sid=".$_REQUEST['sid']; 57: header("Location: ".$loc); 58: exit(); 59: } 60: } 61: 62: ?> 63: <!DOCTYPE html> 64: <html> 65: <head> 66: <link rel="stylesheet" type="text/css" href="customer.css" /> 67: <title>FreeDESK Customer Interface</title> 68: </head> 69: <body> 70: <div class="container"> 71: 72: <div class="header">FreeDESK Customer Interface</div> 73: <div class="menu"> 74: <a href="./?mode=new&sid=<?php echo $_REQUEST['sid']; ?>">New Request</a> | 75: <a href="./?mode=myrequests&sid=<?php echo $_REQUEST['sid']; ?>">My Requests</a> 76: </div> 77: <?php 78: if (!isset($_REQUEST['mode'])) 79: { 80: ?> 81: <div class="contents"> 82: Welcome to the FreeDESK customer interface.<br /><br /> 83: Please select an option from above.<br /><br /> 84: </div> 85: <?php 86: } 87: else if ($_REQUEST['mode'] == "myrequests") 88: { 89: $data = array(); 90: $data[]=array("field"=>"customer", "value"=>$DESK->ContextManager->Session->username); 91: $pris = $DESK->RequestManager->GetPriorityList(); 92: $stats = $DESK->RequestManager->StatusList(); 93: $reqs = $DESK->RequestManager->SearchRequests($data); 94: echo "<table class=\"requestlist\">\n"; 95: foreach($reqs as $req) 96: { 97: echo "<tr>\n"; 98: echo "<td><a href=\"./?mode=request&requestid=".$req['requestid']."&sid=".$_REQUEST['sid']."\">ID ".$req['requestid']."</a></td>\n"; 99: echo "<td>".$req['openeddt']."</td>\n"; 100: echo "<td>"; 101: if (isset($pris[$req['priority']])) 102: echo $pris[$req['priority']]['priorityname']; 103: else 104: echo "-"; 105: echo "</td>\n"; 106: echo "<td>"; 107: if (isset($stats[$req['status']])) 108: echo $stats[$req['status']]; 109: else 110: echo "-"; 111: echo "</td>\n"; 112: echo "</tr>\n"; 113: } 114: echo "</table>"; 115: } 116: else if ($_REQUEST['mode'] == "request") 117: { 118: $req = $DESK->RequestManager->Fetch($_REQUEST['requestid']); 119: $cid = $req->Get("customerid"); 120: //echo $cid; 121: if ($req === false) 122: { 123: echo "<h3>Request not found</h3>"; 124: } 125: else if ($cid != $DESK->ContextManager->Session->username) // not our request (naughty!) 126: { 127: echo "<h3>Access to request denied</h3>"; 128: } 129: else 130: { 131: echo "<table class=\"reqdetails\">\n"; 132: echo "<tr>\n"; 133: echo "<td>ID</td>\n"; 134: echo "<td>".$req->ID."</td></tr>\n"; 135: echo "<tr>\n"; 136: echo "<td>Opened</td>\n"; 137: echo "<td>".$req->Get("openeddt")."</td></tr>\n"; 138: echo "</table>\n"; 139: 140: echo "<br /><br />\n"; 141: 142: $req->LoadUpdates(); 143: $updates=$req->GetUpdates(); 144: 145: echo "<table class=\"requpdates\">\n"; 146: foreach($updates as $update) 147: { 148: echo "<tr><td class=\"updatehead\">"; 149: echo $update['updatedt']." : ".$update['updateby']."\n"; 150: echo "</td></tr>\n"; 151: echo "<tr><td>\n"; 152: echo nl2br($update['update']); 153: echo "</td></tr>"; 154: } 155: echo "</table>\n"; 156: 157: echo "<br /><br />"; 158: 159: if ($req->Get("status")>0) 160: { 161: echo "<form id=\"requestupdate\" action=\"./\" method=\"post\">\n"; 162: echo "<input type=\"hidden\" name=\"action\" value=\"updaterequest\" />\n"; 163: echo "<input type=\"hidden\" name=\"requestid\" value=\"".$_REQUEST['requestid']."\" />\n"; 164: echo "<input type=\"hidden\" name=\"mode\" value=\"request\" />\n"; 165: echo "<input type=\"hidden\" name=\"sid\" value=\"".$_REQUEST['sid']."\" />\n"; 166: echo "<h3>Update Request</h3>\n"; 167: echo "<textarea name=\"update\" rows=\"10\" cols=\"50\"></textarea><br />\n"; 168: echo "<input type=\"submit\" value=\"Update Request\" />\n"; 169: echo "</form>\n"; 170: } 171: else 172: { 173: echo "<h3>Request is closed - contact Service Desk to reopen</h3>\n"; 174: } 175: 176: echo "<br /><br />"; 177: } 178: } 179: else if ($_REQUEST['mode'] == "new") 180: { 181: echo "<h3>New Request</h3>\n"; 182: echo "Please enter as much information about the request as possible.<br /><br />"; 183: echo "<form id=\"requestcreate\" action=\"./\" method=\"post\">\n"; 184: echo "<input type=\"hidden\" name=\"action\" value=\"createrequest\" />\n"; 185: echo "<input type=\"hidden\" name=\"sid\" value=\"".$_REQUEST['sid']."\" />\n"; 186: echo "<textarea name=\"update\" rows=\"10\" cols=\"50\"></textarea><br />\n"; 187: echo "<input type=\"submit\" value=\"Create Request\" />\n"; 188: echo "</form>\n"; 189: } 190: ?> 191: </div> 192: </body> 193: </html> 194: 195: