source: branches/dev/html/admin/products/index_csv.php @ 17

Revision 17, 2.9 KB checked in by uehara, 17 years ago (diff)
Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7require_once(DATA_PATH . "include/csv_output.inc");
8
9$arrREVIEW_CVSCOL = array(
10                        'B.name',
11                        'A.status',
12                        'A.create_date',
13                        'A.reviewer_name',
14                        'A.sex',
15                        'A.recommend_level',
16                        'A.title',
17                        'A.comment'
18                        );
19                       
20$arrREVIEW_CVSTITLE = array(
21                        '¾¦ÉÊ̾',
22                        '¥ì¥Ó¥å¡¼É½¼¨',
23                        'Åê¹ÆÆü',
24                        'Åê¹Æ¼Ô̾',
25                        'À­ÊÌ',
26                        '¤ª¤¹¤¹¤á¥ì¥Ù¥ë',
27                        '¥¿¥¤¥È¥ë',
28                        '¥³¥á¥ó¥È'
29                        );
30
31// CSV½ÐÎϥǡ¼¥¿¤òºîÀ®¤¹¤ë¡£(¾¦ÉÊ)
32function lfGetProductsCSV($where, $option, $arrval, $arrOutputCols) {
33    global $arrPRODUCTS_CVSCOL;
34
35    $from = "vw_product_class AS prdcls";
36    $cols = sfGetCommaList($arrOutputCols);
37   
38    $objQuery = new SC_Query();
39    $objQuery->setoption($option);
40   
41    $list_data = $objQuery->select($cols, $from, $where, $arrval);
42    $max = count($list_data);
43   
44    // µ¬³ÊʬÎà̾°ìÍ÷
45    $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
46   
47    for($i = 0; $i < $max; $i++) {
48        // ´ØÏ¢¾¦ÉʾðÊó¤ÎÉÕÍ¿
49        $list_data[$i]['classcategory_id1'] = $arrClassCatName[$list_data[$i]['classcategory_id1']];
50        $list_data[$i]['classcategory_id2'] = $arrClassCatName[$list_data[$i]['classcategory_id2']];
51       
52        // ³Æ¹àÌܤòCSV½ÐÎÏÍѤËÊÑ´¹¤¹¤ë¡£
53        $data .= lfMakeProductsCSV($list_data[$i]);
54    }
55    return $data;
56}
57
58// CSV½ÐÎϥǡ¼¥¿¤òºîÀ®¤¹¤ë¡£(¥ì¥Ó¥å¡¼)
59function lfGetReviewCSV($where, $option, $arrval) {
60    global $arrREVIEW_CVSCOL;
61
62    $from = "dtb_review AS A INNER JOIN dtb_products AS B on A.product_id = B.product_id ";
63    $cols = sfGetCommaList($arrREVIEW_CVSCOL);
64   
65    $objQuery = new SC_Query();
66    $objQuery->setoption($option);
67   
68    $list_data = $objQuery->select($cols, $from, $where, $arrval); 
69
70    $max = count($list_data);
71    for($i = 0; $i < $max; $i++) {
72        // ³Æ¹àÌܤòCSV½ÐÎÏÍѤËÊÑ´¹¤¹¤ë¡£
73        $data .= lfMakeReviewCSV($list_data[$i]);
74    }
75    return $data;
76}
77
78// ³Æ¹àÌܤòCSV½ÐÎÏÍѤËÊÑ´¹¤¹¤ë¡£(¾¦ÉÊ)
79function lfMakeProductsCSV($list) {
80    global $arrDISP;
81    $line = "";
82    if(is_array($list)) {
83        foreach($list as $key => $val) {
84            $tmp = "";
85            switch($key) {
86            case 'point_rate':
87                if($val == "") {
88                    $tmp = '0';
89                } else {
90                    $tmp = $val;
91                }
92                break;
93            default:
94                $tmp = $val;
95                break;
96            }
97   
98            $tmp = ereg_replace("[\",]", " ", $tmp);
99            $line .= "\"".$tmp."\",";
100        }
101        // ʸËö¤Î","¤òÊÑ´¹
102        $line = ereg_replace(",$", "\n", $line);
103    }
104    return $line;
105}
106
107
108// ³Æ¹àÌܤòCSV½ÐÎÏÍѤËÊÑ´¹¤¹¤ë¡£(¥ì¥Ó¥å¡¼)
109function lfMakeReviewCSV($list) {
110    global $arrSex;
111    global $arrRECOMMEND;
112    global $arrDISP;
113   
114    $line = "";
115   
116    foreach($list as $key => $val) {
117        $tmp = "";
118        switch($key) {
119        case 'sex':
120            $tmp = $arrSex[$val];
121            break;
122        case 'recommend_level':
123            $tmp = $arrRECOMMEND[$val];
124            break;
125        case 'status':
126            $tmp = $arrDISP[$val];
127            break;
128        default:
129            $tmp = $val;
130            break;
131        }
132
133        $tmp = ereg_replace("[\",]", " ", $tmp);
134        $line .= "\"".$tmp."\",";
135    }
136    // ʸËö¤Î","¤òÊÑ´¹
137    $line = ereg_replace(",$", "\n", $line);
138    return $line;
139}
140
141?>
Note: See TracBrowser for help on using the repository browser.