Пример #1
0
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;
}
Пример #2
0
$aFormValues['edate'] = $arr_action[5];
$aFormValues['listType'] = $arr_action[6];
$aFormValues['hidCurpeer'] = $arr_action[7];
if ($aFormValues['sltBooth'] == '' && $aFormValues['hidCurpeer'] != '') {
    $aFormValues['sltBooth'] = $aFormValues['hidCurpeer'];
}
list($syear, $smonth, $sday) = split("[ -]", $aFormValues['sdate']);
$syear = (int) $syear;
$smonth = (int) $smonth;
$sday = (int) $sday;
list($eyear, $emonth, $eday) = split("[ -]", $aFormValues['edate']);
$eyear = (int) $eyear;
$emonth = (int) $emonth;
$eday = (int) $eday;
$color = array('#1F8FA1', '#1F8FA1', '#848484', '#ffccff', '#CACFBE', '#DEF799', '#FF33C9', '#FF653F', '#669900', '#ffcc99', '#ffccff', '#99ccff', '#ffcc00');
$res = astercc::readReportPie($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], $aFormValues['sdate'], $aFormValues['edate'], 'destination', $aFormValues['action'], 'limit');
$ii = 1;
while ($res->fetchInto($row)) {
    //print_r($row);
    $row['markup'] = $row['callshopcredit'] - $row['resellercredit'];
    $col = $color[$ii];
    $title = "" . $row['gid'];
    $iid = $row['gid'];
    if ($aFormValues['resellerid'] == 0 || $aFormValues['resellerid'] == '') {
        $title = "" . $reseller_arr[$iid];
    } else {
        if ($aFormValues['groupid'] == 0 || $aFormValues['groupid'] == '') {
            $title = "" . $group_arr[$iid];
        }
    }
    switch ($action_value) {
Пример #3
0
function listCDR($aFormValues)
{
    global $locate, $config;
    $reseller = astercrm::getAll('resellergroup');
    while ($reseller->fetchInto($row)) {
        $id = $row['id'];
        $reseller_arr[$id] = $row['resellername'];
    }
    $group = astercrm::getAll('accountgroup');
    while ($group->fetchInto($row)) {
        $id = $row['id'];
        $group_arr[$id] = $row['groupname'];
    }
    $objResponse = new xajaxResponse();
    $objResponse->addAssign("divMsg", "style.visibility", "hidden");
    if ($aFormValues['sltBooth'] == '' && $aFormValues['hidCurpeer'] != '') {
        $aFormValues['sltBooth'] = $aFormValues['hidCurpeer'];
    }
    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();
    if ($aFormValues['reporttype'] == "text") {
        $aFormValues['sdate'] = $syear . "-" . $smonth . "-" . $sday . ' ' . $shours . ':' . $smins;
        $aFormValues['edate'] = $eyear . "-" . $emonth . "-" . $eday . ' ' . $ehours . ':' . $emins;
    } else {
        $aFormValues['sdate'] = $syear . "-" . $smonth . "-" . $sday;
        $aFormValues['edate'] = $eyear . "-" . $emonth . "-" . $eday;
    }
    if ($aFormValues['listType'] == "none") {
        $res = astercc::readReport($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], $aFormValues['sdate'], $aFormValues['edate']);
        $answeredNum = astercc::readAnsweredNum($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], $aFormValues['sdate'], $aFormValues['edate']);
        $a2bcost = -1;
        if ($config['a2billing']['enable']) {
            $a2bcost = Customer::readA2Breport($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], $aFormValues['sdate'], $aFormValues['edate']);
        }
        if ($res->fetchInto($myreport)) {
            $result = parseReport($myreport, $answeredNum, $a2bcost);
            $html .= $result['html'];
        }
        $objResponse->addAssign("divUnbilledList", "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 = astercc::readReport($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], "{$year}-1-1 00:00:00", "{$year}-12-31 23:59:59");
                $answeredNum = astercc::readAnsweredNum($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], "{$year}-1-1 00:00:00", "{$year}-12-31 23:59:59");
                $a2bcost = -1;
                if ($config['a2billing']['enable']) {
                    $a2bcost = Customer::readA2Breport($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], "{$year}-1-1 00:00:00", "{$year}-12-31 23:59:59");
                }
                if ($res->fetchInto($myreport)) {
                    $html .= "<div class='box'>";
                    $html .= "{$year} :<br/>";
                    $html .= "<div>";
                    $result = parseReport($myreport, $answeredNum, $a2bcost);
                    $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'];
                    $ary['billsec_leg_a'] += $myreport['billsec_leg_a'];
                    $answeredNumTotal += $answeredNum;
                    if ($config['a2billing']['enable']) {
                        $a2bcostTotal += $a2bcost;
                    }
                }
            }
            if (!$config['a2billing']['enable']) {
                $a2bcostTotal = -1;
            }
            $html .= "<div class='box'>";
            $html .= "total :<br/>";
            $html .= "<div>";
            $result = parseReport($ary, $answeredNumTotal, $a2bcostTotal);
            $html .= $result['html'];
            $html .= "</div>";
            $html .= "</div>";
            $html .= "<div style='clear:both;'></div>";
            $objResponse->addAssign("divUnbilledList", "innerHTML", $html);
        }
        return $objResponse;
    } 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 = astercc::readReport($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], "{$year}-{$month}-1 00:00:00", "{$year}-{$month}-31 23:59:59");
                $answeredNum = astercc::readAnsweredNum($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], "{$year}-{$month}-1 00:00:00", "{$year}-{$month}-31 23:59:59");
                $a2bcost = -1;
                if ($config['a2billing']['enable']) {
                    $a2bcost = Customer::readA2Breport($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], "{$year}-{$month}-1 00:00:00", "{$year}-{$month}-31 23:59:59");
                }
                if ($res->fetchInto($myreport)) {
                    $html .= "<div class='box'>";
                    $html .= "{$year}-{$month} :<br/>";
                    $html .= "<div>";
                    $result = parseReport($myreport, $answeredNum, $a2bcost);
                    $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'];
                    $answeredNumTotal += $answeredNum;
                    if ($config['a2billing']['enable']) {
                        $a2bcostTotal += $a2bcost;
                    }
                }
            }
            //}
            if (!$config['a2billing']['enable']) {
                $a2bcostTotal = -1;
            }
            $html .= "<div class='box'>";
            $html .= "total :<br/>";
            $html .= "<div>";
            $result = parseReport($ary, $answeredNumTotal, $a2bcostTotal);
            $html .= $result['html'];
            $html .= "</div>";
            $html .= "</div>";
            $html .= "<div style='clear:both;'></div>";
            $objResponse->addAssign("divUnbilledList", "innerHTML", $html);
        }
        return $objResponse;
    } 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 = astercc::readReport($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], "{$syear}-{$smonth}-{$day} 00:00:00", "{$syear}-{$smonth}-{$day} 23:59:59");
                $answeredNum = astercc::readAnsweredNum($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], "{$syear}-{$smonth}-{$day} 00:00:00", "{$syear}-{$smonth}-{$day} 23:59:59");
                $a2bcost = -1;
                if ($config['a2billing']['enable']) {
                    $a2bcost = Customer::readA2Breport($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], "{$syear}-{$smonth}-{$day} 00:00:00", "{$syear}-{$smonth}-{$day} 23:59:59");
                }
                if ($res->fetchInto($myreport)) {
                    $html .= "<div class='box'>";
                    $html .= "{$syear}-{$smonth}-{$day} :<br/>";
                    $html .= "<div>";
                    $result = parseReport($myreport, $answeredNum, $a2bcost);
                    $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'];
                    $answeredNumTotal += $answeredNum;
                    if ($config['a2billing']['enable']) {
                        $a2bcostTotal += $a2bcost;
                    }
                }
            }
            if (!$config['a2billing']['enable']) {
                $a2bcostTotal = -1;
            }
            $html .= "<div class='box'>";
            $html .= "total :<br/>";
            $html .= "<div>";
            $result = parseReport($ary, $answeredNumTotal, $a2bcostTotal);
            $html .= $result['html'];
            $html .= "</div>";
            $html .= "</div>";
            $html .= "<div style='clear:both;'></div>";
            $objResponse->addAssign("divUnbilledList", "innerHTML", $html);
        }
        return $objResponse;
    } 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 = astercc::readReport($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], "{$syear}-{$smonth}-{$sday} {$hour}:00:00", "{$syear}-{$smonth}-{$sday} {$hour}:59:59");
                $answeredNum = astercc::readAnsweredNum($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], "{$syear}-{$smonth}-{$sday} {$hour}:00:00", "{$syear}-{$smonth}-{$sday} {$hour}:59:59");
                $a2bcost = -1;
                if ($config['a2billing']['enable']) {
                    $a2bcost = Customer::readA2Breport($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], "{$syear}-{$smonth}-{$sday} {$hour}:00:00", "{$syear}-{$smonth}-{$sday} {$hour}:59:59");
                }
                if ($res->fetchInto($myreport)) {
                    $html .= "<div class='box'>";
                    $html .= "{$syear}-{$smonth}-{$sday} {$hour}:<br/>";
                    $html .= "<div>";
                    $result = parseReport($myreport, $answeredNum, $a2bcost);
                    $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'];
                    $answeredNumTotal += $answeredNum;
                    if ($config['a2billing']['enable']) {
                        $a2bcostTotal += $a2bcost;
                    }
                }
            }
            if (!$config['a2billing']['enable']) {
                $a2bcostTotal = -1;
            }
            $html .= "<div class='box'>";
            $html .= "total :<br/>";
            $html .= "<div>";
            $result = parseReport($ary, $answeredNumTotal, $a2bcostTotal);
            $html .= $result['html'];
            $html .= "</div>";
            $html .= "</div>";
            $html .= "<div style='clear:both;'></div>";
            $objResponse->addAssign("divUnbilledList", "innerHTML", $html);
        }
        return $objResponse;
    } elseif ($aFormValues['listType'] == "sumdest") {
        $res = astercc::readReport($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], $aFormValues['sdate'], $aFormValues['edate'], 'destination');
        $html .= '<form action="" name="f" id="f">';
        $html .= '<table width="99%">';
        if ($_SESSION['curuser']['usertype'] == 'admin' || $_SESSION['curuser']['usertype'] == 'reseller') {
            $html .= '<tr>
					<td width="60"></td>
					<td width="160">' . $locate->Translate("Destination") . '</td>
					<td width="120">' . $locate->Translate("Calls") . '</td>
					<td width="120">' . $locate->Translate("Billsec") . '</td>
					<td width="120">' . $locate->Translate("Sells") . '</td>
					<td width="70">' . $locate->Translate("Callshop Cost") . '</td>
					<td width="90">' . $locate->Translate("Reseller Cost") . '</td>
					<td width="90">' . $locate->Translate("Markup") . '</td>
					</tr>';
        } else {
            if ($_SESSION['curuser']['usertype'] == 'groupadmin') {
                $html .= '<tr>
					<td width="60"></td>
					<td width="160">' . $locate->Translate("Destination") . '</td>
					<td width="120">' . $locate->Translate("Calls") . '</td>
					<td width="120">' . $locate->Translate("Billsec") . '</td>
					<td width="120">' . $locate->Translate("Sells") . '</td>
					<td width="70">' . $locate->Translate("Callshop Cost") . '</td>
					<td width="90">' . $locate->Translate("Markup") . '</td>
					</tr>';
            } else {
                if ($_SESSION['curuser']['usertype'] == 'operator') {
                    $html .= '<tr>
					<td width="60"></td>
					<td width="160">' . $locate->Translate("Destination") . '</td>
					<td width="120">' . $locate->Translate("Calls") . '</td>
					<td width="120">' . $locate->Translate("Billsec") . '</td>
					<td width="120">' . $locate->Translate("Sells") . '</td>
					</tr>';
                }
            }
        }
        while ($res->fetchInto($row)) {
            if ($_SESSION['curuser']['usertype'] == 'admin' || $_SESSION['curuser']['usertype'] == 'reseller') {
                $html .= '<tr>
						<td width="60"></td>
						<td width="160">' . $row['destination'] . '</td>
						<td width="120">' . $row['recordNum'] . '</td>
						<td width="120">' . astercrm::FormatSec($row['seconds']) . '</td>
						<td width="120">' . $row['credit'] . '</td>
						<td width="120">' . $row['callshopcredit'] . '</td>
						<td width="120">' . $row['resellercredit'] . '</td>
						<td width="120">' . ($row['callshopcredit'] - $row['resellercredit']) . '</td>
						</tr>';
            } else {
                if ($_SESSION['curuser']['usertype'] == 'groupadmin') {
                    $html .= '<tr>
						<td width="60"></td>
						<td width="160">' . $row['destination'] . '</td>
						<td width="120">' . $row['recordNum'] . '</td>
						<td width="120">' . astercrm::FormatSec($row['seconds']) . '</td>
						<td width="120">' . $row['credit'] . '</td>
						<td width="120">' . $row['callshopcredit'] . '</td>
						<td width="120">' . ($row['credit'] - $row['callshopcredit']) . '</td>
						</tr>';
                } else {
                    if ($_SESSION['curuser']['usertype'] == 'operator') {
                        $html .= '<tr>
						<td width="60"></td>
						<td width="160">' . $row['destination'] . '</td>
						<td width="120">' . $row['recordNum'] . '</td>
						<td width="120">' . astercrm::FormatSec($row['seconds']) . '</td>
						<td width="120">' . $row['credit'] . '</td>
						</tr>';
                    }
                }
            }
        }
        $html .= '</table>';
        $html .= '</form>';
        if ($_SESSION['curuser']['usertype'] == 'admin' || $_SESSION['curuser']['usertype'] == 'reseller') {
            if ($aFormValues['reporttype'] == "flash") {
                $objResponse->addScript("actionPie1('" . $aFormValues["resellerid"] . "','" . $aFormValues["groupid"] . "','" . $aFormValues["sltBooth"] . "','" . $aFormValues["sdate"] . "','" . $aFormValues["edate"] . "','" . $aFormValues["listType"] . "','" . $aFormValues["hidCurpeer"] . "');");
                $html = '';
            } else {
                $objResponse->addAssign("divUnbilledList", "innerHTML", $html);
            }
        } else {
            if ($_SESSION['curuser']['usertype'] == 'groupadmin') {
                if ($aFormValues['reporttype'] == "flash") {
                    $objResponse->addScript("actionPie2('" . $aFormValues["resellerid"] . "','" . $aFormValues["groupid"] . "','" . $aFormValues["sltBooth"] . "','" . $aFormValues["sdate"] . "','" . $aFormValues["edate"] . "','" . $aFormValues["listType"] . "','" . $aFormValues["hidCurpeer"] . "');");
                    $html = '';
                } else {
                    $objResponse->addAssign("divUnbilledList", "innerHTML", $html);
                }
            } else {
                if ($_SESSION['curuser']['usertype'] == 'operator') {
                    if ($aFormValues['reporttype'] == "flash") {
                        $objResponse->addScript("actionPie3('" . $aFormValues["resellerid"] . "','" . $aFormValues["groupid"] . "','" . $aFormValues["sltBooth"] . "','" . $aFormValues["sdate"] . "','" . $aFormValues["edate"] . "','" . $aFormValues["listType"] . "','" . $aFormValues["hidCurpeer"] . "');");
                        $html = '';
                    } else {
                        $objResponse->addAssign("divUnbilledList", "innerHTML", $html);
                    }
                }
            }
        }
        return $objResponse;
    } 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 .= "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);
        }
        return $objResponse;
    }
    $records = astercc::readAll($aFormValues['resellerid'], $aFormValues['groupid'], $aFormValues['sltBooth'], $aFormValues['sdate'], $aFormValues['edate']);
    $html .= '<form action="" name="f" id="f">';
    $html .= '<table width="99%">';
    $html .= '<tr>
			<td width="60"></td>
			<td width="120">' . $locate->Translate("Calldate") . '</td>
			<td width="120">' . $locate->Translate("Clid") . '</td>
			<td width="120">' . $locate->Translate("Dst") . '</td>
			<td width="70">' . $locate->Translate("Duration") . '</td>
			<td width="90">' . $locate->Translate("Disposition") . '</td>
			<td width="70">' . $locate->Translate("Billsec") . '</td>
			<td width="160">' . $locate->Translate("Destination") . '</td>
			<td width="360">' . $locate->Translate("Rate") . '</td>
 			<td width="120">' . $locate->Translate("Price") . '</td>
 			<td width="70">' . $locate->Translate("Status") . '</td>
			<td width="300">' . $locate->Translate("Note") . '</td>
			</tr>';
    $html .= '<tr>
			<td width="60">
				<input type="checkbox" onclick="ckbAllOnClick(this);" id="ckbAll[]" name="ckbAll[]">' . $locate->Translate("All") . '
			</td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
 			<td></td>
 			<td></td>
			<td></td>
			</tr>';
    while ($records->fetchInto($mycdr)) {
        $price = '';
        $ratedesc = '';
        $trstyle = '';
        $ratedesc = astercc::readRateDesc($mycdr['memo']);
        $callshop_cost = 0;
        $reseller_cost = 0;
        if ($_SESSION['curuser']['usertype'] == 'operator') {
        } else {
            if ($_SESSION['curuser']['usertype'] == 'groupadmin') {
                $callshop_cost = $mycdr['callshopcredit'];
            } else {
                if ($_SESSION['curuser']['usertype'] == 'admin') {
                    $callshop_cost = $mycdr['callshopcredit'];
                    $reseller_cost = $mycdr['resellercredit'];
                }
            }
        }
        if ($mycdr['setfreecall'] == 'yes') {
            $trstyle = 'style="background:#d5c59f;"';
        }
        $html .= '	<tr align="left" id="tr-' . $mycdr['id'] . '" ' . $trstyle . '>
						<td align="right">
							<input type="checkbox" id="ckb[]" name="ckb[]" value="' . $mycdr['id'] . '" onclick="ckbOnClick(this);">
							<input type="hidden" id="price-' . $mycdr['id'] . '" name="price-' . $mycdr['id'] . '" value="' . $mycdr['credit'] . '">
							<input type="hidden" id="callshop-' . $mycdr['id'] . '" name="callshop-' . $mycdr['id'] . '" value="' . $callshop_cost . '">
							<input type="hidden" id="reseller-' . $mycdr['id'] . '" name="reseller-' . $mycdr['id'] . '" value="' . $reseller_cost . '">
							<input type="hidden" id="free-' . $mycdr['id'] . '" name="free-' . $mycdr['id'] . '" value="' . $mycdr['setfreecall'] . '">
						</td>
						<td>' . $mycdr['calldate'] . '</td>
						<td>' . $mycdr['src'] . '</td>
						<td>' . $mycdr['dst'] . '</td>
						<td>' . astercrm::FormatSec($mycdr['duration']) . '</td>
						<td>' . $mycdr['disposition'] . '</td>
						<td>' . astercrm::FormatSec($mycdr['billsec']) . '</td>
						<td>' . $mycdr['destination'] . '</td>
						<td>' . $ratedesc . '</td>';
        if ($_SESSION['curuser']['usertype'] == 'operator') {
            $html .= '<td>' . $mycdr['credit'] . '</td>';
        } else {
            if ($_SESSION['curuser']['usertype'] == 'groupadmin') {
                $html .= '<td>' . $mycdr['credit'] . '<br>' . '(' . $callshop_cost . ')' . '</td>';
            } else {
                if ($_SESSION['curuser']['usertype'] == 'admin') {
                    $html .= '<td>' . $mycdr['credit'] . '<br>' . '(' . $callshop_cost . ')' . '<br>' . '(' . $reseller_cost . ')</td>';
                }
            }
        }
        if ($peer == '-1') {
            if ($mycdr['dst'] == $mycdr['src']) {
                //lega
                $addon = ' [lega]';
            } else {
                //legb
                $addon = ' [legb]';
            }
        }
        if ($mycdr['userfield'] == 'UNBILLED') {
            $html .= '<td bgcolor="red">' . $mycdr['userfield'] . $addon . '</td>';
        } else {
            $html .= '<td>' . $mycdr['userfield'] . $addon . '</td>';
        }
        $html .= '<td>' . $mycdr['note'] . '</td></tr>
					<tr bgcolor="gray">
						<td colspan="12" height="1"></td>
					</tr>
				';
        $i++;
    }
    $html .= '<tr>
			<td width="60">
				<input type="checkbox" onclick="ckbAllOnClick(this);" id="ckbAll[]" name="ckbAll[]">' . $locate->Translate("All") . '
			</td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
 			<td></td>
 			<td></td>
 			<td></td>
			<td></td>
			</tr>';
    $html .= '</table>';
    $html .= '</form>';
    $objResponse->addAssign("divUnbilledList", "innerHTML", $html);
    $objResponse->addAssign("spanTotal", "innerHTML", 0);
    $objResponse->addAssign("spanrealTotal", "innerHTML", 0);
    $objResponse->addAssign("spanCallshopCost", "innerHTML", 0);
    $objResponse->addAssign("spanResellerCost", "innerHTML", 0);
    return $objResponse;
}