1 | <?php |
---|
2 | /* |
---|
3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
4 | * |
---|
5 | * http://www.lockon.co.jp/ |
---|
6 | */ |
---|
7 | |
---|
8 | // {{{ requires |
---|
9 | require_once(CLASS_PATH . "pages/LC_Page.php"); |
---|
10 | |
---|
11 | /** |
---|
12 | * 商品並べ替え のページクラス. |
---|
13 | * |
---|
14 | * @package Page |
---|
15 | * @author LOCKON CO.,LTD. |
---|
16 | * @version $Id$ |
---|
17 | */ |
---|
18 | class LC_Page_Admin_Products_ProductRank extends LC_Page { |
---|
19 | |
---|
20 | // }}} |
---|
21 | // {{{ functions |
---|
22 | |
---|
23 | /** |
---|
24 | * Page を初期化する. |
---|
25 | * |
---|
26 | * @return void |
---|
27 | */ |
---|
28 | function init() { |
---|
29 | parent::init(); |
---|
30 | $this->tpl_mainpage = 'products/product_rank.tpl'; |
---|
31 | $this->tpl_subnavi = 'products/subnavi.tpl'; |
---|
32 | $this->tpl_mainno = 'products'; |
---|
33 | $this->tpl_subno = 'product_rank'; |
---|
34 | $this->tpl_subtitle = '商品並び替え'; |
---|
35 | } |
---|
36 | |
---|
37 | /** |
---|
38 | * Page のプロセス. |
---|
39 | * |
---|
40 | * @return void |
---|
41 | */ |
---|
42 | function process() { |
---|
43 | $conn = new SC_DBConn(); |
---|
44 | $objView = new SC_AdminView(); |
---|
45 | $objSess = new SC_Session(); |
---|
46 | $objDb = new SC_Helper_DB_Ex(); |
---|
47 | |
---|
48 | // 認証可否の判定 |
---|
49 | SC_Utils_Ex::sfIsSuccess($objSess); |
---|
50 | |
---|
51 | $this->tpl_pageno = isset($_POST['pageno']) ? $_POST['pageno'] : ""; |
---|
52 | |
---|
53 | // 通常時は親カテゴリを0に設定する。 |
---|
54 | $this->arrForm['parent_category_id'] = |
---|
55 | isset($_POST['parent_category_id']) ? $_POST['parent_category_id'] : ""; |
---|
56 | |
---|
57 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
58 | switch($_POST['mode']) { |
---|
59 | case 'up': |
---|
60 | $where = "category_id = " . addslashes($_POST['parent_category_id']); |
---|
61 | $objDb->sfRankUp("dtb_products", "product_id", $_POST['product_id'], $where); |
---|
62 | break; |
---|
63 | case 'down': |
---|
64 | $where = "category_id = " . addslashes($_POST['parent_category_id']); |
---|
65 | $objDb->sfRankDown("dtb_products", "product_id", $_POST['product_id'], $where); |
---|
66 | break; |
---|
67 | case 'move': |
---|
68 | $key = "pos-".$_POST['product_id']; |
---|
69 | $input_pos = mb_convert_kana($_POST[$key], "n"); |
---|
70 | if(SC_Utils_Ex::sfIsInt($input_pos)) { |
---|
71 | $where = "category_id = " . addslashes($_POST['parent_category_id']); |
---|
72 | $objDb->sfMoveRank("dtb_products", "product_id", $_POST['product_id'], $input_pos, $where); |
---|
73 | } |
---|
74 | break; |
---|
75 | case 'tree': |
---|
76 | // カテゴリの切替は、ページ番号をクリアする。 |
---|
77 | $this->tpl_pageno = ""; |
---|
78 | break; |
---|
79 | default: |
---|
80 | break; |
---|
81 | } |
---|
82 | |
---|
83 | $this->arrTree = $objDb->sfGetCatTree($this->arrForm['parent_category_id']); |
---|
84 | $this->arrProductsList = |
---|
85 | $this->lfGetProduct($this->arrForm['parent_category_id']); |
---|
86 | |
---|
87 | $objView->assignobj($this); |
---|
88 | $objView->display(MAIN_FRAME); |
---|
89 | } |
---|
90 | |
---|
91 | /** |
---|
92 | * デストラクタ. |
---|
93 | * |
---|
94 | * @return void |
---|
95 | */ |
---|
96 | function destroy() { |
---|
97 | parent::destroy(); |
---|
98 | } |
---|
99 | |
---|
100 | /* 商品読み込み */ |
---|
101 | function lfGetProduct($category_id) { |
---|
102 | $objQuery = new SC_Query(); |
---|
103 | $col = "product_id, name, main_list_image, rank, product_code"; |
---|
104 | $table = "vw_products_nonclass AS noncls "; |
---|
105 | $where = "del_flg = 0 AND category_id = ?"; |
---|
106 | |
---|
107 | // 行数の取得 |
---|
108 | $linemax = $objQuery->count("dtb_products", $where, array($category_id)); |
---|
109 | // 順位、該当件数表示用 |
---|
110 | $this->tpl_linemax = $linemax; |
---|
111 | |
---|
112 | $objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, SEARCH_PMAX, "fnNaviPage", NAVI_PMAX); |
---|
113 | $startno = $objNavi->start_row; |
---|
114 | $this->tpl_strnavi = $objNavi->strnavi; // Navi表示文字列 |
---|
115 | $this->tpl_pagemax = $objNavi->max_page; // ページ最大数(「上へ下へ」表示判定用) |
---|
116 | $this->tpl_disppage = $objNavi->now_page; // 表示ページ番号(「上へ下へ」表示判定用) |
---|
117 | |
---|
118 | // 取得範囲の指定(開始行番号、行数のセット) |
---|
119 | if(DB_TYPE != "mysql") $objQuery->setlimitoffset(SEARCH_PMAX, $startno); |
---|
120 | |
---|
121 | $objQuery->setorder("rank DESC"); |
---|
122 | |
---|
123 | // viewも絞込みをかける(mysql用) |
---|
124 | //sfViewWhere("&&noncls_where&&", $where, array($category_id), $objQuery->order . " " . $objQuery->setlimitoffset(SEARCH_PMAX, $startno, true)); TODO |
---|
125 | |
---|
126 | $arrRet = $objQuery->select($col, $table, $where, array($category_id)); |
---|
127 | return $arrRet; |
---|
128 | } |
---|
129 | } |
---|
130 | ?> |
---|