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

Revision 15342, 27.5 KB checked in by nanasess, 17 years ago (diff)

クラス化対応

  • Property svn:keywords set to Id Revision Date
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 = 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[$keyname]) && !empty($_POST[$keyname])) && $_POST[$delkey] != 1) {
251                $arrRet = $objQuery->select("main_list_image, product_code_min, name", "vw_products_allclass AS allcls", "product_id = ?", array($_POST[$keyname]));
252                $arrRecommend[$i] = $arrRet[0];
253                $arrRecommend[$i]['product_id'] = $_POST[$keyname];
254                $arrRecommend[$i]['comment'] = $this->arrForm[$commentkey];
255            }
256        }
257        return $arrRecommend;
258    }
259
260    /* おすすめ商品の登録 */
261    function lfInsertRecommendProducts($objQuery, $arrList, $product_id) {
262        // 一旦オススメ商品をすべて削除する
263        $objQuery->delete("dtb_recommend_products", "product_id = ?", array($product_id));
264        $sqlval['product_id'] = $product_id;
265        $rank = RECOMMEND_PRODUCT_MAX;
266        for($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) {
267            $keyname = "recommend_id" . $i;
268            $commentkey = "recommend_comment" . $i;
269            $deletekey = "recommend_delete" . $i;
270            if($arrList[$keyname] != "" && $arrList[$deletekey] != '1') {
271                $sqlval['recommend_product_id'] = $arrList[$keyname];
272                $sqlval['comment'] = $arrList[$commentkey];
273                $sqlval['rank'] = $rank;
274                $sqlval['creator_id'] = $_SESSION['member_id'];
275                $sqlval['create_date'] = "now()";
276                $sqlval['update_date'] = "now()";
277                $objQuery->insert("dtb_recommend_products", $sqlval);
278                $rank--;
279            }
280        }
281    }
282
283    /* 登録済みおすすめ商品の読み込み */
284    function lfPreGetRecommendProducts($product_id) {
285        $objQuery = new SC_Query();
286        $objQuery->setorder("rank DESC");
287        $arrRet = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id));
288        $max = count($arrRet);
289        $no = 1;
290
291        for($i = 0; $i < $max; $i++) {
292            $arrProductInfo = $objQuery->select("main_list_image, product_code_min, name", "vw_products_allclass AS allcls", "product_id = ?", array($arrRet[$i]['recommend_product_id']));
293            $arrRecommend[$no] = $arrProductInfo[0];
294            $arrRecommend[$no]['product_id'] = $arrRet[$i]['recommend_product_id'];
295            $arrRecommend[$no]['comment'] = $arrRet[$i]['comment'];
296            $no++;
297        }
298        return $arrRecommend;
299    }
300
301    /* 商品情報の読み込み */
302    function lfGetProduct($product_id) {
303        $objQuery = new SC_Query();
304        $col = "*";
305        $table = "vw_products_nonclass AS noncls ";
306        $where = "product_id = ?";
307
308        // viewも絞込み(mysql対応) TODO
309        //sfViewWhere("&&noncls_where&&", $where, array($product_id));
310
311        $arrRet = $objQuery->select($col, $table, $where, array($product_id));
312
313        return $arrRet[0];
314    }
315
316    /* 商品登録ページ表示用 */
317    function lfProductPage() {
318        $objDb = new SC_Helper_DB_Ex();
319
320        // カテゴリの読込
321        list($this->arrCatVal, $this->arrCatOut) = $objDb->sfGetLevelCatList(false);
322
323        if($this->arrForm['status'] == "") {
324            $this->arrForm['status'] = 1;
325        }
326
327        if(isset($this->arrForm['product_flag']) && !is_array($this->arrForm['product_flag'])) {
328            // 商品ステータスの分割読込
329            $this->arrForm['product_flag'] = SC_Utils_Ex::sfSplitCheckBoxes($this->arrForm['product_flag']);
330        }
331
332        // HIDDEN用に配列を渡す。
333        $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objUpFile->getHiddenFileList());
334        // Form用配列を渡す。
335        $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL);
336
337
338        // アンカーを設定
339        if (isset($_POST['image_key']) && !empty($_POST['image_key'])) {
340            $anchor_hash = "location.hash='#" . $_POST['image_key'] . "'";
341        } elseif (isset($_POST['anchor_key']) && !empty($_POST['anchor_key'])) {
342            $anchor_hash = "location.hash='#" . $_POST['anchor_key'] . "'";
343        } else {
344            $anchor_hash = "";
345        }
346
347        $this->tpl_onload = "fnCheckSaleLimit('" . DISABLED_RGB . "'); fnCheckStockLimit('" . DISABLED_RGB . "'); " . $anchor_hash;
348    }
349
350    /* ファイル情報の初期化 */
351    function lfInitFile() {
352        $this->objUpFile->addFile("一覧-メイン画像", 'main_list_image', array('jpg', 'gif', 'png'),IMAGE_SIZE, true, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
353        $this->objUpFile->addFile("詳細-メイン画像", 'main_image', array('jpg', 'gif', 'png'), IMAGE_SIZE, true, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT);
354        $this->objUpFile->addFile("詳細-メイン拡大画像", 'main_large_image', array('jpg', 'gif', 'png'), IMAGE_SIZE, false, LARGE_IMAGE_WIDTH, LARGE_IMAGE_HEIGHT);
355        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
356            $this->objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg', 'gif', 'png'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_WIDTH, NORMAL_SUBIMAGE_HEIGHT);
357            $this->objUpFile->addFile("詳細-サブ拡大画像$cnt", "sub_large_image$cnt", array('jpg', 'gif', 'png'), IMAGE_SIZE, false, LARGE_SUBIMAGE_WIDTH, LARGE_SUBIMAGE_HEIGHT);
358        }
359        $this->objUpFile->addFile("商品比較画像", 'file1', array('jpg', 'gif', 'png'), IMAGE_SIZE, false, OTHER_IMAGE1_WIDTH, OTHER_IMAGE1_HEIGHT);
360        $this->objUpFile->addFile("商品詳細ファイル", 'file2', array('pdf'), PDF_SIZE, false, 0, 0, false);
361    }
362
363    /* 商品の登録 */
364    function lfRegistProduct($arrList) {
365        $objQuery = new SC_Query();
366        $objDb = new SC_Helper_DB_Ex();
367        $objQuery->begin();
368
369        // 配列の添字を定義
370        $checkArray = array("name", "category_id", "status", "product_flag",
371                            "main_list_comment", "main_comment", "point_rate",
372                            "deliv_fee", "comment1", "comment2", "comment3",
373                            "comment4", "comment5", "comment6", "main_list_comment",
374                            "sale_limit", "sale_unlimited", "deliv_date_id");
375        $arrList = SC_Utils_Ex::arrayDefineIndexes($arrList, $checkArray);
376
377        // INSERTする値を作成する。
378        $sqlval['name'] = $arrList['name'];
379        $sqlval['category_id'] = $arrList['category_id'];
380        $sqlval['status'] = $arrList['status'];
381        $sqlval['product_flag'] = $arrList['product_flag'];
382        $sqlval['main_list_comment'] = $arrList['main_list_comment'];
383        $sqlval['main_comment'] = $arrList['main_comment'];
384        $sqlval['point_rate'] = $arrList['point_rate'];
385        $sqlval['deliv_fee'] = $arrList['deliv_fee'];
386        $sqlval['comment1'] = $arrList['comment1'];
387        $sqlval['comment2'] = $arrList['comment2'];
388        $sqlval['comment3'] = $arrList['comment3'];
389        $sqlval['comment4'] = $arrList['comment4'];
390        $sqlval['comment5'] = $arrList['comment5'];
391        $sqlval['comment6'] = $arrList['comment6'];
392        $sqlval['main_list_comment'] = $arrList['main_list_comment'];
393        $sqlval['sale_limit'] = $arrList['sale_limit'];
394        $sqlval['sale_unlimited'] = $arrList['sale_unlimited'];
395        $sqlval['deliv_date_id'] = $arrList['deliv_date_id'];
396        $sqlval['update_date'] = "Now()";
397        $sqlval['creator_id'] = $_SESSION['member_id'];
398        $arrRet = $this->objUpFile->getDBFileList();
399        $sqlval = array_merge($sqlval, $arrRet);
400
401        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
402            $sqlval['sub_title'.$cnt] = $arrList['sub_title'.$cnt];
403            $sqlval['sub_comment'.$cnt] = $arrList['sub_comment'.$cnt];
404        }
405
406        if($arrList['product_id'] == "") {
407            if (DB_TYPE == "pgsql") {
408                $product_id = $objQuery->nextval("dtb_products", "product_id");
409                $sqlval['product_id'] = $product_id;
410            }
411            // カテゴリ内で最大のランクを割り当てる
412            $sqlval['rank'] = $objQuery->max("dtb_products", "rank", "category_id = ?", array($arrList['category_id'])) + 1;
413            // INSERTの実行
414            $sqlval['create_date'] = "Now()";
415            $objQuery->insert("dtb_products", $sqlval);
416
417            if (DB_TYPE == "mysql") {
418                $product_id = $objQuery->nextval("dtb_products", "product_id");
419                $sqlval['product_id'] = $product_id;
420            }
421
422            // コピー商品の場合には規格もコピーする
423            if($_POST["copy_product_id"] != "" and sfIsInt($_POST["copy_product_id"])){
424                // dtb_products_class のカラムを取得
425                $dbFactory = SC_DB_DBFactory::getInstance();
426                $arrColList = $dbFactory->sfGetColumnList("dtb_products_class", $objQuery);
427                $arrColList_tmp = array_flip($arrColList);
428
429                // コピーしない列
430                unset($arrColList[$arrColList_tmp["product_class_id"]]);     //規格ID
431                unset($arrColList[$arrColList_tmp["product_id"]]);           //商品ID
432
433                $col = SC_Utils_Ex::sfGetCommaList($arrColList);
434
435                $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"]));
436
437            }
438
439        } else {
440            $product_id = $arrList['product_id'];
441            // 削除要求のあった既存ファイルの削除
442            $arrRet = lfGetProduct($arrList['product_id']);
443            $this->objUpFile->deleteDBFile($arrRet);
444
445            // カテゴリ内ランクの調整処理
446            $old_catid = $objQuery->get("dtb_products", "category_id", "product_id = ?", array($arrList['product_id']));
447            sfMoveCatRank($objQuery, "dtb_products", "product_id", "category_id", $old_catid, $arrList['category_id'], $arrList['product_id']);
448
449            // UPDATEの実行
450            $where = "product_id = ?";
451            $objQuery->update("dtb_products", $sqlval, $where, array($arrList['product_id']));
452        }
453
454        // 規格登録
455        SC_Utils_Ex::sfInsertProductClass($objQuery, $arrList, $product_id);
456
457        // おすすめ商品登録
458        $this->lfInsertRecommendProducts($objQuery, $arrList, $product_id);
459
460        $objQuery->commit();
461        return $product_id;
462    }
463
464
465    /* 取得文字列の変換 */
466    function lfConvertParam($array) {
467        /*
468         *  文字列の変換
469         *  K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
470         *  C :  「全角ひら仮名」を「全角かた仮名」に変換
471         *  V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
472         *  n :  「全角」数字を「半角(ハンカク)」に変換
473         */
474        // 人物基本情報
475
476        // スポット商品
477        $arrConvList['name'] = "KVa";
478        $arrConvList['main_list_comment'] = "KVa";
479        $arrConvList['main_comment'] = "KVa";
480        $arrConvList['price01'] = "n";
481        $arrConvList['price02'] = "n";
482        $arrConvList['stock'] = "n";
483        $arrConvList['sale_limit'] = "n";
484        $arrConvList['point_rate'] = "n";
485        $arrConvList['product_code'] = "KVna";
486        $arrConvList['comment1'] = "a";
487        //ホネケーキ:送料の指定なし
488        $arrConvList['deliv_fee'] = "n";
489
490        // 詳細-サブ
491        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
492            $arrConvList["sub_title$cnt"] = "KVa";
493        }
494        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
495            $arrConvList["sub_comment$cnt"] = "KVa";
496        }
497
498        // おすすめ商品
499        for ($cnt = 1; $cnt <= RECOMMEND_PRODUCT_MAX; $cnt++) {
500            $arrConvList["recommend_comment$cnt"] = "KVa";
501        }
502
503        // 文字変換
504        foreach ($arrConvList as $key => $val) {
505            // POSTされてきた値のみ変換する。
506            if(isset($array[$key])) {
507                $array[$key] = mb_convert_kana($array[$key] ,$val);
508            }
509        }
510
511        if (!isset($array['product_flag'])) $array['product_flag'] = "";
512        $array['product_flag'] = SC_Utils_Ex::sfMergeCheckBoxes($array['product_flag'], count($this->arrSTATUS));
513
514        return $array;
515    }
516
517    // 入力エラーチェック
518    function lfErrorCheck($array) {
519
520        $objErr = new SC_CheckError($array);
521        $objErr->doFunc(array("商品名", "name", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
522        $objErr->doFunc(array("商品カテゴリ", "category_id", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
523        $objErr->doFunc(array("一覧-メインコメント", "main_list_comment", MTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
524        $objErr->doFunc(array("詳細-メインコメント", "main_comment", LLTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
525        $objErr->doFunc(array("詳細-メインコメント", "main_comment", $this->arrAllowedTag), array("HTML_TAG_CHECK"));
526        $objErr->doFunc(array("ポイント付与率", "point_rate", PERCENTAGE_LEN), array("EXIST_CHECK", "NUM_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
527        $objErr->doFunc(array("商品送料", "deliv_fee", PRICE_LEN), array("NUM_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
528        $objErr->doFunc(array("検索ワード", "comment3", LLTEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
529        $objErr->doFunc(array("メーカーURL", "comment1", URL_LEN), array("SPTAB_CHECK", "URL_CHECK", "MAX_LENGTH_CHECK"));
530        $objErr->doFunc(array("発送日目安", "deliv_date_id", INT_LEN), array("NUM_CHECK"));
531
532        if($this->tpl_nonclass) {
533            $objErr->doFunc(array("商品コード", "product_code", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK","MAX_LENGTH_CHECK","MAX_LENGTH_CHECK"));
534            $objErr->doFunc(array("通常価格", "price01", PRICE_LEN), array("ZERO_CHECK", "SPTAB_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
535            $objErr->doFunc(array("商品価格", "price02", PRICE_LEN), array("EXIST_CHECK", "NUM_CHECK", "ZERO_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
536
537            if(isset($array['stock_unlinited']) && $array['stock_unlimited'] != "1") {
538                $objErr->doFunc(array("在庫数", "stock", AMOUNT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
539            }
540        }
541
542        if(isset($array['sale_unlimited']) && $array['sale_unlimited'] != "1") {
543            $objErr->doFunc(array("購入制限", "sale_limit", AMOUNT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
544        }
545
546        if(isset($objErr->arrErr['category_id'])) {
547            // 自動選択を防ぐためにダミー文字を入れておく
548            $this->arrForm['category_id'] = "#";
549        }
550
551        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
552            $objErr->doFunc(array("詳細-サブタイトル$cnt", "sub_title$cnt", STEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
553            $objErr->doFunc(array("詳細-サブコメント$cnt", "sub_comment$cnt", LLTEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
554            $objErr->doFunc(array("詳細-サブコメント$cnt", "sub_comment$cnt", $this->arrAllowedTag),  array("HTML_TAG_CHECK"));
555        }
556
557        for ($cnt = 1; $cnt <= RECOMMEND_PRODUCT_MAX; $cnt++) {
558            if($_POST["recommend_id$cnt"] != "" && $_POST["recommend_delete$cnt"] != 1) {
559                $objErr->doFunc(array("おすすめ商品コメント$cnt", "recommend_comment$cnt", LTEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
560            }
561        }
562
563        return $objErr->arrErr;
564    }
565
566    /* 確認ページ表示用 */
567    function lfProductConfirmPage() {
568        $this->tpl_mainpage = 'products/confirm.tpl';
569        $this->arrForm['mode'] = 'complete';
570        $objDb = new SC_Helper_DB_Ex();
571        // カテゴリの読込
572        $this->arrCatList = $objDb->sfGetCategoryList();
573        // Form用配列を渡す。
574        $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL);
575    }
576
577    /* 規格あり判定用(規格が登録されていない場合:TRUE) */
578    function lfCheckNonClass($product_id) {
579        if(SC_Utils_Ex::sfIsInt($product_id)) {
580            $objQuery  = new SC_Query();
581            $where = "product_id = ? AND classcategory_id1 <> 0 AND classcategory_id1 <> 0";
582            $count = $objQuery->count("dtb_products_class", $where, array($product_id));
583            if($count > 0) {
584                return false;
585            }
586        }
587        return true;
588    }
589
590    // 縮小した画像をセットする
591    function lfSetScaleImage(){
592
593        $subno = str_replace("sub_large_image", "", $_POST['image_key']);
594        switch ($_POST['image_key']){
595            case "main_large_image":
596                // 詳細メイン画像
597                $this->lfMakeScaleImage($_POST['image_key'], "main_image");
598            case "main_image":
599                // 一覧メイン画像
600                $this->lfMakeScaleImage($_POST['image_key'], "main_list_image");
601                break;
602            case "sub_large_image" . $subno:
603                // サブメイン画像
604                $this->lfMakeScaleImage($_POST['image_key'], "sub_image" . $subno);
605                break;
606            default:
607                break;
608        }
609    }
610
611    // 縮小画像生成
612    function lfMakeScaleImage($from_key, $to_key, $forced = false){
613        $arrImageKey = array_flip($this->objUpFile->keyname);
614
615        if($this->objUpFile->temp_file[$arrImageKey[$from_key]]){
616            $from_path = $this->objUpFile->temp_dir . $this->objUpFile->temp_file[$arrImageKey[$from_key]];
617        }elseif($this->objUpFile->save_file[$arrImageKey[$from_key]]){
618            $from_path = $this->objUpFile->save_dir . $this->objUpFile->save_file[$arrImageKey[$from_key]];
619        }else{
620            return "";
621        }
622
623        if(file_exists($from_path)){
624            // 元画像サイズを取得
625            list($from_w, $from_h) = getimagesize($from_path);
626
627            // 生成先の画像サイズを取得
628            $to_w = $this->objUpFile->width[$arrImageKey[$to_key]];
629            $to_h = $this->objUpFile->height[$arrImageKey[$to_key]];
630
631
632            if($forced) $this->objUpFile->save_file[$arrImageKey[$to_key]] = "";
633
634            if((isset($this->objUpFile->temp_file[$arrImageKey[$to_key]])
635                   && $this->objUpFile->temp_file[$arrImageKey[$to_key]] == ""
636                and isset($this->objUpFile->save_file[$arrImageKey[$to_key]])
637                       && $this->objUpFile->save_file[$arrImageKey[$to_key]] == "")) {
638
639                $path = $this->objUpFile->makeThumb($from_path, $to_w, $to_h);
640                $this->objUpFile->temp_file[$arrImageKey[$to_key]] = basename($path);
641            }
642        }else{
643            return "";
644        }
645    }
646}
647?>
Note: See TracBrowser for help on using the repository browser.