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_PATH . "pages/LC_Page.php"); |
---|
26 | |
---|
27 | /** |
---|
28 | * 商品登録(商品規格)のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class LC_Page_Admin_Products_ProductClass extends LC_Page { |
---|
35 | |
---|
36 | // }}} |
---|
37 | // {{{ functions |
---|
38 | /** ダウンロード用ファイル管理クラスのインスタンス */ |
---|
39 | var $objDownFile; |
---|
40 | |
---|
41 | /** hidden 項目の配列 */ |
---|
42 | var $arrHidden; |
---|
43 | |
---|
44 | /** |
---|
45 | * Page を初期化する. |
---|
46 | * |
---|
47 | * @return void |
---|
48 | */ |
---|
49 | function init() { |
---|
50 | parent::init(); |
---|
51 | $this->tpl_mainpage = 'products/product_class.tpl'; |
---|
52 | $this->tpl_subnavi = 'products/subnavi.tpl'; |
---|
53 | $this->tpl_mainno = 'products'; |
---|
54 | $this->tpl_subno = 'product'; |
---|
55 | $this->tpl_subtitle = '商品登録(商品規格)'; |
---|
56 | $masterData = new SC_DB_MasterData_Ex(); |
---|
57 | $this->arrDown = $masterData->getMasterData("mtb_down"); |
---|
58 | } |
---|
59 | |
---|
60 | function lfInitDownFile() { |
---|
61 | $i = 1; |
---|
62 | while (isset($_POST['classcategory_id1:' . $i])) { |
---|
63 | //ファイル系処理 |
---|
64 | $this->objDownFile->addFile("ダウンロード販売用ファイル". ":" . $i, 'down_realfilename'. ":" . $i, explode(",", DOWNLOAD_EXTENSION),DOWN_SIZE, true, 0, 0); |
---|
65 | $i++; |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | function process() { |
---|
70 | $this->authorization(); |
---|
71 | |
---|
72 | $this->arrSearchHidden = $this->createSearchParams($_POST); |
---|
73 | |
---|
74 | // FORMデータの引き継ぎ |
---|
75 | $this->arrForm = $_POST; |
---|
76 | |
---|
77 | $this->tpl_product_id = |
---|
78 | isset($_POST['product_id']) ? $_POST['product_id'] : "" ; |
---|
79 | $this->tpl_pageno = isset($_POST['pageno']) ? $_POST['pageno'] : ""; |
---|
80 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
81 | |
---|
82 | // Downファイル管理クラス |
---|
83 | $this->objDownFile = new SC_UploadFile(DOWN_TEMP_DIR, DOWN_SAVE_DIR); |
---|
84 | |
---|
85 | switch ($_POST['mode']) { |
---|
86 | case 'edit': |
---|
87 | // 入力値の変換 |
---|
88 | $this->arrForm = $this->lfConvertParam($_POST); |
---|
89 | // エラーチェック |
---|
90 | $this->arrErr = $this->lfProductClassError($this->arrForm); |
---|
91 | if ($this->arrErr == null){ |
---|
92 | //if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
93 | $this->tpl_mainpage = 'products/product_class_confirm.tpl'; |
---|
94 | $this->lfProductConfirmPage(); // 確認ページ表示 |
---|
95 | } else { |
---|
96 | $this->doPreEdit(false,true); |
---|
97 | // Hiddenからのデータを引き継ぐ |
---|
98 | $this->objDownFile->setHiddenFileList($_POST); |
---|
99 | // HIDDEN用に配列を渡す。 |
---|
100 | $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objDownFile->getHiddenFileList()); |
---|
101 | // Form用に配列を渡す。 |
---|
102 | $this->arrForm = array_merge((array)$this->arrForm, (array)$this->objDownFile->getFormKikakuDownFile()); |
---|
103 | } |
---|
104 | break; |
---|
105 | |
---|
106 | case 'delete': |
---|
107 | $this->doDelete(); |
---|
108 | break; |
---|
109 | |
---|
110 | case 'pre_edit': |
---|
111 | $this->doPreEdit(); |
---|
112 | // HIDDEN用に配列を渡す。 |
---|
113 | $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objDownFile->getHiddenFileList()); |
---|
114 | break; |
---|
115 | |
---|
116 | case 'disp': |
---|
117 | $this->doDisp(); |
---|
118 | break; |
---|
119 | // ダウンロード商品ファイルアップロード |
---|
120 | case 'upload_down': |
---|
121 | $this->doPreEdit(); |
---|
122 | // Hiddenからのデータを引き継ぐ |
---|
123 | $this->objDownFile->setHiddenKikakuFileList($_POST); |
---|
124 | // ファイル存在チェック |
---|
125 | $this->arrErr = array_merge((array)$this->arrErr, (array)$this->objDownFile->checkEXISTS($_POST['down_key'])); |
---|
126 | // ファイル保存処理 |
---|
127 | $this->arrErr[$_POST['down_key']] = $this->objDownFile->makeTempDownFile($_POST['down_key']); |
---|
128 | // HIDDEN用に配列を渡す。 |
---|
129 | $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objDownFile->getHiddenFileList()); |
---|
130 | // Form用に配列を渡す。 |
---|
131 | $this->arrForm = array_merge((array)$this->arrForm, (array)$this->objDownFile->getFormKikakuDownFile()); |
---|
132 | break; |
---|
133 | // ダウンロードファイルの削除 |
---|
134 | case 'delete_down': |
---|
135 | $this->doPreEdit(); |
---|
136 | // Hiddenからのデータを引き継ぐ |
---|
137 | $this->objDownFile->setHiddenKikakuFileList($_POST); |
---|
138 | // ファイル削除処理 |
---|
139 | $this->objDownFile->deleteKikakuFile($_POST['down_key']); |
---|
140 | // HIDDEN用に配列を渡す。 |
---|
141 | $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objDownFile->getHiddenFileList()); |
---|
142 | // Form用に配列を渡す。 |
---|
143 | $this->arrForm = array_merge((array)$this->arrForm, (array)$this->objDownFile->getFormKikakuDownFile()); |
---|
144 | break; |
---|
145 | case 'confirm_return': |
---|
146 | // フォームパラメータの引き継ぎ |
---|
147 | $this->arrForm = $_POST; |
---|
148 | // 規格の選択情報は引き継がない。 |
---|
149 | $this->arrForm['select_class_id1'] = ""; |
---|
150 | $this->arrForm['select_class_id2'] = ""; |
---|
151 | $this->doPreEdit(false,true); |
---|
152 | // Hiddenからのデータを引き継ぐ |
---|
153 | $this->objDownFile->setHiddenFileList($_POST); |
---|
154 | // HIDDEN用に配列を渡す。 |
---|
155 | $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objDownFile->getHiddenFileList()); |
---|
156 | // Form用に配列を渡す。 |
---|
157 | $this->arrForm = array_merge((array)$this->arrForm, (array)$this->objDownFile->getFormKikakuDownFile()); |
---|
158 | break; |
---|
159 | case 'complete': |
---|
160 | // 完了ページ設定 |
---|
161 | $this->tpl_mainpage = 'products/product_class_complete.tpl'; |
---|
162 | // ファイル情報の初期化 |
---|
163 | $this->lfInitDownFile(); |
---|
164 | // Hiddenからのデータを引き継ぐ |
---|
165 | $this->objDownFile->setHiddenFileList($_POST); |
---|
166 | // 商品規格の登録 |
---|
167 | $this->registerProductClass($_POST, $_POST['product_id']); |
---|
168 | // 一時ファイルを本番ディレクトリに移動する |
---|
169 | $this->objDownFile->moveTempDownFile(); |
---|
170 | break; |
---|
171 | |
---|
172 | default: |
---|
173 | } |
---|
174 | $this->arrClass = $this->getAllClass(); |
---|
175 | $this->arrForm['product_name'] = $this->getProductName($_POST['product_id']); |
---|
176 | $this->assignView(); |
---|
177 | } |
---|
178 | |
---|
179 | /** |
---|
180 | * デストラクタ. |
---|
181 | * |
---|
182 | * @return void |
---|
183 | */ |
---|
184 | function destroy() { |
---|
185 | parent::destroy(); |
---|
186 | } |
---|
187 | |
---|
188 | /** |
---|
189 | * 規格の登録または更新を行う. |
---|
190 | * |
---|
191 | * TODO dtb_class_combination は, dtb_product_categories に倣って, |
---|
192 | * DELETE to INSERT だが, UPDATE を検討する. |
---|
193 | * |
---|
194 | * @param array $arrList 入力フォームの内容 |
---|
195 | * @param integer $product_id 登録を行う商品ID |
---|
196 | */ |
---|
197 | function registerProductClass($arrList, $product_id) { |
---|
198 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
199 | $objDb = new SC_Helper_DB_Ex(); |
---|
200 | |
---|
201 | $objQuery->begin(); |
---|
202 | |
---|
203 | $productsClass = $objQuery->select("*", "dtb_products_class", "product_id = ?", array($product_id)); |
---|
204 | |
---|
205 | $exists = array(); |
---|
206 | foreach ($productsClass as $val) { |
---|
207 | $exists[$val['product_class_id']] = $val; |
---|
208 | } |
---|
209 | |
---|
210 | $i = 1; |
---|
211 | while (isset($arrList['classcategory_id1:' . $i])) { |
---|
212 | $pVal = array(); |
---|
213 | $pVal['product_id'] = $product_id;; |
---|
214 | $pVal['product_code'] = $arrList["product_code:".$i]; |
---|
215 | $pVal['stock'] = $arrList["stock:".$i]; |
---|
216 | $pVal['stock_unlimited'] = ($arrList["stock_unlimited:".$i]) ? '1' : '0'; |
---|
217 | $pVal['price01'] = $arrList['price01:'.$i]; |
---|
218 | $pVal['price02'] = $arrList['price02:'.$i]; |
---|
219 | $pVal['down'] = $arrList['down:'.$i]; |
---|
220 | $pVal['down_filename'] = $arrList['down_filename:'.$i]; |
---|
221 | $pVal['down_realfilename'] = $arrList['down_realfilename:'.$i]; |
---|
222 | $pVal['creator_id'] = $_SESSION['member_id']; |
---|
223 | $pVal['update_date'] = "now()"; |
---|
224 | |
---|
225 | if($arrList["check:".$i] == 1) { |
---|
226 | $pVal['del_flg'] = 0; |
---|
227 | } else { |
---|
228 | $pVal['del_flg'] = 1; |
---|
229 | } |
---|
230 | |
---|
231 | // 更新 or 登録 |
---|
232 | $isUpdate = false; |
---|
233 | if (!SC_Utils_Ex::isBlank($arrList["product_class_id:".$i])) { |
---|
234 | $isUpdate = true; |
---|
235 | // 更新の場合は規格組み合わせを検索し, 削除しておく |
---|
236 | $class_combination_id = $exists[$arrList["product_class_id:".$i]]['class_combination_id']; |
---|
237 | $existsCombi = $objQuery->getRow("dtb_class_combination", |
---|
238 | "*", "class_combination_id = ?", |
---|
239 | array($class_combination_id)); |
---|
240 | |
---|
241 | $objQuery->delete("dtb_class_combination", |
---|
242 | "class_combination_id IN (?, ?)", |
---|
243 | array($existsCombi['class_combination_id'], |
---|
244 | $existsCombi['parent_class_combination_id'])); |
---|
245 | } |
---|
246 | |
---|
247 | // 規格組み合わせを登録 |
---|
248 | $cVal1['class_combination_id'] = $objQuery->nextVal('dtb_class_combination_class_combination_id'); |
---|
249 | |
---|
250 | $cVal1['classcategory_id'] = $arrList["classcategory_id1:".$i]; |
---|
251 | $cVal1['level'] = 1; |
---|
252 | $objQuery->insert("dtb_class_combination", $cVal1); |
---|
253 | |
---|
254 | $pVal['class_combination_id'] = $cVal1['class_combination_id']; |
---|
255 | |
---|
256 | // 規格2も登録する場合 |
---|
257 | if (!SC_Utils_Ex::isBlank($arrList["classcategory_id2:".$i])) { |
---|
258 | $cVal2['class_combination_id'] = $objQuery->nextVal('dtb_class_combination_class_combination_id'); |
---|
259 | $cVal2['classcategory_id'] = $arrList["classcategory_id2:".$i]; |
---|
260 | $cVal2['parent_class_combination_id'] = $cVal1['class_combination_id']; |
---|
261 | $cVal2['level'] = 2; |
---|
262 | $objQuery->insert("dtb_class_combination", $cVal2); |
---|
263 | |
---|
264 | $pVal['class_combination_id'] = $cVal2['class_combination_id']; |
---|
265 | } |
---|
266 | |
---|
267 | // 更新 |
---|
268 | if ($isUpdate) { |
---|
269 | $pVal['product_class_id'] = $arrList["product_class_id:".$i]; |
---|
270 | $objQuery->update("dtb_products_class", $pVal, |
---|
271 | "product_class_id = ?", |
---|
272 | array($pVal['product_class_id'])); |
---|
273 | } |
---|
274 | // 新規登録 |
---|
275 | else { |
---|
276 | $pVal['create_date'] = "now()"; |
---|
277 | $pVal['product_class_id'] = $objQuery->nextVal('dtb_products_class_product_class_id'); |
---|
278 | $objQuery->insert("dtb_products_class", $pVal); |
---|
279 | } |
---|
280 | $i++; |
---|
281 | } |
---|
282 | |
---|
283 | // 規格無し用の商品規格を非表示に |
---|
284 | $bVal['del_flg'] = 1; |
---|
285 | $bVal['update_date'] = 'now()'; |
---|
286 | $objQuery->update("dtb_products_class", $bVal, |
---|
287 | "product_class_id = ? AND class_combination_id IS NULL", |
---|
288 | array($pVal['product_class_id'])); |
---|
289 | |
---|
290 | // 件数カウントバッチ実行 |
---|
291 | $objDb->sfCategory_Count($objQuery); |
---|
292 | $objQuery->commit(); |
---|
293 | } |
---|
294 | |
---|
295 | // 規格選択エラーチェック |
---|
296 | function lfClassError() { |
---|
297 | $objErr = new SC_CheckError(); |
---|
298 | $objErr->doFunc(array("規格1", "select_class_id1"), array("EXIST_CHECK")); |
---|
299 | $objErr->doFunc(array("規格", "select_class_id1", "select_class_id2"), array("TOP_EXIST_CHECK")); |
---|
300 | $objErr->doFunc(array("規格1", "規格2", "select_class_id1", "select_class_id2"), array("DIFFERENT_CHECK")); |
---|
301 | return $objErr->arrErr; |
---|
302 | } |
---|
303 | |
---|
304 | /* 取得文字列の変換 */ |
---|
305 | function lfConvertParam($array) { |
---|
306 | /* |
---|
307 | * 文字列の変換 |
---|
308 | * K : 「半角(ハンカク)片仮名」を「全角片仮名」に変換 |
---|
309 | * C : 「全角ひら仮名」を「全角かた仮名」に変換 |
---|
310 | * V : 濁点付きの文字を一文字に変換。"K","H"と共に使用します |
---|
311 | * n : 「全角」数字を「半角(ハンカク)」に変換 |
---|
312 | */ |
---|
313 | |
---|
314 | $no = 1; // FIXME 未定義変数の修正 |
---|
315 | while($array["classcategory_id1:".$no] != "") { |
---|
316 | $arrConvList["product_code:".$no] = "KVa"; |
---|
317 | $arrConvList["price01:".$no] = "n"; |
---|
318 | $arrConvList["price02:".$no] = "n"; |
---|
319 | $arrConvList["stock:".$no] = "n"; |
---|
320 | $no++; |
---|
321 | } |
---|
322 | |
---|
323 | // 文字変換 |
---|
324 | foreach ($arrConvList as $key => $val) { |
---|
325 | // POSTされてきた値のみ変換する。 |
---|
326 | if(isset($array[$key])) { |
---|
327 | $array[$key] = mb_convert_kana($array[$key] ,$val); |
---|
328 | } |
---|
329 | } |
---|
330 | return $array; |
---|
331 | } |
---|
332 | |
---|
333 | // 商品規格エラーチェック |
---|
334 | function lfProductClassError($array) { |
---|
335 | $objErr = new SC_CheckError($array); |
---|
336 | $no = 1; // FIXME 未定義変数の修正 |
---|
337 | while($array["classcategory_id1:".$no] != "") { |
---|
338 | if($array["check:".$no] == 1) { |
---|
339 | $objErr->doFunc(array("商品コード", "product_code:".$no, STEXT_LEN), array("MAX_LENGTH_CHECK")); |
---|
340 | $objErr->doFunc(array(NORMAL_PRICE_TITLE, "price01:".$no, PRICE_LEN), array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
341 | $objErr->doFunc(array(SALE_PRICE_TITLE, "price02:".$no, PRICE_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
342 | |
---|
343 | if($array["stock_unlimited:".$no] != '1') { |
---|
344 | $objErr->doFunc(array("在庫数", "stock:".$no, AMOUNT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
345 | } |
---|
346 | |
---|
347 | //ダウンロード商品チェック |
---|
348 | if($array["down:".$no] == "2") { |
---|
349 | $objErr->doFunc(array("ダウンロードファイル名", "down_filename:".$no, STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
350 | if($array["down_realfilename:".$no] == "") { |
---|
351 | $objErr->arrErr["down_realfilename:".$no] = "※ ダウンロード商品の場合はダウンロード商品用ファイルをアップロードしてください。<br />"; |
---|
352 | } |
---|
353 | } |
---|
354 | //実商品チェック |
---|
355 | else if($array["down:".$no] == "1") { |
---|
356 | if($array["down_filename:".$no] != "") { |
---|
357 | $objErr->arrErr["down_filename:".$no] = "※ 実商品の場合はダウンロードファイル名を設定できません。<br />"; |
---|
358 | } |
---|
359 | if($array["down_realfilename:".$no] != "") { |
---|
360 | $objErr->arrErr["down_realfilename:".$no] = "※ 実商品の場合はダウンロード商品用ファイルをアップロードできません。<br />ファイルを取り消してください。<br />"; |
---|
361 | } |
---|
362 | } |
---|
363 | } |
---|
364 | if(count($objErr->arrErr) > 0) { |
---|
365 | $objErr->arrErr["error:".$no] = $objErr->arrErr["product_code:".$no]; |
---|
366 | $objErr->arrErr["error:".$no].= $objErr->arrErr["price01:".$no]; |
---|
367 | $objErr->arrErr["error:".$no].= $objErr->arrErr["price02:".$no]; |
---|
368 | $objErr->arrErr["error:".$no].= $objErr->arrErr["stock:".$no]; |
---|
369 | } |
---|
370 | $no++; |
---|
371 | } |
---|
372 | return $objErr->arrErr; |
---|
373 | } |
---|
374 | |
---|
375 | /* 確認ページ表示用 */ |
---|
376 | function lfProductConfirmPage() { |
---|
377 | $objDb = new SC_Helper_DB_Ex(); |
---|
378 | $this->arrForm['mode'] = 'complete'; |
---|
379 | $this->arrClass = $objDb->sfGetIDValueList("dtb_class", 'class_id', 'name'); |
---|
380 | $cnt = 0; |
---|
381 | $check = 0; |
---|
382 | $no = 1; |
---|
383 | while($_POST["classcategory_id1:".$no] != "") { |
---|
384 | if($_POST["check:".$no] != "") { |
---|
385 | $check++; |
---|
386 | } |
---|
387 | $no++; |
---|
388 | $cnt++; |
---|
389 | } |
---|
390 | $this->tpl_check = $check; |
---|
391 | $this->tpl_count = $cnt; |
---|
392 | } |
---|
393 | |
---|
394 | /** |
---|
395 | * 規格の組み合わせ一覧を表示する. |
---|
396 | * |
---|
397 | * 1. 規格1, 規格2を組み合わせた場合の妥当性を検証する. |
---|
398 | * 2. 規格1, 規格2における規格分類のすべての組み合わせを取得し, |
---|
399 | * 該当商品の商品規格の内容を取得し, フォームに設定する. |
---|
400 | */ |
---|
401 | function doDisp() { |
---|
402 | $this->arrForm['select_class_id1'] = $_POST['select_class_id1']; |
---|
403 | $this->arrForm['select_class_id2'] = $_POST['select_class_id2']; |
---|
404 | |
---|
405 | $this->arrErr = $this->lfClassError(); |
---|
406 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
407 | $this->arrClassCat = $this->getAllClassCategory($_POST['select_class_id1'], $_POST['select_class_id2']); |
---|
408 | |
---|
409 | $productsClass = $this->getProductsClass($_POST['product_id']); |
---|
410 | |
---|
411 | $total = count($this->arrClassCat); |
---|
412 | for ($i = 1; $i <= $total; $i++) { |
---|
413 | foreach ($productsClass as $key => $val) { |
---|
414 | $this->arrForm[$key . ":" . $i] = $val; |
---|
415 | } |
---|
416 | } |
---|
417 | } |
---|
418 | $this->tpl_onload.= "fnCheckAllStockLimit('$total', '" . DISABLED_RGB . "');"; |
---|
419 | } |
---|
420 | |
---|
421 | /** |
---|
422 | * 規格編集画面を表示する. |
---|
423 | */ |
---|
424 | function doPreEdit($existsValue = true,$usepostValue = false) { |
---|
425 | $existsProductsClass = $this->getProductsClassAndClasscategory($_POST['product_id']); |
---|
426 | $productsClass = $this->getProductsClass($_POST['product_id']); |
---|
427 | $this->arrForm["class_id1"] = $existsProductsClass[0]['class_id1']; |
---|
428 | $this->arrForm["class_id2"] = $existsProductsClass[0]['class_id2']; |
---|
429 | $this->arrForm['select_class_id1'] = $this->arrForm["class_id1"]; |
---|
430 | $this->arrForm['select_class_id2'] = $this->arrForm["class_id2"]; |
---|
431 | |
---|
432 | $this->arrClassCat = $this->getAllClassCategory($this->arrForm["class_id1"], $this->arrForm["class_id2"]); |
---|
433 | |
---|
434 | $total = count($this->arrClassCat); |
---|
435 | for ($i = 1; $i <= $total; $i++) { |
---|
436 | if ($existsValue) { |
---|
437 | foreach ($productsClass as $key => $val) { |
---|
438 | if(!$usepostValue){ |
---|
439 | $this->arrForm[$key . ":" . $i] = $val; |
---|
440 | } |
---|
441 | } |
---|
442 | } |
---|
443 | foreach ($existsProductsClass[$i] as $key => $val) { |
---|
444 | if(!$usepostValue){ |
---|
445 | $this->arrForm[$key . ":" . $i] = $val; |
---|
446 | } |
---|
447 | } |
---|
448 | if (!SC_Utils_Ex::isBlank($this->arrForm['product_id:' . $i]) |
---|
449 | && $this->arrForm["del_flg:" . $i] == 0) { |
---|
450 | $line .= "'check:" . $i . "',"; |
---|
451 | } |
---|
452 | } |
---|
453 | //直前のLoopが$existsProductsClassを1始まりで参照しているので最初の情報が抜ける? |
---|
454 | for ($i = 0; $i < $total; $i++) { |
---|
455 | foreach ($existsProductsClass[$i] as $key => $val) { |
---|
456 | //ダウンロードファイル初期設定 |
---|
457 | if($key=="down"){ |
---|
458 | $this->objDownFile->addFile("ダウンロード販売用ファイル". ":" . ($i+1), 'down_realfilename'. ":" . ($i+1), explode(",", DOWNLOAD_EXTENSION),DOWN_SIZE, true, 0, 0); |
---|
459 | } |
---|
460 | } |
---|
461 | } |
---|
462 | |
---|
463 | $line = preg_replace("/,$/", "", $line); |
---|
464 | $this->tpl_javascript = "list = new Array($line);"; |
---|
465 | $color = DISABLED_RGB; |
---|
466 | $this->tpl_onload.= "fnListCheck(list); fnCheckAllStockLimit('$total', '$color');"; |
---|
467 | |
---|
468 | // DBデータからダウンロードファイル名の読込 |
---|
469 | $this->objDownFile->setDBFileList($this->arrForm); |
---|
470 | // PostデータからダウンロードTempファイル名の読込 |
---|
471 | $this->objDownFile->setPostFileList($_POST,$this->arrForm); |
---|
472 | } |
---|
473 | |
---|
474 | function doDelete() { |
---|
475 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
476 | |
---|
477 | $objQuery->begin(); |
---|
478 | $val['del_flg'] = 0; |
---|
479 | $objQuery->update("dtb_products_class", $val, "product_id = ? AND class_combination_id IS NULL", array($_POST['product_id'])); |
---|
480 | |
---|
481 | $val['del_flg'] = 1; |
---|
482 | $objQuery->update("dtb_products_class", $val, "product_id = ? AND class_combination_id IS NOT NULL", array($_POST['product_id'])); |
---|
483 | |
---|
484 | $objQuery->commit(); |
---|
485 | |
---|
486 | // 在庫無し商品の非表示対応 |
---|
487 | if (NOSTOCK_HIDDEN === true) { |
---|
488 | // 件数カウントバッチ実行 |
---|
489 | //$objDb->sfCategory_Count($objQuery); |
---|
490 | } |
---|
491 | } |
---|
492 | |
---|
493 | /** |
---|
494 | * 規格ID1, 規格ID2の規格分類すべてを取得する. |
---|
495 | * |
---|
496 | * @param integer $class_id1 規格ID1 |
---|
497 | * @param integer $class_id2 規格ID2 |
---|
498 | * @return array 規格と規格分類の配列 |
---|
499 | */ |
---|
500 | function getAllClassCategory($class_id1, $class_id2 = null) { |
---|
501 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
502 | |
---|
503 | $col = "T1.class_id AS class_id1, " |
---|
504 | . " T1.classcategory_id AS classcategory_id1, " |
---|
505 | . " T1.name AS name1, " |
---|
506 | . " T1.rank AS rank1 "; |
---|
507 | |
---|
508 | if(SC_Utils_Ex::isBlank($class_id2)) { |
---|
509 | $table = "dtb_classcategory T1 "; |
---|
510 | $objQuery->setWhere("T1.class_id = ?") |
---|
511 | ->setOrder("T1.rank DESC"); |
---|
512 | $val = array($class_id1); |
---|
513 | } else { |
---|
514 | $col .= "," |
---|
515 | . "T2.class_id AS class_id2," |
---|
516 | . "T2.classcategory_id AS classcategory_id2," |
---|
517 | . "T2.name AS name2," |
---|
518 | . "T2.rank AS rank2"; |
---|
519 | $table = "dtb_classcategory AS T1, dtb_classcategory AS T2"; |
---|
520 | $objQuery->setWhere("T1.class_id = ? AND T2.class_id = ?") |
---|
521 | ->setOrder("T1.rank DESC, T2.rank DESC"); |
---|
522 | $val = array($class_id1, $class_id2); |
---|
523 | } |
---|
524 | return $objQuery->select($col, $table, "", $val); |
---|
525 | } |
---|
526 | |
---|
527 | /** |
---|
528 | * 商品名を取得する. |
---|
529 | * |
---|
530 | * @access private |
---|
531 | * @param integer $product_id 商品ID |
---|
532 | * @return string 商品名の文字列 |
---|
533 | */ |
---|
534 | function getProductName($product_id) { |
---|
535 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
536 | return $objQuery->getOne("SELECT name FROM dtb_products WHERE product_id = ?", array($product_id)); |
---|
537 | } |
---|
538 | |
---|
539 | /** |
---|
540 | * 検索パラメータを生成する. |
---|
541 | * |
---|
542 | * "search_" で始まるパラメータのみを生成して返す. |
---|
543 | * |
---|
544 | * TODO パラメータの妥当性検証 |
---|
545 | * |
---|
546 | * @access private |
---|
547 | * @param array $params 生成元の POST パラメータ |
---|
548 | * @return array View にアサインするパラメータの配列 |
---|
549 | */ |
---|
550 | function createSearchParams($params) { |
---|
551 | $results = array(); |
---|
552 | foreach ($params as $key => $val) { |
---|
553 | if (substr($key, 0, 7) == "search_") { |
---|
554 | $results[$key] = $val; |
---|
555 | } |
---|
556 | } |
---|
557 | return $results; |
---|
558 | } |
---|
559 | |
---|
560 | /** |
---|
561 | * 規格分類の登録された, すべての規格を取得する. |
---|
562 | * |
---|
563 | * @access private |
---|
564 | * @return array 規格分類の登録された, すべての規格 |
---|
565 | */ |
---|
566 | function getAllClass() { |
---|
567 | $objDb = new SC_Helper_DB_Ex(); |
---|
568 | $arrClass = $objDb->sfGetIDValueList("dtb_class", 'class_id', 'name'); |
---|
569 | |
---|
570 | // 規格分類が登録されていない規格は表示しないようにする。 |
---|
571 | $arrClassCatCount = SC_Utils_Ex::sfGetClassCatCount(); |
---|
572 | |
---|
573 | $results = array(); |
---|
574 | if (!SC_Utils_Ex::isBlank($arrClass)) { |
---|
575 | foreach($arrClass as $key => $val) { |
---|
576 | if($arrClassCatCount[$key] > 0) { |
---|
577 | $results[$key] = $arrClass[$key]; |
---|
578 | } |
---|
579 | } |
---|
580 | } |
---|
581 | return $results; |
---|
582 | } |
---|
583 | |
---|
584 | /** |
---|
585 | * 商品IDをキーにして, 商品規格を取得する. |
---|
586 | * |
---|
587 | * @param integer $product_id 商品ID |
---|
588 | * @return array 商品規格の配列 |
---|
589 | */ |
---|
590 | function getProductsClass($product_id) { |
---|
591 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
592 | return $objQuery->getRow("dtb_products_class", "*", "product_id = ?", array($product_id)); |
---|
593 | } |
---|
594 | |
---|
595 | /** |
---|
596 | * 登録済みの商品規格, 規格, 規格分類を取得する. |
---|
597 | * |
---|
598 | * @param integer $product_id 商品ID |
---|
599 | * @return array 商品規格, 規格, 規格分類の配列 |
---|
600 | */ |
---|
601 | function getProductsClassAndClasscategory($productId) { |
---|
602 | $objProduct = new SC_Product(); |
---|
603 | return $objProduct->getProductsClassFullByProductId($productId); |
---|
604 | } |
---|
605 | |
---|
606 | /** |
---|
607 | * @access private |
---|
608 | */ |
---|
609 | function authorization() { |
---|
610 | SC_Utils_Ex::sfIsSuccess(new SC_Session()); |
---|
611 | } |
---|
612 | |
---|
613 | /** |
---|
614 | * @access private |
---|
615 | */ |
---|
616 | function assignView() { |
---|
617 | $objView = new SC_AdminView(); |
---|
618 | $objView->assignobj($this); |
---|
619 | $objView->display(MAIN_FRAME); |
---|
620 | } |
---|
621 | } |
---|
622 | ?> |
---|