1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
6 | * |
---|
7 | * http://www.lockon.co.jp/ |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License |
---|
11 | * as published by the Free Software Foundation; either version 2 |
---|
12 | * of the License, or (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | // {{{ requires |
---|
25 | require_once(CLASS_FILE_PATH . "pages/admin/LC_Page_Admin.php"); |
---|
26 | require_once(CLASS_EX_FILE_PATH . "helper_extends/SC_Helper_CSV_Ex.php"); |
---|
27 | |
---|
28 | /** |
---|
29 | * CSV項目設定 のページクラス. |
---|
30 | * |
---|
31 | * @package Page |
---|
32 | * @author LOCKON CO.,LTD. |
---|
33 | * @version $Id$ |
---|
34 | */ |
---|
35 | class LC_Page_Admin_Contents_CSV extends LC_Page_Admin { |
---|
36 | |
---|
37 | // }}} |
---|
38 | // {{{ functions |
---|
39 | |
---|
40 | /** |
---|
41 | * Page を初期化する. |
---|
42 | * |
---|
43 | * @return void |
---|
44 | */ |
---|
45 | function init() { |
---|
46 | parent::init(); |
---|
47 | $this->tpl_mainpage = 'contents/csv.tpl'; |
---|
48 | $this->tpl_subnavi = 'contents/subnavi.tpl'; |
---|
49 | $this->tpl_subno = 'csv'; |
---|
50 | |
---|
51 | $this->tpl_mainno = "contents"; |
---|
52 | $this->tpl_subtitle = 'CSV出力設定'; |
---|
53 | } |
---|
54 | |
---|
55 | /** |
---|
56 | * Page のプロセス. |
---|
57 | * |
---|
58 | * @return void |
---|
59 | */ |
---|
60 | function process() { |
---|
61 | $this->action(); |
---|
62 | $this->sendResponse(); |
---|
63 | } |
---|
64 | |
---|
65 | /** |
---|
66 | * Page のアクション. |
---|
67 | * |
---|
68 | * @return void |
---|
69 | */ |
---|
70 | function action() { |
---|
71 | $objSess = new SC_Session(); |
---|
72 | $objCSV = new SC_Helper_CSV_Ex(); |
---|
73 | |
---|
74 | $this->arrSubnavi = $objCSV->arrSubnavi; |
---|
75 | $this->tpl_subno_csv = $objCSV->arrSubnavi[1]; |
---|
76 | $this->arrSubnaviName = $objCSV->arrSubnaviName; |
---|
77 | |
---|
78 | // 認証可否の判定 |
---|
79 | $objSess = new SC_Session(); |
---|
80 | SC_Utils_Ex::sfIsSuccess($objSess); |
---|
81 | |
---|
82 | $get_tpl_subno_csv = isset($_GET['tpl_subno_csv']) |
---|
83 | ? $_GET['tpl_subno_csv'] : ""; |
---|
84 | |
---|
85 | // GETで値が送られている場合にはその値を元に画面表示を切り替える |
---|
86 | if ($get_tpl_subno_csv != ""){ |
---|
87 | // 送られてきた値が配列に登録されていなければTOPを表示 |
---|
88 | if (in_array($get_tpl_subno_csv,$this->arrSubnavi)){ |
---|
89 | $subno_csv = $get_tpl_subno_csv; |
---|
90 | }else{ |
---|
91 | $subno_csv = $this->arrSubnavi[1]; |
---|
92 | } |
---|
93 | } else { |
---|
94 | // GETで値がなければPOSTの値を使用する |
---|
95 | if (isset($_POST['tpl_subno_csv']) |
---|
96 | && $_POST['tpl_subno_csv'] != "") { |
---|
97 | |
---|
98 | $subno_csv = $_POST['tpl_subno_csv']; |
---|
99 | }else{ |
---|
100 | $subno_csv = $this->arrSubnavi[1]; |
---|
101 | } |
---|
102 | } |
---|
103 | |
---|
104 | // subnoの番号を取得 |
---|
105 | $subno_id = array_keys($this->arrSubnavi,$subno_csv); |
---|
106 | $subno_id = $subno_id[0]; |
---|
107 | // データの登録 |
---|
108 | |
---|
109 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
110 | |
---|
111 | if ($_POST["mode"] == "confirm") { |
---|
112 | |
---|
113 | // エラーチェック |
---|
114 | $this->arrErr = $this->lfCheckError($_POST['output_list']); |
---|
115 | |
---|
116 | if (count($this->arrErr) <= 0){ |
---|
117 | // データの更新 |
---|
118 | $this->lfUpdCsvOutput($subno_id, $_POST['output_list']); |
---|
119 | |
---|
120 | // 画面のリロード |
---|
121 | $this->objDisplay->reload(array("tpl_subno_csv" => $subno_csv)); |
---|
122 | } |
---|
123 | } |
---|
124 | |
---|
125 | // 出力項目の取得 |
---|
126 | $arrSelected = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput($subno_id, 'status = 1')); |
---|
127 | |
---|
128 | if (!isset($arrSelected['no'])) $arrSelected['no'] = array(); |
---|
129 | |
---|
130 | $this->arrSelected = $arrSelected['no']; |
---|
131 | |
---|
132 | // 全項目の取得 |
---|
133 | $arrOptions = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput($subno_id)); |
---|
134 | |
---|
135 | if (!isset($arrOptions['no'])) $arrOptions['no'] = array(); |
---|
136 | if (!isset($arrOptions['disp_name'])) $arrOptions['disp_name'] = array(); |
---|
137 | |
---|
138 | $arrOptions = SC_Utils_Ex::sfarrCombine($arrOptions['no'], $arrOptions['disp_name']); |
---|
139 | |
---|
140 | $this->arrOptions = $arrOptions; |
---|
141 | |
---|
142 | $this->SubnaviName = $this->arrSubnaviName[$subno_id]; |
---|
143 | $this->tpl_subno_csv = $subno_csv; |
---|
144 | } |
---|
145 | |
---|
146 | /** |
---|
147 | * デストラクタ. |
---|
148 | * |
---|
149 | * @return void |
---|
150 | */ |
---|
151 | function destroy() { |
---|
152 | parent::destroy(); |
---|
153 | } |
---|
154 | |
---|
155 | function lfUpdCsvOutput($csv_id, $arrData = array()){ |
---|
156 | $objQuery = new SC_Query(); |
---|
157 | |
---|
158 | // ひとまず、全部使用しないで更新する |
---|
159 | $upd_sql = "UPDATE dtb_csv SET status = 2, rank = NULL, update_date = now() WHERE csv_id = ?"; |
---|
160 | $objQuery->query($upd_sql, array($csv_id)); |
---|
161 | |
---|
162 | // 使用するものだけ、再更新する。 |
---|
163 | if (is_array($arrData)) { |
---|
164 | foreach($arrData as $key => $val){ |
---|
165 | $upd_sql = "UPDATE dtb_csv SET status = 1, rank = ? WHERE csv_id = ? AND no = ? "; |
---|
166 | $objQuery->query($upd_sql, array($key+1, $csv_id, $val)); |
---|
167 | } |
---|
168 | } |
---|
169 | } |
---|
170 | |
---|
171 | Function Lfcheckerror($data){ |
---|
172 | $objErr = new SC_CheckError(); |
---|
173 | $objErr->doFunc( array("出力項目", "output_list"), array("EXIST_CHECK") ); |
---|
174 | |
---|
175 | return $objErr->arrErr; |
---|
176 | |
---|
177 | } |
---|
178 | } |
---|
179 | ?> |
---|