function fmt_gravacao($params, $smarty) { $calldate = $params['a']; $userfield = $params['b']; $caminho = Snep_Manutencao::arquivoExiste($calldate, $userfield); if ($caminho) { $smarty->assign('voz', $caminho); } else { $smarty->assign('voz', 'N.D.'); } }
public function reportAction() { $db = Zend_Registry::get('db'); $config = Zend_Registry::get('config'); $format = new Formata(); // View labels $this->view->seq = $this->view->translate("SEQ"); $this->view->calldate = $this->view->translate("Call's date"); $this->view->origin = $this->view->translate("Source"); $this->view->destination = $this->view->translate("Destination"); $this->view->callstatus = $this->view->translate("Status"); $this->view->duration = $this->view->translate("Duration"); $this->view->conversation = $this->view->translate("Conversation"); $this->view->cost_center = $this->view->translate("Cost Center"); $this->view->city = $this->view->translate("City"); $this->view->state = $this->view->translate("State"); $this->view->filter = $this->view->translate("Filter"); $this->view->calls = $this->view->translate("Calls"); $this->view->totals_sub = $this->view->translate("Totals"); $this->view->times = $this->view->translate("Times"); $this->view->tot_tariffed = $this->view->translate("Total tariffed"); $this->view->answered = $this->view->translate("Answered"); $this->view->nanswered = $this->view->translate("Not Answered"); $this->view->busy = $this->view->translate("Busy"); $this->view->failure = $this->view->translate("Failed"); $this->view->other = $this->view->translate("Other"); $this->view->tarrifation = $this->view->translate("Charging"); $this->view->wait = $this->view->translate("Waiting"); $this->view->sub_total = $this->view->translate("Subtotal"); $this->view->gravation = $this->view->translate("Records"); $this->view->back = $this->view->translate("Back"); $defaultNS = new Zend_Session_Namespace('call_sql'); $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Reports"), $this->view->translate("Calls"), $defaultNS->sub_title)); $this->view->totals = $defaultNS->totais; $this->view->tariffed = $defaultNS->view_tarif; $this->view->files = $defaultNS->view_files; $this->view->status = $defaultNS->status; $this->view->compress_files = $this->view->translate("Compress selected files"); $this->view->duration_call = $format->fmt_segundos(array("a" => $defaultNS->totais['duration'], "b" => 'hms')); $this->view->bill_sec = $format->fmt_segundos(array("a" => $defaultNS->totais['billsec'], "b" => 'hms')); $this->view->wait_call = $format->fmt_segundos(array("a" => $defaultNS->totais['espera'], "b" => 'hms')); $row = $defaultNS->row; if ($defaultNS->report_type == 'synth') { // Cost center treatment $cc = $defaultNS->contas; if ($cc != '') { $valores = ''; $sqlcc = "select nome from ccustos where codigo IN (" . $cc . ")"; $ccs = $db->query($sqlcc)->fetchAll(PDO::FETCH_ASSOC); $ccusto_sintetic = ''; foreach ($ccs as $id => $value) { $ccusto_sintetic .= $ccs[$id]['nome'] . ", "; } } else { $ccusto_sintetic = $this->view->translate("Any"); } $this->view->cost_center_res = $ccusto_sintetic; // Groups treatment $sint_destino = $defaultNS->dst; $sint_groupdst = $defaultNS->groupdst; if ($sint_destino != '' && $sint_groupdst == '') { $sint_dest = $sint_destino; } if ($sint_groupdst != '' && $sint_destino == '') { $sqldst = "select name from peers where peers.group = '{$sint_groupdst}' "; $sint_dst = $db->query($sqldst)->fetchAll(PDO::FETCH_ASSOC); $sint_dest = ''; foreach ($sint_dst as $id => $value) { $sint_dest .= $sint_dst[$id]['name'] . ", "; } } if (!empty($sint_dest)) { $this->view->sinteticdst = $sint_dest; } $sint_origem = $defaultNS->src; $sint_groupsrc = $defaultNS->groupsrc; if ($sint_origem != '' && $sint_groupsrc == '') { $src_sintetic = trim($sint_origem); } if ($sint_groupsrc != '' && $sint_origem == '') { $sqlsrc = "select name from peers where peers.group = '{$sint_groupsrc}' "; $sint_src = $db->query($sqlsrc)->fetchAll(PDO::FETCH_ASSOC); $src_sintetic = ''; foreach ($sint_src as $id => $value) { $src_sintetic .= $sint_src[$id]['name'] . ", "; } } if (!empty($sint_dest)) { $this->view->sinteticsrc = $src_sintetic; } $this->renderScript('calls-report/synthetic-report.phtml'); } else { // Analytical Report $paginatorAdapter = new Zend_Paginator_Adapter_Array($row); $paginator = new Zend_Paginator($paginatorAdapter); $paginator->setCurrentPageNumber($this->_request->page); $paginator->setItemCountPerPage(Zend_Registry::get('config')->ambiente->linelimit); $items = $paginator->getCurrentItems(); $this->view->pages = $paginator->getPages(); $this->view->PAGE_URL = "/snep/index.php/calls-report/report/"; $listItems = array(); foreach ($items as $item) { // Status switch ($item['disposition']) { case 'ANSWERED': $item['disposition'] = $this->view->translate('Answered'); break; case 'NO ANSWER': $item['disposition'] = $this->view->translate('Not Answered'); break; case 'FAILED': $item['disposition'] = $this->view->translate('Failed'); break; case 'BUSY': $item['disposition'] = $this->view->translate('Busy'); break; case 'OTHER': $item['disposition'] = $this->view->translate('Others'); break; } // Search for a city or format the telephone type if (strlen($item['src']) > 7 && strlen($item['dst']) < 5) { $item['city'] = $this->telType($item['src']); } else { $item['city'] = $this->telType($item['dst']); } $item['nome'] = $item['tipo'] . " : " . $item['codigo'] . " - " . $item['nome']; if ($defaultNS->view_tarif) { $item['rate'] = $format->fmt_tarifa(array("a" => $item['dst'], "b" => $item['billsec'], "c" => $item['accountcode'], "d" => $item['calldate'], "e" => $item['tipo'])); } $item['src'] = $format->fmt_telefone(array("a" => $item['src'])); $item['dst'] = $format->fmt_telefone(array("a" => $item['dst'])); // Tarrifation $item['billsec'] = $format->fmt_segundos(array("a" => $item['billsec'], "b" => 'hms')); $item['duration'] = $format->fmt_segundos(array("a" => $item['duration'], "b" => 'hms')); if ($defaultNS->view_files) { $filePath = Snep_Manutencao::arquivoExiste($item['calldate'], $item['userfield']); $item['file_name'] = $item['userfield'] . ".wav"; if ($filePath) { $item['file_path'] = $filePath; } else { $item['file_path'] = 'N.D.'; } } array_push($listItems, $item); } $this->view->call_list = $listItems; $this->view->compact_success = $this->view->translate("The files were compressed successfully! Wait for the download start."); $this->renderScript('calls-report/analytical-report.phtml'); } return; }