Viewing File email.php of 0.01.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: * Send an email update to customer 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 Email"); 55: $DESK->Skin->IncludeFile("min_header.php",$data); 56: 57: $request = $DESK->RequestManager->Fetch($_REQUEST['request']); 58: //echo "<pre>"; 59: //print_r($request); 60: 61: $customerid = $request->Get("customerid"); 62: 63: $q="SELECT * FROM ".$DESK->Database->Table("customer")." WHERE ".$DESK->Database->Field("customerid")."=".$DESK->Database->Safe($customerid)." LIMIT 0,1"; 64: $r=$DESK->Database->Query($q); 65: 66: $customer = $DESK->Database->FetchAssoc($r) 67: or die("wah"); 68: 69: $DESK->Database->Free($r); 70: 71: echo "<form id=\"email\" onsubmit=\"return false;\">\n"; 72: echo "<input type=\"hidden\" name=\"mode\" value=\"email_send\" />\n"; 73: echo "<table>"; 74: 75: echo "<tr><td>".$DESK->Lang->Get("from")."</td>\n"; 76: 77: $accounts = $DESK->Email->GetAccounts(); 78: 79: echo "<td>\n"; 80: echo "<select name=\"id\">\n"; 81: foreach($accounts as $id => $acc) 82: { 83: echo "<option value=\"".$id."\">".$acc['name']." "".$acc['fromname']."" <".$acc['from']."></option>\n"; 84: } 85: echo "</select>\n"; 86: echo "</td></tr>\n"; 87: 88: $customername = $customer['firstname']." ".$customer['lastname']; 89: $requestid = $_REQUEST['request']; 90: $update = $_REQUEST['update']; 91: 92: echo "<tr><td>".$DESK->Lang->Get("to")."</td>\n"; 93: echo "<td><input type=\"text\" name=\"to\" value=\"".$customer['email']."\" size=\"50\" /></td></tr>\n"; 94: 95: $data = array( 96: "customer" => $customername, 97: "requestid" => $requestid, 98: "update" => $update ); 99: 100: $message = $DESK->Email->GetSubTemplate($_REQUEST['template'], $data); 101: 102: echo "<tr><td>".$DESK->Lang->Get("subject")."</td>\n"; 103: echo "<td><input type=\"text\" name=\"subject\" value=\"".$message['subject']."\" size=\"50\" /></td></tr>\n"; 104: 105: echo "<tr><td colspan=\"2\">\n"; 106: echo "<textarea name=\"body\" rows=\"15\" cols=\"60\">".$message['body']."</textarea></td></tr>\n"; 107: 108: echo "<tr><td> </td><td><input type=\"submit\" value=\"".$DESK->Lang->Get("send")."\" onclick=\"DESK.formAPI('email',true);\" />\n"; 109: echo "</td></tr>\n"; 110: 111: echo "</table></form>\n"; 112: 113: $DESK->Skin->IncludeFile("min_footer.php"); 114: 115: 116: ?> 117: