} catch (Exception $e) { $email_sent = false; } if ($email_sent == true) { $query = "insert Correspondence (StudentNo, Subject, Content, Email) values ({$StudentNo}, '" . $Subject . "', '" . $Content . "', '" . $Email . "')"; $result = mysql_query($query) or die("SQL Error 1: " . mysql_error()); if ($result == true && $email_sent == true) { getSuccessCreateResponse('Email sent Successfully', $Id); } else { getErrorResponse("Email Sent, Correspondence failed!"); } } else { getErrorResponse("Email Failed!"); } } else { getErrorResponse("No Schedule to send!"); } } else { if (isset($_REQUEST["type"]) && trim($_REQUEST["type"]) == 'INSTRUCTOR') { $query = "SELECT cb.StudentNo, cb.Receipt_No, CONCAT(s.GivenName,' ',s.Surname) as Student_Name, cb.Course_Date as Course_Date_No, cda.Course_Date, cb.Course_No, cb.Lesson_No, cd.Description as Course, cb.Lesson_No, l.Description as Lesson, cb.Instructor_No, i.Name as Instructor, cb.Boat_No, b.Name as Boat from Course_Bookings cb inner join Students s on s.StudentNo = cb.StudentNo inner join Course_Details cd on cd.ID = cb.Course_No left join Course_Dates cda on cda.ID = cb.Course_Date inner join Lessons l on l.Course_No = cb.Course_No and l.Lesson_No = cb.Lesson_No inner join Instructor i on i.ID = cb.Instructor_No inner join Boats b on b.Id = cb.Boat_No where cda.Course_Date >= now() order by cda.Course_Date, cb.Instructor_No, cb.StudentNo, cb.Course_No, cb.Lesson_No"; //echo $query; $result = mysql_query($query) or die("SQL Error 1: " . mysql_error()); $courses = null; // get data and store in a json array while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $Booking_ID = strval($row['Receipt_No']) . "_" . strval($row['Lesson_No']); $courses[] = array('StudentNo' => $row['StudentNo'], 'Receipt_No' => $row['Receipt_No'], 'Student_Name' => $row['Student_Name'], 'Surname' => $row['Surname'], 'Course_Date' => $row['Course_Date'], 'Course_Date_No' => $row['Course_Date_No'], 'Course_No' => $row['Course_No'], 'Lesson_No' => $row['Lesson_No'], 'Course' => $row['Course'], 'Lesson' => $row['Lesson'], 'Instructor_No' => $row['Instructor_No'], 'Instructor' => $row['Instructor'], 'Boat_No' => $row['Boat_No'], 'Boat' => $row['Boat']); } $data[] = array('Rows' => $courses); echo json_encode($data); } else {
} catch (Exception $e) { $email_sent = false; } if ($email_sent == true) { $Notes = '\\r' . date('d-m-Y H:i:s') . ' - Email Sent: ' . $Subject; $query = "update Students set Notes = concat(ifnull(Notes, ''),'" . $Notes . "') where StudentNo = " . $StudentNo; $result = mysql_query($query) or die("SQL Error 1: " . mysql_error()); $query = "insert Correspondence (StudentNo, Subject, Content, Email) values ({$StudentNo}, '" . $Subject . "', '" . $Content . "', '" . $Email . "')"; $result = mysql_query($query) or die("SQL Error 1: " . mysql_error()); if ($result == true && $email_sent == true) { getSuccessCreateResponse('Email sent Successfully', $StudentNo); } else { getErrorResponse("Email Sent, Correspondence failed!"); } } else { getErrorResponse("Email Failed!"); } } else { $pagenum = $_GET['pagenum']; $pagesize = $_GET['pagesize']; $start = $pagenum * $pagesize; $query = "SELECT SQL_CALC_FOUND_ROWS * from Email_Content order by ID LIMIT {$start}, {$pagesize} "; $result = mysql_query($query) or die("SQL Error 1: " . mysql_error()); $sql = "SELECT FOUND_ROWS() AS `found_rows`;"; $rows = mysql_query($sql); $rows = mysql_fetch_assoc($rows); $total_rows = $rows['found_rows']; $filterquery = ""; // filter data. if (isset($_GET['filterscount'])) { $filterscount = $_GET['filterscount'];
$topic_row = mysqli_fetch_array($topic_result, MYSQLI_ASSOC); $Topic_ID = $topic_row["Topic_ID"]; $prevTopic = $Topic; } if ($Question_ID != $row["ID"]) { $query = 'insert into Topic_Questions (Topic_ID, Question, Question_Order, Answer_1, Answer_2, Answer_3, Answer_4, Answer_5, Correct_Answer, Supporting_Documentation) values (' . $Topic_ID . ', "' . $Question . '",' . $Question_Order . ',"' . $Answer1 . '","' . $Answer2 . '","' . $Answer3 . '","' . $Answer4 . '","' . $Answer5 . '",' . $Correct_Answer . ',"")'; echo $query; $question_result = $mysqli->query($query); $Answer_No = 1; $Answer1 = ""; $Answer2 = ""; $Answer3 = ""; $Answer4 = ""; $Answer5 = ""; $Correct_Answer = 0; $Question_ID = $row["ID"]; } ${'Answer' . $Answer_No} = $row["answer"]; if ($row["correct"] == 1) { $Correct_Answer = $Answer_No; } $Question_Order = $row["sort_order"]; $Answer_No = $Answer_No + 1; } if ($Question_result == true) { getSuccessCreateResponse('Updated Successfully', $Student_Cost); } else { getErrorResponse("Add Failed!"); } } $mysqli->close();
$query = "update Expertise_Categories set Expertise = '" . $Expertise . "' where ID = '" . $Id . "'"; $result = $mysqli->query($query); if ($result == true) { getSuccessCreateResponse('Updated Successfully', $Id); } else { getErrorResponse("Update Failed!"); } } else { if (isset($_REQUEST["type"]) && trim($_REQUEST["type"]) == 'DEL') { $Id = $_REQUEST['ID']; $query = "delete from Expertise_Categories where ID = '" . $Id . "'"; $result = $mysqli->query($query); if ($result == true) { getSuccessCreateResponse('Deleted Successfully', $Id); } else { getErrorResponse("Delete Failed!"); } } else { if (isset($_REQUEST["type"]) && trim($_REQUEST["type"]) == 'LIST') { $query = 'SELECT * FROM `Expertise_Categories` order by Expertise'; $result = $mysqli->query($query); $categories = array(); while ($row = mysqli_fetch_array($result)) { $categories[] = array('ID' => $row['ID'], 'Expertise' => $row["Expertise"]); } echo json_encode($categories); } else { $pagenum = $_GET['pagenum']; $pagesize = $_GET['pagesize']; $start = $pagenum * $pagesize; $query = "SELECT SQL_CALC_FOUND_ROWS * from `Expertise_Categories` order by Expertise LIMIT {$start}, {$pagesize} ";
if ($result == true) { getSuccessCreateResponse('Updated Successfully', $Id); } else { getErrorResponse("Update Failed!"); } } else { if (isset($_REQUEST["type"]) && trim($_REQUEST["type"]) == 'DEL') { $Id = strtoupper($_REQUEST['ID']); $In_Use = checkIDinUse('Students', 'SalesPerson', $Id); if ($In_Use == false) { $query = "delete from SalesPerson where ID = '" . $Id . "'"; $result = mysql_query($query) or die("SQL Error 1: " . mysql_error()); if ($result == true) { getSuccessCreateResponse('Deleted Successfully', $Id); } else { getErrorResponse("Delete Failed!"); } } else { getErrorResponse("Delete Failed! ID still in use."); } } else { $query = "SELECT * FROM SalesPerson order by ID"; $result = mysql_query($query) or die("SQL Error 1: " . mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $source[] = array('ID' => $row['ID'], 'Name' => $row['Name']); } echo json_encode($source); } } } }
getErrorResponse("Update Failed!"); } } else { if (isset($_REQUEST["type"]) && trim($_REQUEST["type"]) == 'DEL') { $Course_No = $_REQUEST['Course_No']; $Lesson_No = $_REQUEST['Lesson_No']; if (checkLessonInUse($Course_No, $Lesson_No) == false) { $query = "delete from Lessons where Course_No = " . $Course_No . " and Lesson_No = " . $Lesson_No; $result = mysql_query($query) or die("SQL Error 1: " . mysql_error()); if ($result == true) { getSuccessCreateResponse('Deleted Successfully', $Id); } else { getErrorResponse("Delete Failed!"); } } else { getErrorResponse("Course/Lesson still in use!"); } } else { if (isset($_REQUEST["type"]) && trim($_REQUEST["type"]) == 'LIST') { $query = "SELECT cd.Description as Course, l.* from Lessons l inner join Course_Details cd on cd.ID = l.Course_No order by cd.Description, l.Description"; $result = mysql_query($query) or die("SQL Error 1: " . mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $source[] = array('Lesson_No' => $row['Lesson_No'], 'Description' => $row['Description'], 'Course' => $row['Course'], 'Followup' => $row['Followup']); } echo json_encode($source); } else { $pagenum = $_GET['pagenum']; $pagesize = $_GET['pagesize']; $start = $pagenum * $pagesize; $query = "SELECT SQL_CALC_FOUND_ROWS cd.Description as Course, l.* from Lessons l inner join Course_Details cd on cd.ID = l.Course_No order by cd.Description, l.Description LIMIT {$start}, {$pagesize} "; $result = mysql_query($query) or die("SQL Error 1: " . mysql_error());
if (isset($_REQUEST["type"]) && trim($_REQUEST["type"]) == 'DET_SAVE') { $ID = $_REQUEST['ID']; $Fund_Size = $_REQUEST['Fund_Size']; $Strategy_Size = $_REQUEST['Strategy_Size']; $Investment_Term = $_REQUEST['Investment_Term']; $BuySell_Spread = $_REQUEST['BuySell_Spread']; $Management_Fees = $_REQUEST['Management_Fees']; $Performance_Fees = $_REQUEST['Performance_Fees']; $Contribution_Fees = $_REQUEST['Contribution_Fees']; $Other_Fees = $_REQUEST['Other_Fees']; $query = "update Products set Fund_Size = {$Fund_Size} , Strategy_Size = {$Strategy_Size} , Investment_Term = {$Investment_Term} , BuySell_Spread = {$BuySell_Spread} , Management_Fees = {$Management_Fees}, Performance_Fees = {$Performance_Fees} , Contribution_Fees = {$Contribution_Fees} , Other_Fees = {$Other_Fees} where ID = {$ID}"; $result = $mysqli->query($query); if ($result == true) { getSuccessCreateResponse('Updated Successfully', $Id); } else { getErrorResponse("Update Failed !"); } } else { if (isset($_REQUEST["type"]) && trim($_REQUEST["type"]) == 'ISSUER') { $User_ID = $_REQUEST["User_ID"]; $query = "SELECT p.*, i.Name as Issuer from Products p inner join Issuer i on p.Issuer_ID = i.ID inner join Users u on u.User_ID = '" . $User_ID . "' where u.Category_ID = p.Issuer_ID order by p.Issuer_ID, p.Name"; $result = $mysqli->query($query); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $products[] = array('ID' => $row['ID'], 'Issuer_ID' => $row['Issuer_ID'], 'Issuer' => $row['Issuer'], 'Name' => $row['Name'], 'APIR' => $row['APIR'], 'ARSN' => $row['ARSN'], 'Meta_Data' => $row['Meta_Data'], 'PDS_Location' => $row['PDS_Location'], 'Fund_Manager' => $row['Fund_Manager'], 'Category' => $row['Category'], 'Structure' => $row['Structure'], 'Benchmark' => $row['Benchmark'], 'Min_Investment' => $row['Min_Investment'], 'Inception_Date' => $row['Inception_Date'], 'Image_Location' => $row['Image_Location'], 'Meta_Data' => $row['Meta_Data'], 'PDS_Location' => $row['PDS_Location'], 'Month1_Fund' => $row['Month1_Fund'], 'Month1_Index' => $row['Month1_Index'], 'Month3_Fund' => $row['Month3_Fund'], 'Month3_Index' => $row['Month3_Index'], 'Month6_Fund' => $row['Month6_Fund'], 'Month6_Index' => $row['Month6_Index'], 'Year1_Fund' => $row['Year1_Fund'], 'Year1_Index' => $row['Year1_Index'], 'Year2_Fund' => $row['Year2_Fund'], 'Year2_Index' => $row['Year2_Index'], 'Year3_Fund' => $row['Year3_Fund'], 'Year3_Index' => $row['Year3_Index'], 'Year5_Fund' => $row['Year5_Fund'], 'Year5_Index' => $row['Year5_Index'], 'Year7_Fund' => $row['Year7_Fund'], 'Year7_Index' => $row['Year7_Index'], 'Inception_Fund' => $row['Inception_Fund'], 'Inception_Index' => $row['Inception_Index'], 'Fund_Size' => $row['Fund_Size'], 'Investment_Size' => $row['Investment_Size'], 'Strategy_Size' => $row['Strategy_Size'], 'Investment_Term' => $row['Investment_Term'], 'BuySell_Spread' => $row['BuySell_Spread'], 'Management_Fees' => $row['Management_Fees'], 'Performance_Fees' => $row['Performance_Fees'], 'Contribution_Fees' => $row['Contribution_Fees'], 'Other_Fees' => $row['Other_Fees']); } echo json_encode($products); } else { if (isset($_REQUEST["type"]) && trim($_REQUEST["type"]) == 'FEES') { $Product_ID = $_REQUEST["Product_ID"]; $query = "SELECT p.* from Products p where ID = {$Product_ID} "; $result = $mysqli->query($query);
function do_login($user_id) { global $mysqli; session_start(); $response = ""; $query = "SELECT u.User_ID, u.Facebook_ID, Password, User_Level, Category, Colour,\n\t\t\t\t\tCase \n\t\t\t\t\t\twhen (u.Category = 'CONSUMER' or u.Category = 'SELF-DIRECTED' or u.Category = 'ADVISER-DIRECTED') then concat(c.GivenName, ' ',c.Surname) \n\t\t\t\t\t\twhen Category = 'ADVISER' then concat(a.Given_Name, ' ', a.Surname) \n\t\t\t\t\t\twhen Category = 'GROUP' then ag.Group_Description \n\t\t\t\t\t\twhen Category = 'ISSUER' then i.Name \n\t\t\t\t\t\telse u.User_Name end AS User_Name \n\t\t\t\tFROM Users u \n\t\t\t\tleft join Clients c on c.User_ID = u.id \n\t\t\t\tleft join Adviser a on a.User_ID = u.ID \n\t\t\t\tleft join Adviser_Groups ag on ag.ID = u.Category_ID \n\t\t\t\tleft join Issuer i on i.ID = u.Category_ID \n\t\t\t\twhere u.ID = '" . $user_id . "' and u.Status = 'ACTIVE' "; $result = $mysqli->query($query); if ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $loginData = array("user_id" => $row["User_ID"], "facebook_id" => $row["Facebook_ID"], "user_name" => $row["User_Name"], "user_level" => $row["User_Level"], "category" => $row["Category"], "colour" => $row["Colour"], "theme" => "bootstrap"); $myDomain = $_SERVER['SERVER_NAME']; if ($myDomain != "www.sunwindwater.com.au") { $myDomain = "inferwise.com.au"; } $cookie_name = "user_id"; $cookie_value = base64_encode(json_encode($loginData)); setcookie($cookie_name, $cookie_value, time() + 60 * 30, "/", $myDomain); /* //rememberMe not used by Facebook $rememberMe = array( "user_id" => $row["User_ID"], "password" => $row["Password"], "facebook_id" => $row["Facebook_ID"], ); if ($_REQUEST['rememberMe'] == "true") { $cookie_name = "infer_wid"; $cookie_value = base64_encode(json_encode($rememberMe)); setcookie($cookie_name, $cookie_value, time() + (60 * 200000), "/",$myDomain); } */ /* //the user_log at the moment doesn't support facebook users (need to ALTER User_Log table first) $query = 'insert into User_Log (User_ID, Login_Time) values ("'.$row["User_ID"].'",now())'; $result = $mysqli->query($query); */ getSuccessCreateResponse('Logged in Successfully', $loginData); } else { getErrorResponse("Login Failed!"); } }
session_start(); header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE'); header('Content-type: application/json'); include_once 'Connect.php'; include_once 'UtilFunctions.php'; $formData = array("username" => $_REQUEST["User_ID"], "password" => $_REQUEST["Password"], "rememberMe" => $_REQUEST["rememberMe"]); $response = ""; $query = "SELECT u.User_ID, Password, User_Level, Category, Colour,Case when (u.Category = 'CONSUMER' or u.Category = 'SELF-DIRECTED' or u.Category = 'ADVISER-DIRECTED') then concat(c.GivenName, ' ',c.Surname) when Category = 'ADVISER' \n\tthen concat(a.Given_Name, ' ', a.Surname) when Category = 'GROUP' then ag.Group_Description when Category = 'ISSUER' then i.Name else u.User_Name end as User_Name FROM Users u \n\tleft join Clients c on c.User_ID = u.ID left join Adviser a on a.User_ID = u.ID left join Adviser_Groups ag on ag.ID = u.Category_ID left join Issuer i on i.ID = u.Category_ID where \n\tu.User_Id = '" . $formData['username'] . "' and Password = '******'password']) . "' and u.Status = 'ACTIVE'"; $result = $mysqli->query($query); if ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $loginData = array("user_id" => $row["User_ID"], "user_name" => $row["User_Name"], "user_level" => $row["User_Level"], "category" => $row["Category"], "colour" => $row["Colour"], "theme" => "bootstrap"); $rememberMe = array("user_id" => $row["User_ID"], "password" => $row["Password"]); $myDomain = $_SERVER['SERVER_NAME']; //if ($myDomain != "www.dev.sunwindwater.com.au") { $myDomain = "inferwise.com.au" ; } $cookie_name = "user_id"; $cookie_value = base64_encode(json_encode($loginData)); setcookie($cookie_name, $cookie_value, time() + 60 * 30, "/", $myDomain); if ($formData['rememberMe'] == "Y") { $cookie_name = "infer_wid"; $cookie_value = base64_encode(json_encode($rememberMe)); setcookie($cookie_name, $cookie_value, time() + 60 * 200000, "/", $myDomain); } $query = 'insert into User_Log (User_ID, Login_Time) values ("' . $row["User_ID"] . '",now())'; $result = $mysqli->query($query); getSuccessCreateResponse('Logged in Successfully', $loginData); } else { getErrorResponse("Login Failed!"); } $mysqli->close();
$Post_Code = $_REQUEST['Post_Code']; $query = "SELECT Post_Code, concat(Suburb, ' - ' , State, ', ' , Post_Code) as Suburb from Post_Codes order by Post_Code"; $result = $mysqli->query($query); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $postcodes[] = array('Suburb' => checkNull($row['Suburb'], ''), 'Post_Code' => checkNull($row['Post_Code'], '')); } echo json_encode($postcodes); } else { if (isset($_REQUEST["type"]) && trim($_REQUEST["type"]) == 'PCODE_VAL') { $Post_Code = $_REQUEST['Post_Code']; $query = "SELECT count(*) as PCode_Exists from Post_Codes where Post_Code = '" . $Post_Code . "'"; $result = $mysqli->query($query); // get data and store in a json array $row = mysqli_fetch_array($result, MYSQLI_ASSOC); if (!$row["PCode_Exists"] || $row["PCode_Exists"] == 0) { getErrorResponse("Post Code does not exists!"); } else { getSuccessCreateResponse('', $Post_Code); } } else { if (isset($_REQUEST["type"]) && trim($_REQUEST["type"]) == 'DETAILS') { $User_ID = $_REQUEST['User_ID']; $query = "SELECT a.* from Adviser a inner join Users u on u.ID = a.User_ID where u.User_ID = '" . $User_ID . "' limit 1"; //echo $query; $result = $mysqli->query($query); $advisers = array(); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { //echo $row['ID']; $advisers[] = array('ID' => checkNull($row['ID'], ''), 'Given_Name' => checkNull($row['Given_Name'], ''), 'Surname' => checkNull($row['Surname'], ''), 'LicenseNo' => checkNull($row['LicenseNo'], ''), 'AR_Number' => checkNull($row['AR_Number'], ''), 'Email' => checkNull($row['Email'], ''), 'Mobile' => checkNull($row['Mobile'], ''), 'Phone' => checkNull($row['Phone'], ''), 'DOB' => checkNull($row['DOB'], ''), 'Referral' => checkNull($row['Referral'], ''), 'Practise_Name' => checkNull($row['Practise_Name'], ''), 'Address' => checkNull($row['Address'], ''), 'PostCode' => checkNull($row['PostCode'], ''), 'Expertise_Areas' => checkNull($row['Expertise_Areas'], '')); } getSuccessCreateResponse('', $advisers);
getSuccessCreateResponse('Deleted Successfully', $Id); } else { getErrorResponse("Delete Failed!"); } } else { getErrorResponse("Delete Failed! ID still in use."); } } else { if (isset($_REQUEST["type"]) && trim($_REQUEST["type"]) == 'COUNTER') { $Topic_ID = $_REQUEST['Topic_ID']; $query = "update Product_Knowledge set Monthly_Counter = Monthly_Counter + 1, Last_Viewed = now() where ID = " . $Topic_ID; $result = $mysqli->query($query); if ($result == true) { getSuccessCreateResponse('Updated Successfully', $Id); } else { getErrorResponse($query); } } else { if (isset($_REQUEST["type"]) && trim($_REQUEST["type"]) == 'RECENT') { $Product_ID = $_REQUEST['Product_ID']; $Category_ID = $_REQUEST['Category_ID']; $query = "select CPD_Categories from Product_Categories where ID = " . $Category_ID . " limit 1"; $result = $mysqli->query($query); $row = mysqli_fetch_array($result, MYSQLI_ASSOC); $CPD_Categories = $row["CPD_Categories"]; $query = "SELECT ID, 'KB' as Type, Topic, DATE_FORMAT(Last_Viewed, '%d/%m/%y') as Last_Viewed FROM Product_Knowledge where Product_ID =" . $Product_ID . " union SELECT ID, 'CPD', Summary as Topic, DATE_FORMAT(Article_Date, '%d/%m/%y') as Last_Viewed from CPD_Articles cp inner join CPD_Details cd on cd.ID = cp.CPD_ID where cd.Product_ID = 999999 and INSTR('" . $CPD_Categories . "', CONCAT( Topic_ID, ',' ) ) >0 order by Last_Viewed desc limit 5"; $result = $mysqli->query($query); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $topics[] = array('ID' => $row['ID'], 'Topic' => $row['Topic'], 'Type' => $row['Type'], 'Last_Viewed' => $row['Last_Viewed']); } echo json_encode($topics);
if (isset($_REQUEST["type"]) && trim($_REQUEST["type"]) == 'ADD') { //Merge fields allow you to prepopulate pdf form fields with data //they are optional and can be excluded if not required $filepath = $_REQUEST["file"]; $file = EchoSign\Info\FileInfo::createFromFile($filepath); $m_fields = $_REQUEST["Merge_Fields"]; $merge_fields = explode(',', $m_fields); $merge_fields = array('first_name' => 'Craig', 'last_name' => 'Ballinger', 'website' => 'craigballinger.com'); $sender_info = array('email' => '*****@*****.**', 'password' => 'Oldbastard@49', 'user_key' => ''); $widget = new EchoSign\Info\WidgetCreationInfo('Test createUrlWidget', $file); $widget->setMergeFields(new EchoSign\Info\MergeFieldInfo($merge_fields)); $senderinfo = new EchoSign\Info\SenderInfo($sender_info); try { $result = $api->createUrlWidget($widget, $senderinfo); } catch (Exception $e) { getErrorResponse("Document Creation Failed!"); } $doc_info[] = array($result); echo json_encode($result); /* $document = new EchoSign\Info\DocumentCreationInfo('Test sendDocument', $file); $document->setRecipients($recipients) ->setMergeFields(new EchoSign\Info\MergeFieldInfo($merge_fields)); try{ $result = $api->sendDocument($document); }catch(Exception $e){ print '<h3>An exception occurred:</h3>'; var_dump($e); }
$mail->AddReplyTo('*****@*****.**', 'info @ inferwise.com.au'); $mail->Subject = $EmailSubject; $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; $mail->MsgHTML($MESSAGE_BODY); $mail->Send(); $email_sent = true; } catch (phpmailerException $e) { $email_sent = false; } catch (Exception $e) { $email_sent = false; } if ($email_sent) { getSuccessCreateResponse('Email successfully sent', $Email); } } else { getErrorResponse("We have no record of this email address"); } } else { if (isset($_REQUEST["type"]) && trim($_REQUEST["type"]) == 'LIST') { $query = "SELECT u.User_ID, Password, User_Level, Category, Case when (u.Category = 'CONSUMER' or u.Category = 'SELF-DIRECTED' or u.Category = 'ADVISER-DIRECTED') then concat(c.GivenName, ' ',c.Surname) when Category = 'ADVISER' \n\tthen concat(a.Given_Name, ' ',a.Surname) when Category = 'ISSUER' then i.Name else u.User_Name end as User_Name FROM Users u left join Clients c on c.User_ID = u.User_ID left join Adviser a on a.Adviser_ID = u.User_ID \n\tleft join Issuer i on i.ID = u.Category_ID order by User_ID"; $result = $mysqli->query($query); while ($row = mysqli_fetch_array($result, MYSQL_ASSOC)) { $source[] = array('User_ID' => $row['User_ID'], 'User_Name' => $row['User_Name']); } echo json_encode($source); } else { $pagenum = $_GET['pagenum']; $pagesize = $_GET['pagesize']; $start = $pagenum * $pagesize; $basequery = "SELECT SQL_CALC_FOUND_ROWS u.User_ID, u.Password, u.User_Level, u.Category, u.Category_ID, u.Status, Case when (u.Category = 'CONSUMER' or u.Category = 'SELF-DIRECTED' or u.Category = 'ADVISER-DIRECTED') then concat(c.GivenName, ' ',c.Surname) when Category = 'ADVISER' \n\tthen concat(a.Given_Name, ' ', a.Surname) when Category = 'GROUP' then ag.Group_Description when Category = 'ISSUER' then i.Name else u.User_Name end as User_Name FROM Users u \n\tleft join Clients c on c.User_ID = u.User_ID left join Adviser a on a.Adviser_ID = u.User_ID left join Adviser_Groups ag on ag.ID = u.Category_ID left join Issuer i on i.ID = u.Category_ID "; $query = $basequery . " order by User_ID LIMIT {$start}, {$pagesize} ";
if ($Salesperson != '') { $html = $html . '<tr><td></td><td></td><td></td><td></td><td></td><td><strong>Total Paid</strong></td><td align="right">' . money_format('%=*(#10.2n', $Total_Balance) . '</td></tr></table>'; $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); $pdf->AddPage(); $Total_Balance = 0.0; } $Salesperson = $row["Salesperson"]; $html = '<p>' . $Salesperson . '</p><table border="1"><tr><td width="80"><h3>Student No</h3></td><td width="120"><h3>Given Name</h3></td><td width="120"><h3>Surname</h3></td><td width="120"><h3>Receipt Date</h3></td><td width="150"><h3>Receipt Details</h3></td><td width="180"><h3>Course</h3></td><td width="100"><h3>Amount</h3></td><td width="100"><h3>How Paid</h3></td></tr>'; $line_number = 5; } $Receipt_Date = new DateTime($row["Receipt_Date"]); $html .= '<tr><td>' . $row["StudentNo"] . '</td><td>' . $row["GivenName"] . '</td><td>' . $row["Surname"] . '</td><td>' . date_format($Receipt_Date, 'd/m/Y') . '</td><td>' . $row["Receipt_Details"] . '</td><td>' . $row["Course"] . '</td><td align="right">' . $row["Credit_Amt"] . '</td><td>' . $row["How_Paid"] . '</td></tr>'; $line_number = $line_number + 1; $Total_Balance = (double) $Total_Balance + (double) $row["Credit_Amt"]; } // Set some content to print $html = $html . '<tr><td></td><td></td><td></td><td></td><td></td><td><strong>Total Paid</strong></td><td align="right">' . money_format('%=*(#10.2n', $Total_Balance) . '</td></tr></table>'; //echo $html; // Print text using writeHTMLCell() $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); // --------------------------------------------------------- // Close and output PDF document // This method has several options, check the source code documentation for more information. $outputFile = 'Reports/Commission_Report_' . $Report_User . '.pdf'; $output = $pdf->Output($outputFile, 'F'); //echo "This is value of output = ".$output; if ($output != NULL) { getErrorResponse("Could not create file!"); } else { getSuccessCreateResponse('', $Report_User); }