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


PHP CSV::addRow方法代码示例

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


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

示例1: exportCSV

function exportCSV($artistid)
{
    global $tableprefix;
    $adminCurrency = GetAdminCurrency();
    $currencycode = getSellerCurrencySybol($artistid);
    $currencySymbol = getCurrencySybol($currencycode);
    $csv = new CSV(array('Order #', 'Order Total', 'Commission (%)', 'Total Tax Amount', 'Total Shipping Amount', 'Product Total Amount', 'Amount Received [ Product Total Amount - Admin Commision  + Product Shipping + Tax ]', 'Date Paid(mm/dd/yyyy)', 'Payment Status'), ";");
    $qryopt = "";
    $qrybtw = "";
    $sql = " SELECT sp.*,s.artist_name FROM " . $tableprefix . "artist_payments sp\n\t\tINNER JOIN  " . $tableprefix . "artists s ON sp.artist_id = s.artist_id\n                INNER JOIN  " . $tableprefix . "orders o ON o.order_id = sp.order_id" . $qryopt . "\n\t\tWHERE sp.artist_id = '" . addslashes($artistid) . "' AND o.vpayment_status='C'" . $qrybtw . "order by sp.artist_payment_id DESC   ";
    $rs = mysql_query($sql) or die("qqqq" . mysql_error());
    $result = mysql_query($sql) or die("www" . mysql_error());
    if (mysql_num_rows($result) > 0) {
        $i = 1;
        $total = 0;
        while ($row = mysql_fetch_array($rs)) {
            $txtPaymentDate = isNotNull($row["payment_date"] and $row["payment_date"] != "0000-00-00") ? dateFormat($row["payment_date"], "Y-m-d", "m/d/Y") : " Not Yet Settled;";
            if ($row['payment_status'] == 'P') {
                $Paymentstatus = 'Pending';
            } else {
                $Paymentstatus = 'Paid';
            }
            $qryopt1 = " ";
            $taxtotal = 0;
            $sql1 = "SELECT o.*, u.user_name, u.email, od.product_discount,sum( (od.product_price-(od.product_price*product_discount/100)) * od.product_quantity) as total,sum(od.product_tax)as taxtotal\n\t\tFROM " . $tableprefix . "orders o\n\t\tINNER JOIN " . $tableprefix . "users u ON o.user_id = u.user_id\n\t\tINNER JOIN " . $tableprefix . "order_details od ON o.order_id = od.order_id\n\t\tWHERE od.artist_id = '" . $artistid . "'\n                AND o.order_id = " . $row['order_id'] . "\n\t\tAND o.vpayment_status != 'P'" . $qryopt1 . " GROUP BY o.order_id ORDER BY o.order_date,o.order_id DESC ";
            $sellerCurrency = getSellerCurrencySybol($artistid);
            $result1 = mysql_query($sql1);
            if (mysql_num_rows($result1) != 0) {
                $row1 = mysql_fetch_array($result1);
                $ordernumber = $row1["order_id"];
                $username = $row1["user_name"];
                if ($row1['vorder_currency'] != $sellerCurrency and $row1['vorder_currency'] != "USD") {
                    $get_conversion_price = getCurrencyrate($sellerCurrency);
                    $ordertotal = $row1["total"];
                } else {
                    $ordertotal = $row1["total"];
                }
                $taxtotal = $row1["taxtotal"];
            }
            $select_shipping_cost = "SELECT sd.vshipping_name, sd.nshipping_cost,od.product_name\n                           FROM " . $tableprefix . "shipping_details sd," . $tableprefix . "order_details  od\n                          WHERE od.product_id=sd.nshp_productid\n                            AND norder_id = " . $row['order_id'] . "\n                            AND nshp_status = 'C'\n                            AND od.artist_id = '" . $artistid . "'\n                       GROUP BY sd.nshp_productid order by  od.product_name";
            $result_shipping_cost = mysql_query($select_shipping_cost);
            if (mysql_num_rows($result_shipping_cost) > 0) {
                $totalshippingcost = 0;
                while ($shipping_row = mysql_fetch_array($result_shipping_cost)) {
                    $totalshippingcost += $shipping_row['nshipping_cost'];
                }
            }
            $csv->addRow(array($row["order_id"], html_entity_decode($adminCurrency['currency_symbol']) . " " . number_format($row["seller_order_total_amount"], 2, '.', ''), $row["commission_percentage"], html_entity_decode($adminCurrency['currency_symbol']) . " " . number_format($taxtotal, 2, '.', ''), html_entity_decode($adminCurrency['currency_symbol']) . " " . number_format($totalshippingcost, 2, '.', ''), html_entity_decode($adminCurrency['currency_symbol']) . " " . number_format($row["total_amount"], 2, '.', ''), html_entity_decode($adminCurrency['currency_symbol']) . " " . number_format($row["amount_paid"], 2, '.', ''), $txtPaymentDate, $Paymentstatus));
            $artistName = $row["artist_name"];
            $i++;
            $total += $row["amount_paid"];
        }
        if ($total > 0) {
            $csv->addRow(array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '));
            $csv->addRow(array(' ', ' ', ' ', ' ', ' ', ' ', 'Total Seller Amount Received', html_entity_decode($currencySymbol) . " " . number_format($total, 2, '.', ''), ' '));
        }
    }
    // export csv as a download
    $filename = 'order_payment_details_' . $artistName;
    //$filename = 'order_payment_details'.$artistid;
    $csv->export($filename);
    // *or* pass the csv data to a variable as a string
    //$string = $csv;
}
开发者ID:kevinsmasters,项目名称:purecatskillsmarketplace,代码行数:64,代码来源:functions.php


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