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