File: 0.01.0a/customer/index.php (View as Code)

1: 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: 64: 65: 66: 67: FreeDESK Customer Interface 68: 69: 70:
71: 72:
FreeDESK Customer Interface
73: 78: 79: if (!isset($_REQUEST['mode'])) 80: { 81: ?> 82:
83: Welcome to the FreeDESK customer interface.

84: Please select an option from above.

85:
86: 87: } 88: else if ($_REQUEST['mode'] == "myrequests") 89: { 90: $data = array(); 91: $data[]=array("field"=>"customer", "value"=>$DESK->ContextManager->Session->username); 92: $pris = $DESK->RequestManager->GetPriorityList(); 93: $stats = $DESK->RequestManager->StatusList(); 94: $reqs = $DESK->RequestManager->SearchRequests($data); 95: echo "\n"; 96: foreach($reqs as $req) 97: { 98: echo "\n"; 99: echo "\n"; 100: echo "\n"; 101: echo "\n"; 107: echo "\n"; 113: echo "\n"; 114: } 115: echo "
ID ".$req['requestid']."".$req['openeddt'].""; 102: if (isset($pris[$req['priority']])) 103: echo $pris[$req['priority']]['priorityname']; 104: else 105: echo "-"; 106: echo ""; 108: if (isset($stats[$req['status']])) 109: echo $stats[$req['status']]; 110: else 111: echo "-"; 112: echo "
";
116: } 117: else if ($_REQUEST['mode'] == "request") 118: { 119: $req = $DESK->RequestManager->Fetch($_REQUEST['requestid']); 120: $cid = $req->Get("customerid"); 121: //echo $cid; 122: if ($req === false) 123: { 124: echo "

Request not found

";
125: } 126: else if ($cid != $DESK->ContextManager->Session->username) // not our request (naughty!) 127: { 128: echo "

Access to request denied

";
129: } 130: else 131: { 132: echo "\n"; 133: echo "\n"; 134: echo "\n"; 135: echo "\n"; 136: echo "\n"; 137: echo "\n"; 138: echo "\n"; 139: echo "
ID".$req->ID."
Opened".$req->Get("openeddt")."
\n";
140: 141: echo "

\n";
142: 143: $req->LoadUpdates(); 144: $updates=$req->GetUpdates(); 145: 146: echo "\n"; 147: foreach($updates as $update) 148: { 149: echo "\n"; 152: echo ""; 155: } 156: echo "
"; 150: echo $update['updatedt']." : ".$update['updateby']."\n"; 151: echo "
\n"; 153: echo nl2br($update['update']); 154: echo "
\n";
157: 158: echo "

";
159: 160: if ($req->Get("status")>0) 161: { 162: echo "
\n"; 163: echo "\n"; 164: echo "\n"; 165: echo "\n"; 166: echo "\n"; 167: echo "

Update Request

\n";
168: echo "
\n";
169: echo "\n"; 170: echo "\n";
171: } 172: else 173: { 174: echo "

Request is closed - contact Service Desk to reopen

\n";
175: } 176: 177: echo "

";
178: } 179: } 180: else if ($_REQUEST['mode'] == "new") 181: { 182: echo "

New Request

\n";
183: echo "Please enter as much information about the request as possible.

";
184: echo "
\n"; 185: echo "\n"; 186: echo "\n"; 187: echo "
\n";
188: echo "\n"; 189: echo "\n";
190: } 191: ?> 192:
193: 194: 195: 196: