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