Advertisement
Guest User

Dmitry Popovich

a guest
Dec 15th, 2010
583
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.51 KB | None | 0 0
  1. function reportMonitoring($smarty, $module_name, $local_templates_dir, &$pDB, &$pDBACL, $arrConf, $arrLang)
  2. {
  3.     $pMonitoring = new paloSantoMonitoring($pDB);
  4.     $pACL = new paloACL($pDBACL);
  5.     $filter_field = getParameter("filter_field");
  6.     $filter_value = getParameter("filter_value");
  7.     $action = getParameter("nav");
  8.     $start  = getParameter("start");
  9.     $as_csv = getParameter("exportcsv");
  10.     $date_ini = getParameter("date_start");
  11.     $date_end = getParameter("date_end");
  12.     $path_record = $arrConf['records_dir'];
  13.     $user = isset($_SESSION['elastix_user'])?$_SESSION['elastix_user']:"";
  14.  
  15.        
  16.     $_POST['date_start'] = isset($date_ini)?$date_ini:date("d M Y");
  17.     $_POST['date_end']   = isset($date_end)?$date_end:date("d M Y");
  18.  
  19.     if (!empty($pACL->errMsg)) {
  20.         echo "ERROR DE ACL: $pACL->errMsg <br>";
  21.     }
  22.  
  23.     $extension = $pACL->getUserExtension($user);
  24.     $esMonitoringAdmin = $pACL->isUserMonitoringGroup($user);
  25.     $esAdministrador = $pACL->isUserAdministratorGroup($user);
  26.  
  27.     $esAdministrador = $esMonitoringAdmin || $esAdministrador;
  28.  
  29.     $date_initial = date('Y-m-d',strtotime($_POST['date_start']))." 00:00:00";
  30.     $date_final   = date('Y-m-d',strtotime($_POST['date_end']))." 23:59:59";
  31.  
  32.     $_DATA = $_POST;
  33.     //begin grid parameters
  34.     $oGrid  = new paloSantoGrid($smarty);
  35.     if($esAdministrador)
  36.         $totalMonitoring = $pMonitoring->getNumMonitoring($filter_field, $filter_value, null, $date_initial, $date_final);
  37.     else
  38.         $totalMonitoring = $pMonitoring->getNumMonitoring($filter_field, $filter_value, $extension, $date_initial, $date_final);
  39.  
  40.     $limit  = 20;
  41.     $total  = $totalMonitoring;
  42.     $oGrid->setLimit($limit);
  43.     $oGrid->setTotal($total);
  44.     $oGrid->enableExport();   // enable csv export.
  45.     $oGrid->pagingShow(true); // show paging section.
  46.  
  47.     $oGrid->calculatePagination($action,$start);
  48.     $offset = $oGrid->getOffsetValue();
  49.     $end    = $oGrid->getEnd();
  50.     $url = array(
  51.         'menu'          =>  $module_name,
  52.         'filter_field'  =>  $filter_field,
  53.         'filter_value'  =>  $filter_value,
  54.         'date_start'    =>  $_POST['date_start'],
  55.         'date_end'      =>  $_POST['date_end'],
  56.     );
  57.  
  58.     $arrData = null;
  59.  
  60.     if($esAdministrador)
  61.         $arrResult =$pMonitoring->getMonitoring($limit, $offset, $filter_field, $filter_value, null, $date_initial, $date_final);
  62.     else
  63.         $arrResult =$pMonitoring->getMonitoring($limit, $offset, $filter_field, $filter_value, $extension, $date_initial, $date_final);
  64.  
  65.     if(!$esAdministrador & ($extension=="" || is_null($extension))){
  66.         $smarty->assign("mb_message", "<b>".$arrLang["no_extension"]."</b>");
  67.     }else{
  68.  
  69.         if($extension=="" || is_null($extension))
  70.             $smarty->assign("mb_message", "<b>".$arrLang["no_extension"]."</b>");
  71.  
  72.         if(is_array($arrResult) && $total>0){
  73.             $src = "";
  74.             $dst = "";
  75.             foreach($arrResult as $key => $value){
  76.                 $arrTmp[0] = "<input type='checkbox' name='id_".$value['uniqueid']."' />";
  77.               $arrTmp[1] = date('d M Y',strtotime($value['calldate']));
  78.               $arrTmp[2] = date('H:i:s',strtotime($value['calldate']));
  79.                 if(!isset($value['src']) || $value['src']=="")
  80.                     $src = "<font color='gray'>".$arrLang["unknown"]."</font>";
  81.                 else
  82.                     $src = $value['src'];
  83.                 if(!isset($value['dst']) || $value['dst']=="")
  84.                     $dst = "<font color='gray'>".$arrLang["unknown"]."</font>";
  85.                 else
  86.                     $dst = $value['dst'];
  87.               $arrTmp[3] = $src;
  88.               $arrTmp[4] = $dst;
  89.               $arrTmp[5] = "<label title='".$value['duration']." seconds' style='color:green'>".SecToHHMMSS( $value['duration'] )."</label>";
  90.  
  91.                 //$file = base64_encode($value['userfield']);
  92.                 $file = $value['uniqueid'];
  93.                 $namefile = basename($value['userfield']);
  94.                 $namefile = str_replace("audio:","",$namefile);
  95.                 switch($namefile[0]){
  96.                     case "O":
  97.                         $arrTmp[6] = $arrLang["Outgoing"];
  98.                         break;
  99.                     case "g":
  100.                         $arrTmp[6] = $arrLang["Group"];
  101.                         break;
  102.                     case "q":
  103.                         $arrTmp[6] = $arrLang["Queue"];
  104.                         break;
  105.                     default :
  106.                         $arrTmp[6] = $arrLang["Incoming"];
  107.                         break;
  108.                 }
  109.                 $recordingLink = "<a  href=\"javascript:popUp('index.php?menu=$module_name&action=display_record&id=$file&rawmode=yes',350,100);\">{$arrLang['Listen']}</a>&nbsp;";
  110.  
  111.                 $recordingLink .= "<a href='?menu=$module_name&action=download&id=$file&rawmode=yes' >{$arrLang['Download']}</a>";
  112.  
  113.               $arrTmp[7] = $recordingLink;
  114.                 $arrData[] = $arrTmp;
  115.             }
  116.         }
  117.     }
  118.  
  119.  
  120.     $arrGrid = array("title"    => $arrLang["Monitoring"],
  121.                         "icon"     => "images/record.png",
  122.                         "width"    => "99%",
  123.                         "start"    => ($total==0) ? 0 : $offset + 1,
  124.                         "end"      => $end,
  125.                         "total"    => $total,
  126.                         "url"      => $url,
  127.                         "columns"  => array(
  128.             0 => array("name"      => "<input type='submit' onClick=\"return confirmSubmit('{$arrLang["message_alert"]}');\" name='submit_eliminar' value='{$arrLang["Delete"]}' class='button' />",
  129.                                    "property1" => ""),
  130.       1 => array("name"      => $arrLang["Date"],
  131.                                    "property1" => ""),
  132.       2 => array("name"      => $arrLang["Time"],
  133.                                    "property1" => ""),
  134.       3 => array("name"      => $arrLang["Source"],
  135.                                    "property1" => ""),
  136.       4 => array("name"      => $arrLang["Destination"],
  137.                                    "property1" => ""),
  138.       5 => array("name"      => $arrLang["Duration"],
  139.                                    "property1" => ""),
  140.       6 => array("name"      => $arrLang["Type"],
  141.                                    "property1" => ""),
  142.       7 => array("name"      => $arrLang["Message"],
  143.                                    "property1" => ""),
  144.                                         )
  145.                     );
  146.  
  147.     //begin section filter
  148.     $arrFormFilterMonitoring = createFieldFilter($arrLang);
  149.     $oFilterForm = new paloForm($smarty, $arrFormFilterMonitoring);
  150.     $smarty->assign("SHOW", $arrLang["Show"]);
  151.     if($esAdministrador)
  152.   $smarty->assign("user", "admin");
  153.     else
  154.         $smarty->assign("user", $user);
  155.    
  156.     $htmlFilter = $oFilterForm->fetchForm("$local_templates_dir/filter.tpl","",$_POST);
  157.     //end section filter
  158.  
  159.     if($as_csv == 'yes'){
  160.         $name_csv = "Monitoring_".date("d-M-Y").".csv";
  161.         header("Cache-Control: private");
  162.         header("Pragma: cache");
  163.         header("Content-Type: application/octec-stream");
  164.         header("Content-disposition: inline; filename={$name_csv}");
  165.         header("Content-Type: application/force-download");
  166.         $content = $oGrid->fetchGridCSV($arrGrid, $arrData);
  167.     }
  168.     else{
  169.         $oGrid->showFilter(trim($htmlFilter));
  170.         $content = $oGrid->fetchGrid($arrGrid, $arrData,$arrLang);
  171.     }
  172.     //end grid parameters
  173.  
  174.     return $content;
  175. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement