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

Revision 19711, 25.3 KB checked in by nanasess, 13 years ago (diff)
  • #748(モバイルのデザイン管理機能)
    • dtb_pagelayout, dtb_bloc, dtb_blocposition のプライマリーキー変更, device_type_id 追加
    • 管理画面のメニュー修正
  • 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_PATH . "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_DIR, DOWN_SAVE_DIR);
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("dtb_class_combination",
251                                                 "*", "class_combination_id = ?",
252                                                 array($class_combination_id));
253
254                $objQuery->delete("dtb_class_combination",
255                                  "class_combination_id IN (?, ?)",
256                                  array($existsCombi['class_combination_id'],
257                                        $existsCombi['parent_class_combination_id']));
258            }
259
260            // 規格組み合わせを登録
261            $cVal1['class_combination_id'] = $objQuery->nextVal('dtb_class_combination_class_combination_id');
262
263            $cVal1['classcategory_id'] = $arrList["classcategory_id1:".$i];
264            $cVal1['level'] = 1;
265            $objQuery->insert("dtb_class_combination", $cVal1);
266
267            $pVal['class_combination_id'] = $cVal1['class_combination_id'];
268
269            // 規格2も登録する場合
270            if (!SC_Utils_Ex::isBlank($arrList["classcategory_id2:".$i])) {
271                $cVal2['class_combination_id'] = $objQuery->nextVal('dtb_class_combination_class_combination_id');
272                $cVal2['classcategory_id'] = $arrList["classcategory_id2:".$i];
273                $cVal2['parent_class_combination_id'] = $cVal1['class_combination_id'];
274                $cVal2['level'] = 2;
275                $objQuery->insert("dtb_class_combination", $cVal2);
276
277                $pVal['class_combination_id'] = $cVal2['class_combination_id'];
278            }
279
280            // 更新
281            if ($isUpdate) {
282                $pVal['product_class_id'] = $arrList["product_class_id:".$i];
283                $objQuery->update("dtb_products_class", $pVal,
284                                  "product_class_id = ?",
285                                  array($pVal['product_class_id']));
286            }
287            // 新規登録
288            else {
289                $pVal['create_date'] = "now()";
290                $pVal['product_class_id'] = $objQuery->nextVal('dtb_products_class_product_class_id');
291                $objQuery->insert("dtb_products_class", $pVal);
292            }
293
294            // 支払方法登録
295            $objProduct = new SC_Product();
296            $objProduct->setPaymentOptions($pVal['product_class_id'], $arrList['payment_ids:'.$i]);
297            $i++;
298        }
299
300        // 規格無し用の商品規格を非表示に
301        $bVal['del_flg'] = 1;
302        $bVal['update_date'] = 'now()';
303        $objQuery->update("dtb_products_class", $bVal,
304                          "product_class_id = ? AND class_combination_id IS NULL",
305                          array($pVal['product_class_id']));
306
307        // 件数カウントバッチ実行
308        $objDb->sfCategory_Count($objQuery);
309        $objQuery->commit();
310    }
311
312    // 規格選択エラーチェック
313    function lfClassError() {
314        $objErr = new SC_CheckError();
315        $objErr->doFunc(array("規格1", "select_class_id1"), array("EXIST_CHECK"));
316        $objErr->doFunc(array("規格", "select_class_id1", "select_class_id2"), array("TOP_EXIST_CHECK"));
317        $objErr->doFunc(array("規格1", "規格2", "select_class_id1", "select_class_id2"), array("DIFFERENT_CHECK"));
318        return $objErr->arrErr;
319    }
320
321    /* 取得文字列の変換 */
322    function lfConvertParam($array) {
323        /*
324         *  文字列の変換
325         *  K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
326         *  C :  「全角ひら仮名」を「全角かた仮名」に変換
327         *  V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
328         *  n :  「全角」数字を「半角(ハンカク)」に変換
329         */
330
331        $no = 1; // FIXME 未定義変数の修正
332        while($array["classcategory_id1:".$no] != "") {
333            $arrConvList["product_code:".$no] = "KVa";
334            $arrConvList["price01:".$no] = "n";
335            $arrConvList["price02:".$no] = "n";
336            $arrConvList["stock:".$no] = "n";
337            $no++;
338        }
339
340        // 文字変換
341        foreach ($arrConvList as $key => $val) {
342            // POSTされてきた値のみ変換する。
343            if(isset($array[$key])) {
344                $array[$key] = mb_convert_kana($array[$key] ,$val);
345            }
346        }
347        return $array;
348    }
349
350    // 商品規格エラーチェック
351    function lfProductClassError($array) {
352        $objErr = new SC_CheckError($array);
353        $no = 1; // FIXME 未定義変数の修正
354        while($array["classcategory_id1:".$no] != "") {
355            if($array["check:".$no] == 1) {
356                $objErr->doFunc(array("商品コード", "product_code:".$no, STEXT_LEN), array("MAX_LENGTH_CHECK"));
357                $objErr->doFunc(array(NORMAL_PRICE_TITLE, "price01:".$no, PRICE_LEN), array("NUM_CHECK", "MAX_LENGTH_CHECK"));
358                $objErr->doFunc(array(SALE_PRICE_TITLE, "price02:".$no, PRICE_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
359
360                if($array["stock_unlimited:".$no] != '1') {
361                    $objErr->doFunc(array("在庫数", "stock:".$no, AMOUNT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
362                }
363
364                // 支払方法チェック
365                if (empty($array['payment_ids:' . $no])) {
366                    $objErr->arrErr['payment_ids:' . $no] = "※ 支払方法は、いずれかを選択してください。<br />";
367                }
368
369                //ダウンロード商品チェック
370                if($array["product_type_id:".$no] == PRODUCT_TYPE_DOWNLOAD) {
371                    $objErr->doFunc(array("ダウンロードファイル名", "down_filename:".$no, STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
372                    if($array["down_realfilename:".$no] == "") {
373                        $objErr->arrErr["down_realfilename:".$no] = "※ ダウンロード商品の場合はダウンロード商品用ファイルをアップロードしてください。<br />";
374                    }
375                }
376                //実商品チェック
377                else if($array["product_type_id:".$no] == PRODUCT_TYPE_DOWNLOAD) {
378                    if($array["down_filename:".$no] != "") {
379                        $objErr->arrErr["down_filename:".$no] = "※ 実商品の場合はダウンロードファイル名を設定できません。<br />";
380                    }
381                    if($array["down_realfilename:".$no] != "") {
382                        $objErr->arrErr["down_realfilename:".$no] = "※ 実商品の場合はダウンロード商品用ファイルをアップロードできません。<br />ファイルを取り消してください。<br />";
383                    }
384                }
385            }
386            if(count($objErr->arrErr) > 0) {
387                $objErr->arrErr["error:".$no] = $objErr->arrErr["product_code:".$no];
388                $objErr->arrErr["error:".$no].= $objErr->arrErr["price01:".$no];
389                $objErr->arrErr["error:".$no].= $objErr->arrErr["price02:".$no];
390                $objErr->arrErr["error:".$no].= $objErr->arrErr["stock:".$no];
391            }
392            $no++;
393        }
394        return $objErr->arrErr;
395    }
396
397    /* 確認ページ表示用 */
398    function lfProductConfirmPage() {
399        $objDb = new SC_Helper_DB_Ex();
400        $this->arrForm['mode'] = 'complete';
401        $this->arrClass = $objDb->sfGetIDValueList("dtb_class", 'class_id', 'name');
402        $cnt = 0;
403        $check = 0;
404        $no = 1;
405        while($_POST["classcategory_id1:".$no] != "") {
406            if($_POST["check:".$no] != "") {
407                $check++;
408            }
409            $no++;
410            $cnt++;
411        }
412        $this->tpl_check = $check;
413        $this->tpl_count = $cnt;
414    }
415
416    /**
417     * 規格の組み合わせ一覧を表示する.
418     *
419     * 1. 規格1, 規格2を組み合わせた場合の妥当性を検証する.
420     * 2. 規格1, 規格2における規格分類のすべての組み合わせを取得し,
421     *    該当商品の商品規格の内容を取得し, フォームに設定する.
422     */
423    function doDisp() {
424        $this->arrForm['select_class_id1'] = $_POST['select_class_id1'];
425        $this->arrForm['select_class_id2'] = $_POST['select_class_id2'];
426
427        $this->arrErr = $this->lfClassError();
428        if (SC_Utils_Ex::isBlank($this->arrErr)) {
429            $this->arrClassCat = $this->getAllClassCategory($_POST['select_class_id1'], $_POST['select_class_id2']);
430
431            $productsClass = $this->getProductsClass($_POST['product_id']);
432
433            $total = count($this->arrClassCat);
434            for ($i = 1; $i <= $total; $i++) {
435                foreach ($productsClass as $key => $val) {
436                    $this->arrForm[$key . ":" . $i] = $val;
437                }
438            }
439        }
440        $this->tpl_onload.= "fnCheckAllStockLimit('$total', '" . DISABLED_RGB . "');";
441    }
442
443    /**
444     * 規格編集画面を表示する.
445     */
446    function doPreEdit($existsValue = true,$usepostValue = false) {
447        $existsProductsClass = $this->getProductsClassAndClasscategory($_POST['product_id']);
448        $productsClass = $this->getProductsClass($_POST['product_id']);
449        $this->arrForm["class_id1"] = $existsProductsClass[0]['class_id1'];
450        $this->arrForm["class_id2"] = $existsProductsClass[0]['class_id2'];
451        $this->arrForm['select_class_id1'] = $this->arrForm["class_id1"];
452        $this->arrForm['select_class_id2'] = $this->arrForm["class_id2"];
453        $this->arrClassCat = $this->getAllClassCategory($this->arrForm["class_id1"], $this->arrForm["class_id2"]);
454        $objProduct = new SC_Product();
455        $total = count($this->arrClassCat);
456        // XXX $i = 1 にすれば ($i+1) は $i で良い?
457        for ($i = 0; $i < $total; $i++) {
458            if ($existsValue) {
459                foreach ($productsClass as $key => $val) {
460                    if(!$usepostValue){
461                        $this->arrForm[$key . ":" . ($i+1)] = $val;
462                    }
463                }
464            }
465            foreach ($existsProductsClass[$i] as $key => $val) {
466                if(!$usepostValue){
467                    $this->arrForm[$key . ":" . ($i+1)] = $val;
468                }
469
470                switch ($key) {
471                case 'down':
472                    $this->objDownFile->addFile("ダウンロード販売用ファイル". ":" . ($i+1), 'down_realfilename'. ":" . ($i+1), explode(",", DOWNLOAD_EXTENSION),DOWN_SIZE, true, 0, 0);
473                    break;
474
475                    case 'product_class_id':
476                        $this->arrForm["payment_ids:" . ($i+1)] = $objProduct->getEnablePaymentIds(array($val));
477                        break;
478                default:
479                }
480            }
481            if (!SC_Utils_Ex::isBlank($this->arrForm['product_id:' . ($i+1)])
482                && $this->arrForm["del_flg:" . ($i+1)] == 0) {
483                $line .= "'check:" . ($i+1) . "',";
484            }
485        }
486
487        $line = preg_replace("/,$/", "", $line);
488        $this->tpl_javascript = "list = new Array($line);";
489        $color = DISABLED_RGB;
490        $this->tpl_onload.= "fnListCheck(list); fnCheckAllStockLimit('$total', '$color');";
491
492        // DBデータからダウンロードファイル名の読込
493        $this->objDownFile->setDBFileList($this->arrForm);
494        // PostデータからダウンロードTempファイル名の読込
495        $this->objDownFile->setPostFileList($_POST,$this->arrForm);
496    }
497
498    function doDelete() {
499        $objQuery =& SC_Query::getSingletonInstance();
500
501        $objQuery->begin();
502        $val['del_flg'] = 0;
503        $objQuery->update("dtb_products_class", $val, "product_id = ? AND class_combination_id IS NULL", array($_POST['product_id']));
504
505        $val['del_flg'] = 1;
506        $objQuery->update("dtb_products_class", $val, "product_id = ? AND class_combination_id IS NOT NULL", array($_POST['product_id']));
507
508        $objQuery->commit();
509
510        // 在庫無し商品の非表示対応
511        if (NOSTOCK_HIDDEN === true) {
512            // 件数カウントバッチ実行
513            //$objDb->sfCategory_Count($objQuery);
514        }
515    }
516
517    /**
518     * 規格ID1, 規格ID2の規格分類すべてを取得する.
519     *
520     * @param integer $class_id1 規格ID1
521     * @param integer $class_id2 規格ID2
522     * @return array 規格と規格分類の配列
523     */
524    function getAllClassCategory($class_id1, $class_id2 = null) {
525        $objQuery =& SC_Query::getSingletonInstance();
526
527        $col = "T1.class_id AS class_id1, "
528            . " T1.classcategory_id AS classcategory_id1, "
529            . " T1.name AS name1, "
530            . " T1.rank AS rank1 ";
531
532        if(SC_Utils_Ex::isBlank($class_id2)) {
533            $table = "dtb_classcategory T1 ";
534            $objQuery->setWhere("T1.class_id = ?")
535                     ->setOrder("T1.rank DESC");
536            $val = array($class_id1);
537        } else {
538            $col .= ","
539                . "T2.class_id AS class_id2,"
540                . "T2.classcategory_id AS classcategory_id2,"
541                . "T2.name AS name2,"
542                . "T2.rank AS rank2";
543            $table = "dtb_classcategory AS T1, dtb_classcategory AS T2";
544            $objQuery->setWhere("T1.class_id = ? AND T2.class_id = ?")
545                     ->setOrder("T1.rank DESC, T2.rank DESC");
546            $val = array($class_id1, $class_id2);
547        }
548        return $objQuery->select($col, $table, "", $val);
549    }
550
551    /**
552     * 商品名を取得する.
553     *
554     * @access private
555     * @param integer $product_id 商品ID
556     * @return string 商品名の文字列
557     */
558    function getProductName($product_id) {
559        $objQuery =& SC_Query::getSingletonInstance();
560        return $objQuery->getOne("SELECT name FROM dtb_products WHERE product_id = ?", array($product_id));
561    }
562
563    /**
564     * 検索パラメータを生成する.
565     *
566     * "search_" で始まるパラメータのみを生成して返す.
567     *
568     * TODO パラメータの妥当性検証
569     *
570     * @access private
571     * @param array $params 生成元の POST パラメータ
572     * @return array View にアサインするパラメータの配列
573     */
574    function createSearchParams($params) {
575        $results = array();
576        foreach ($params as $key => $val) {
577            if (substr($key, 0, 7) == "search_") {
578                $results[$key] = $val;
579            }
580        }
581        return $results;
582    }
583
584    /**
585     * 規格分類の登録された, すべての規格を取得する.
586     *
587     * @access private
588     * @return array 規格分類の登録された, すべての規格
589     */
590    function getAllClass() {
591        $objDb = new SC_Helper_DB_Ex();
592        $arrClass = $objDb->sfGetIDValueList("dtb_class", 'class_id', 'name');
593
594        // 規格分類が登録されていない規格は表示しないようにする。
595        $arrClassCatCount = SC_Utils_Ex::sfGetClassCatCount();
596
597        $results = array();
598        if (!SC_Utils_Ex::isBlank($arrClass)) {
599            foreach($arrClass as $key => $val) {
600                if($arrClassCatCount[$key] > 0) {
601                    $results[$key] = $arrClass[$key];
602                }
603            }
604        }
605        return $results;
606    }
607
608    /**
609     * 商品IDをキーにして, 商品規格を取得する.
610     *
611     * @param integer $product_id 商品ID
612     * @return array 商品規格の配列
613     */
614    function getProductsClass($product_id) {
615        $objQuery =& SC_Query::getSingletonInstance();
616        return $objQuery->getRow("dtb_products_class", "*", "product_id = ?", array($product_id));
617    }
618
619    /**
620     * 登録済みの商品規格, 規格, 規格分類を取得する.
621     *
622     * @param integer $product_id 商品ID
623     * @return array 商品規格, 規格, 規格分類の配列
624     */
625    function getProductsClassAndClasscategory($productId) {
626        $objProduct = new SC_Product();
627        return $objProduct->getProductsClassFullByProductId($productId);
628    }
629
630    /**
631     * @access private
632     */
633    function authorization() {
634        SC_Utils_Ex::sfIsSuccess(new SC_Session());
635    }
636}
637?>
Note: See TracBrowser for help on using the repository browser.