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

Revision 18815, 5.9 KB checked in by nanasess, 14 years ago (diff)

規格まわりの内部構成変更に伴う修正(#781)

  • 規格のデータ構造を木構造へ変更
  • 商品検索ロジックを SC_Product クラスへできるだけ集約
  • 以下の VIEW を削除
    • vw_category_count;
    • vw_product_class;
    • vw_products_nonclass;
    • vw_cross_products_class;
    • vw_cross_class;
    • vw_download_class;
  • 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/LC_Page.php");
26
27/**
28 * 商品並べ替え のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_Products_ProductRank extends LC_Page {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_mainpage = 'products/product_rank.tpl';
47        $this->tpl_subnavi = 'products/subnavi.tpl';
48        $this->tpl_mainno = 'products';
49        $this->tpl_subno = 'product_rank';
50        $this->tpl_subtitle = '商品並び替え';
51    }
52
53    /**
54     * Page のプロセス.
55     *
56     * @return void
57     */
58    function process() {
59        $objQuery = new SC_Query();
60        $objView = new SC_AdminView();
61        $objSess = new SC_Session();
62        $objDb = new SC_Helper_DB_Ex();
63
64        // 認証可否の判定
65        SC_Utils_Ex::sfIsSuccess($objSess);
66
67        $this->tpl_pageno = isset($_POST['pageno']) ? $_POST['pageno'] : "";
68
69        // 通常時は親カテゴリを0に設定する。
70        $this->arrForm['parent_category_id'] =
71            isset($_POST['parent_category_id']) ? $_POST['parent_category_id'] : 0;
72
73        if (!isset($_POST['mode'])) $_POST['mode'] = "";
74        switch($_POST['mode']) {
75        case 'up':
76            $where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['parent_category_id']);
77            $objDb->sfRankUp("dtb_product_categories", "product_id", $_POST['product_id'], $where);
78            break;
79        case 'down':
80            $where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['parent_category_id']);
81            $objDb->sfRankDown("dtb_product_categories", "product_id", $_POST['product_id'], $where);
82            break;
83        case 'move':
84            $key = "pos-".$_POST['product_id'];
85            $input_pos = mb_convert_kana($_POST[$key], "n");
86            if(SC_Utils_Ex::sfIsInt($input_pos)) {
87                $where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['parent_category_id']);
88                $objDb->sfMoveRank("dtb_product_categories", "product_id", $_POST['product_id'], $input_pos, $where);
89            }
90            break;
91        case 'tree':
92            // カテゴリの切替は、ページ番号をクリアする。
93            $this->tpl_pageno = "";
94            break;
95           
96        case 'renumber':
97            $sql = <<< __EOS__
98                UPDATE dtb_product_categories
99                SET
100                    rank =
101                        (
102                            SELECT COUNT(*)
103                            FROM dtb_product_categories t_in
104                            WHERE t_in.category_id = dtb_product_categories.category_id
105                                AND (
106                                    t_in.rank < dtb_product_categories.rank
107                                    OR (
108                                        t_in.rank = dtb_product_categories.rank
109                                        AND t_in.product_id < dtb_product_categories.product_id
110                                    )
111                                )
112                        ) + 1
113                WHERE dtb_product_categories.category_id = ?
114__EOS__;
115            $objQuery->query($sql, array($_POST['parent_category_id']));
116            break;
117       
118        default:
119            break;
120        }
121
122        $this->arrTree = $objDb->sfGetCatTree($this->arrForm['parent_category_id']);
123        $this->arrProductsList =
124            $this->lfGetProduct($this->arrForm['parent_category_id']);
125
126        $objView->assignobj($this);
127        $objView->display(MAIN_FRAME);
128    }
129
130    /**
131     * デストラクタ.
132     *
133     * @return void
134     */
135    function destroy() {
136        parent::destroy();
137    }
138
139    /* 商品読み込み */
140    function lfGetProduct($category_id) {
141        // FIXME SC_Product クラスを使用した実装
142        $objQuery = new SC_Query();
143        $col = "product_id, name, main_list_image, product_code_min, product_code_max, status";
144        $table = "vw_products_allclass AS allcls";
145        $where = "del_flg = 0 AND category_id = ?";
146
147        // 行数の取得
148        $linemax = $objQuery->count($table, $where, array($category_id));
149        // 該当件数表示用
150        $this->tpl_linemax = $linemax;
151
152        $objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, SEARCH_PMAX, "fnNaviPage", NAVI_PMAX);
153        $startno = $objNavi->start_row;
154        $this->tpl_start_row = $objNavi->start_row;
155        $this->tpl_strnavi = $objNavi->strnavi;     // Navi表示文字列
156        $this->tpl_pagemax = $objNavi->max_page;    // ページ最大数(「上へ下へ」表示判定用)
157        $this->tpl_disppage = $objNavi->now_page;   // 表示ページ番号(「上へ下へ」表示判定用)
158
159        // 取得範囲の指定(開始行番号、行数のセット)
160        $objQuery->setLimitOffset(SEARCH_PMAX, $startno);
161
162        $objQuery->setOrder("product_rank DESC, product_id DESC");
163
164        $arrRet = $objQuery->select($col, $table, $where, array($category_id));
165        return $arrRet;
166    }
167}
168?>
Note: See TracBrowser for help on using the repository browser.