dbconnect(); /* Below we create a cursor named log that selects all of the communications made by a contact that the user has chosen. In the loop down below we output the results in a table format. The contact cursor gets the first and last name of the contact. */ var today = new Date() if(request.rangewithin) { log = database.cursor("SELECT * FROM Calls WHERE ContactID = " + request.id + " AND calldate >= (today - " + request.submit + ")") } if(request.rangebetween) { log = database.cursor("SELECT * FROM Calls WHERE ContactID = " + request.id + " AND calldate BETWEEN '" + request.rangebetween1 + "' AND '" + request.rangebetween2 + "'") } contact = database.cursor("SELECT firstname, lastname FROM Contacts WHERE contactID = " + request.id)

Communication Log Report

if(contact.next()) { write("Contact Name: " + contact.firstname + " " + contact.lastname + "
") // communication details are displayed individually in a table if a log is // found for the search criteria. if(log.next()) { write("") write("") write("") write("") write("") write("
Call Date: "+ datetoString(log.calldate) + " Call Time: " + log.calltime + "
Subject: " + log.subject +"
Notes: " + log.notes +"

") while(log.next()) { write("") write("") write("") write("") write("") write("
Call Date: "+ datetoString(log.calldate) + " Call Time: " + log.calltime + "
Subject: " + log.subject +"
Notes: " + log.notes +"

") } } else { // error message for no logs. if(request.rangewithin) { write("There was no communications logged for " + contact.firstname + " " + contact.lastname + " within the last " + request.submit + " day(s).") } if(request.rangebetween) { write("There was no communications logged for " + contact.firstname + " " + contact.lastname + " between the dates " + request.rangebetween1 + " and " + request.rangebetween2 + ".") } } }