1 | <?php |
---|
2 | /* |
---|
3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
4 | * |
---|
5 | * http://www.lockon.co.jp/ |
---|
6 | */ |
---|
7 | require_once("../require.php"); |
---|
8 | |
---|
9 | class LC_Page { |
---|
10 | var $arrCatList; |
---|
11 | var $arrSRANK; |
---|
12 | var $arrForm; |
---|
13 | var $arrSubList; |
---|
14 | var $arrHidden; |
---|
15 | var $arrTempImage; |
---|
16 | var $arrSaveImage; |
---|
17 | var $tpl_mode; |
---|
18 | function LC_Page() { |
---|
19 | $this->tpl_mainpage = 'products/product.tpl'; |
---|
20 | $this->tpl_subnavi = 'products/subnavi.tpl'; |
---|
21 | $this->tpl_mainno = 'products'; |
---|
22 | $this->tpl_subno = 'product'; |
---|
23 | $this->tpl_subtitle = '商品登録'; |
---|
24 | global $arrSRANK; |
---|
25 | $this->arrSRANK = $arrSRANK; |
---|
26 | global $arrDISP; |
---|
27 | $this->arrDISP = $arrDISP; |
---|
28 | global $arrCLASS; |
---|
29 | $this->arrCLASS = $arrCLASS; |
---|
30 | global $arrSTATUS; |
---|
31 | $this->arrSTATUS = $arrSTATUS; |
---|
32 | global $arrSTATUS_VALUE; |
---|
33 | $this->arrSTATUS_VALUE = $arrSTATUS_VALUE; |
---|
34 | global $arrSTATUS_IMAGE; |
---|
35 | $this->arrSTATUS_IMAGE = $arrSTATUS_IMAGE; |
---|
36 | global $arrDELIVERYDATE; |
---|
37 | $this->arrDELIVERYDATE = $arrDELIVERYDATE; |
---|
38 | $this->tpl_nonclass = true; |
---|
39 | } |
---|
40 | } |
---|
41 | |
---|
42 | $objPage = new LC_Page(); |
---|
43 | $objView = new SC_AdminView(); |
---|
44 | $objSiteInfo = new SC_SiteInfo(); |
---|
45 | $objQuery = new SC_Query(); |
---|
46 | |
---|
47 | // 認証可否の判定 |
---|
48 | $objSess = new SC_Session(); |
---|
49 | sfIsSuccess($objSess); |
---|
50 | |
---|
51 | // ファイル管理クラス |
---|
52 | $objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR); |
---|
53 | |
---|
54 | // ファイル情報の初期化 |
---|
55 | lfInitFile(); |
---|
56 | // Hiddenからのデータを引き継ぐ |
---|
57 | $objUpFile->setHiddenFileList($_POST); |
---|
58 | |
---|
59 | // 検索パラメータの引き継ぎ |
---|
60 | foreach ($_POST as $key => $val) { |
---|
61 | if (ereg("^search_", $key)) { |
---|
62 | $objPage->arrSearchHidden[$key] = $val; |
---|
63 | } |
---|
64 | } |
---|
65 | |
---|
66 | // FORMデータの引き継ぎ |
---|
67 | $objPage->arrForm = $_POST; |
---|
68 | |
---|
69 | switch($_POST['mode']) { |
---|
70 | // 検索画面からの編集 |
---|
71 | case 'pre_edit': |
---|
72 | case 'copy' : |
---|
73 | // 編集時 |
---|
74 | if(sfIsInt($_POST['product_id'])){ |
---|
75 | // DBから商品情報の読込 |
---|
76 | $arrForm = lfGetProduct($_POST['product_id']); |
---|
77 | // DBデータから画像ファイル名の読込 |
---|
78 | $objUpFile->setDBFileList($arrForm); |
---|
79 | |
---|
80 | if($_POST['mode'] == "copy"){ |
---|
81 | $arrForm["copy_product_id"] = $arrForm["product_id"]; |
---|
82 | $arrForm["product_id"] = ""; |
---|
83 | // 画像ファイルのコピー |
---|
84 | $arrKey = $objUpFile->keyname; |
---|
85 | $arrSaveFile = $objUpFile->save_file; |
---|
86 | |
---|
87 | foreach($arrSaveFile as $key => $val){ |
---|
88 | lfMakeScaleImage($arrKey[$key], $arrKey[$key], true); |
---|
89 | } |
---|
90 | } |
---|
91 | $objPage->arrForm = $arrForm; |
---|
92 | |
---|
93 | // 商品ステータスの変換 |
---|
94 | $arrRet = sfSplitCBValue($objPage->arrForm['product_flag'], "product_flag"); |
---|
95 | $objPage->arrForm = array_merge($objPage->arrForm, $arrRet); |
---|
96 | // DBからおすすめ商品の読み込み |
---|
97 | $objPage->arrRecommend = lfPreGetRecommendProducts($_POST['product_id']); |
---|
98 | |
---|
99 | // 規格登録ありなし判定 |
---|
100 | $objPage->tpl_nonclass = lfCheckNonClass($_POST['product_id']); |
---|
101 | lfProductPage(); // 商品登録ページ |
---|
102 | } |
---|
103 | break; |
---|
104 | // 商品登録・編集 |
---|
105 | case 'edit': |
---|
106 | // 規格登録ありなし判定 |
---|
107 | $tpl_nonclass = lfCheckNonClass($_POST['product_id']); |
---|
108 | |
---|
109 | if($_POST['product_id'] == "" and sfIsInt($_POST['copy_product_id'])){ |
---|
110 | $tpl_nonclass = lfCheckNonClass($_POST['copy_product_id']); |
---|
111 | } |
---|
112 | $objPage->tpl_nonclass = $tpl_nonclass; |
---|
113 | |
---|
114 | // 入力値の変換 |
---|
115 | $objPage->arrForm = lfConvertParam($objPage->arrForm); |
---|
116 | // エラーチェック |
---|
117 | $objPage->arrErr = lfErrorCheck($objPage->arrForm); |
---|
118 | // ファイル存在チェック |
---|
119 | $objPage->arrErr = array_merge((array)$objPage->arrErr, (array)$objUpFile->checkEXISTS()); |
---|
120 | // エラーなしの場合 |
---|
121 | if(count($objPage->arrErr) == 0) { |
---|
122 | lfProductConfirmPage(); // 確認ページ |
---|
123 | } else { |
---|
124 | lfProductPage(); // 商品登録ページ |
---|
125 | } |
---|
126 | break; |
---|
127 | // 確認ページから完了ページへ |
---|
128 | case 'complete': |
---|
129 | $objPage->tpl_mainpage = 'products/complete.tpl'; |
---|
130 | |
---|
131 | $objPage->tpl_product_id = lfRegistProduct($_POST); // データ登録 |
---|
132 | |
---|
133 | $objQuery = new SC_Query(); |
---|
134 | // 件数カウントバッチ実行 |
---|
135 | sfCategory_Count($objQuery); |
---|
136 | // 一時ファイルを本番ディレクトリに移動する |
---|
137 | $objUpFile->moveTempFile(); |
---|
138 | |
---|
139 | break; |
---|
140 | // 画像のアップロード |
---|
141 | case 'upload_image': |
---|
142 | // ファイル存在チェック |
---|
143 | $objPage->arrErr = array_merge((array)$objPage->arrErr, (array)$objUpFile->checkEXISTS($_POST['image_key'])); |
---|
144 | // 画像保存処理 |
---|
145 | $objPage->arrErr[$_POST['image_key']] = $objUpFile->makeTempFile($_POST['image_key']); |
---|
146 | |
---|
147 | // 中、小画像生成 |
---|
148 | lfSetScaleImage(); |
---|
149 | |
---|
150 | lfProductPage(); // 商品登録ページ |
---|
151 | break; |
---|
152 | // 画像の削除 |
---|
153 | case 'delete_image': |
---|
154 | $objUpFile->deleteFile($_POST['image_key']); |
---|
155 | lfProductPage(); // 商品登録ページ |
---|
156 | break; |
---|
157 | // 確認ページからの戻り |
---|
158 | case 'confirm_return': |
---|
159 | // 規格登録ありなし判定 |
---|
160 | $objPage->tpl_nonclass = lfCheckNonClass($_POST['product_id']); |
---|
161 | lfProductPage(); // 商品登録ページ |
---|
162 | break; |
---|
163 | // おすすめ商品選択 |
---|
164 | case 'recommend_select' : |
---|
165 | lfProductPage(); // 商品登録ページ |
---|
166 | break; |
---|
167 | default: |
---|
168 | // 公開・非公開のデフォルト値 |
---|
169 | $objPage->arrForm['status'] = DEFAULT_PRODUCT_DISP; |
---|
170 | lfProductPage(); // 商品登録ページ |
---|
171 | break; |
---|
172 | } |
---|
173 | |
---|
174 | if($_POST['mode'] != 'pre_edit') { |
---|
175 | // おすすめ商品の読み込み |
---|
176 | $objPage->arrRecommend = lfGetRecommendProducts(); |
---|
177 | } |
---|
178 | |
---|
179 | // 基本情報を渡す |
---|
180 | $objPage->arrInfo = $objSiteInfo->data; |
---|
181 | |
---|
182 | // サブ情報の入力があるかどうかチェックする |
---|
183 | $sub_find = false; |
---|
184 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
185 | if( $objPage->arrForm['sub_title'.$cnt] != "" || |
---|
186 | $objPage->arrForm['sub_comment'.$cnt] != "" || |
---|
187 | $objPage->arrForm['sub_image'.$cnt] != "" || |
---|
188 | $objPage->arrForm['sub_large_image'.$cnt] != "" || |
---|
189 | is_array($objPage->arrFile['sub_image'.$cnt]) || |
---|
190 | is_array($objPage->arrFile['sub_large_image'.$cnt])) { |
---|
191 | $sub_find = true; |
---|
192 | break; |
---|
193 | } |
---|
194 | } |
---|
195 | // サブ情報表示・非表示のチェックに使用する。 |
---|
196 | $objPage->sub_find = $sub_find; |
---|
197 | |
---|
198 | $objView->assignobj($objPage); |
---|
199 | $objView->display(MAIN_FRAME); |
---|
200 | //----------------------------------------------------------------------------------------------------------------------------- |
---|
201 | |
---|
202 | /* おすすめ商品の読み込み */ |
---|
203 | function lfGetRecommendProducts() { |
---|
204 | global $objPage; |
---|
205 | $objQuery = new SC_Query(); |
---|
206 | |
---|
207 | for($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) { |
---|
208 | $keyname = "recommend_id" . $i; |
---|
209 | $delkey = "recommend_delete" . $i; |
---|
210 | $commentkey = "recommend_comment" . $i; |
---|
211 | |
---|
212 | if($_POST[$keyname] != "" && $_POST[$delkey] != 1) { |
---|
213 | $arrRet = $objQuery->select("main_list_image, product_code_min, name", "vw_products_allclass AS allcls", "product_id = ?", array($_POST[$keyname])); |
---|
214 | $arrRecommend[$i] = $arrRet[0]; |
---|
215 | $arrRecommend[$i]['product_id'] = $_POST[$keyname]; |
---|
216 | $arrRecommend[$i]['comment'] = $objPage->arrForm[$commentkey]; |
---|
217 | } |
---|
218 | } |
---|
219 | return $arrRecommend; |
---|
220 | } |
---|
221 | |
---|
222 | /* おすすめ商品の登録 */ |
---|
223 | function lfInsertRecommendProducts($objQuery, $arrList, $product_id) { |
---|
224 | // 一旦オススメ商品をすべて削除する |
---|
225 | $objQuery->delete("dtb_recommend_products", "product_id = ?", array($product_id)); |
---|
226 | $sqlval['product_id'] = $product_id; |
---|
227 | $rank = RECOMMEND_PRODUCT_MAX; |
---|
228 | for($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) { |
---|
229 | $keyname = "recommend_id" . $i; |
---|
230 | $commentkey = "recommend_comment" . $i; |
---|
231 | $deletekey = "recommend_delete" . $i; |
---|
232 | if($arrList[$keyname] != "" && $arrList[$deletekey] != '1') { |
---|
233 | $sqlval['recommend_product_id'] = $arrList[$keyname]; |
---|
234 | $sqlval['comment'] = $arrList[$commentkey]; |
---|
235 | $sqlval['rank'] = $rank; |
---|
236 | $sqlval['creator_id'] = $_SESSION['member_id']; |
---|
237 | $sqlval['create_date'] = "now()"; |
---|
238 | $sqlval['update_date'] = "now()"; |
---|
239 | $objQuery->insert("dtb_recommend_products", $sqlval); |
---|
240 | $rank--; |
---|
241 | } |
---|
242 | } |
---|
243 | } |
---|
244 | |
---|
245 | /* 登録済みおすすめ商品の読み込み */ |
---|
246 | function lfPreGetRecommendProducts($product_id) { |
---|
247 | $objQuery = new SC_Query(); |
---|
248 | $objQuery->setorder("rank DESC"); |
---|
249 | $arrRet = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id)); |
---|
250 | $max = count($arrRet); |
---|
251 | $no = 1; |
---|
252 | |
---|
253 | for($i = 0; $i < $max; $i++) { |
---|
254 | $arrProductInfo = $objQuery->select("main_list_image, product_code_min, name", "vw_products_allclass AS allcls", "product_id = ?", array($arrRet[$i]['recommend_product_id'])); |
---|
255 | $arrRecommend[$no] = $arrProductInfo[0]; |
---|
256 | $arrRecommend[$no]['product_id'] = $arrRet[$i]['recommend_product_id']; |
---|
257 | $arrRecommend[$no]['comment'] = $arrRet[$i]['comment']; |
---|
258 | $no++; |
---|
259 | } |
---|
260 | return $arrRecommend; |
---|
261 | } |
---|
262 | |
---|
263 | /* 商品情報の読み込み */ |
---|
264 | function lfGetProduct($product_id) { |
---|
265 | $objQuery = new SC_Query(); |
---|
266 | $col = "*"; |
---|
267 | $table = "vw_products_nonclass AS noncls "; |
---|
268 | $where = "product_id = ?"; |
---|
269 | |
---|
270 | // viewも絞込み(mysql対応) |
---|
271 | sfViewWhere("&&noncls_where&&", $where, array($product_id)); |
---|
272 | |
---|
273 | $arrRet = $objQuery->select($col, $table, $where, array($product_id)); |
---|
274 | |
---|
275 | return $arrRet[0]; |
---|
276 | } |
---|
277 | |
---|
278 | /* 商品登録ページ表示用 */ |
---|
279 | function lfProductPage() { |
---|
280 | global $objPage; |
---|
281 | global $objUpFile; |
---|
282 | |
---|
283 | // カテゴリの読込 |
---|
284 | list($objPage->arrCatVal, $objPage->arrCatOut) = sfGetLevelCatList(false); |
---|
285 | |
---|
286 | if($objPage->arrForm['status'] == "") { |
---|
287 | $objPage->arrForm['status'] = 1; |
---|
288 | } |
---|
289 | |
---|
290 | if(!is_array($objPage->arrForm['product_flag'])) { |
---|
291 | // 商品ステータスの分割読込 |
---|
292 | $objPage->arrForm['product_flag'] = sfSplitCheckBoxes($objPage->arrForm['product_flag']); |
---|
293 | } |
---|
294 | |
---|
295 | // HIDDEN用に配列を渡す。 |
---|
296 | $objPage->arrHidden = array_merge((array)$objPage->arrHidden, (array)$objUpFile->getHiddenFileList()); |
---|
297 | // Form用配列を渡す。 |
---|
298 | $objPage->arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL); |
---|
299 | |
---|
300 | |
---|
301 | // アンカーを設定 |
---|
302 | if($_POST['image_key'] != ""){ |
---|
303 | $anchor_hash = "location.hash='#" . $_POST['image_key'] . "'"; |
---|
304 | }elseif($_POST['anchor_key'] != ""){ |
---|
305 | $anchor_hash = "location.hash='#" . $_POST['anchor_key'] . "'"; |
---|
306 | } |
---|
307 | |
---|
308 | $objPage->tpl_onload = "fnCheckSaleLimit('" . DISABLED_RGB . "'); fnCheckStockLimit('" . DISABLED_RGB . "'); " . $anchor_hash; |
---|
309 | } |
---|
310 | |
---|
311 | /* ファイル情報の初期化 */ |
---|
312 | function lfInitFile() { |
---|
313 | global $objUpFile; |
---|
314 | $objUpFile->addFile("一覧-メイン画像", 'main_list_image', array('jpg', 'gif', 'png'),IMAGE_SIZE, true, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); |
---|
315 | $objUpFile->addFile("詳細-メイン画像", 'main_image', array('jpg', 'gif', 'png'), IMAGE_SIZE, true, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT); |
---|
316 | $objUpFile->addFile("詳細-メイン拡大画像", 'main_large_image', array('jpg', 'gif', 'png'), IMAGE_SIZE, false, LARGE_IMAGE_WIDTH, LARGE_IMAGE_HEIGHT); |
---|
317 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
318 | $objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg', 'gif', 'png'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_WIDTH, NORMAL_SUBIMAGE_HEIGHT); |
---|
319 | $objUpFile->addFile("詳細-サブ拡大画像$cnt", "sub_large_image$cnt", array('jpg', 'gif', 'png'), IMAGE_SIZE, false, LARGE_SUBIMAGE_WIDTH, LARGE_SUBIMAGE_HEIGHT); |
---|
320 | } |
---|
321 | $objUpFile->addFile("商品比較画像", 'file1', array('jpg', 'gif', 'png'), IMAGE_SIZE, false, OTHER_IMAGE1_WIDTH, OTHER_IMAGE1_HEIGHT); |
---|
322 | $objUpFile->addFile("商品詳細ファイル", 'file2', array('pdf'), PDF_SIZE, false, 0, 0, false); |
---|
323 | } |
---|
324 | |
---|
325 | /* 商品の登録 */ |
---|
326 | function lfRegistProduct($arrList) { |
---|
327 | global $objUpFile; |
---|
328 | global $arrSTATUS; |
---|
329 | $objQuery = new SC_Query(); |
---|
330 | $objQuery->begin(); |
---|
331 | |
---|
332 | // INSERTする値を作成する。 |
---|
333 | $sqlval['name'] = $arrList['name']; |
---|
334 | $sqlval['category_id'] = $arrList['category_id']; |
---|
335 | $sqlval['status'] = $arrList['status']; |
---|
336 | $sqlval['product_flag'] = $arrList['product_flag']; |
---|
337 | $sqlval['main_list_comment'] = $arrList['main_list_comment']; |
---|
338 | $sqlval['main_comment'] = $arrList['main_comment']; |
---|
339 | $sqlval['point_rate'] = $arrList['point_rate']; |
---|
340 | $sqlval['deliv_fee'] = $arrList['deliv_fee']; |
---|
341 | $sqlval['comment1'] = $arrList['comment1']; |
---|
342 | $sqlval['comment2'] = $arrList['comment2']; |
---|
343 | $sqlval['comment3'] = $arrList['comment3']; |
---|
344 | $sqlval['comment4'] = $arrList['comment4']; |
---|
345 | $sqlval['comment5'] = $arrList['comment5']; |
---|
346 | $sqlval['comment6'] = $arrList['comment6']; |
---|
347 | $sqlval['main_list_comment'] = $arrList['main_list_comment']; |
---|
348 | $sqlval['sale_limit'] = $arrList['sale_limit']; |
---|
349 | $sqlval['sale_unlimited'] = $arrList['sale_unlimited']; |
---|
350 | $sqlval['deliv_date_id'] = $arrList['deliv_date_id']; |
---|
351 | $sqlval['update_date'] = "Now()"; |
---|
352 | $sqlval['creator_id'] = $_SESSION['member_id']; |
---|
353 | $arrRet = $objUpFile->getDBFileList(); |
---|
354 | $sqlval = array_merge($sqlval, $arrRet); |
---|
355 | |
---|
356 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
357 | $sqlval['sub_title'.$cnt] = $arrList['sub_title'.$cnt]; |
---|
358 | $sqlval['sub_comment'.$cnt] = $arrList['sub_comment'.$cnt]; |
---|
359 | } |
---|
360 | |
---|
361 | if($arrList['product_id'] == "") { |
---|
362 | if (DB_TYPE == "pgsql") { |
---|
363 | $product_id = $objQuery->nextval("dtb_products", "product_id"); |
---|
364 | $sqlval['product_id'] = $product_id; |
---|
365 | } |
---|
366 | // カテゴリ内で最大のランクを割り当てる |
---|
367 | $sqlval['rank'] = $objQuery->max("dtb_products", "rank", "category_id = ?", array($arrList['category_id'])) + 1; |
---|
368 | // INSERTの実行 |
---|
369 | $sqlval['create_date'] = "Now()"; |
---|
370 | $objQuery->insert("dtb_products", $sqlval); |
---|
371 | |
---|
372 | if (DB_TYPE == "mysql") { |
---|
373 | $product_id = $objQuery->nextval("dtb_products", "product_id"); |
---|
374 | $sqlval['product_id'] = $product_id; |
---|
375 | } |
---|
376 | |
---|
377 | // コピー商品の場合には規格もコピーする |
---|
378 | if($_POST["copy_product_id"] != "" and sfIsInt($_POST["copy_product_id"])){ |
---|
379 | // dtb_products_class のカラムを取得 |
---|
380 | $arrColList = sfGetColumnList("dtb_products_class", $objQuery); |
---|
381 | $arrColList_tmp = array_flip($arrColList); |
---|
382 | |
---|
383 | // コピーしない列 |
---|
384 | unset($arrColList[$arrColList_tmp["product_class_id"]]); //規格ID |
---|
385 | unset($arrColList[$arrColList_tmp["product_id"]]); //商品ID |
---|
386 | |
---|
387 | $col = sfGetCommaList($arrColList); |
---|
388 | |
---|
389 | $objQuery->query("INSERT INTO dtb_products_class (product_id, ". $col .") SELECT ?, " . $col. " FROM dtb_products_class WHERE product_id = ? ORDER BY product_class_id", array($product_id, $_POST["copy_product_id"])); |
---|
390 | |
---|
391 | } |
---|
392 | |
---|
393 | } else { |
---|
394 | $product_id = $arrList['product_id']; |
---|
395 | // 削除要求のあった既存ファイルの削除 |
---|
396 | $arrRet = lfGetProduct($arrList['product_id']); |
---|
397 | $objUpFile->deleteDBFile($arrRet); |
---|
398 | |
---|
399 | // カテゴリ内ランクの調整処理 |
---|
400 | $old_catid = $objQuery->get("dtb_products", "category_id", "product_id = ?", array($arrList['product_id'])); |
---|
401 | sfMoveCatRank($objQuery, "dtb_products", "product_id", "category_id", $old_catid, $arrList['category_id'], $arrList['product_id']); |
---|
402 | |
---|
403 | // UPDATEの実行 |
---|
404 | $where = "product_id = ?"; |
---|
405 | $objQuery->update("dtb_products", $sqlval, $where, array($arrList['product_id'])); |
---|
406 | } |
---|
407 | |
---|
408 | // 規格登録 |
---|
409 | sfInsertProductClass($objQuery, $arrList, $product_id); |
---|
410 | |
---|
411 | // おすすめ商品登録 |
---|
412 | lfInsertRecommendProducts($objQuery, $arrList, $product_id); |
---|
413 | |
---|
414 | $objQuery->commit(); |
---|
415 | return $product_id; |
---|
416 | } |
---|
417 | |
---|
418 | |
---|
419 | /* 取得文字列の変換 */ |
---|
420 | function lfConvertParam($array) { |
---|
421 | /* |
---|
422 | * 文字列の変換 |
---|
423 | * K : 「半角(ハンカク)片仮名」を「全角片仮名」に変換 |
---|
424 | * C : 「全角ひら仮名」を「全角かた仮名」に変換 |
---|
425 | * V : 濁点付きの文字を一文字に変換。"K","H"と共に使用します |
---|
426 | * n : 「全角」数字を「半角(ハンカク)」に変換 |
---|
427 | */ |
---|
428 | // 人物基本情報 |
---|
429 | |
---|
430 | // スポット商品 |
---|
431 | $arrConvList['name'] = "KVa"; |
---|
432 | $arrConvList['main_list_comment'] = "KVa"; |
---|
433 | $arrConvList['main_comment'] = "KVa"; |
---|
434 | $arrConvList['price01'] = "n"; |
---|
435 | $arrConvList['price02'] = "n"; |
---|
436 | $arrConvList['stock'] = "n"; |
---|
437 | $arrConvList['sale_limit'] = "n"; |
---|
438 | $arrConvList['point_rate'] = "n"; |
---|
439 | $arrConvList['product_code'] = "KVna"; |
---|
440 | $arrConvList['comment1'] = "a"; |
---|
441 | //ホネケーキ:送料の指定なし |
---|
442 | $arrConvList['deliv_fee'] = "n"; |
---|
443 | |
---|
444 | // 詳細-サブ |
---|
445 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
446 | $arrConvList["sub_title$cnt"] = "KVa"; |
---|
447 | } |
---|
448 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
449 | $arrConvList["sub_comment$cnt"] = "KVa"; |
---|
450 | } |
---|
451 | |
---|
452 | // おすすめ商品 |
---|
453 | for ($cnt = 1; $cnt <= RECOMMEND_PRODUCT_MAX; $cnt++) { |
---|
454 | $arrConvList["recommend_comment$cnt"] = "KVa"; |
---|
455 | } |
---|
456 | |
---|
457 | // 文字変換 |
---|
458 | foreach ($arrConvList as $key => $val) { |
---|
459 | // POSTされてきた値のみ変換する。 |
---|
460 | if(isset($array[$key])) { |
---|
461 | $array[$key] = mb_convert_kana($array[$key] ,$val); |
---|
462 | } |
---|
463 | } |
---|
464 | |
---|
465 | global $arrSTATUS; |
---|
466 | $array['product_flag'] = sfMergeCheckBoxes($array['product_flag'], count($arrSTATUS)); |
---|
467 | |
---|
468 | return $array; |
---|
469 | } |
---|
470 | |
---|
471 | // 入力エラーチェック |
---|
472 | function lfErrorCheck($array) { |
---|
473 | global $objPage; |
---|
474 | global $arrAllowedTag; |
---|
475 | |
---|
476 | $objErr = new SC_CheckError($array); |
---|
477 | $objErr->doFunc(array("商品名", "name", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
478 | $objErr->doFunc(array("商品カテゴリ", "category_id", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
479 | $objErr->doFunc(array("一覧-メインコメント", "main_list_comment", MTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
480 | $objErr->doFunc(array("詳細-メインコメント", "main_comment", LLTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
481 | $objErr->doFunc(array("詳細-メインコメント", "main_comment", $arrAllowedTag), array("HTML_TAG_CHECK")); |
---|
482 | $objErr->doFunc(array("ポイント付与率", "point_rate", PERCENTAGE_LEN), array("EXIST_CHECK", "NUM_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
483 | $objErr->doFunc(array("商品送料", "deliv_fee", PRICE_LEN), array("NUM_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
484 | $objErr->doFunc(array("検索ワード", "comment3", LLTEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
485 | $objErr->doFunc(array("メーカーURL", "comment1", URL_LEN), array("SPTAB_CHECK", "URL_CHECK", "MAX_LENGTH_CHECK")); |
---|
486 | $objErr->doFunc(array("発送日目安", "deliv_date_id", INT_LEN), array("NUM_CHECK")); |
---|
487 | |
---|
488 | if($objPage->tpl_nonclass) { |
---|
489 | $objErr->doFunc(array("商品コード", "product_code", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK","MAX_LENGTH_CHECK","MAX_LENGTH_CHECK")); |
---|
490 | $objErr->doFunc(array("通常価格", "price01", PRICE_LEN), array("ZERO_CHECK", "SPTAB_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
491 | $objErr->doFunc(array("商品価格", "price02", PRICE_LEN), array("EXIST_CHECK", "NUM_CHECK", "ZERO_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
492 | |
---|
493 | if($array['stock_unlimited'] != "1") { |
---|
494 | $objErr->doFunc(array("在庫数", "stock", AMOUNT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
495 | } |
---|
496 | } |
---|
497 | |
---|
498 | if($array['sale_unlimited'] != "1") { |
---|
499 | $objErr->doFunc(array("購入制限", "sale_limit", AMOUNT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
500 | } |
---|
501 | |
---|
502 | if(isset($objErr->arrErr['category_id'])) { |
---|
503 | // 自動選択を防ぐためにダミー文字を入れておく |
---|
504 | $objPage->arrForm['category_id'] = "#"; |
---|
505 | } |
---|
506 | |
---|
507 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
508 | $objErr->doFunc(array("詳細-サブタイトル$cnt", "sub_title$cnt", STEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
509 | $objErr->doFunc(array("詳細-サブコメント$cnt", "sub_comment$cnt", LLTEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
510 | $objErr->doFunc(array("詳細-サブコメント$cnt", "sub_comment$cnt", $arrAllowedTag), array("HTML_TAG_CHECK")); |
---|
511 | } |
---|
512 | |
---|
513 | for ($cnt = 1; $cnt <= RECOMMEND_PRODUCT_MAX; $cnt++) { |
---|
514 | if($_POST["recommend_id$cnt"] != "" && $_POST["recommend_delete$cnt"] != 1) { |
---|
515 | $objErr->doFunc(array("おすすめ商品コメント$cnt", "recommend_comment$cnt", LTEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
516 | } |
---|
517 | } |
---|
518 | |
---|
519 | return $objErr->arrErr; |
---|
520 | } |
---|
521 | |
---|
522 | /* 確認ページ表示用 */ |
---|
523 | function lfProductConfirmPage() { |
---|
524 | global $objPage; |
---|
525 | global $objUpFile; |
---|
526 | $objPage->tpl_mainpage = 'products/confirm.tpl'; |
---|
527 | $objPage->arrForm['mode'] = 'complete'; |
---|
528 | // カテゴリの読込 |
---|
529 | $objPage->arrCatList = sfGetCategoryList(); |
---|
530 | // Form用配列を渡す。 |
---|
531 | $objPage->arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL); |
---|
532 | } |
---|
533 | |
---|
534 | /* 規格あり判定用(規格が登録されていない場合:TRUE) */ |
---|
535 | function lfCheckNonClass($product_id) { |
---|
536 | if(sfIsInt($product_id)) { |
---|
537 | $objQuery = new SC_Query(); |
---|
538 | $where = "product_id = ? AND classcategory_id1 <> 0 AND classcategory_id1 <> 0"; |
---|
539 | $count = $objQuery->count("dtb_products_class", $where, array($product_id)); |
---|
540 | if($count > 0) { |
---|
541 | return false; |
---|
542 | } |
---|
543 | } |
---|
544 | return true; |
---|
545 | } |
---|
546 | |
---|
547 | // 縮小した画像をセットする |
---|
548 | function lfSetScaleImage(){ |
---|
549 | |
---|
550 | $subno = str_replace("sub_large_image", "", $_POST['image_key']); |
---|
551 | switch ($_POST['image_key']){ |
---|
552 | case "main_large_image": |
---|
553 | // 詳細メイン画像 |
---|
554 | lfMakeScaleImage($_POST['image_key'], "main_image"); |
---|
555 | case "main_image": |
---|
556 | // 一覧メイン画像 |
---|
557 | lfMakeScaleImage($_POST['image_key'], "main_list_image"); |
---|
558 | break; |
---|
559 | case "sub_large_image" . $subno: |
---|
560 | // サブメイン画像 |
---|
561 | lfMakeScaleImage($_POST['image_key'], "sub_image" . $subno); |
---|
562 | break; |
---|
563 | default: |
---|
564 | break; |
---|
565 | } |
---|
566 | } |
---|
567 | |
---|
568 | // 縮小画像生成 |
---|
569 | function lfMakeScaleImage($from_key, $to_key, $forced = false){ |
---|
570 | global $objUpFile; |
---|
571 | $arrImageKey = array_flip($objUpFile->keyname); |
---|
572 | |
---|
573 | if($objUpFile->temp_file[$arrImageKey[$from_key]]){ |
---|
574 | $from_path = $objUpFile->temp_dir . $objUpFile->temp_file[$arrImageKey[$from_key]]; |
---|
575 | }elseif($objUpFile->save_file[$arrImageKey[$from_key]]){ |
---|
576 | $from_path = $objUpFile->save_dir . $objUpFile->save_file[$arrImageKey[$from_key]]; |
---|
577 | }else{ |
---|
578 | return ""; |
---|
579 | } |
---|
580 | |
---|
581 | if(file_exists($from_path)){ |
---|
582 | // 元画像サイズを取得 |
---|
583 | list($from_w, $from_h) = getimagesize($from_path); |
---|
584 | |
---|
585 | // 生成先の画像サイズを取得 |
---|
586 | $to_w = $objUpFile->width[$arrImageKey[$to_key]]; |
---|
587 | $to_h = $objUpFile->height[$arrImageKey[$to_key]]; |
---|
588 | |
---|
589 | |
---|
590 | if($forced) $objUpFile->save_file[$arrImageKey[$to_key]] = ""; |
---|
591 | |
---|
592 | if(($objUpFile->temp_file[$arrImageKey[$to_key]] == "" and $objUpFile->save_file[$arrImageKey[$to_key]] == "")){ |
---|
593 | $path = $objUpFile->makeThumb($from_path, $to_w, $to_h); |
---|
594 | $objUpFile->temp_file[$arrImageKey[$to_key]] = basename($path); |
---|
595 | } |
---|
596 | }else{ |
---|
597 | return ""; |
---|
598 | } |
---|
599 | } |
---|
600 | |
---|
601 | ?> |
---|