Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('../config2.php');
- $query = "SELECT start, finished FROM billingdates ORDER BY start ASC";
- $result = mysql_query($query);
- while ($row2=mysql_fetch_array($result))
- {
- $startdate[] = $row2['start'];
- $enddate[] = $row2['finished'];
- }
- $query = "SELECT account, did, calls, msgs, deliveryhistory, frequency, email FROM reports";
- $results = mysql_query($query);
- while ($row=mysql_fetch_array($results))
- {
- $did = $row['did'];
- $dow = date(l);
- $dom = date(d);
- $today = date("D, F j, Y");
- // Checks to make sure it can run the report for calls
- if ($row['calls']=="1")
- {
- // Checks the frequency of the run - If it is 1 - it runs daily - If it is 7 it runs weekly - 30 is monthly
- if ($row['frequency']=="1")
- {
- // Email Recipient/Sender
- $recip = $row['email'];
- $sender = "service@maximumcallcenter.com";
- // Starts message
- $strMessage = "Call Report: \n\n\n";
- $strMessage .= '<html><head></head><body><table><tr><th>Call Time</th><th>Talk Time</th><th>Caller ID (If Available)</th></tr>';
- $db = pg_connect('host=10.0.11.64 dbname=call_linx_trans_db_backup user=call_linx password=');
- $query = sprintf("select * from (SELECT to_char(time_start, 'mm-dd-yyyy hh12:mm:ss') AS time_start, dura_caller :: numeric, dura_wrapup ::numeric, callerid, round(round(((round((((COALESCE(dura_caller,.00000000001) :: numeric)/6)+0.49),0)*6)/60),1)+((round((((COALESCE(dura_vmsoutb,.0000000000000001) :: numeric)/6)+0.49),0)*6)/60)+(((round((((COALESCE(dura_wrapup,0) :: numeric)/6)+.49),0)*6)/60)*.5),1) AS agent_time FROM call_stats WHERE mainbox = '" . $row['did'] . "' AND time_start BETWEEN '$startdate[2]' AND '$enddate[2]') as x where x.agent_time > 0 ORDER BY time_start");
- $result = pg_query($query);
- if (!$result) {
- echo "Problem with query " . $query . "<br/>";
- echo pg_last_error();
- exit();
- }
- $num_rows = pg_num_rows($result);
- while($row = pg_fetch_array($result))
- {
- $strMessage .= '<tr><td><center>' . $row['time_start'] . '</center></td><td><center>' . $row['agent_time'] . '</center></td><td><center>' . $row['callerid'] . '</center></td></tr>';
- }
- }
- $db = pg_connect('host=10.0.11.64 dbname=call_linx_trans_db_backup user=call_linx password=');
- $query2 = "SELECT COUNT(inbound) AS inboundcount FROM call_stats WHERE inbound = 1 AND dura_released = null AND mainbox= '$did' AND time_start between '$startdate[2]' AND '$enddate[2]'";
- $result2 = pg_query($query2);
- if (!$result2) {
- echo "Problem with query " . $query2 . "<br/>";
- echo pg_last_error();
- exit();
- }
- $row = pg_fetch_array($result2);
- $Inbound = $row['inboundcount'];
- $avgcount = "SELECT round((SUM((dura_wait :: numeric))/(SUM(inbound))),1) as avghold FROM call_stats WHERE inbound = 1 AND dura_released = null AND mainbox= '$did' AND time_start between '$startdate[2]' AND '$enddate[2]'";
- $avgcountresult = pg_query($avgcount);
- if (!$avgcountresult) {
- echo "Problem with query " . $avgcount . "<br/>";
- echo pg_last_error();
- exit();
- }
- $row = pg_fetch_array($avgcountresult);
- $AvgHold = $row['avghold'];
- $query3 = sprintf("SELECT round(SUM(round(((round((((COALESCE(dura_caller,.00000000001) :: numeric)/6)+0.49),0)*6)/60),1)+((round((((COALESCE(dura_vmsoutb,.0000000000000001) :: numeric)/6)+0.49),0)*6)/60)
- +(((round((((COALESCE(dura_wrapup,0) :: numeric)/6)+.49),0)*6)/60)*.5)),1) AS agenttime FROM call_stats WHERE mainbox= '$did' AND time_start between '$startdate[2]' AND '$enddate[2]'");
- $result3 = pg_query($query3);
- if (!$result3) {
- echo "Problem with query " . $query3 . "<br/>";
- echo pg_last_error();
- exit();
- }
- $row1 = pg_fetch_array($result3);
- $TotalMinutes = $row1['agenttime'];
- $strMessage .= "<font size=\"3\"><br /><br />Total Calls: <strong>" . $Inbound . "</strong><br /> Total Minutes Used: <strong>" . $TotalMinutes . "</strong><br /> Average Hold (seconds): <strong>" . $AvgHold . "</strong><br /><br /><br /></font><br /><br />";
- $headers = 'MIME-Version: 1.0' . "\r\n";
- $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
- $headers .= 'From: MAXIMUM Call Center <service@maximumcallcenter.com>' . "\r\n";
- $subject = 'MAXIMUM Call Center - Call Report';
- // Sends email
- mail( $recip, $subject, $strMessage, $headers );
- var_dump($strMessage);
- }
- }
- // This checks the frequency if it is not 1 day a week
- if ($row['frequency']=="7")
- {
- // Checks to make sure its Monday. If it is not, the report wont run
- if ($dow=="Monday")
- {
- // Email Recipient/Sender
- $recip = $row['email'];
- $sender = "service@maximumcallcenter.com";
- // Starts message
- $strMessage = "Call Report: \n\n\n";
- $strMessage .= '<html><head></head><body><table><tr><th>Call Time</th><th>Talk Time</th><th>Caller ID (If Available)</th></tr>';
- $db = pg_connect('host=10.0.11.64 dbname=call_linx_trans_db_backup user=call_linx password=');
- $query = sprintf("select * from (SELECT to_char(time_start, 'mm-dd-yyyy hh12:mm:ss') AS time_start, dura_caller :: numeric, dura_wrapup ::numeric, callerid, round(round(((round((((COALESCE(dura_caller,.00000000001) :: numeric)/6)+0.49),0)*6)/60),1)+((round((((COALESCE(dura_vmsoutb,.0000000000000001) :: numeric)/6)+0.49),0)*6)/60)+(((round((((COALESCE(dura_wrapup,0) :: numeric)/6)+.49),0)*6)/60)*.5),1) AS agent_time FROM call_stats WHERE mainbox = '" . $row['did'] . "' AND time_start BETWEEN '$startdate[2]' AND '$enddate[2]') as x where x.agent_time > 0 ORDER BY time_start");
- $result = pg_query($query);
- if (!$result) {
- echo "Problem with query " . $query . "<br/>";
- echo pg_last_error();
- exit();
- }
- $num_rows = pg_num_rows($result);
- while($row = pg_fetch_array($result))
- {
- $strMessage .= '<tr><td><center>' . $row['time_start'] . '</center></td><td><center>' . $row['agent_time'] . '</center></td><td><center>' . $row['callerid'] . '</center></td></tr>';
- }
- }
- $db = pg_connect('host=10.0.11.64 dbname=call_linx_trans_db_backup user=call_linx password=');
- $query2 = "SELECT COUNT(inbound) AS inboundcount FROM call_stats WHERE inbound = 1 AND dura_released = null AND mainbox= '$did' AND time_start between '$startdate[2]' AND '$enddate[2]'";
- $result2 = pg_query($query2);
- if (!$result2) {
- echo "Problem with query " . $query2 . "<br/>";
- echo pg_last_error();
- exit();
- }
- $row = pg_fetch_array($result2);
- $Inbound = $row['inboundcount'];
- $avgcount = "SELECT round((SUM((dura_wait :: numeric))/(SUM(inbound))),1) as avghold FROM call_stats WHERE inbound = 1 AND dura_released = null AND mainbox= '$did' AND time_start between '$startdate[2]' AND '$enddate[2]'";
- $avgcountresult = pg_query($avgcount);
- if (!$avgcountresult) {
- echo "Problem with query " . $avgcount . "<br/>";
- echo pg_last_error();
- exit();
- }
- $row = pg_fetch_array($avgcountresult);
- $AvgHold = $row['avghold'];
- $query3 = sprintf("SELECT round(SUM(round(((round((((COALESCE(dura_caller,.00000000001) :: numeric)/6)+0.49),0)*6)/60),1)+((round((((COALESCE(dura_vmsoutb,.0000000000000001) :: numeric)/6)+0.49),0)*6)/60)
- +(((round((((COALESCE(dura_wrapup,0) :: numeric)/6)+.49),0)*6)/60)*.5)),1) AS agenttime FROM call_stats WHERE mainbox= '$did' AND time_start between '$startdate[2]' AND '$enddate[2]'");
- $result3 = pg_query($query3);
- if (!$result3) {
- echo "Problem with query " . $query3 . "<br/>";
- echo pg_last_error();
- exit();
- }
- $row1 = pg_fetch_array($result3);
- $TotalMinutes = $row1['agenttime'];
- $strMessage .= "<font size=\"3\"><br /><br />Total Calls: <strong>" . $Inbound . "</strong><br /> Total Minutes Used: <strong>" . $TotalMinutes . "</strong><br /> Average Hold (seconds): <strong>" . $AvgHold . "</strong><br /><br /><br /></font><br /><br />";
- $headers = 'MIME-Version: 1.0' . "\r\n";
- $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
- $headers .= 'From: MAXIMUM Call Center <service@maximumcallcenter.com>' . "\r\n";
- $subject = 'MAXIMUM Call Center - Call Report';
- // Sends email
- mail( $recip, $subject, $strMessage, $headers );
- }
- if ($row['frequency']=="30")
- {
- // Checks to make sure its Monday. If it is not, the report wont run
- if ($dom=="31")
- {
- // Email Recipient/Sender
- $recip = $row['email'];
- $sender = "service@maximumcallcenter.com";
- // Starts message
- $strMessage = "Call Report: \n\n\n";
- $strMessage .= '<html><head></head><body><table><tr><th>Call Time</th><th>Talk Time</th><th>Caller ID (If Available)</th></tr>';
- $db = pg_connect('host=10.0.11.64 dbname=call_linx_trans_db_backup user=call_linx password=');
- $query = sprintf("select * from (SELECT to_char(time_start, 'mm-dd-yyyy hh12:mm:ss') AS time_start, dura_caller :: numeric, dura_wrapup ::numeric, callerid, round(round(((round((((COALESCE(dura_caller,.00000000001) :: numeric)/6)+0.49),0)*6)/60),1)+((round((((COALESCE(dura_vmsoutb,.0000000000000001) :: numeric)/6)+0.49),0)*6)/60)+(((round((((COALESCE(dura_wrapup,0) :: numeric)/6)+.49),0)*6)/60)*.5),1) AS agent_time FROM call_stats WHERE mainbox = '" . $row['did'] . "' AND time_start BETWEEN '$startdate[2]' AND '$enddate[2]') as x where x.agent_time > 0 ORDER BY time_start");
- $result = pg_query($query);
- if (!$result) {
- echo "Problem with query " . $query . "<br/>";
- echo pg_last_error();
- exit();
- }
- $num_rows = pg_num_rows($result);
- while($row = pg_fetch_array($result))
- {
- $strMessage .= '<tr><td><center>' . $row['time_start'] . '</center></td><td><center>' . $row['agent_time'] . '</center></td><td><center>' . $row['callerid'] . '</center></td></tr>';
- }
- }
- $db = pg_connect('host=10.0.11.64 dbname=call_linx_trans_db_backup user=call_linx password=');
- $query2 = "SELECT COUNT(inbound) AS inboundcount FROM call_stats WHERE inbound = 1 AND dura_released = null AND mainbox= '$did' AND time_start between '$startdate[2]' AND '$enddate[2]'";
- $result2 = pg_query($query2);
- if (!$result2) {
- echo "Problem with query " . $query2 . "<br/>";
- echo pg_last_error();
- exit();
- }
- $row = pg_fetch_array($result2);
- $Inbound = $row['inboundcount'];
- $avgcount = "SELECT round((SUM((dura_wait :: numeric))/(SUM(inbound))),1) as avghold FROM call_stats WHERE inbound = 1 AND dura_released = null AND mainbox= '$did' AND time_start between '$startdate[2]' AND '$enddate[2]'";
- $avgcountresult = pg_query($avgcount);
- if (!$avgcountresult) {
- echo "Problem with query " . $avgcount . "<br/>";
- echo pg_last_error();
- exit();
- }
- $row = pg_fetch_array($avgcountresult);
- $AvgHold = $row['avghold'];
- $query3 = sprintf("SELECT round(SUM(round(((round((((COALESCE(dura_caller,.00000000001) :: numeric)/6)+0.49),0)*6)/60),1)+((round((((COALESCE(dura_vmsoutb,.0000000000000001) :: numeric)/6)+0.49),0)*6)/60)
- +(((round((((COALESCE(dura_wrapup,0) :: numeric)/6)+.49),0)*6)/60)*.5)),1) AS agenttime FROM call_stats WHERE mainbox= '$did' AND time_start between '$startdate[2]' AND '$enddate[2]'");
- $result3 = pg_query($query3);
- if (!$result3) {
- echo "Problem with query " . $query3 . "<br/>";
- echo pg_last_error();
- exit();
- }
- $row1 = pg_fetch_array($result3);
- $TotalMinutes = $row1['agenttime'];
- $strMessage .= "<font size=\"3\"><br /><br />Total Calls: <strong>" . $Inbound . "</strong><br /> Total Minutes Used: <strong>" . $TotalMinutes . "</strong><br /> Average Hold (seconds): <strong>" . $AvgHold . "</strong><br /><br /><br /></font><br /><br />";
- $headers = 'MIME-Version: 1.0' . "\r\n";
- $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
- $headers .= 'From: MAXIMUM Call Center <service@maximumcallcenter.com>' . "\r\n";
- $subject = 'MAXIMUM Call Center - Call Report';
- // Sends email
- mail( $recip, $subject, $strMessage, $headers );
- }
- $date = date(D, d, l, yy)
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement