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

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