Viewing File request.php of 0.01.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: 113: echo "<table>\n"; 114: 115: $statuses = $DESK->RequestManager->StatusList(); 116: $priorities = $DESK->RequestManager->GetPriorityList(); 117: 118: echo "<tr>\n"; 119: echo "<td>".$DESK->Lang->Get("status").": </td>\n"; 120: echo "<td>"; 121: if (isset($statuses[$request->Get("status")])) 122: echo $statuses[$request->Get("status")]; 123: else 124: echo $DESK->Lang->Get("unknown"); 125: echo "</td>\n"; 126: echo "</tr>\n"; 127: 128: echo "<tr>\n"; 129: echo "<td>".$DESK->Lang->Get("priority").": </td>\n"; 130: echo "<td>"; 131: if (isset($priorities[$request->Get("priority")])) 132: echo $priorities[$request->Get("priority")]['priorityname']; 133: else 134: echo $DESK->Lang->Get("unknown"); 135: echo "</td>\n"; 136: echo "</tr>\n"; 137: 138: echo "</table>\n"; 139: 140: echo "</div>"; 141: 142: echo "<div id=\"pane_request_update_content\" class=\"pane_content_hidden\">\n"; 143: 144: echo "<form id=\"request_update\" onsubmit=\"return false;\">"; 145: 146: echo "<table class=\"request_update\">\n"; 147: 148: echo "<tr><td colspan=\"2\">\n"; 149: 150: echo "<input type=\"hidden\" name=\"mode\" value=\"request_update\">\n"; 151: echo "<input type=\"hidden\" name=\"requestid\" value=\"".$id."\">\n"; 152: echo "<textarea rows=\"10\" cols=\"50\" name=\"update\"></textarea>\n"; 153: 154: echo "</td></tr>\n"; 155: echo "<tr><td>"; 156: 157: echo $DESK->Lang->Get("assign")." "; 158: 159: echo "</td><td>"; 160: 161: echo "<select name=\"assign\">\n"; 162: 163: echo "<option value=\" \" selected>".$DESK->Lang->Get("no_change")."</option>\n"; 164: 165: $list = $DESK->RequestManager->TeamUserList(); 166: 167: foreach($list as $teamid => $team) 168: { 169: $teamname = $team['name']; 170: if ($team['assign']) 171: echo "<option value=\"".$teamid."\">".$teamname."</option>\n"; 172: if (is_array($team['items'])) 173: { 174: foreach($team['items'] as $username => $detail) 175: { 176: if ($team['team']) 177: $tid = $teamid; 178: else 179: $tid = 0; 180: if ($detail['assign']) 181: echo "<option value=\"".$tid."/".$username."\">".$teamname." > ".$detail['realname']."</option>\n"; 182: } 183: } 184: } 185: echo "</select>\n"; 186: 187: echo "</td></tr>\n"; 188: 189: echo "<tr><td>\n"; 190: 191: echo $DESK->Lang->Get("status"); 192: 193: echo "</td><td>\n"; 194: 195: $statuses = $DESK->RequestManager->StatusList(); 196: 197: echo "<select name=\"status\">\n"; 198: echo "<option value=\" \" selected>".$DESK->Lang->Get("no_change")."</option>\n"; 199: 200: foreach($statuses as $code => $desc) 201: echo "<option value=\"".$code."\">".$desc."</option>\n"; 202: 203: echo "</select>\n"; 204: echo "</td></tr>\n"; 205: 206: if ($DESK->Email->hasAccounts()) 207: { 208: echo "<tr><td>\n"; 209: echo $DESK->Lang->Get("email_customer")."\n"; 210: echo "</td>\n"; 211: echo "<td><input type=\"checkbox\" name=\"emailflag\" checked=\"1\" /></td>\n"; 212: echo "</tr>\n"; 213: } 214: 215: echo "<tr><td>\n"; 216: 217: echo "<input type=\"submit\" value=\"".$DESK->Lang->Get("save")."\" onclick=\"DESK.formAPI('request_update',false,true,DESKRequest.emailUpdateCheck);\">"; 218: 219: echo "</td><td>\n"; 220: 221: echo "<input type=\"submit\" value=\"".$DESK->Lang->Get("save_close")."\" onclick=\"DESK.formAPI('request_update',true,false,DESKRequest.emailUpdateCheck);\">"; 222: 223: echo "</td></tr>\n"; 224: 225: echo "</table>"; 226: 227: echo "</form>\n"; 228: 229: echo "</div>"; 230: 231: echo "<script type=\"text/javascript\">\n"; 232: echo "var currentRequestID = ".$_REQUEST['id'].";\n"; 233: echo "</script>\n"; 234: 235: 236: 237: $DESK->Skin->IncludeFile("pane_finish.php"); 238: } 239: else // new request 240: { 241: 242: echo "<div id=\"customer_select\" class=\"customer_select\">\n"; 243: 244: echo "<form id=\"customersearch\" onsubmit=\"return false;\">\n"; 245: echo "<table class=\"search\">\n"; 246: 247: $table=$DESK->DataDictionary->Tables["customer"]; 248: 249: foreach($table->fields as $id => $field) 250: { 251: if ($field->searchable) 252: { 253: echo "<tr><td>".$field->name."</td>\n"; 254: $val=""; 255: if (isset($_REQUEST[$field->field])) 256: { 257: $val=$_REQUEST[$field->field]; 258: $searchnow=true; 259: } 260: echo "<td><input type=\"text\" name=\"".$field->field."\" value=\"".$val."\" /></td></tr>\n"; 261: } 262: } 263: echo "<tr><td> </td>\n"; 264: echo "<td><input type=\"submit\" value=\"".$DESK->Lang->Get("search")."\" onclick=\"DESKRequest.searchCustomer();\" /></td>\n"; 265: echo "</tr>"; 266: echo "</table>\n"; 267: echo "</form>\n"; 268: 269: 270: echo "</div>"; 271: echo "<div id=\"customer_details\" class=\"customer_details\">\n"; 272: echo "<br /><b>".$DESK->Lang->Get("customer")." : </b><span id=\"customer_id\"></span> \n"; 273: echo "<a href=\"#\" onclick=\"DESKRequest.searchCustomerAgain();\">Change</a>"; 274: echo "</div>"; 275: 276: echo "<hr class=\"request\" />\n"; 277: 278: echo "<form id=\"request_create\" onsubmit=\"return false;\">"; 279: 280: echo "<table class=\"request_update\">\n"; 281: 282: echo "<tr><td colspan=\"2\">\n"; 283: 284: echo "<textarea rows=\"10\" cols=\"50\" name=\"update\"></textarea>\n"; 285: 286: echo "</td></tr>\n"; 287: echo "<tr><td>"; 288: 289: echo $DESK->Lang->Get("assign")." "; 290: 291: echo "</td><td>"; 292: 293: echo "<select name=\"assign\">\n"; 294: 295: $list = $DESK->RequestManager->TeamUserList(); 296: 297: foreach($list as $teamid => $team) 298: { 299: $teamname = $team['name']; 300: if ($team['assign']) 301: echo "<option value=\"".$teamid."\">".$teamname."</option>\n"; 302: if (is_array($team['items'])) 303: { 304: foreach($team['items'] as $username => $detail) 305: { 306: if ($team['team']) 307: $tid = $teamid; 308: else 309: $tid = 0; 310: if ($detail['assign']) 311: echo "<option value=\"".$tid."/".$username."\">".$teamname." > ".$detail['realname']."</option>\n"; 312: } 313: } 314: } 315: echo "</select>\n"; 316: 317: echo "</td></tr>\n"; 318: 319: echo "<tr><td>\n"; 320: 321: echo $DESK->Lang->Get("status"); 322: 323: echo "</td><td>\n"; 324: 325: $statuses = $DESK->RequestManager->StatusList(); 326: 327: echo "<select name=\"status\">\n"; 328: 329: foreach($statuses as $code => $desc) 330: echo "<option value=\"".$code."\">".$desc."</option>\n"; 331: 332: echo "</select>\n"; 333: 334: echo "</td></tr>\n"; 335: 336: echo "<tr><td>\n"; 337: 338: echo $DESK->Lang->Get("priority"); 339: 340: echo "</td><td>"; 341: 342: $priorities = $DESK->RequestManager->GetPriorityList(); 343: 344: echo "<select name=\"priority\">\n"; 345: 346: foreach($priorities as $code => $priority) 347: echo "<option value=\"".$code."\">".$priority['priorityname']."</option>\n"; 348: 349: echo "</td></tr>\n"; 350: 351: if ($DESK->Email->hasAccounts()) 352: { 353: echo "<tr><td>\n"; 354: echo $DESK->Lang->Get("email_customer")."\n"; 355: echo "</td>\n"; 356: echo "<td><input type=\"checkbox\" name=\"emailflag\" checked=\"1\" /></td>\n"; 357: echo "</tr>\n"; 358: } 359: 360: echo "<tr><td>\n"; 361: 362: echo "<input type=\"submit\" value=\"".$DESK->Lang->Get("save")."\" onclick=\"DESKRequest.Create();\" />"; 363: 364: echo "</td><td>\n"; 365: 366: echo "<input type=\"submit\" value=\"".$DESK->Lang->Get("save_close")."\" onclick=\"DESKRequest.Create(true);\" />"; 367: 368: echo "</td></tr>\n"; 369: 370: echo "</table>"; 371: 372: echo "</form>"; 373: 374: } 375: 376: 377: 378: $DESK->Skin->IncludeFile("min_footer.php"); 379: 380: 381: ?> 382: