예제 #1
0
 function createRecordsGrid($customerid = '', $start = 0, $limit = 1, $filter = null, $content = null, $order = null, $divName = "formRecords", $ordering = "", $stype = null)
 {
     global $locate;
     $_SESSION['ordering'] = $ordering;
     if ($filter == null || $content == null || !is_array($content) && $content == 'Array' || !is_array(filter) && $filter == 'Array') {
         $content = null;
         $filter = null;
         $numRows =& astercrm::getRecNumRows($customerid);
         $arreglo =& astercrm::getAllRecRecords($customerid, $start, $limit, $order);
     } else {
         foreach ($content as $value) {
             if (trim($value) != "") {
                 //搜索内容有值
                 $flag = "1";
                 break;
             }
         }
         foreach ($filter as $value) {
             if (trim($value) != "") {
                 //搜索条件有值
                 $flag2 = "1";
                 break;
             }
         }
         foreach ($stype as $value) {
             if (trim($value) != "") {
                 //搜索方式有值
                 $flag3 = "1";
                 break;
             }
         }
         if ($flag != "1" || $flag2 != "1") {
             //无值
             $order = null;
             $numRows =& astercrm::getRecNumRows($customerid);
             $arreglo =& astercrm::getAllRecRecords($customerid, $start, $limit, $order);
         } elseif ($flag3 != 1) {
             //未选择搜索方式
             $order = "mycdr.id";
             $numRows =& astercrm::getRecNumRowsMore($customerid, $filter, $content);
             $arreglo =& astercrm::getRecRecordsFilteredMore($customerid, $start, $limit, $filter, $content, $order);
         } else {
             $order = "mycdr.id";
             $numRows =& astercrm::getRecNumRowsMorewithstype($customerid, $filter, $content, $stype);
             $arreglo =& astercrm::getRecRecordsFilteredMorewithstype($customerid, $start, $limit, $filter, $content, $stype, $order);
         }
     }
     // Databse Table: fields
     $fields = array();
     $fields[] = 'calldate';
     $fields[] = 'src';
     $fields[] = 'dst';
     $fields[] = 'didnumber';
     $fields[] = 'dstchannel';
     $fields[] = 'duration';
     $fields[] = 'billsec';
     $fields[] = 'filename';
     $fields[] = 'creby';
     // HTML table: Headers showed
     $headers = array();
     $headers[] = $locate->Translate("Calldate");
     $headers[] = $locate->Translate("Src");
     $headers[] = $locate->Translate("Dst");
     $headers[] = $locate->Translate("Callee Id");
     $headers[] = $locate->Translate("Agent");
     $headers[] = $locate->Translate("Duration");
     $headers[] = $locate->Translate("Billsec");
     $headers[] = $locate->Translate("filename");
     $headers[] = $locate->Translate("creby");
     // HTML table: hearders attributes
     $attribsHeader = array();
     $attribsHeader[] = 'width="11%"';
     $attribsHeader[] = 'width="11%"';
     $attribsHeader[] = 'width="11%"';
     $attribsHeader[] = 'width="12%"';
     $attribsHeader[] = 'width="11%"';
     $attribsHeader[] = 'width="10%"';
     $attribsHeader[] = 'width="10%"';
     $attribsHeader[] = 'width="12%"';
     $attribsHeader[] = 'width="10%"';
     // HTML Table: columns attributes
     $attribsCols = array();
     $attribsCols[] = 'style="text-align: left"';
     $attribsCols[] = 'style="text-align: left"';
     $attribsCols[] = 'style="text-align: left"';
     $attribsCols[] = 'style="text-align: left"';
     $attribsCols[] = 'style="text-align: left"';
     $attribsCols[] = 'style="text-align: left"';
     $attribsCols[] = 'style="text-align: left"';
     $attribsCols[] = 'style="text-align: left"';
     $attribsCols[] = 'style="text-align: left"';
     // HTML Table: If you want ascendent and descendent ordering, set the Header Events.
     $eventHeader = array();
     $eventHeader[] = 'onClick=\'xajax_showRecords(' . $customerid . ',0,' . $limit . ',"' . $filter . '","' . $content . '","mycdr.calldate","' . $divName . '","ORDERING","' . $stype . '");return false;\'';
     $eventHeader[] = 'onClick=\'xajax_showRecords(' . $customerid . ',0,' . $limit . ',"' . $filter . '","' . $content . '","mycdr.src","' . $divName . '","ORDERING","' . $stype . '");return false;\'';
     $eventHeader[] = 'onClick=\'xajax_showRecords(' . $customerid . ',0,' . $limit . ',"' . $filter . '","' . $content . '","mycdr.dst","' . $divName . '","ORDERING","' . $stype . '");return false;\'';
     $eventHeader[] = 'onClick=\'xajax_showRecords(' . $customerid . ',0,' . $limit . ',"' . $filter . '","' . $content . '","mycdr.didnumber","' . $divName . '","ORDERING","' . $stype . '");return false;\'';
     $eventHeader[] = 'onClick=\'xajax_showRecords(' . $customerid . ',0,' . $limit . ',"' . $filter . '","' . $content . '","mycdr.dstchannel","' . $divName . '","ORDERING");return false;\'';
     $eventHeader[] = 'onClick=\'xajax_showRecords(' . $customerid . ',0,' . $limit . ',"' . $filter . '","' . $content . '","mycdr.duration","' . $divName . '","ORDERING");return false;\'';
     $eventHeader[] = 'onClick=\'xajax_showRecords(' . $customerid . ',0,' . $limit . ',"' . $filter . '","' . $content . '","mycdr.billsec","' . $divName . '","ORDERING","' . $stype . '");return false;\'';
     $eventHeader[] = 'onClick=\'xajax_showRecords(' . $customerid . ',0,' . $limit . ',"' . $filter . '","' . $content . '","monitorrecord.filename","' . $divName . '","ORDERING","' . $stype . '");return false;\'';
     $eventHeader[] = 'onClick=\'xajax_showRecords(' . $customerid . ',0,' . $limit . ',"' . $filter . '","' . $content . '","monitorrecord.creby","' . $divName . '","ORDERING","' . $stype . '");return false;\'';
     // Select Box: type table.
     $typeFromSearch = array();
     $typeFromSearch[] = 'like';
     $typeFromSearch[] = 'equal';
     $typeFromSearch[] = 'more';
     $typeFromSearch[] = 'less';
     // Selecct Box: Labels showed on searchtype select box.
     $typeFromSearchShowAs = array();
     $typeFromSearchShowAs[] = 'like';
     $typeFromSearchShowAs[] = '=';
     $typeFromSearchShowAs[] = '>';
     $typeFromSearchShowAs[] = '<';
     // Select Box: fields table.
     $fieldsFromSearch = array();
     $fieldsFromSearch[] = 'src';
     $fieldsFromSearch[] = 'calldate';
     $fieldsFromSearch[] = 'dst';
     $fieldsFromSearch[] = 'didnumber';
     $fieldsFromSearch[] = 'billsec';
     $fieldsFromSearch[] = 'filename';
     $fieldsFromSearch[] = 'creby';
     // Selecct Box: Labels showed on search select box.
     $fieldsFromSearchShowAs = array();
     $fieldsFromSearchShowAs[] = $locate->Translate("src");
     $fieldsFromSearchShowAs[] = $locate->Translate("calldate");
     $fieldsFromSearchShowAs[] = $locate->Translate("dst");
     $fieldsFromSearchShowAs[] = $locate->Translate("callee id");
     $fieldsFromSearchShowAs[] = $locate->Translate("billsec");
     $fieldsFromSearchShowAs[] = $locate->Translate("filename");
     $fieldsFromSearchShowAs[] = $locate->Translate("creby");
     // Create object whit 5 cols and all data arrays set before.
     $table = new ScrollTable(7, $start, $limit, $filter, $numRows, $content, $order, $customerid, '', '', 'monitorrecord');
     $table->setHeader('title', $headers, $attribsHeader, $eventHeader, $edit = false, $delete = false, $detail = false);
     $table->setAttribsCols($attribsCols);
     $table->addRowSearchMore("cur_mycdrs", $fieldsFromSearch, $fieldsFromSearchShowAs, $filter, $content, $start, $limit, 0, 0, $typeFromSearch, $typeFromSearchShowAs, $stype);
     while ($arreglo->fetchInto($row)) {
         // Change here by the name of fields of its database table
         $rowc = array();
         $rowc[] = $row['id'];
         $rowc[] = $row['calldate'];
         $rowc[] = $row['src'];
         $rowc[] = $row['dst'];
         $rowc[] = $row['didnumber'];
         if (strstr($row['dstchannel'], 'agent')) {
             $agent = split('/', $row['dstchannel']);
             $rowc[] = $agent['1'];
         } else {
             $rowc[] = '';
         }
         $rowc[] = $row['duration'];
         $rowc[] = $row['billsec'];
         if ($row['processed'] == 'yes' && $row['fileformat'] != 'error') {
             $rowc['filename'] = $row['filename'] . '.' . $row['fileformat'];
         } else {
             $rowc['filename'] = '';
         }
         $rowc[] = $row['creby'];
         $table->addRow("monitorrecord", $rowc, false, false, false, $divName, $fields);
     }
     //donnie
     // End Editable Zone
     $html = $table->render();
     return $html;
 }