当前位置: 首页>>代码示例>>PHP>>正文


PHP astercrm::exportDataToCSV方法代码示例

本文整理汇总了PHP中astercrm::exportDataToCSV方法的典型用法代码示例。如果您正苦于以下问题:PHP astercrm::exportDataToCSV方法的具体用法?PHP astercrm::exportDataToCSV怎么用?PHP astercrm::exportDataToCSV使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在astercrm的用法示例。


在下文中一共展示了astercrm::exportDataToCSV方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: and

                $sql .= " and (groupid = " . $_SESSION['curuser']['groupid'] . " OR (groupid = 0 AND (resellerid='" . $_SESSION['curuser']['resellerid'] . "' OR resellerid=0)))";
            } else {
                $sql .= " where (groupid = " . $_SESSION['curuser']['groupid'] . " OR (groupid = 0 AND (resellerid='" . $_SESSION['curuser']['resellerid'] . "' OR resellerid=0)))";
            }
        } else {
            if (strpos(strtolower($sql), 'where')) {
                $sql .= " and groupid = " . $_SESSION['curuser']['groupid'];
            } else {
                $sql .= " where groupid = " . $_SESSION['curuser']['groupid'];
            }
        }
    } elseif ($_SESSION['curuser']['usertype'] == 'reseller') {
        if (strpos(strtolower($sql), 'where')) {
            $sql .= " and resellerid = " . $_SESSION['curuser']['resellerid'];
        } else {
            $sql .= " where resellerid = " . $_SESSION['curuser']['resellerid'];
        }
    }
}
if (!function_exists('mb_convert_encoding')) {
    echo "Please install php-mbstring!";
    exit;
}
ob_start();
header("charset=uft-8");
header('Content-type:  application/force-download');
header('Content-Transfer-Encoding:  Binary');
header('Content-disposition:  attachment; filename=astercc.csv');
echo astercrm::exportDataToCSV($sql);
ob_end_flush();
unset($_SESSION['export_sql']);
开发者ID:ljhcj,项目名称:IRISCC,代码行数:31,代码来源:dataexport.php

示例2: archiveCDR

function archiveCDR($archiveDate)
{
    global $db, $locate, $config;
    $objResponse = new xajaxResponse();
    $date = date("Y-m-d");
    $end_date = date("Y-m-d", strtotime("{$date} - {$archiveDate} month"));
    if ($config['system']['useHistoryCdr'] == 1) {
        $table = 'historycdr';
    } else {
        $table = 'mycdr';
    }
    $sql = "SELECT calldate FROM {$table} WHERE calldate < '" . $end_date . "' ORDER BY calldate ASC LIMIT 1";
    $start_date = $db->getOne($sql);
    if ($start_date == '') {
        $objResponse->addAlert($locate->Translate('no cdr data early than') . " " . $archiveDate . " " . $locate->Translate('months'));
        $objResponse->addAssign("divMsg", "style.visibility", "hidden");
        $objResponse->addClear("msgZone", "innerHTML");
        return $objResponse->getXML();
    }
    $file_dir = $config['system']['upload_file_path'] . "cdr_archive";
    if (!is_dir($file_dir)) {
        if (!mkdir($file_dir)) {
            $objResponse->addAlert($locate->Translate('cant create archive directory'));
            $objResponse->addAssign("divMsg", "style.visibility", "hidden");
            $objResponse->addClear("msgZone", "innerHTML");
            return $objResponse->getXML();
        }
    }
    $start_date = split('\\ ', $start_date);
    $start_date = $start_date['0'];
    $file_name = $start_date . "_to_" . $end_date;
    if (!($handle = fopen($file_dir . "/" . $file_name . ".csv", 'x'))) {
        $objResponse->addAlert($locate->Translate('cant create archive file'));
        $objResponse->addAssign("divMsg", "style.visibility", "hidden");
        $objResponse->addClear("msgZone", "innerHTML");
        return $objResponse->getXML();
    }
    $sql = "SELECT * FROM {$table} WHERE calldate < '" . $end_date . "' ORDER BY calldate ASC";
    $archiveData = astercrm::exportDataToCSV($sql);
    if (!fwrite($handle, $archiveData)) {
        $objResponse->addAlert($locate->Translate('cant create archive file'));
        $objResponse->addAssign("divMsg", "style.visibility", "hidden");
        $objResponse->addClear("msgZone", "innerHTML");
        return $objResponse->getXML();
    }
    fclose($handle);
    system("tar zcf " . $file_dir . "/" . $file_name . ".tar.gz " . $file_dir . "/" . $file_name . ".csv", $r);
    if ($r === false) {
        $final_file = $file_dir . "/" . $file_name . ".csv";
    } else {
        $final_file = $file_dir . "/" . $file_name . ".tar.gz";
        unlink($file_dir . "/" . $file_name . ".csv");
    }
    $objResponse->addAlert($locate->Translate('archive success') . ", " . $locate->Translate('file save in') . ": " . $final_file);
    $sql = "DELETE FROM {$table} WHERE calldate < '" . $end_date . "'";
    $res = $db->query($sql);
    if ($res == 1) {
        $objResponse->addAlert($locate->Translate('clear cdr date success'));
    } else {
        $objResponse->addAlert($locate->Translate('clear cdr date failed'));
    }
    $html = createGrid(0, ROWSXPAGE);
    $objResponse->addAssign("divMsg", "style.visibility", "hidden");
    $objResponse->addClear("msgZone", "innerHTML");
    $objResponse->addAssign("grid", "innerHTML", $html);
    return $objResponse->getXML();
    //echo $file_name;exit;
}
开发者ID:ljhcj,项目名称:IRISCC,代码行数:68,代码来源:cdr.server.php

示例3: ob_start

    if (strpos(strtolower($sql), 'where')) {
        if ($table != '') {
            //判断是否传了主表名
            $sql .= " and {$table}.groupid = " . $_SESSION['curuser']['groupid'];
            $filename = $table;
        } else {
            $sql .= " and groupid = " . $_SESSION['curuser']['groupid'];
        }
    } else {
        if ($table != '') {
            //判断是否传了主表名
            $sql .= " where {$table}.groupid = " . $_SESSION['curuser']['groupid'];
            $filename = $table;
        } else {
            $sql .= " where groupid = " . $_SESSION['curuser']['groupid'];
        }
    }
}
if ($table != '') {
    //判断是否传了主表名
    $filename = $table . '.csv';
}
//echo $sql;exit;
ob_start();
header("charset=uft-8");
header('Content-type:  application/force-download');
header('Content-Transfer-Encoding:  Binary');
header('Content-disposition:  attachment; filename=' . $filename);
echo astercrm::exportDataToCSV($sql, $table);
ob_end_flush();
unset($_SESSION['export_sql']);
开发者ID:ljhcj,项目名称:IRISCC,代码行数:31,代码来源:dataexport1.php


注:本文中的astercrm::exportDataToCSV方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。