source: branches/version-2_5-dev/data/class/pages/admin/products/LC_Page_Admin_Products_ProductClass.php @ 19805

Revision 19805, 25.5 KB checked in by Seasoft, 13 years ago (diff)

#834(パラメータの定数名に「URL」を含むにもかかわらず、パスのみのものがある) 一部実装

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