Viewing File request.php of 0.00.0a
|
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: * Request Display 25: **/ 26: 27: 28: // Output buffer on and start FreeDESK then discard startup whitespace-spam 29: ob_start(); 30: include("core/FreeDESK.php"); 31: $DESK = new FreeDESK("./"); 32: $DESK->Start(); 33: ob_end_clean(); 34: 35: 36: if (!isset($_REQUEST['sid']) || !$DESK->ContextManager->Open(ContextType::User, $_REQUEST['sid'])) 37: { 38: $data=array("title"=>$DESK->Lang->Get("welcome")); 39: $DESK->Skin->IncludeFile("min_header.php",$data); 40: 41: echo "\n<noscript>\n"; 42: echo "<h1>Sorry you must have Javascript enabled to use FreeDESK analyst portal</h1>\n"; 43: echo "</noscript>\n"; 44: 45: echo "<h3>".$DESK->Lang->Get("login_invalid").":</h3>\n"; 46: 47: 48: $DESK->Skin->IncludeFile("min_footer.php"); 49: exit(); 50: } 51: 52: 53: // So we're authenticated let's view the main page 54: $data=array("title"=>"FreeDESK"); 55: $DESK->Skin->IncludeFile("min_header.php",$data); 56: 57: if (isset($_REQUEST['id'])) 58: { 59: $id=$_REQUEST['id']; 60: 61: $request = $DESK->RequestManager->Fetch($id); 62: 63: if ($request === false) 64: { 65: echo $DESK->Lang->Get("entity_not_found"); 66: $DESK->Skin->IncludeFile("min_footer.php"); 67: exit(); 68: } 69: 70: echo "<div id=\"request_header\">\n"; 71: echo "<b>".$DESK->Lang->Get("request")." ".$id.": "; 72: 73: $q="SELECT * FROM ".$DESK->Database->Table("customer")." WHERE ".$DESK->Database->Field("customerid")."=".$DESK->Database->Safe($request->Get("customerid"))." LIMIT 0,1"; 74: $r=$DESK->Database->Query($q); 75: $cust = $DESK->Database->FetchAssoc($r); 76: $DESK->Database->Free($r); 77: 78: echo $cust['firstname']." ".$cust['lastname']; 79: 80: echo "</b>\n"; 81: echo "</div>"; 82: 83: $request->LoadUpdates(); 84: 85: $panes = array( 86: "log" => array( "title" => "Request History" ), 87: //"details" => array( "title" => "Details" ), 88: "update" => array( "title" => "Update Request" ) ); 89: 90: $data = array( "id" => "request", "panes" => $panes ); 91: $DESK->Skin->IncludeFile("pane_start.php", $data); 92: 93: echo "<div id=\"pane_request_log_content\" class=\"pane_content\">\n"; 94: 95: $updates = $request->GetUpdates(); 96: 97: foreach($updates as $update) 98: { 99: echo "<div id=\"update_".$update['updateid']."\" class=\"update\">\n"; 100: echo "<div id=\"update_header_".$update['updateid']."\" class=\"update_header\">\n"; 101: echo $update['updatedt']." : ".$update['updateby']."\n"; 102: echo "</div>\n"; 103: echo "<div id=\"update_content_".$update['updateid']."\" class=\"update_content\">"; 104: echo $update['update']."\n\n"; 105: echo "</div>\n"; 106: echo "</div>\n"; 107: } 108: 109: echo "</div>"; 110: 111: echo "<div id=\"pane_request_details_content\" class=\"pane_content_hidden\">\n"; 112: echo "Details"; 113: echo "</div>"; 114: 115: echo "<div id=\"pane_request_update_content\" class=\"pane_content_hidden\">\n"; 116: 117: echo "<form id=\"request_update\" onsubmit=\"return false;\">"; 118: 119: echo "<table class=\"request_update\">\n"; 120: 121: echo "<tr><td colspan=\"2\">\n"; 122: 123: echo "<input type=\"hidden\" name=\"mode\" value=\"request_update\">\n"; 124: echo "<input type=\"hidden\" name=\"requestid\" value=\"".$id."\">\n"; 125: echo "<textarea rows=\"10\" cols=\"50\" name=\"update\"></textarea>\n"; 126: 127: echo "</td></tr>\n"; 128: echo "<tr><td>"; 129: 130: echo $DESK->Lang->Get("assign")." "; 131: 132: echo "</td><td>"; 133: 134: echo "<select name=\"assign\">\n"; 135: 136: echo "<option value=\" \" selected>".$DESK->Lang->Get("no_change")."</option>\n"; 137: 138: $list = $DESK->RequestManager->TeamUserList(); 139: 140: foreach($list as $teamid => $team) 141: { 142: $teamname = $team['name']; 143: if ($team['assign']) 144: echo "<option value=\"".$teamid."\">".$teamname."</option>\n"; 145: if (is_array($team['items'])) 146: { 147: foreach($team['items'] as $username => $detail) 148: { 149: if ($team['team']) 150: $tid = $teamid; 151: else 152: $tid = 0; 153: if ($detail['assign']) 154: echo "<option value=\"".$tid."/".$username."\">".$teamname." > ".$detail['realname']."</option>\n"; 155: } 156: } 157: } 158: echo "</select>\n"; 159: 160: echo "</td></tr>\n"; 161: 162: echo "<tr><td>\n"; 163: 164: echo $DESK->Lang->Get("status"); 165: 166: echo "</td><td>\n"; 167: 168: $statuses = $DESK->RequestManager->StatusList(); 169: 170: echo "<select name=\"status\">\n"; 171: echo "<option value=\" \" selected>".$DESK->Lang->Get("no_change")."</option>\n"; 172: 173: foreach($statuses as $code => $desc) 174: echo "<option value=\"".$code."\">".$desc."</option>\n"; 175: 176: echo "</select>\n"; 177: echo "</td></tr>\n"; 178: 179: echo "<tr><td>\n"; 180: 181: echo "<input type=\"submit\" value=\"".$DESK->Lang->Get("save")."\" onclick=\"DESK.formAPI('request_update',false,true);\">"; 182: 183: echo "</td><td>\n"; 184: 185: echo "<input type=\"submit\" value=\"".$DESK->Lang->Get("save_close")."\" onclick=\"DESK.formAPI('request_update',true,false);\">"; 186: 187: echo "</td></tr>\n"; 188: 189: echo "</table>"; 190: 191: echo "</form>\n"; 192: 193: echo "</div>"; 194: 195: 196: 197: $DESK->Skin->IncludeFile("pane_finish.php"); 198: } 199: else // new request 200: { 201: 202: echo "<div id=\"customer_select\" class=\"customer_select\">\n"; 203: 204: echo "<form id=\"customersearch\" onsubmit=\"return false;\">\n"; 205: echo "<table class=\"search\">\n"; 206: 207: $table=$DESK->DataDictionary->Tables["customer"]; 208: 209: foreach($table->fields as $id => $field) 210: { 211: if ($field->searchable) 212: { 213: echo "<tr><td>".$field->name."</td>\n"; 214: $val=""; 215: if (isset($_REQUEST[$field->field])) 216: { 217: $val=$_REQUEST[$field->field]; 218: $searchnow=true; 219: } 220: echo "<td><input type=\"text\" name=\"".$field->field."\" value=\"".$val."\" /></td></tr>\n"; 221: } 222: } 223: echo "<tr><td> </td>\n"; 224: echo "<td><input type=\"submit\" value=\"".$DESK->Lang->Get("search")."\" onclick=\"DESKRequest.searchCustomer();\" /></td>\n"; 225: echo "</tr>"; 226: echo "</table>\n"; 227: echo "</form>\n"; 228: 229: 230: echo "</div>"; 231: echo "<div id=\"customer_details\" class=\"customer_details\">\n"; 232: echo "<br /><b>".$DESK->Lang->Get("customer")." : </b><span id=\"customer_id\"></span> \n"; 233: echo "<a href=\"#\" onclick=\"DESKRequest.searchCustomerAgain();\">Change</a>"; 234: echo "</div>"; 235: 236: echo "<hr class=\"request\" />\n"; 237: 238: echo "<form id=\"request_create\" onsubmit=\"return false;\">"; 239: 240: echo "<table class=\"request_update\">\n"; 241: 242: echo "<tr><td colspan=\"2\">\n"; 243: 244: echo "<textarea rows=\"10\" cols=\"50\" name=\"update\"></textarea>\n"; 245: 246: echo "</td></tr>\n"; 247: echo "<tr><td>"; 248: 249: echo $DESK->Lang->Get("assign")." "; 250: 251: echo "</td><td>"; 252: 253: echo "<select name=\"assign\">\n"; 254: 255: $list = $DESK->RequestManager->TeamUserList(); 256: 257: foreach($list as $teamid => $team) 258: { 259: $teamname = $team['name']; 260: if ($team['assign']) 261: echo "<option value=\"".$teamid."\">".$teamname."</option>\n"; 262: if (is_array($team['items'])) 263: { 264: foreach($team['items'] as $username => $detail) 265: { 266: if ($team['team']) 267: $tid = $teamid; 268: else 269: $tid = 0; 270: if ($detail['assign']) 271: echo "<option value=\"".$tid."/".$username."\">".$teamname." > ".$detail['realname']."</option>\n"; 272: } 273: } 274: } 275: echo "</select>\n"; 276: 277: echo "</td></tr>\n"; 278: 279: echo "<tr><td>\n"; 280: 281: echo $DESK->Lang->Get("status"); 282: 283: echo "</td><td>\n"; 284: 285: $statuses = $DESK->RequestManager->StatusList(); 286: 287: echo "<select name=\"status\">\n"; 288: 289: foreach($statuses as $code => $desc) 290: echo "<option value=\"".$code."\">".$desc."</option>\n"; 291: 292: echo "</select>\n"; 293: echo "</td></tr>\n"; 294: 295: echo "<tr><td>\n"; 296: 297: echo "<input type=\"submit\" value=\"".$DESK->Lang->Get("save")."\" onclick=\"DESKRequest.Create();\" />"; 298: 299: echo "</td><td>\n"; 300: 301: echo "<input type=\"submit\" value=\"".$DESK->Lang->Get("save_close")."\" onclick=\"DESKRequest.Create(true);\" />"; 302: 303: echo "</td></tr>\n"; 304: 305: echo "</table>"; 306: 307: echo "</form>"; 308: 309: } 310: 311: 312: 313: $DESK->Skin->IncludeFile("min_footer.php"); 314: 315: 316: ?> 317: