} } if ($table != 'report') { $res = $db->query($sql); } global $locate; if ($table == 'report') { $groupid = 0; $accountid = 0; if (!empty($_REQUEST['groupid'])) { $groupid = $_REQUEST['groupid']; } if (!empty($_REQUEST['accountid'])) { $accountid = $_REQUEST['accountid']; } $rows = astercrm::readReportAgent($groupid, $accountid, $_REQUEST['sdate'], $_REQUEST['edate']); $data = array(); if ($rows['type'] == 'grouplist') { foreach ($rows as $key => $row) { $data_tmp = array(); if ($key != 'type') { $hour = intval($row['seconds'] / 3600); if ($hour < 3) { $data_tmp['color'] = 'FF0000'; } $minute = intval($row['seconds'] % 3600 / 60); $sec = intval($row['seconds'] % 60); $asr = round($row['arecordNum'] / $row['recordNum'] * 100, 2); $acd = round($row['seconds'] / $row['arecordNum'], 2); $acdminute = intval($acd / 60); $acdsec = intval($acd % 60);
function listReport($aFormValues) { global $locate; $objResponse = new xajaxResponse(); list($syear, $smonth, $sday, $stime) = split("[ -]", $aFormValues['sdate']); $syear = (int) $syear; $smonth = (int) $smonth; $sday = (int) $sday; list($shours, $smins) = split("[ :]", $stime); $shours = (int) $shours; if ($shours == 0) { $shours = '00'; } $smins = (int) $smins; if ($smins == 0) { $smins = '00'; } list($eyear, $emonth, $eday, $etime) = split("[ -]", $aFormValues['edate']); $eyear = (int) $eyear; $emonth = (int) $emonth; $eday = (int) $eday; list($ehours, $emins) = split("[ :]", $etime); $ehours = (int) $ehours; if ($ehours == 0) { $ehours = '00'; } $emins = (int) $emins; if ($emins == 0) { $emins = '00'; } $ary = array(); $aFormValues['sdate'] = $syear . "-" . $smonth . "-" . $sday . ' ' . $shours . ':' . $smins; $aFormValues['edate'] = $eyear . "-" . $emonth . "-" . $eday . ' ' . $ehours . ':' . $emins; $res = astercrm::readReport($aFormValues['groupid'], $aFormValues['accountid'], $aFormValues['sdate'], $aFormValues['edate'], 'both'); if ($aFormValues['listType'] == "none") { if ($res['all']->fetchInto($myreport)) { $myreport['answeredNum'] = $res['answered']; $result = parseReport($myreport, " "); $html .= "<b>" . $result['html'] . "</b>"; } $objResponse->addAssign("divGeneralList", "innerHTML", $html); $objResponse->addScript("document.getElementById('exportlist').innerHTML = '';"); $objResponse->addScript("document.getElementById('frmFilter').action = '';"); return $objResponse; } elseif ($aFormValues['listType'] == "list") { if ($aFormValues['reporttype'] == "flash") { $objResponse->addScript("actionFlash('" . $aFormValues["resellerid"] . "','" . $aFormValues["groupid"] . "','" . $aFormValues["sltBooth"] . "','" . $aFormValues["sdate"] . "','" . $aFormValues["edate"] . "','" . $aFormValues["listType"] . "','" . $aFormValues["hidCurpeer"] . "');"); $html = ""; } else { $exportlist = '<input type="submit" value="' . $locate->Translate("export") . '">'; $objResponse->addAssign("exportlist", "innerHTML", $exportlist); $objResponse->addScript("document.getElementById('frmFilter').action = 'dataexport.php';"); $rows = astercrm::readReportAgent($aFormValues['groupid'], $aFormValues['accountid'], $aFormValues["sdate"], $aFormValues["edate"]); $html = '<table class="adminlist" border="1" style="width:800px;">'; $class = 'row1'; if ($rows['type'] == 'grouplist') { $html .= '<tr><th>' . $locate->Translate("groupname") . '</th> <th>' . $locate->Translate("total calls") . '</th> <th>' . $locate->Translate("answered calls") . '</th> <th>' . $locate->Translate("answered duration") . '</th> <th>' . $locate->Translate("ASR") . '</th> <th>' . $locate->Translate("ACD") . '</th></tr>'; $class = 'row1'; foreach ($rows as $key => $row) { if ($key != 'type') { $hour = intval($row['seconds'] / 3600); if ($hour < 3) { $hour = '<font color="red">' . $hour; } $minute = intval($row['seconds'] % 3600 / 60); $sec = intval($row['seconds'] % 60); $asr = round($row['arecordNum'] / $row['recordNum'] * 100, 2); $acd = round($row['seconds'] / $row['arecordNum'], 2); $acdminute = intval($acd / 60); $acdsec = intval($acd % 60); $html .= '<tr class="' . $class . '"><td>' . $row['groupname'] . '</td> <td>' . $row['recordNum'] . '</td> <td>' . $row['arecordNum'] . '</td> <td>' . $hour . $locate->Translate("hour") . $minute . $locate->Translate("minute") . $sec . $locate->Translate("sec") . '</td> <td>' . $asr . '%</td> <td>' . $acdminute . $locate->Translate("minute") . $acdsec . $locate->Translate("sec") . '</td></tr>'; if ($class == 'row1') { $class = 'row0'; } else { $class = 'row1'; } } } } elseif ($rows['type'] == 'agentlist') { //print_r($rows);exit; $group = astercrm::getRecordByID($aFormValues['groupid'], "astercrm_accountgroup"); $html .= '<tr><th>' . $locate->Translate("groupname") . '</th> <th>' . $locate->Translate("username") . '</th> <th>' . $locate->Translate("name") . '</th> <th>' . $locate->Translate("total calls") . '</th> <th>' . $locate->Translate("answered calls") . '</th> <th>' . $locate->Translate("answered duration") . '</th> <th>' . $locate->Translate("ASR") . '</th> <th>' . $locate->Translate("ACD") . '</th></tr>'; $class = 'row1'; foreach ($rows as $key => $row) { //print_r($rows);exit; if ($key != 'type') { $hour = intval($row['seconds'] / 3600); if ($hour < 3) { $hour = '<font color="red">' . $hour; } $minute = intval($row['seconds'] % 3600 / 60); $sec = intval($row['seconds'] % 60); $asr = round($row['arecordNum'] / $row['recordNum'] * 100, 2); $acd = round($row['seconds'] / $row['arecordNum'], 2); $acdminute = intval($acd / 60); $acdsec = intval($acd % 60); $html .= '<tr class="' . $class . '"><td>' . $group['groupname'] . '</td> <td>' . $row['username'] . '</td> <td>' . $row['name'] . '</td> <td>' . $row['recordNum'] . '</td> <td>' . $row['arecordNum'] . '</td> <td>' . $hour . $locate->Translate("hour") . $minute . $locate->Translate("minute") . $sec . $locate->Translate("sec") . '</td> <td>' . $asr . '%</td> <td>' . $acdminute . $locate->Translate("minute") . $acdsec . $locate->Translate("sec") . '</td></tr>'; if ($class == 'row1') { $class = 'row0'; } else { $class = 'row1'; } } } } elseif ($rows['type'] == 'agentsingle') { print_r($rows); exit; } $objResponse->addAssign("divGeneralList", "innerHTML", $html); return $objResponse; } } elseif ($aFormValues['listType'] == "sumyear") { if ($aFormValues['reporttype'] == "flash") { $objResponse->addScript("actionFlash('" . $aFormValues["resellerid"] . "','" . $aFormValues["groupid"] . "','" . $aFormValues["sltBooth"] . "','" . $aFormValues["sdate"] . "','" . $aFormValues["edate"] . "','" . $aFormValues["listType"] . "','" . $aFormValues["hidCurpeer"] . "');"); $html = ""; } else { for ($year = $syear; $year <= $eyear; $year++) { $res = astercrm::readReport($aFormValues['groupid'], $aFormValues['accountid'], "{$year}-1-1 00:00:00", "{$year}-12-31 23:59:59", 'both'); if ($res['all']->fetchInto($myreport)) { $myreport['answeredNum'] = $res['answered']; $html .= "<div class='box'>"; $html .= "{$year} :<br/>"; $html .= "<div>"; $result = parseReport($myreport); $html .= $result['html']; $html .= "</div>"; $html .= "</div>"; $ary['recordNum'] += $result['data']['recordNum']; $ary['seconds'] += $result['data']['seconds']; $ary['answeredNum'] += $result['data']['answeredNum']; } } $html .= "<div class='box'>"; $html .= $locate->Translate("total") . " :<br/>"; $html .= "<div>"; $result = parseReport($ary); $html .= $result['html']; $html .= "</div>"; $html .= "</div>"; $objResponse->addAssign("divGeneralList", "innerHTML", $html); $objResponse->addScript("document.getElementById('exportlist').innerHTML = '';"); $objResponse->addScript("document.getElementById('frmFilter').action = '';"); } } elseif ($aFormValues['listType'] == "summonth") { if ($aFormValues['reporttype'] == "flash") { $objResponse->addScript("actionFlash('" . $aFormValues["resellerid"] . "','" . $aFormValues["groupid"] . "','" . $aFormValues["sltBooth"] . "','" . $aFormValues["sdate"] . "','" . $aFormValues["edate"] . "','" . $aFormValues["listType"] . "','" . $aFormValues["hidCurpeer"] . "');"); } else { //for ($year = $syear; $year<=$eyear;$year++){ $year = $syear; for ($month = 1; $month <= 12; $month++) { $res = astercrm::readReport($aFormValues['groupid'], $aFormValues['accountid'], "{$year}-{$month}-1 00:00:00", "{$year}-{$month}-31 23:59:59", 'both'); if ($res['all']->fetchInto($myreport)) { $myreport['answeredNum'] = $res['answered']; $html .= "<div class='box'>"; $html .= "{$year}-{$month} :<br/>"; $html .= "<div>"; $result = parseReport($myreport); $html .= $result['html']; $html .= "</div>"; $html .= "</div>"; $ary['recordNum'] += $result['data']['recordNum']; $ary['seconds'] += $result['data']['seconds']; $ary['answeredNum'] += $result['data']['answeredNum']; } } //} $html .= "<div class='box'>"; $html .= $locate->Translate("total") . " :<br/>"; $html .= "<div>"; $result = parseReport($ary); $html .= $result['html']; $html .= "</div>"; $html .= "</div>"; $objResponse->addAssign("divGeneralList", "innerHTML", $html); $objResponse->addScript("document.getElementById('exportlist').innerHTML = '';"); $objResponse->addScript("document.getElementById('frmFilter').action = '';"); } } elseif ($aFormValues['listType'] == "sumday") { if ($aFormValues['reporttype'] == "flash") { $objResponse->addScript("actionFlash('" . $aFormValues["resellerid"] . "','" . $aFormValues["groupid"] . "','" . $aFormValues["sltBooth"] . "','" . $aFormValues["sdate"] . "','" . $aFormValues["edate"] . "','" . $aFormValues["listType"] . "','" . $aFormValues["hidCurpeer"] . "');"); } else { for ($day = $sday; $day <= 31; $day++) { $res = astercrm::readReport($aFormValues['groupid'], $aFormValues['accountid'], "{$syear}-{$smonth}-{$day} 00:00:00", "{$syear}-{$smonth}-{$day} 23:59:59", 'both'); if ($res['all']->fetchInto($myreport)) { $myreport['answeredNum'] = $res['answered']; $html .= "<div class='box'>"; $html .= "{$syear}-{$smonth}-{$day} :<br/>"; $html .= "<div>"; $result = parseReport($myreport); $html .= $result['html']; $html .= "</div>"; $html .= "</div>"; $ary['recordNum'] += $result['data']['recordNum']; $ary['seconds'] += $result['data']['seconds']; $ary['answeredNum'] += $result['data']['answeredNum']; } } $html .= "<div class='box'>"; $html .= $locate->Translate("total") . " :<br/>"; $html .= "<div>"; $result = parseReport($ary); $html .= $result['html']; $html .= "</div>"; $html .= "</div>"; $objResponse->addAssign("divGeneralList", "innerHTML", $html); $objResponse->addScript("document.getElementById('exportlist').innerHTML = '';"); $objResponse->addScript("document.getElementById('frmFilter').action = '';"); } } elseif ($aFormValues['listType'] == "sumhour") { if ($aFormValues['reporttype'] == "flash") { $objResponse->addScript("actionFlash('" . $aFormValues["resellerid"] . "','" . $aFormValues["groupid"] . "','" . $aFormValues["sltBooth"] . "','" . $aFormValues["sdate"] . "','" . $aFormValues["edate"] . "','" . $aFormValues["listType"] . "','" . $aFormValues["hidCurpeer"] . "');"); } else { for ($hour = 0; $hour <= 23; $hour++) { $res = astercrm::readReport($aFormValues['groupid'], $aFormValues['accountid'], "{$syear}-{$smonth}-{$sday} {$hour}:00:00", "{$syear}-{$smonth}-{$sday} {$hour}:59:59", 'both'); if ($res['all']->fetchInto($myreport)) { $myreport['answeredNum'] = $res['answered']; $html .= "<div class='box'>"; $html .= "{$syear}-{$smonth}-{$sday} {$hour}:<br/>"; $html .= "<div>"; $result = parseReport($myreport); $html .= $result['html']; $html .= "</div>"; $html .= "</div>"; $ary['recordNum'] += $result['data']['recordNum']; $ary['seconds'] += $result['data']['seconds']; $ary['answeredNum'] += $result['data']['answeredNum']; } } $html .= "<div class='box'>"; $html .= $locate->Translate("total") . " :<br/>"; $html .= "<div>"; $result = parseReport($ary); $html .= $result['html']; $html .= "</div>"; $html .= "</div>"; $objResponse->addAssign("divGeneralList", "innerHTML", $html); $objResponse->addScript("document.getElementById('exportlist').innerHTML = '';"); $objResponse->addScript("document.getElementById('frmFilter').action = '';"); } } elseif ($aFormValues['listType'] == "sumgroup") { if ($aFormValues['reporttype'] == "flash") { $objResponse->addScript("actionPieGroup('" . $aFormValues["resellerid"] . "','" . $aFormValues["groupid"] . "','" . $aFormValues["sltBooth"] . "','" . $aFormValues["sdate"] . "','" . $aFormValues["edate"] . "','" . $aFormValues["listType"] . "','" . $aFormValues["hidCurpeer"] . "');"); } else { $res = astercc::readReportPie($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], $aFormValues['sdate'], $aFormValues['edate'], 'destination', $aFormValues['action'], 'limit'); while ($res->fetchInto($row)) { $iid = $row['gid']; if ($aFormValues['resellerid'] == 0 || $aFormValues['resellerid'] == '') { $title = "" . $reseller_arr[$iid]; } else { if ($aFormValues['groupid'] == 0 || $aFormValues['groupid'] == '') { $title = "" . $group_arr[$iid]; } else { $title = "" . $iid; } } $html .= "<div class='box'>"; $html .= "{$title} :<br/>"; $html .= "<div>"; $result = parseReport($row); $html .= $result['html']; $html .= "</div>"; $html .= "</div>"; $ary['recordNum'] += $result['data']['recordNum']; $ary['seconds'] += $result['data']['seconds']; $ary['credit'] += $result['data']['credit']; $ary['callshopcredit'] += $result['data']['callshopcredit']; $ary['resellercredit'] += $result['data']['resellercredit']; } $html .= "<div class='box'>"; $html .= $locate->Translate("total") . " :<br/>"; $html .= "<div>"; $result = parseReport($ary); $html .= $result['html']; $html .= "</div>"; $html .= "</div>"; $html .= "<div style='clear:both;'></div>"; $objResponse->addAssign("divUnbilledList", "innerHTML", $html); $objResponse->addScript("document.getElementById('exportlist').innerHTML = '';"); $objResponse->addScript("document.getElementById('frmFilter').action = '';"); } } return $objResponse; }