1 | <?php
|
---|
2 | /*
|
---|
3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
|
---|
4 | *
|
---|
5 | * http://www.lockon.co.jp/
|
---|
6 | */
|
---|
7 |
|
---|
8 | require_once("../require.php");
|
---|
9 | require_once(DATA_PATH . "include/file_manager.inc");
|
---|
10 |
|
---|
11 | class LC_Page {
|
---|
12 |
|
---|
13 | function LC_Page() {
|
---|
14 | $this->tpl_mainpage = 'contents/campaign_create_tag.tpl';
|
---|
15 | $this->tpl_mainno = 'create';
|
---|
16 | $this->tpl_subtitle = '商品設定';
|
---|
17 | /*
|
---|
18 | session_start時のno-cacheヘッダーを抑制することで
|
---|
19 | 「戻る」ボタン使用時の有効期限切れ表示を抑制する。
|
---|
20 | private-no-expire:クライアントのキャッシュを許可する。
|
---|
21 | */
|
---|
22 | session_cache_limiter('private-no-expire');
|
---|
23 | }
|
---|
24 | }
|
---|
25 |
|
---|
26 | $objPage = new LC_Page();
|
---|
27 | $objView = new SC_AdminView();
|
---|
28 | $objSess = new SC_Session();
|
---|
29 | $objQuery = new SC_Query();
|
---|
30 |
|
---|
31 | // 認証可否の判定
|
---|
32 | sfIsSuccess($objSess);
|
---|
33 |
|
---|
34 | switch($_POST['mode']) {
|
---|
35 |
|
---|
36 | // 商品検索
|
---|
37 | case 'search':
|
---|
38 | // POST値の引き継ぎ
|
---|
39 | $objPage->arrForm = $_POST;
|
---|
40 | // 入力文字の強制変換
|
---|
41 | lfConvertParam();
|
---|
42 |
|
---|
43 | $where = "del_flg = 0";
|
---|
44 |
|
---|
45 | // where句生成
|
---|
46 | foreach ($objPage->arrForm as $key => $val) {
|
---|
47 | if($val == "") {
|
---|
48 | continue;
|
---|
49 | }
|
---|
50 |
|
---|
51 | switch ($key) {
|
---|
52 | case 'search_name':
|
---|
53 | $where .= " AND name ILIKE ?";
|
---|
54 | $arrval[] = "%$val%";
|
---|
55 | break;
|
---|
56 | case 'search_category_id':
|
---|
57 | // 子カテゴリIDの取得
|
---|
58 | $arrRet = sfGetChildsID("dtb_category", "parent_category_id", "category_id", $val);
|
---|
59 | $tmp_where = "";
|
---|
60 | foreach ($arrRet as $val) {
|
---|
61 | if($tmp_where == "") {
|
---|
62 | $tmp_where.= " AND ( category_id = ?";
|
---|
63 | } else {
|
---|
64 | $tmp_where.= " OR category_id = ?";
|
---|
65 | }
|
---|
66 | $arrval[] = $val;
|
---|
67 | }
|
---|
68 | $where.= $tmp_where . " )";
|
---|
69 | break;
|
---|
70 | case 'search_product_id':
|
---|
71 | if($val != "") {
|
---|
72 | $where .= " AND product_id = ?";
|
---|
73 | if(!sfIsInt($val)) $val = 0;
|
---|
74 | $arrval[] = $val;
|
---|
75 | }
|
---|
76 | break;
|
---|
77 | default:
|
---|
78 | break;
|
---|
79 | }
|
---|
80 | }
|
---|
81 |
|
---|
82 | $order = "update_date DESC, product_id DESC ";
|
---|
83 |
|
---|
84 | // 読み込む列とテーブルの指定
|
---|
85 | $col = "product_id, name, category_id, main_list_image, status, product_code, price01, stock, stock_unlimited";
|
---|
86 | $from = "vw_products_nonclass AS noncls ";
|
---|
87 |
|
---|
88 | // 行数の取得
|
---|
89 | $linemax = $objQuery->count("dtb_products", $where, $arrval);
|
---|
90 | $objPage->tpl_linemax = $linemax; // 何件が該当しました。表示用
|
---|
91 |
|
---|
92 | // ページ送りの処理
|
---|
93 | if(is_numeric($_POST['search_page_max'])) {
|
---|
94 | $page_max = $_POST['search_page_max'];
|
---|
95 | } else {
|
---|
96 | $page_max = SEARCH_PMAX;
|
---|
97 | }
|
---|
98 |
|
---|
99 | // ページ送りの取得
|
---|
100 | $objNavi = new SC_PageNavi($_POST['search_pageno'], $linemax, $page_max, "fnNaviSearchOnlyPage", NAVI_PMAX);
|
---|
101 | $objPage->tpl_strnavi = $objNavi->strnavi; // 表示文字列
|
---|
102 | $startno = $objNavi->start_row;
|
---|
103 |
|
---|
104 | // 取得範囲の指定(開始行番号、行数のセット)
|
---|
105 | if(DB_TYPE != "mysql") $objQuery->setlimitoffset($page_max, $startno);
|
---|
106 | // 表示順序
|
---|
107 | $objQuery->setorder($order);
|
---|
108 |
|
---|
109 | // viewも絞込みをかける(mysql用)
|
---|
110 | sfViewWhere("&&noncls_where&&", $where, $arrval, $objQuery->order . " " . $objQuery->setlimitoffset($page_max, $startno, true));
|
---|
111 |
|
---|
112 | // 検索結果の取得
|
---|
113 | $objPage->arrProducts = $objQuery->select($col, $from, $where, $arrval);
|
---|
114 | break;
|
---|
115 |
|
---|
116 | // タグ表示
|
---|
117 | case 'view':
|
---|
118 |
|
---|
119 | // タグを生成
|
---|
120 | $create_tag = lfGetCreateTag($_POST['product_id']);
|
---|
121 | $objPage->tpl_create_tag = $create_tag;
|
---|
122 | break;
|
---|
123 | }
|
---|
124 |
|
---|
125 | // カテゴリ取得
|
---|
126 | $objPage->arrCatList = sfGetCategoryList();
|
---|
127 |
|
---|
128 | //---- ページ表示
|
---|
129 | $objView->assignobj($objPage);
|
---|
130 | $objView->display($objPage->tpl_mainpage);
|
---|
131 |
|
---|
132 | //---------------------------------------------------------------------------------------------------------------------------------------------------------
|
---|
133 |
|
---|
134 | /* 取得文字列の変換 */
|
---|
135 | function lfConvertParam() {
|
---|
136 | global $objPage;
|
---|
137 | /*
|
---|
138 | * 文字列の変換
|
---|
139 | * K : 「半角(ハンカク)片仮名」を「全角片仮名」に変換
|
---|
140 | * C : 「全角ひら仮名」を「全角かた仮名」に変換
|
---|
141 | * V : 濁点付きの文字を一文字に変換。"K","H"と共に使用します
|
---|
142 | * n : 「全角」数字を「半角(ハンカク)」に変換
|
---|
143 | */
|
---|
144 | $arrConvList['search_name'] = "KVa";
|
---|
145 | $arrConvList['search_product_code'] = "KVa";
|
---|
146 |
|
---|
147 | // 文字変換
|
---|
148 | foreach ($arrConvList as $key => $val) {
|
---|
149 | // POSTされてきた値のみ変換する。
|
---|
150 | if(isset($objPage->arrForm[$key])) {
|
---|
151 | $objPage->arrForm[$key] = mb_convert_kana($objPage->arrForm[$key] ,$val);
|
---|
152 | }
|
---|
153 | }
|
---|
154 | }
|
---|
155 |
|
---|
156 | /* タグを生成 */
|
---|
157 | function lfGetCreateTag($product_id) {
|
---|
158 |
|
---|
159 | global $objQuery;
|
---|
160 |
|
---|
161 | // 書き込みタグ
|
---|
162 | $read_file = file_get_contents(CAMPAIGN_BLOC_PATH . "cart_tag.tpl");
|
---|
163 | $read_file = ereg_replace("<{assign_product_id}>", $product_id, $read_file);
|
---|
164 | // カートタグ保存用ファイル作成
|
---|
165 | $create_tag .= "<!--{* ▼商品ID$product_id *}-->\n";
|
---|
166 | $create_tag .= $read_file;
|
---|
167 |
|
---|
168 | return $create_tag;
|
---|
169 | }
|
---|
170 | ?> |
---|