source: branches/feature-module-update/data/class/pages/admin/products/LC_Page_Admin_Products_Product.php @ 15556

Revision 15556, 27.9 KB checked in by nanasess, 17 years ago (diff)

未定義変数の修正

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