[15342] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[18701] | 5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
[15342] | 6 | * |
---|
| 7 | * http://www.lockon.co.jp/ |
---|
[16582] | 8 | * |
---|
| 9 | * This program is free software; you can redistribute it and/or |
---|
| 10 | * modify it under the terms of the GNU General Public License |
---|
| 11 | * as published by the Free Software Foundation; either version 2 |
---|
| 12 | * of the License, or (at your option) any later version. |
---|
| 13 | * |
---|
| 14 | * This program is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this program; if not, write to the Free Software |
---|
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
[15342] | 22 | */ |
---|
| 23 | |
---|
| 24 | // {{{ requires |
---|
| 25 | require_once(CLASS_PATH . "pages/LC_Page.php"); |
---|
| 26 | |
---|
| 27 | /** |
---|
[17840] | 28 | * 商品登録 のページクラス |
---|
[15342] | 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author LOCKON CO.,LTD. |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
| 34 | class LC_Page_Admin_Products_Product extends LC_Page { |
---|
| 35 | |
---|
[17902] | 36 | // {{{ properties |
---|
[15342] | 37 | |
---|
[17902] | 38 | /** ファイル管理クラスのインスタンス */ |
---|
| 39 | var $objUpFile; |
---|
[15342] | 40 | |
---|
[18777] | 41 | /** ダウンロード用ファイル管理クラスのインスタンス */ |
---|
| 42 | var $objDownFile; |
---|
| 43 | |
---|
[17902] | 44 | /** hidden 項目の配列 */ |
---|
| 45 | var $arrHidden; |
---|
[15342] | 46 | |
---|
[17902] | 47 | /** エラー情報 */ |
---|
| 48 | var $arrErr; |
---|
[15342] | 49 | |
---|
[17902] | 50 | // }}} |
---|
| 51 | // {{{ functions |
---|
[15342] | 52 | |
---|
[17902] | 53 | /** |
---|
| 54 | * Page を初期化する. |
---|
| 55 | * |
---|
| 56 | * @return void |
---|
| 57 | */ |
---|
| 58 | function init() { |
---|
| 59 | parent::init(); |
---|
| 60 | $this->tpl_mainpage = 'products/product.tpl'; |
---|
| 61 | $this->tpl_subnavi = 'products/subnavi.tpl'; |
---|
| 62 | $this->tpl_mainno = 'products'; |
---|
| 63 | $this->tpl_subno = 'product'; |
---|
| 64 | $this->tpl_subtitle = '商品登録'; |
---|
| 65 | $this->arrErr = array(); |
---|
[15342] | 66 | |
---|
[17902] | 67 | $masterData = new SC_DB_MasterData_Ex(); |
---|
| 68 | $this->arrSRANK = $masterData->getMasterData("mtb_srank"); |
---|
| 69 | $this->arrDISP = $masterData->getMasterData("mtb_disp"); |
---|
| 70 | $this->arrCLASS = $masterData->getMasterData("mtb_class"); |
---|
| 71 | $this->arrSTATUS = $masterData->getMasterData("mtb_status"); |
---|
| 72 | $this->arrSTATUS_IMAGE = $masterData->getMasterData("mtb_status_image"); |
---|
| 73 | $this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date"); |
---|
| 74 | $this->arrAllowedTag = $masterData->getMasterData("mtb_allowed_tag"); |
---|
| 75 | $this->arrMaker = SC_Helper_DB_Ex::sfGetIDValueList("dtb_maker", "maker_id", "name"); |
---|
[18777] | 76 | $this->arrDown = $masterData->getMasterData("mtb_down"); |
---|
[17902] | 77 | $this->tpl_nonclass = true; |
---|
| 78 | } |
---|
[15342] | 79 | |
---|
[17902] | 80 | /** |
---|
| 81 | * Page のプロセス. |
---|
| 82 | * |
---|
| 83 | * @return void |
---|
| 84 | */ |
---|
| 85 | function process() { |
---|
| 86 | $objView = new SC_AdminView(); |
---|
| 87 | $objSiteInfo = new SC_SiteInfo(); |
---|
| 88 | $objQuery = new SC_Query(); |
---|
| 89 | $objDb = new SC_Helper_DB_Ex(); |
---|
[15342] | 90 | |
---|
[17902] | 91 | // 認証可否の判定 |
---|
| 92 | $objSess = new SC_Session(); |
---|
| 93 | SC_Utils_Ex::sfIsSuccess($objSess); |
---|
[15342] | 94 | |
---|
[18777] | 95 | // Downファイル管理クラス |
---|
| 96 | $this->objDownFile = new SC_UploadFile(DOWN_TEMP_DIR, DOWN_SAVE_DIR); |
---|
| 97 | // Downファイル情報の初期化 |
---|
| 98 | $this->lfInitDownFile(); |
---|
| 99 | // Hiddenからのデータを引き継ぐ |
---|
| 100 | $this->objDownFile->setHiddenFileList($_POST); |
---|
| 101 | |
---|
[17902] | 102 | // ファイル管理クラス |
---|
| 103 | $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR); |
---|
[15342] | 104 | |
---|
[17902] | 105 | // ファイル情報の初期化 |
---|
| 106 | $this->lfInitFile(); |
---|
| 107 | // Hiddenからのデータを引き継ぐ |
---|
| 108 | $this->objUpFile->setHiddenFileList($_POST); |
---|
[15342] | 109 | |
---|
[17902] | 110 | // 規格の有り無し判定 |
---|
[18435] | 111 | $this->tpl_nonclass = !$objDb->sfHasProductClass($_POST['product_id']); |
---|
[17579] | 112 | |
---|
[17902] | 113 | // 検索パラメータの引き継ぎ |
---|
| 114 | foreach ($_POST as $key => $val) { |
---|
| 115 | if (ereg("^search_", $key)) { |
---|
| 116 | $this->arrSearchHidden[$key] = $val; |
---|
| 117 | } |
---|
| 118 | } |
---|
[15342] | 119 | |
---|
[17902] | 120 | // FORMデータの引き継ぎ |
---|
| 121 | $this->arrForm = $_POST; |
---|
[15342] | 122 | |
---|
[17902] | 123 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
[15342] | 124 | |
---|
[17902] | 125 | switch($_POST['mode']) { |
---|
| 126 | // 検索画面からの編集 |
---|
| 127 | case 'pre_edit': |
---|
| 128 | case 'copy' : |
---|
[18378] | 129 | if (!SC_Utils_Ex::sfIsInt($_POST['product_id'])) { |
---|
| 130 | SC_Utils_Ex::sfDispException(); |
---|
| 131 | } |
---|
[15342] | 132 | |
---|
[18378] | 133 | // DBから商品情報の読込 |
---|
| 134 | $this->arrForm = $this->lfGetProduct($_POST['product_id']); |
---|
| 135 | // DBデータから画像ファイル名の読込 |
---|
| 136 | $this->objUpFile->setDBFileList($this->arrForm); |
---|
[18777] | 137 | // DBデータからダウンロードファイル名の読込 |
---|
| 138 | $this->objDownFile->setDBDownFile($this->arrForm); |
---|
[15342] | 139 | |
---|
[18378] | 140 | // 商品ステータスの変換 |
---|
| 141 | $arrRet = SC_Utils_Ex::sfSplitCBValue($this->arrForm['product_flag'], "product_flag"); |
---|
| 142 | $this->arrForm = array_merge($this->arrForm, $arrRet); |
---|
| 143 | // DBから関連商品の読み込み |
---|
| 144 | $this->lfPreGetRecommendProducts($_POST['product_id']); |
---|
[15342] | 145 | |
---|
[18378] | 146 | $this->lfProductPage(); // 商品登録ページ |
---|
[15342] | 147 | |
---|
[18378] | 148 | if($_POST['mode'] == "copy"){ |
---|
| 149 | $this->arrForm["copy_product_id"] = $this->arrForm["product_id"]; |
---|
| 150 | $this->arrForm["product_id"] = ""; |
---|
| 151 | // 画像ファイルのコピー |
---|
| 152 | $arrKey = $this->objUpFile->keyname; |
---|
| 153 | $arrSaveFile = $this->objUpFile->save_file; |
---|
| 154 | |
---|
| 155 | foreach($arrSaveFile as $key => $val){ |
---|
| 156 | $this->lfMakeScaleImage($arrKey[$key], $arrKey[$key], true); |
---|
| 157 | } |
---|
[17902] | 158 | } |
---|
| 159 | break; |
---|
[18171] | 160 | // 商品登録・編集 |
---|
[17902] | 161 | case 'edit': |
---|
| 162 | if($_POST['product_id'] == "" and SC_Utils_Ex::sfIsInt($_POST['copy_product_id'])){ |
---|
[18435] | 163 | $this->tpl_nonclass = !$objDb->sfHasProductClass($_POST['copy_product_id']); |
---|
[17902] | 164 | } |
---|
[15342] | 165 | |
---|
[17902] | 166 | // 入力値の変換 |
---|
| 167 | $this->arrForm = $this->lfConvertParam($this->arrForm); |
---|
| 168 | // エラーチェック |
---|
| 169 | $this->arrErr = $this->lfErrorCheck($this->arrForm); |
---|
| 170 | // ファイル存在チェック |
---|
| 171 | $this->arrErr = array_merge((array)$this->arrErr, (array)$this->objUpFile->checkEXISTS()); |
---|
| 172 | // エラーなしの場合 |
---|
| 173 | if(count($this->arrErr) == 0) { |
---|
| 174 | $this->lfProductConfirmPage(); // 確認ページ |
---|
| 175 | } else { |
---|
[17903] | 176 | $this->lfProductPage(); // 商品登録ページ |
---|
[17902] | 177 | } |
---|
| 178 | break; |
---|
[18171] | 179 | // 確認ページから完了ページへ |
---|
[17902] | 180 | case 'complete': |
---|
| 181 | $this->tpl_mainpage = 'products/complete.tpl'; |
---|
[15342] | 182 | |
---|
[17903] | 183 | $this->arrForm['product_id'] = $this->lfRegistProduct($_POST); // データ登録 |
---|
[15342] | 184 | |
---|
[17902] | 185 | // 件数カウントバッチ実行 |
---|
| 186 | $objDb->sfCategory_Count($objQuery); |
---|
| 187 | $objDb->sfMaker_Count($objQuery); |
---|
| 188 | // 一時ファイルを本番ディレクトリに移動する |
---|
| 189 | $this->objUpFile->moveTempFile(); |
---|
[18777] | 190 | $this->objDownFile->moveTempDownFile(); |
---|
[15342] | 191 | |
---|
[17902] | 192 | break; |
---|
[18171] | 193 | // 画像のアップロード |
---|
[17902] | 194 | case 'upload_image': |
---|
| 195 | // ファイル存在チェック |
---|
| 196 | $this->arrErr = array_merge((array)$this->arrErr, (array)$this->objUpFile->checkEXISTS($_POST['image_key'])); |
---|
| 197 | // 画像保存処理 |
---|
[18171] | 198 | $this->arrErr[$_POST['image_key']] = $this->objUpFile->makeTempFile($_POST['image_key'],IMAGE_RENAME); |
---|
[15342] | 199 | |
---|
[17902] | 200 | // 中、小画像生成 |
---|
| 201 | $this->lfSetScaleImage(); |
---|
[15342] | 202 | |
---|
[17902] | 203 | $this->lfProductPage(); // 商品登録ページ |
---|
| 204 | break; |
---|
[18171] | 205 | // 画像の削除 |
---|
[17902] | 206 | case 'delete_image': |
---|
| 207 | $this->objUpFile->deleteFile($_POST['image_key']); |
---|
| 208 | $this->lfProductPage(); // 商品登録ページ |
---|
| 209 | break; |
---|
[18777] | 210 | // ダウンロード商品ファイルアップロード |
---|
| 211 | case 'upload_down': |
---|
| 212 | // ファイル存在チェック |
---|
| 213 | $this->arrErr = array_merge((array)$this->arrErr, (array)$this->objDownFile->checkEXISTS($_POST['down_key'])); |
---|
| 214 | // 画像保存処理 |
---|
| 215 | $this->arrErr[$_POST['down_key']] = $this->objDownFile->makeTempDownFile(); |
---|
| 216 | |
---|
| 217 | $this->lfProductPage(); // 商品登録ページ |
---|
| 218 | break; |
---|
| 219 | // ダウンロードファイルの削除 |
---|
| 220 | case 'delete_down': |
---|
| 221 | $this->objDownFile->deleteFile($_POST['down_key']); |
---|
| 222 | $this->lfProductPage(); // 商品登録ページ |
---|
| 223 | break; |
---|
[18171] | 224 | // 確認ページからの戻り |
---|
[17902] | 225 | case 'confirm_return': |
---|
[17903] | 226 | $this->lfProductPage(); // 商品登録ページ |
---|
[17902] | 227 | break; |
---|
[18171] | 228 | // 関連商品選択 |
---|
[17902] | 229 | case 'recommend_select' : |
---|
[17903] | 230 | $this->lfProductPage(); // 商品登録ページ |
---|
[17902] | 231 | break; |
---|
| 232 | default: |
---|
[17903] | 233 | $this->lfProductPage(); // 商品登録ページ |
---|
[17902] | 234 | break; |
---|
| 235 | } |
---|
[15342] | 236 | |
---|
[18378] | 237 | // 関連商品の読み込み |
---|
| 238 | $this->arrRecommend = $this->lfGetRecommendProducts(); |
---|
[15342] | 239 | |
---|
[17902] | 240 | // 基本情報を渡す |
---|
| 241 | $this->arrInfo = $objSiteInfo->data; |
---|
[15342] | 242 | |
---|
[17902] | 243 | // サブ情報の入力があるかどうかチェックする |
---|
| 244 | $sub_find = false; |
---|
| 245 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
[17903] | 246 | if( (isset($this->arrForm['sub_title'.$cnt]) |
---|
[17902] | 247 | && !empty($this->arrForm['sub_title'.$cnt])) || |
---|
| 248 | (isset($this->arrForm['sub_comment'.$cnt]) |
---|
| 249 | && !empty($this->arrForm['sub_comment'.$cnt])) || |
---|
| 250 | (isset($this->arrForm['sub_image'.$cnt]) |
---|
| 251 | && !empty($this->arrForm['sub_image'.$cnt])) || |
---|
| 252 | (isset($this->arrForm['sub_large_image'.$cnt]) |
---|
| 253 | && !empty($this->arrForm['sub_large_image'.$cnt])) || |
---|
| 254 | (isset($this->arrForm['sub_image'.$cnt]) |
---|
| 255 | && is_array($this->arrFile['sub_image'.$cnt])) || |
---|
| 256 | (isset($this->arrForm['sub_large_image'.$cnt]) |
---|
| 257 | && is_array($this->arrFile['sub_large_image'.$cnt]))) { |
---|
| 258 | $sub_find = true; |
---|
| 259 | break; |
---|
| 260 | } |
---|
| 261 | } |
---|
[18777] | 262 | |
---|
[17902] | 263 | // サブ情報表示・非表示のチェックに使用する。 |
---|
| 264 | $this->sub_find = $sub_find; |
---|
| 265 | $objView->assignobj($this); |
---|
| 266 | $objView->display(MAIN_FRAME); |
---|
| 267 | } |
---|
[15342] | 268 | |
---|
[17902] | 269 | /** |
---|
| 270 | * デストラクタ. |
---|
| 271 | * |
---|
| 272 | * @return void |
---|
| 273 | */ |
---|
| 274 | function destroy() { |
---|
| 275 | parent::destroy(); |
---|
| 276 | } |
---|
[15342] | 277 | |
---|
[18378] | 278 | /** |
---|
| 279 | * 関連商品の名称などを商品マスタから読み込み、一つの配列にまとめて返す |
---|
| 280 | * |
---|
| 281 | * @return array 関連商品の情報を格納した2次元配列 |
---|
| 282 | */ |
---|
[17902] | 283 | function lfGetRecommendProducts() { |
---|
| 284 | $objQuery = new SC_Query(); |
---|
| 285 | $arrRecommend = array(); |
---|
| 286 | for($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) { |
---|
| 287 | $keyname = "recommend_id" . $i; |
---|
| 288 | $delkey = "recommend_delete" . $i; |
---|
| 289 | $commentkey = "recommend_comment" . $i; |
---|
[15342] | 290 | |
---|
[18378] | 291 | if (!isset($this->arrForm[$delkey])) $this->arrForm[$delkey] = null; |
---|
[15556] | 292 | |
---|
[18378] | 293 | if((isset($this->arrForm[$keyname]) && !empty($this->arrForm[$keyname])) && $this->arrForm[$delkey] != 1) { |
---|
| 294 | $arrRet = $objQuery->select("main_list_image, product_code_min, name", "vw_products_allclass AS allcls", "product_id = ?", array($this->arrForm[$keyname])); |
---|
[17902] | 295 | $arrRecommend[$i] = $arrRet[0]; |
---|
[18378] | 296 | $arrRecommend[$i]['product_id'] = $this->arrForm[$keyname]; |
---|
[17902] | 297 | $arrRecommend[$i]['comment'] = $this->arrForm[$commentkey]; |
---|
| 298 | } |
---|
| 299 | } |
---|
| 300 | return $arrRecommend; |
---|
| 301 | } |
---|
[15342] | 302 | |
---|
[17902] | 303 | /* 関連商品の登録 */ |
---|
| 304 | function lfInsertRecommendProducts($objQuery, $arrList, $product_id) { |
---|
| 305 | // 一旦関連商品をすべて削除する |
---|
| 306 | $objQuery->delete("dtb_recommend_products", "product_id = ?", array($product_id)); |
---|
| 307 | $sqlval['product_id'] = $product_id; |
---|
| 308 | $rank = RECOMMEND_PRODUCT_MAX; |
---|
| 309 | for($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) { |
---|
| 310 | $keyname = "recommend_id" . $i; |
---|
| 311 | $commentkey = "recommend_comment" . $i; |
---|
| 312 | $deletekey = "recommend_delete" . $i; |
---|
[15556] | 313 | |
---|
[17902] | 314 | if (!isset($arrList[$deletekey])) $arrList[$deletekey] = null; |
---|
[15556] | 315 | |
---|
[17902] | 316 | if($arrList[$keyname] != "" && $arrList[$deletekey] != '1') { |
---|
| 317 | $sqlval['recommend_product_id'] = $arrList[$keyname]; |
---|
| 318 | $sqlval['comment'] = $arrList[$commentkey]; |
---|
| 319 | $sqlval['rank'] = $rank; |
---|
| 320 | $sqlval['creator_id'] = $_SESSION['member_id']; |
---|
| 321 | $sqlval['create_date'] = "now()"; |
---|
| 322 | $sqlval['update_date'] = "now()"; |
---|
| 323 | $objQuery->insert("dtb_recommend_products", $sqlval); |
---|
| 324 | $rank--; |
---|
| 325 | } |
---|
| 326 | } |
---|
| 327 | } |
---|
[15342] | 328 | |
---|
[18378] | 329 | /** |
---|
| 330 | * 指定商品の関連商品をDBから読み込む |
---|
| 331 | * |
---|
| 332 | * @param string $product_id 商品ID |
---|
| 333 | * @return void |
---|
| 334 | */ |
---|
[17902] | 335 | function lfPreGetRecommendProducts($product_id) { |
---|
| 336 | $objQuery = new SC_Query(); |
---|
[18675] | 337 | $objQuery->setOrder("rank DESC"); |
---|
[17902] | 338 | $arrRet = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id)); |
---|
| 339 | $no = 1; |
---|
[15342] | 340 | |
---|
[18378] | 341 | foreach ($arrRet as $ret) { |
---|
| 342 | $this->arrForm['recommend_id' . $no] = $ret['recommend_product_id']; |
---|
| 343 | $this->arrForm['recommend_comment' . $no] = $ret['comment']; |
---|
[17902] | 344 | $no++; |
---|
| 345 | } |
---|
| 346 | } |
---|
[15342] | 347 | |
---|
[17902] | 348 | /* 商品情報の読み込み */ |
---|
| 349 | function lfGetProduct($product_id) { |
---|
| 350 | $objQuery = new SC_Query(); |
---|
[18435] | 351 | $objDb = new SC_Helper_DB_Ex(); |
---|
| 352 | |
---|
[17902] | 353 | $col = "*"; |
---|
| 354 | $table = "vw_products_nonclass AS noncls "; |
---|
| 355 | $where = "product_id = ?"; |
---|
[15342] | 356 | |
---|
[17902] | 357 | $arrRet = $objQuery->select($col, $table, $where, array($product_id)); |
---|
[15342] | 358 | |
---|
[17902] | 359 | // カテゴリID を取得 |
---|
| 360 | $arrRet[0]['category_id'] = $objQuery->getCol("dtb_product_categories", |
---|
[16546] | 361 | "category_id", |
---|
| 362 | "product_id = ?", |
---|
[17902] | 363 | array($product_id)); |
---|
| 364 | //編集時に規格IDが変わってしまうのを防ぐために規格が登録されていなければ規格IDを取得する |
---|
[18435] | 365 | if (!$objDb->sfHasProductClass($_POST['product_id'])) { |
---|
[17902] | 366 | $arrRet[0]['product_class_id'] = SC_Utils::sfGetProductClassId($product_id,"0","0"); |
---|
| 367 | } |
---|
| 368 | return $arrRet[0]; |
---|
| 369 | } |
---|
[15342] | 370 | |
---|
[17902] | 371 | /* 商品登録ページ表示用 */ |
---|
| 372 | function lfProductPage() { |
---|
| 373 | $objDb = new SC_Helper_DB_Ex(); |
---|
[15342] | 374 | |
---|
[17902] | 375 | // カテゴリの読込 |
---|
| 376 | list($this->arrCatVal, $this->arrCatOut) = $objDb->sfGetLevelCatList(false); |
---|
[15342] | 377 | |
---|
[17902] | 378 | if (isset($this->arrForm['category_id']) && !is_array($this->arrForm['category_id'])) { |
---|
| 379 | $this->arrForm['category_id'] = unserialize($this->arrForm['category_id']); |
---|
| 380 | } |
---|
| 381 | if($this->arrForm['status'] == "") { |
---|
[18059] | 382 | $this->arrForm['status'] = DEFAULT_PRODUCT_DISP; |
---|
[17902] | 383 | } |
---|
[18777] | 384 | if($this->arrForm['down'] == "") { |
---|
| 385 | $this->arrForm['down'] = DEFAULT_PRODUCT_DOWN; |
---|
| 386 | } |
---|
[15342] | 387 | |
---|
[17902] | 388 | if(isset($this->arrForm['product_flag']) && !is_array($this->arrForm['product_flag'])) { |
---|
| 389 | // 商品ステータスの分割読込 |
---|
| 390 | $this->arrForm['product_flag'] = SC_Utils_Ex::sfSplitCheckBoxes($this->arrForm['product_flag']); |
---|
| 391 | } |
---|
[15342] | 392 | |
---|
[17902] | 393 | // HIDDEN用に配列を渡す。 |
---|
| 394 | $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objUpFile->getHiddenFileList()); |
---|
[18777] | 395 | $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objDownFile->getHiddenFileList()); |
---|
[17902] | 396 | // Form用配列を渡す。 |
---|
| 397 | $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL); |
---|
[15342] | 398 | |
---|
[18777] | 399 | $this->arrForm['down_realfilename'] = $this->objDownFile->getFormDownFile(); |
---|
[15342] | 400 | |
---|
[17902] | 401 | // アンカーを設定 |
---|
| 402 | if (isset($_POST['image_key']) && !empty($_POST['image_key'])) { |
---|
| 403 | $anchor_hash = "location.hash='#" . $_POST['image_key'] . "'"; |
---|
| 404 | } elseif (isset($_POST['anchor_key']) && !empty($_POST['anchor_key'])) { |
---|
| 405 | $anchor_hash = "location.hash='#" . $_POST['anchor_key'] . "'"; |
---|
| 406 | } else { |
---|
| 407 | $anchor_hash = ""; |
---|
| 408 | } |
---|
[15342] | 409 | |
---|
[18275] | 410 | $this->tpl_onload = "fnCheckStockLimit('" . DISABLED_RGB . "'); fnMoveSelect('category_id_unselect', 'category_id');" . $anchor_hash; |
---|
[17902] | 411 | } |
---|
[15342] | 412 | |
---|
[17902] | 413 | /* ファイル情報の初期化 */ |
---|
| 414 | function lfInitFile() { |
---|
[17967] | 415 | $this->objUpFile->addFile("一覧-メイン画像", 'main_list_image', array('jpg', 'gif', 'png'),IMAGE_SIZE, false, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); |
---|
| 416 | $this->objUpFile->addFile("詳細-メイン画像", 'main_image', array('jpg', 'gif', 'png'), IMAGE_SIZE, false, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT); |
---|
[17902] | 417 | $this->objUpFile->addFile("詳細-メイン拡大画像", 'main_large_image', array('jpg', 'gif', 'png'), IMAGE_SIZE, false, LARGE_IMAGE_WIDTH, LARGE_IMAGE_HEIGHT); |
---|
| 418 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
| 419 | $this->objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg', 'gif', 'png'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_WIDTH, NORMAL_SUBIMAGE_HEIGHT); |
---|
| 420 | $this->objUpFile->addFile("詳細-サブ拡大画像$cnt", "sub_large_image$cnt", array('jpg', 'gif', 'png'), IMAGE_SIZE, false, LARGE_SUBIMAGE_WIDTH, LARGE_SUBIMAGE_HEIGHT); |
---|
| 421 | } |
---|
| 422 | $this->objUpFile->addFile("商品比較画像", 'file1', array('jpg', 'gif', 'png'), IMAGE_SIZE, false, OTHER_IMAGE1_WIDTH, OTHER_IMAGE1_HEIGHT); |
---|
| 423 | $this->objUpFile->addFile("商品詳細ファイル", 'file2', array('pdf'), PDF_SIZE, false, 0, 0, false); |
---|
| 424 | } |
---|
[15342] | 425 | |
---|
[17902] | 426 | /* 商品の登録 */ |
---|
| 427 | function lfRegistProduct($arrList) { |
---|
| 428 | $objQuery = new SC_Query(); |
---|
| 429 | $objDb = new SC_Helper_DB_Ex(); |
---|
| 430 | $objQuery->begin(); |
---|
[15342] | 431 | |
---|
[17902] | 432 | // 配列の添字を定義 |
---|
| 433 | $checkArray = array("name", "status", "product_flag", |
---|
[15342] | 434 | "main_list_comment", "main_comment", "point_rate", |
---|
| 435 | "deliv_fee", "comment1", "comment2", "comment3", |
---|
| 436 | "comment4", "comment5", "comment6", "main_list_comment", |
---|
[18777] | 437 | "sale_limit", "deliv_date_id", "maker_id", "note", "down", "down_filename", "down_realfilename"); |
---|
[17902] | 438 | $arrList = SC_Utils_Ex::arrayDefineIndexes($arrList, $checkArray); |
---|
[15342] | 439 | |
---|
[17902] | 440 | // INSERTする値を作成する。 |
---|
| 441 | $sqlval['name'] = $arrList['name']; |
---|
| 442 | $sqlval['status'] = $arrList['status']; |
---|
| 443 | $sqlval['product_flag'] = $arrList['product_flag']; |
---|
| 444 | $sqlval['main_list_comment'] = $arrList['main_list_comment']; |
---|
| 445 | $sqlval['main_comment'] = $arrList['main_comment']; |
---|
| 446 | $sqlval['point_rate'] = $arrList['point_rate']; |
---|
| 447 | $sqlval['deliv_fee'] = $arrList['deliv_fee']; |
---|
| 448 | $sqlval['comment1'] = $arrList['comment1']; |
---|
| 449 | $sqlval['comment2'] = $arrList['comment2']; |
---|
| 450 | $sqlval['comment3'] = $arrList['comment3']; |
---|
| 451 | $sqlval['comment4'] = $arrList['comment4']; |
---|
| 452 | $sqlval['comment5'] = $arrList['comment5']; |
---|
| 453 | $sqlval['comment6'] = $arrList['comment6']; |
---|
| 454 | $sqlval['main_list_comment'] = $arrList['main_list_comment']; |
---|
| 455 | $sqlval['sale_limit'] = $arrList['sale_limit']; |
---|
| 456 | $sqlval['deliv_date_id'] = $arrList['deliv_date_id']; |
---|
| 457 | $sqlval['maker_id'] = $arrList['maker_id']; |
---|
| 458 | $sqlval['note'] = $arrList['note']; |
---|
[18777] | 459 | $sqlval['down'] = $arrList['down']; |
---|
| 460 | $sqlval['down_filename'] = $arrList['down_filename']; |
---|
| 461 | $sqlval['down_realfilename'] = $arrList['down_realfilename']; |
---|
[17902] | 462 | $sqlval['update_date'] = "Now()"; |
---|
| 463 | $sqlval['creator_id'] = $_SESSION['member_id']; |
---|
| 464 | $arrRet = $this->objUpFile->getDBFileList(); |
---|
| 465 | $sqlval = array_merge($sqlval, $arrRet); |
---|
[15342] | 466 | |
---|
[17902] | 467 | $arrList['category_id'] = unserialize($arrList['category_id']); |
---|
[16553] | 468 | |
---|
[17902] | 469 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
| 470 | $sqlval['sub_title'.$cnt] = $arrList['sub_title'.$cnt]; |
---|
| 471 | $sqlval['sub_comment'.$cnt] = $arrList['sub_comment'.$cnt]; |
---|
| 472 | } |
---|
[15342] | 473 | |
---|
[18435] | 474 | // 新規登録(複製時を含む) |
---|
| 475 | if ($arrList['product_id'] == "") { |
---|
[17902] | 476 | // product_id 取得(PostgreSQLの場合) |
---|
| 477 | if(DB_TYPE=='pgsql'){ |
---|
| 478 | $product_id = $objQuery->nextval("dtb_products", "product_id"); |
---|
| 479 | $sqlval['product_id'] = $product_id; |
---|
| 480 | } |
---|
[17579] | 481 | |
---|
[17902] | 482 | // INSERTの実行 |
---|
| 483 | $sqlval['create_date'] = "Now()"; |
---|
| 484 | $objQuery->insert("dtb_products", $sqlval); |
---|
[17579] | 485 | |
---|
[17902] | 486 | // product_id 取得(MySQLの場合) |
---|
| 487 | if(DB_TYPE=='mysql'){ |
---|
| 488 | $product_id = $objQuery->nextval("dtb_products", "product_id"); |
---|
| 489 | } |
---|
[17579] | 490 | |
---|
[18435] | 491 | $arrList['product_id'] = $product_id; |
---|
| 492 | |
---|
[17902] | 493 | // カテゴリを更新 |
---|
| 494 | $objDb->updateProductCategories($arrList['category_id'], $product_id); |
---|
[16546] | 495 | |
---|
[18435] | 496 | // 複製商品の場合には規格も複製する |
---|
[17902] | 497 | if($_POST["copy_product_id"] != "" and SC_Utils_Ex::sfIsInt($_POST["copy_product_id"])){ |
---|
[18304] | 498 | |
---|
[17902] | 499 | if($this->tpl_nonclass) |
---|
| 500 | { |
---|
[18435] | 501 | //規格なしの場合、複製は価格等の入力が発生しているため、その内容で追加登録を行う |
---|
[17902] | 502 | $this->lfCopyProductClass($arrList, $objQuery); |
---|
| 503 | } |
---|
| 504 | else |
---|
| 505 | { |
---|
[18435] | 506 | //規格がある場合の複製は複製元の内容で追加登録を行う |
---|
[17902] | 507 | // dtb_products_class のカラムを取得 |
---|
| 508 | $dbFactory = SC_DB_DBFactory_Ex::getInstance(); |
---|
| 509 | $arrColList = $dbFactory->sfGetColumnList("dtb_products_class", $objQuery); |
---|
| 510 | $arrColList_tmp = array_flip($arrColList); |
---|
[15342] | 511 | |
---|
[18435] | 512 | // 複製しない列 |
---|
[17902] | 513 | unset($arrColList[$arrColList_tmp["product_class_id"]]); //規格ID |
---|
[17903] | 514 | unset($arrColList[$arrColList_tmp["product_id"]]); //商品ID |
---|
[17902] | 515 | unset($arrColList[$arrColList_tmp["create_date"]]); |
---|
[15342] | 516 | |
---|
[17902] | 517 | $col = SC_Utils_Ex::sfGetCommaList($arrColList); |
---|
[15342] | 518 | |
---|
[18062] | 519 | $objQuery->query("INSERT INTO dtb_products_class (product_id, create_date, ". $col .") SELECT ?, now(), " . $col. " FROM dtb_products_class WHERE product_id = ? ORDER BY product_class_id", array($product_id, $_POST["copy_product_id"])); |
---|
[17902] | 520 | } |
---|
| 521 | } |
---|
[18435] | 522 | } |
---|
| 523 | // 更新 |
---|
| 524 | else { |
---|
[17902] | 525 | $product_id = $arrList['product_id']; |
---|
| 526 | // 削除要求のあった既存ファイルの削除 |
---|
| 527 | $arrRet = $this->lfGetProduct($arrList['product_id']); |
---|
| 528 | $this->objUpFile->deleteDBFile($arrRet); |
---|
[18777] | 529 | $this->objDownFile->deleteDBDownFile($arrRet); |
---|
[15342] | 530 | |
---|
[17902] | 531 | // UPDATEの実行 |
---|
| 532 | $where = "product_id = ?"; |
---|
| 533 | $objQuery->update("dtb_products", $sqlval, $where, array($product_id)); |
---|
[16546] | 534 | |
---|
[17902] | 535 | // カテゴリを更新 |
---|
| 536 | $objDb->updateProductCategories($arrList['category_id'], $product_id); |
---|
| 537 | } |
---|
[15342] | 538 | |
---|
[17902] | 539 | //商品登録の時は規格を生成する。複製の場合は規格も複製されるのでこの処理は不要。 |
---|
| 540 | if( $_POST["copy_product_id"] == "" ){ |
---|
| 541 | // 規格登録 |
---|
[18435] | 542 | $this->lfInsertDummyProductClass($arrList); |
---|
[17902] | 543 | } |
---|
[15342] | 544 | |
---|
[17902] | 545 | // 関連商品登録 |
---|
| 546 | $this->lfInsertRecommendProducts($objQuery, $arrList, $product_id); |
---|
[15342] | 547 | |
---|
[17902] | 548 | $objQuery->commit(); |
---|
| 549 | return $product_id; |
---|
| 550 | } |
---|
[15342] | 551 | |
---|
| 552 | |
---|
[17902] | 553 | /* 取得文字列の変換 */ |
---|
| 554 | function lfConvertParam($array) { |
---|
| 555 | /* |
---|
[17903] | 556 | * 文字列の変換 |
---|
| 557 | * K : 「半角(ハンカク)片仮名」を「全角片仮名」に変換 |
---|
| 558 | * C : 「全角ひら仮名」を「全角かた仮名」に変換 |
---|
| 559 | * V : 濁点付きの文字を一文字に変換。"K","H"と共に使用します |
---|
| 560 | * n : 「全角」数字を「半角(ハンカク)」に変換 |
---|
[17902] | 561 | */ |
---|
[15342] | 562 | |
---|
[17902] | 563 | // スポット商品 |
---|
| 564 | $arrConvList['name'] = "KVa"; |
---|
| 565 | $arrConvList['main_list_comment'] = "KVa"; |
---|
| 566 | $arrConvList['main_comment'] = "KVa"; |
---|
| 567 | $arrConvList['price01'] = "n"; |
---|
| 568 | $arrConvList['price02'] = "n"; |
---|
| 569 | $arrConvList['stock'] = "n"; |
---|
| 570 | $arrConvList['sale_limit'] = "n"; |
---|
| 571 | $arrConvList['point_rate'] = "n"; |
---|
| 572 | $arrConvList['product_code'] = "KVna"; |
---|
| 573 | $arrConvList['comment1'] = "a"; |
---|
| 574 | $arrConvList['deliv_fee'] = "n"; |
---|
[15342] | 575 | |
---|
[17902] | 576 | // 詳細-サブ |
---|
| 577 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
| 578 | $arrConvList["sub_title$cnt"] = "KVa"; |
---|
| 579 | } |
---|
| 580 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
| 581 | $arrConvList["sub_comment$cnt"] = "KVa"; |
---|
| 582 | } |
---|
[15342] | 583 | |
---|
[17902] | 584 | // 関連商品 |
---|
| 585 | for ($cnt = 1; $cnt <= RECOMMEND_PRODUCT_MAX; $cnt++) { |
---|
| 586 | $arrConvList["recommend_comment$cnt"] = "KVa"; |
---|
| 587 | } |
---|
[15342] | 588 | |
---|
[17902] | 589 | // 文字変換 |
---|
| 590 | foreach ($arrConvList as $key => $val) { |
---|
| 591 | // POSTされてきた値のみ変換する。 |
---|
| 592 | if(isset($array[$key])) { |
---|
| 593 | $array[$key] = mb_convert_kana($array[$key] ,$val); |
---|
| 594 | } |
---|
| 595 | } |
---|
[15342] | 596 | |
---|
[17902] | 597 | if (!isset($array['product_flag'])) $array['product_flag'] = ""; |
---|
| 598 | $max = max(array_keys($this->arrSTATUS)); |
---|
| 599 | $array['product_flag'] = SC_Utils_Ex::sfMergeCheckBoxes($array['product_flag'], $max); |
---|
[15342] | 600 | |
---|
[17902] | 601 | return $array; |
---|
| 602 | } |
---|
[15342] | 603 | |
---|
[17902] | 604 | // 入力エラーチェック |
---|
| 605 | function lfErrorCheck($array) { |
---|
[15342] | 606 | |
---|
[17902] | 607 | $objErr = new SC_CheckError($array); |
---|
| 608 | $objErr->doFunc(array("商品名", "name", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 609 | $objErr->doFunc(array("一覧-メインコメント", "main_list_comment", MTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 610 | $objErr->doFunc(array("詳細-メインコメント", "main_comment", LLTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 611 | $objErr->doFunc(array("詳細-メインコメント", "main_comment", $this->arrAllowedTag), array("HTML_TAG_CHECK")); |
---|
| 612 | $objErr->doFunc(array("ポイント付与率", "point_rate", PERCENTAGE_LEN), array("EXIST_CHECK", "NUM_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 613 | $objErr->doFunc(array("商品送料", "deliv_fee", PRICE_LEN), array("NUM_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 614 | $objErr->doFunc(array("備考欄(SHOP専用)", "note", LLTEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 615 | $objErr->doFunc(array("検索ワード", "comment3", LLTEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 616 | $objErr->doFunc(array("メーカーURL", "comment1", URL_LEN), array("SPTAB_CHECK", "URL_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 617 | $objErr->doFunc(array("発送日目安", "deliv_date_id", INT_LEN), array("NUM_CHECK")); |
---|
| 618 | $objErr->doFunc(array("メーカー", 'maker_id', INT_LEN), array("NUM_CHECK")); |
---|
[15342] | 619 | |
---|
[18777] | 620 | //ダウンロード商品チェック |
---|
| 621 | if($array['down'] == "2") { |
---|
| 622 | $objErr->doFunc(array("ダウンロードファイル名", "down_filename", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 623 | if($array['down_realfilename'] == "") { |
---|
| 624 | $objErr->arrErr['down_realfilename'] = "※ ダウンロード商品の場合はダウンロード商品用ファイルをアップロードしてください。<br />"; |
---|
| 625 | } |
---|
| 626 | } |
---|
| 627 | //実商品チェック |
---|
| 628 | if($array['down'] == "1") { |
---|
| 629 | if($array['down_filename'] != "") { |
---|
| 630 | $objErr->arrErr['down_filename'] = "※ 実商品の場合はダウンロードファイル名を設定できません。<br />"; |
---|
| 631 | } |
---|
| 632 | if($array['down_realfilename'] != "") { |
---|
| 633 | $objErr->arrErr['down_realfilename'] = "※ 実商品の場合はダウンロード商品用ファイルをアップロードできません。<br />ファイルを取り消してください。<br />"; |
---|
| 634 | } |
---|
| 635 | } |
---|
| 636 | |
---|
[17902] | 637 | if($this->tpl_nonclass) { |
---|
[18298] | 638 | $objErr->doFunc(array("商品コード", "product_code", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK","MAX_LENGTH_CHECK")); |
---|
[17902] | 639 | $objErr->doFunc(array(NORMAL_PRICE_TITLE, "price01", PRICE_LEN), array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 640 | $objErr->doFunc(array(SALE_PRICE_TITLE, "price02", PRICE_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
[16553] | 641 | |
---|
[17902] | 642 | if(!isset($array['stock_unlimited']) && $array['stock_unlimited'] != "1") { |
---|
| 643 | $objErr->doFunc(array("在庫数", "stock", AMOUNT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 644 | } |
---|
| 645 | } |
---|
[15342] | 646 | |
---|
[18275] | 647 | $objErr->doFunc(array("購入制限", "sale_limit", AMOUNT_LEN), array("SPTAB_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
[15556] | 648 | |
---|
[17902] | 649 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
| 650 | $objErr->doFunc(array("詳細-サブタイトル$cnt", "sub_title$cnt", STEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 651 | $objErr->doFunc(array("詳細-サブコメント$cnt", "sub_comment$cnt", LLTEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 652 | $objErr->doFunc(array("詳細-サブコメント$cnt", "sub_comment$cnt", $this->arrAllowedTag), array("HTML_TAG_CHECK")); |
---|
| 653 | } |
---|
[15556] | 654 | |
---|
[17902] | 655 | for ($cnt = 1; $cnt <= RECOMMEND_PRODUCT_MAX; $cnt++) { |
---|
[15342] | 656 | |
---|
[17902] | 657 | if (!isset($_POST["recommend_delete$cnt"])) $_POST["recommend_delete$cnt"] = ""; |
---|
[15342] | 658 | |
---|
[17902] | 659 | if(isset($_POST["recommend_id$cnt"]) |
---|
| 660 | && $_POST["recommend_id$cnt"] != "" |
---|
| 661 | && $_POST["recommend_delete$cnt"] != 1) { |
---|
| 662 | $objErr->doFunc(array("関連商品コメント$cnt", "recommend_comment$cnt", LTEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 663 | } |
---|
| 664 | } |
---|
[16546] | 665 | |
---|
[17902] | 666 | // カテゴリID のチェック |
---|
| 667 | if (empty($array['category_id'])) { |
---|
| 668 | $objErr->arrErr['category_id'] = "※ 商品カテゴリが選択されていません。<br />"; |
---|
| 669 | } else { |
---|
| 670 | $arrCategory_id = array(); |
---|
| 671 | for ($i = 0; $i < count($array['category_id']); $i++) { |
---|
| 672 | $arrCategory_id['category_id' . $i] = $array['category_id'][$i]; |
---|
| 673 | } |
---|
| 674 | $objCheckCategory = new SC_CheckError($arrCategory_id); |
---|
| 675 | for ($i = 0; $i < count($array['category_id']); $i++) { |
---|
| 676 | $objCheckCategory->doFunc(array("商品カテゴリ", "category_id" . $i, STEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 677 | } |
---|
| 678 | if (!empty($objCheckCategory->arrErr)) { |
---|
| 679 | $objErr->arrErr = array_merge($objErr->arrErr, |
---|
| 680 | $objCheckCategory->arrErr); |
---|
| 681 | } |
---|
| 682 | } |
---|
| 683 | return $objErr->arrErr; |
---|
| 684 | } |
---|
[16546] | 685 | |
---|
[17902] | 686 | /* 確認ページ表示用 */ |
---|
| 687 | function lfProductConfirmPage() { |
---|
| 688 | $this->tpl_mainpage = 'products/confirm.tpl'; |
---|
| 689 | $this->arrForm['mode'] = 'complete'; |
---|
[16546] | 690 | |
---|
[17902] | 691 | $objDb = new SC_Helper_DB_Ex(); |
---|
[16546] | 692 | |
---|
[17902] | 693 | // カテゴリ表示 |
---|
| 694 | $this->arrCategory_id = $this->arrForm['category_id']; |
---|
| 695 | $this->arrCatList = array(); |
---|
| 696 | list($arrCatVal, $arrCatOut) = $objDb->sfGetLevelCatList(false); |
---|
| 697 | for ($i = 0; $i < count($arrCatVal); $i++) { |
---|
| 698 | $this->arrCatList[$arrCatVal[$i]] = $arrCatOut[$i]; |
---|
| 699 | } |
---|
[15342] | 700 | |
---|
[17902] | 701 | // hidden に渡す値は serialize する |
---|
| 702 | $this->arrForm['category_id'] = serialize($this->arrForm['category_id']); |
---|
[15342] | 703 | |
---|
[17902] | 704 | // Form用配列を渡す。 |
---|
| 705 | $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL); |
---|
[18777] | 706 | $this->arrForm['down_realfilename'] = $this->objDownFile->getFormDownFile(); |
---|
[17902] | 707 | } |
---|
[15342] | 708 | |
---|
[17902] | 709 | // 縮小した画像をセットする |
---|
| 710 | function lfSetScaleImage(){ |
---|
[15342] | 711 | |
---|
[17902] | 712 | $subno = str_replace("sub_large_image", "", $_POST['image_key']); |
---|
| 713 | switch ($_POST['image_key']){ |
---|
| 714 | case "main_large_image": |
---|
| 715 | // 詳細メイン画像 |
---|
| 716 | $this->lfMakeScaleImage($_POST['image_key'], "main_image"); |
---|
| 717 | case "main_image": |
---|
| 718 | // 一覧メイン画像 |
---|
| 719 | $this->lfMakeScaleImage($_POST['image_key'], "main_list_image"); |
---|
| 720 | break; |
---|
| 721 | case "sub_large_image" . $subno: |
---|
| 722 | // サブメイン画像 |
---|
| 723 | $this->lfMakeScaleImage($_POST['image_key'], "sub_image" . $subno); |
---|
| 724 | break; |
---|
| 725 | default: |
---|
| 726 | break; |
---|
| 727 | } |
---|
| 728 | } |
---|
[15342] | 729 | |
---|
[17902] | 730 | // 縮小画像生成 |
---|
| 731 | function lfMakeScaleImage($from_key, $to_key, $forced = false){ |
---|
| 732 | $arrImageKey = array_flip($this->objUpFile->keyname); |
---|
[15342] | 733 | |
---|
[17902] | 734 | if($this->objUpFile->temp_file[$arrImageKey[$from_key]]){ |
---|
| 735 | $from_path = $this->objUpFile->temp_dir . $this->objUpFile->temp_file[$arrImageKey[$from_key]]; |
---|
| 736 | }elseif($this->objUpFile->save_file[$arrImageKey[$from_key]]){ |
---|
| 737 | $from_path = $this->objUpFile->save_dir . $this->objUpFile->save_file[$arrImageKey[$from_key]]; |
---|
| 738 | }else{ |
---|
| 739 | return ""; |
---|
| 740 | } |
---|
[15342] | 741 | |
---|
[17902] | 742 | if(file_exists($from_path)){ |
---|
| 743 | // 生成先の画像サイズを取得 |
---|
| 744 | $to_w = $this->objUpFile->width[$arrImageKey[$to_key]]; |
---|
| 745 | $to_h = $this->objUpFile->height[$arrImageKey[$to_key]]; |
---|
[15342] | 746 | |
---|
[17902] | 747 | if($forced) $this->objUpFile->save_file[$arrImageKey[$to_key]] = ""; |
---|
[17840] | 748 | |
---|
[17902] | 749 | if(empty($this->objUpFile->temp_file[$arrImageKey[$to_key]]) && |
---|
| 750 | empty($this->objUpFile->save_file[$arrImageKey[$to_key]])) { |
---|
[17840] | 751 | |
---|
[18171] | 752 | // リネームする際は、自動生成される画像名に一意となるように、Suffixを付ける |
---|
| 753 | $dst_file = $this->objUpFile->lfGetTmpImageName(IMAGE_RENAME, "", $this->objUpFile->temp_file[$arrImageKey[$from_key]]) . $this->lfGetAddSuffix($to_key); |
---|
| 754 | $path = $this->objUpFile->makeThumb($from_path, $to_w, $to_h, $dst_file); |
---|
[17902] | 755 | $this->objUpFile->temp_file[$arrImageKey[$to_key]] = basename($path); |
---|
| 756 | } |
---|
| 757 | }else{ |
---|
| 758 | return ""; |
---|
| 759 | } |
---|
| 760 | } |
---|
[18171] | 761 | |
---|
[17902] | 762 | /** |
---|
[18171] | 763 | * リネームする際は、自動生成される画像名に一意となるように、Suffixを付ける |
---|
| 764 | */ |
---|
| 765 | function lfGetAddSuffix($to_key){ |
---|
| 766 | if( IMAGE_RENAME === true ){ return ; } |
---|
| 767 | |
---|
| 768 | // 自動生成される画像名 |
---|
| 769 | $dist_name = ""; |
---|
| 770 | switch($to_key){ |
---|
| 771 | case "main_list_image": |
---|
| 772 | $dist_name = '_s'; |
---|
| 773 | break; |
---|
| 774 | case "main_image": |
---|
| 775 | $dist_name = '_m'; |
---|
| 776 | break; |
---|
[18463] | 777 | default: |
---|
[18171] | 778 | $arrRet = explode('sub_image', $to_key); |
---|
| 779 | $dist_name = '_sub' .$arrRet[1]; |
---|
| 780 | break; |
---|
| 781 | } |
---|
| 782 | return $dist_name; |
---|
| 783 | } |
---|
[18304] | 784 | |
---|
[18171] | 785 | /** |
---|
[17902] | 786 | * dtb_products_classの複製 |
---|
| 787 | * 複製後、価格や商品コードを更新する |
---|
| 788 | * |
---|
| 789 | * @param array $arrList |
---|
| 790 | * @param array $objQuery |
---|
| 791 | * @return bool |
---|
| 792 | */ |
---|
[18221] | 793 | function lfCopyProductClass($arrList,$objQuery) |
---|
[17902] | 794 | { |
---|
[18304] | 795 | // 複製元のdtb_products_classを取得(規格なしのため、1件のみの取得) |
---|
[17902] | 796 | $col = "*"; |
---|
| 797 | $table = "dtb_products_class"; |
---|
| 798 | $where = "product_id = ?"; |
---|
| 799 | $arrProductClass = $objQuery->select($col, $table, $where, array($arrList["copy_product_id"])); |
---|
[17840] | 800 | |
---|
[17902] | 801 | //トランザクション開始 |
---|
| 802 | $objQuery->begin(); |
---|
| 803 | $err_flag = false; |
---|
[18435] | 804 | //非編集項目は複製、編集項目は上書きして登録 |
---|
[17902] | 805 | foreach($arrProductClass as $records) |
---|
| 806 | { |
---|
| 807 | foreach($records as $key => $value) |
---|
| 808 | { |
---|
| 809 | if(isset($arrList[$key])) |
---|
| 810 | { |
---|
| 811 | $records[$key] = $arrList[$key]; |
---|
| 812 | } |
---|
| 813 | } |
---|
| 814 | unset($records["product_class_id"]); |
---|
| 815 | unset($records["update_date"]); |
---|
[18304] | 816 | |
---|
[17902] | 817 | $records["create_date"] = "Now()"; |
---|
| 818 | $objQuery->insert($table, $records); |
---|
| 819 | //エラー発生時は中断 |
---|
| 820 | if($objQuery->isError()) |
---|
| 821 | { |
---|
| 822 | $err_flag = true; |
---|
| 823 | continue; |
---|
| 824 | } |
---|
| 825 | } |
---|
| 826 | //トランザクション終了 |
---|
| 827 | if($err_flag) |
---|
| 828 | { |
---|
| 829 | $objQuery->rollback(); |
---|
| 830 | } |
---|
| 831 | else |
---|
| 832 | { |
---|
| 833 | $objQuery->commit(); |
---|
| 834 | } |
---|
| 835 | return !$err_flag; |
---|
| 836 | } |
---|
[18435] | 837 | |
---|
| 838 | /** |
---|
| 839 | * 規格を設定していない商品を商品規格テーブルに登録 |
---|
| 840 | * |
---|
| 841 | * @param array $arrList |
---|
| 842 | * @return void |
---|
| 843 | */ |
---|
| 844 | function lfInsertDummyProductClass($arrList) { |
---|
| 845 | $objQuery = new SC_Query(); |
---|
| 846 | $objDb = new SC_Helper_DB_Ex(); |
---|
| 847 | |
---|
| 848 | $product_id = $arrList['product_id']; |
---|
| 849 | // 規格登録してある商品の場合、処理しない |
---|
| 850 | if ($objDb->sfHasProductClass($product_id)) return; |
---|
| 851 | |
---|
| 852 | // 既存規格の削除 |
---|
| 853 | $where = 'product_id = ?'; |
---|
| 854 | $objQuery->delete('dtb_products_class', $where, array($product_id)); |
---|
| 855 | |
---|
| 856 | // 配列の添字を定義 |
---|
| 857 | $checkArray = array('product_class_id', 'product_id', 'product_code', 'stock', 'stock_unlimited', 'price01', 'price02'); |
---|
| 858 | $sqlval = SC_Utils_Ex::sfArrayIntersectKeys($arrList, $checkArray); |
---|
| 859 | $sqlval = SC_Utils_Ex::arrayDefineIndexes($sqlval, $checkArray); |
---|
| 860 | |
---|
| 861 | if (strlen($sqlval['product_class_id']) == 0) { |
---|
| 862 | unset($sqlval['product_class_id']); |
---|
| 863 | } |
---|
| 864 | $sqlval['classcategory_id1'] = '0'; |
---|
| 865 | $sqlval['classcategory_id2'] = '0'; |
---|
| 866 | $sqlval['stock_unlimited'] = $sqlval['stock_unlimited'] ? '1' : '0'; |
---|
| 867 | $sqlval['creator_id'] = strlen($_SESSION['member_id']) >= 1 ? $_SESSION['member_id'] : '0'; |
---|
| 868 | $sqlval['create_date'] = 'now()'; |
---|
| 869 | |
---|
| 870 | // INSERTの実行 |
---|
| 871 | $objQuery->insert('dtb_products_class', $sqlval); |
---|
| 872 | } |
---|
[18777] | 873 | /* ダウンロードファイル情報の初期化 */ |
---|
| 874 | function lfInitDownFile() { |
---|
| 875 | $this->objDownFile->addFile("ダウンロード販売用ファイル", 'down_file', array('zip', 'jpg', 'mp3', 'gif', 'png'),DOWN_SIZE, true, 0, 0); |
---|
| 876 | } |
---|
[15342] | 877 | } |
---|
| 878 | ?> |
---|