• Adds the current date and time to the call data received from Phone Manager Pro.
• Writes the data to the log file simplelog.txt.
• The log file is placed in the same folder as the simplelog.bat program.
• If the log file is not present it is automatically created the first time Phone Manager Pro pops the application.
• To run the application configure it in Phone Manager Pro but don't enter the .bat.
Simplelog.bat Code
echo off cls setlocal
rem =========================================================================
set name=Phone Manager Pro Simple Log
set copyright=(c)2004 Avaya ([email protected]) set version=Version 1.2 9th March 2004
rem =========================================================================
rem ===== Sets values to match the program name and location ================
set _path=%~dp0 set _filename=%~n0
rem =========================================================================
rem ===== THIS IS THE PART THAT DOES ALL THE WORK: THAT'S ALL FOLKS
rem ===== Write data to file. %1-%5 are values passed by Phone Manager Pro ===
if "%1"=="" goto Usage
echo %date%, %time%, %1, %2, %3, %4, %5 >> %_path%%_filename%.txt goto End
rem =========================================================================
:Usage
rem ===== Show instructions if no call values passed to program =============
if exist %_path%pmlogger.chm (start %_path%pmlogger.chm) mode con cols=80 lines=14
title %name%
echo An simple application to which Phone Manager Pro can pop call data.
echo.
echo 1. In Phone Manager Pro, select "Configure | Configure Preferences".
echo 2. Select the "Phone Manager" tab.
echo 3. Tick "Pop on Answer".
echo 4. In "Pop External Program" enter the batch file name without .bat.
echo eg. %_path%%_filename%
echo.
echo Call data is written to '%_path%%_filename%.txt'.
echo The file contains: "Date, Time, From, To, Tag, Account Code, Display Text"
echo.
echo %version% %copyright%
pause goto End
rem =========================================================================
:End endlocal
Popping Applications & Screen Popping
Phonelog.bat
This application:
• Adds the current date and time to the call data received from Phone Manager Pro.
• Writes the data to the log file phonelog.txt.
• The log file is placed in the same folder as the phonelog.bat program.
• If the log file is not present it is automatically created the first time Phone Manager Pro pops the application.
• The file can be edited to enable a number of options:
• Change the log file extension. Use .csv for direct import into Excel.
• Use daily mode to append the date to the log file name. A new log file is created each day.
• Demo mode displays the log file on screen each time a new entry is written.
• A header line can be written into the start of the log file each time a new log is started.
• Fixed width operation expands the data received to a set width using padding characters (spaces by default).
• To run the application configure it in Phone Manager Pro but don't enter the .bat.
Phonelog.bat Code
echo off cls
rem =========================================================================
set name=Phone Manager Pro Call Log
set copyright=(c)2004 Avaya ([email protected]) set version=Version 1.2 9th March 2004
rem =========================================================================
setlocal title %name%
:Settings
rem ===== Program settings ==================================================
rem Filename: Sets the output filename to match program name and location set _path=%~dp0
set _filename=%~n0
rem --- Filetype: Sets the file extension for the log file (txt/csv) --- set filetype=txt
rem --- Daily Log: Adds the date to log file name for each day (on/off) -- set dailymode=on
rem --- Demo/Show Log: If on, the log file is shown on screen (on/off) ---- set demomode=on
rem --- Fixed Width: NB. Makes things very slow (on/off) --- set fixedwidth=on
set width=15 set pad=
rem --- Write Header: Write header line into file (on/off) --- set writehead=on
rem --- set data1=%1
set data2=%2 set data3=%3 set data4=%4 set data5=%5
rem =========================================================================
if not "%1"=="" goto GetDateTime :Usage
rem ===== Instructions for usage, shown if no call values passed to file ====
title %name%
echo An example application to which Phone Manager Pro can pop call data.
echo.
echo 1. In Phone Manager Pro, select "Configure | Configure Preferences".
echo 2. Select the "Phone Manager" tab.
echo 3. Tick "Pop on Answer".
echo 4. In "Pop External Program" enter the batch file name without .bat.
echo eg. %_path%%_filename%.
echo 5. The settings section of the batch file contains a range of editable echo options: daily or continuous log, fixed width data, file type, etc.
echo.
echo Call data is written to '%_path%%_filename%.%filetype%'.
echo The file contains: "Date, Time, From, To, Tag, Account Code, Display Text"
echo.
echo %version% %copyright%
pause goto End
rem =========================================================================
:GetDateTime
rem ===== Get date/time values and remove / characters from date ============
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do set _date=%%c/%%b/%%a for /f "tokens=2-4 delims=/ " %%a in ('date /t') do set _filedate=%%c%%b%%a for /f "tokens=1-2 delims=: " %%a in ('time /t') do set _time=%%a:%%b
if "%dailymode%"=="on" (set _filename=%_filename%_%_filedate%)
rem =========================================================================
:Fixwidth
rem ===== Pad out call data if fixed width on ===============================
if not "%fixedwidth%"=="on" (goto Calldata) set word=%data1% & call :Count %word%
set data1=%word%
set word=%data2% & call :Count %word%
set data2=%word%
set word=%data3% & call :Count %word%
set data3=%word%
set word=%data4% & call :Count %word%
set data4=%word%
set word=%data5% & call :Count %word%
set data5=%word%
goto Calldata
rem =========================================================================
rem ===== Called-routine to find length of item and then add padding ========
:Count
set mirror=%word%
set length=0
rem -- Decrements mirror and increments length until mirror all gone ---:GetLength
if not defined mirror goto :CheckMatch set /A length+=1
set mirror=%mirror:~1%
goto GetLength
rem -- Check length --- :CheckMatch
if %length% GEQ %WIDTH% (goto :EOF)
rem -- Loop to add padding characters required --- :Loop
for /L %%a in (%length%,1,%width%) do call :Pad %%a goto :EOF
rem -- Command called by loop to add padding character --- :Pad
set calldata=%_date%, %_time%, %data1%, %data2%, %data3%, %data4%, %data5%
Popping Applications & Screen Popping set logfile=%_path%%_filename%.%filetype%
rem =========================================================================
:Header
rem ===== Adds header to log if option on and log file doesn't exist ========
if not "%writehead%"=="on" (goto Write) if exist %logfile% (goto Write)
set head1=From set head2=To set head3=Tag set head4=Account set head5=Display
rem --- Expand header terms if fixed width on --- if not "%fixedwidth%"=="on" (goto Writeheader)
set word=%head1% & call :Count %word%
set head1=%word%
set word=%head2% & call :Count %word%
set head2=%word%
set word=%head3% & call :Count %word%
set head3=%word%
set word=%head4% & call :Count %word%
set head4=%word%
set word=%head5% & call :Count %word%
set head5=%word%
rem --- Write header into log file --- :Writeheader
set header=Date, Time, %head1%, %head2%, %head3%, %head4%, %head5%
echo %header% >> %logfile%
rem =========================================================================
:Write
rem ===== Write call data values to file ====================================
echo %calldata% >> %logfile%
rem =========================================================================
:DemoMode
rem ===== Demo mode leaves prompt window open showing the log so far ========
if not "%demomode%"=="on" (goto End)
if "%fixedwidth%"=="on" (mode con cols=110 lines=10) else (mode con cols=60 lines=10) type %logfile%
pause
rem =========================================================================
:End endlocal
Weblog.bat & Weblog.php
This application consists of two parts:
• weblog.bat takes the call data provided by Phone Manager Pro and turns it into an intranet URL.
It then launches that URL in the user's default web browser.
• weblog.php is a web page that uses php script. It receives the URL (including the call data) created by weblog.bat. The form can then be adapted to submit the call data and any other information entered by the user into a central intranet database.
This example application is naturally more complex that the other two. It requires an intranet web server to host the form.
• In this example PHP was used. However is could just as easily been ASP, PERL/CGI, JavaScript or Java. In this example we're still simply logging call data. Alternative we could have used the call information to also retrieve data based on the calling party (ie. screen popping) or a combination of both (ie. heading towards a CRM type system).
phplog.bat Code
This batch file sits on the Phone Manager Pro users PC. When called by Phone Manager Pro, it takes the call data and rewrites in a form suitable to pass to a web page.
echo off cls setlocal
rem =========================================================================
set name=Phone Manager Pro Web Log
set copyright=(c)2004 Avaya ([email protected]) set version=Version 1.2 9th March 2004
rem =========================================================================
rem ===== Set address of intranet phone log page ============================
set _webform=www.mysite.com/phonelog/weblog.php
rem =========================================================================
rem ===== Call web page and send data. ======================================
rem ===== %1-%5 are values passed by Phone Manager Pro ======================
if "%1"=="" goto Usage
start http://%_webform%?From=%1^&To=%2^&Tag=%3^&Account=%4^&Display=%5 goto End
rem =========================================================================
:Usage
rem ===== Show instructions if no call values passed to program =============
if exist %_path%pmlogger.chm (start %_path%pmlogger.chm) mode con cols=80 lines=14
title %name%
echo An sample application to which Phone Manager Pro can pop call data.
echo The application then calls an intranet form and passes the data to echo that form.
echo.
echo 1. In Phone Manager Pro, select "Configure | Configure Preferences".
echo 2. Select the "Phone Manager" tab.
echo 3. Tick "Pop on Answer".
echo 4. In "Pop External Program" enter the batch file name without .bat.
echo eg. %_path%%_filename%
echo.
echo The data passed is: "From, To, Tag, Account Code, Display Text"
echo.
echo %version% %copyright%
pause goto End
rem =========================================================================
Popping Applications & Screen Popping :End
endlocal
weblog.php Code
This code forms a web page that receives the Phone Manager Pro call data as a URL string and then uses it to populate the pages fields.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<title>Phone Manager to PHP Call Log Form</title>
</head>
<body bgcolor="White">
<h1>Call Log Entry Form</h1>
<table>
<tr><td><p> Date:</td>
<td><input type="text" name="Date" size="20" value="<?php echo date("F d Y" ,time());
?>" readonly></td>
<td><p> Time:</td>
<td><input type="text" name="Time" size="10" value="<?php echo date("H:i" ,time());
?>" readonly></td></tr>
<tr><td><p> From:</td>
<td><input type="text" name="From" size="20" value="<?php echo $_GET['From']; ?>"
readonly></td>
<td><p> To:</td>
<td><input type="text" name="To" size="10" value="<?php echo $_GET['To']; ?>"
readonly></td></tr>
<tr><td><p> Display Text:</td>
<td><input type="text" name="Display" value="<?php echo $_GET['Display']; ?>"
size="20" readonly></td>
<td><p> Tag:</td>
<td><input type="text" name="Tag" size="15" value="<?php echo $_GET['Tag']; ?>"
readonly></td></tr>
<tr><td><p> Account Code:</td>
<td colspan="3"><input type="text" name="Account" value="<?php echo $_GET['Account'];
?>" size="20"></td></tr>
<tr><td valign="top"><p>Note:</td>
<td colspan="3"><textarea cols="20" rows="6" name="Note"></textarea></td></tr>
<tr><td> </td>
<td colspan="3"><input type="submit" value="Save"> <input type="Reset"
value="Clear"></td></tr>
</table>
</body></html>