[15342] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[20764] | 5 | * Copyright(c) 2000-2011 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 |
---|
[20534] | 25 | require_once CLASS_EX_REALDIR . 'page_extends/admin/products/LC_Page_Admin_Products_Ex.php'; |
---|
[15342] | 26 | |
---|
| 27 | /** |
---|
[17840] | 28 | * 商品登録 のページクラス |
---|
[15342] | 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author LOCKON CO.,LTD. |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
[20386] | 34 | class LC_Page_Admin_Products_Product extends LC_Page_Admin_Products_Ex { |
---|
[15342] | 35 | |
---|
[17902] | 36 | // }}} |
---|
| 37 | // {{{ functions |
---|
[15342] | 38 | |
---|
[17902] | 39 | /** |
---|
| 40 | * Page を初期化する. |
---|
| 41 | * |
---|
| 42 | * @return void |
---|
| 43 | */ |
---|
| 44 | function init() { |
---|
| 45 | parent::init(); |
---|
| 46 | $this->tpl_mainpage = 'products/product.tpl'; |
---|
| 47 | $this->tpl_mainno = 'products'; |
---|
| 48 | $this->tpl_subno = 'product'; |
---|
[20911] | 49 | $this->tpl_maintitle = '商品管理'; |
---|
[17902] | 50 | $this->tpl_subtitle = '商品登録'; |
---|
[15342] | 51 | |
---|
[17902] | 52 | $masterData = new SC_DB_MasterData_Ex(); |
---|
[20386] | 53 | $this->arrProductType = $masterData->getMasterData("mtb_product_type"); |
---|
[17902] | 54 | $this->arrDISP = $masterData->getMasterData("mtb_disp"); |
---|
| 55 | $this->arrCLASS = $masterData->getMasterData("mtb_class"); |
---|
| 56 | $this->arrSTATUS = $masterData->getMasterData("mtb_status"); |
---|
| 57 | $this->arrSTATUS_IMAGE = $masterData->getMasterData("mtb_status_image"); |
---|
| 58 | $this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date"); |
---|
[20538] | 59 | $this->arrMaker = SC_Helper_DB_Ex::sfGetIDValueList("dtb_maker", "maker_id", 'name'); |
---|
[17902] | 60 | $this->arrAllowedTag = $masterData->getMasterData("mtb_allowed_tag"); |
---|
| 61 | } |
---|
[15342] | 62 | |
---|
[17902] | 63 | /** |
---|
| 64 | * Page のプロセス. |
---|
| 65 | * |
---|
| 66 | * @return void |
---|
| 67 | */ |
---|
| 68 | function process() { |
---|
[19661] | 69 | $this->action(); |
---|
| 70 | $this->sendResponse(); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | /** |
---|
| 74 | * Page のアクション. |
---|
| 75 | * |
---|
| 76 | * @return void |
---|
| 77 | */ |
---|
| 78 | function action() { |
---|
[20501] | 79 | $objFormParam = new SC_FormParam_Ex(); |
---|
[15342] | 80 | |
---|
[20386] | 81 | // アップロードファイル情報の初期化 |
---|
[20497] | 82 | $objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR); |
---|
[20386] | 83 | $this->lfInitFile($objUpFile); |
---|
| 84 | $objUpFile->setHiddenFileList($_POST); |
---|
[18777] | 85 | |
---|
[20386] | 86 | // ダウンロード販売ファイル情報の初期化 |
---|
[20497] | 87 | $objDownFile = new SC_UploadFile_Ex(DOWN_TEMP_REALDIR, DOWN_SAVE_REALDIR); |
---|
[20386] | 88 | $this->lfInitDownFile($objDownFile); |
---|
| 89 | $objDownFile->setHiddenFileList($_POST); |
---|
[15342] | 90 | |
---|
[20970] | 91 | // 検索パラメーター引き継ぎ |
---|
[20386] | 92 | $this->arrSearchHidden = $this->lfGetSearchParam($_POST); |
---|
[15342] | 93 | |
---|
[20386] | 94 | $mode = $this->getMode(); |
---|
| 95 | switch($mode) { |
---|
| 96 | case 'pre_edit': |
---|
| 97 | case 'copy' : |
---|
[20970] | 98 | // パラメーター初期化(商品ID) |
---|
[20386] | 99 | $this->lfInitFormParam_PreEdit($objFormParam, $_POST); |
---|
| 100 | // エラーチェック |
---|
| 101 | $this->arrErr = $objFormParam->checkError(); |
---|
| 102 | if(count($this->arrErr) > 0) { |
---|
| 103 | SC_Utils_Ex::sfDispException(); |
---|
[17902] | 104 | } |
---|
[15342] | 105 | |
---|
[20386] | 106 | // 商品ID取得 |
---|
| 107 | $product_id = $objFormParam->getValue('product_id'); |
---|
| 108 | // 商品データ取得 |
---|
| 109 | $arrForm = $this->lfGetFormParam_PreEdit($objUpFile, $objDownFile, $product_id); |
---|
[21214] | 110 | |
---|
| 111 | // 複製の場合は、ダウンロード商品情報部分はコピーしない |
---|
| 112 | if ($mode == 'copy') { |
---|
| 113 | // ダウンロード商品ファイル名をunset |
---|
| 114 | $arrForm['down_filename'] = ''; |
---|
| 115 | |
---|
| 116 | // $objDownFile->setDBDownFile()でsetされたダウンロードファイル名をunset |
---|
| 117 | unset($objDownFile->save_file[0]); |
---|
| 118 | } |
---|
| 119 | |
---|
[20970] | 120 | // ページ表示用パラメーター設定 |
---|
[20386] | 121 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
[15342] | 122 | |
---|
[20386] | 123 | // 商品複製の場合、画像ファイルコピー |
---|
[20538] | 124 | if($mode == 'copy') { |
---|
[20386] | 125 | $this->arrForm["copy_product_id"] = $this->arrForm["product_id"]; |
---|
| 126 | $this->arrForm["product_id"] = ""; |
---|
| 127 | // 画像ファイルのコピー |
---|
| 128 | $this->lfCopyProductImageFiles($objUpFile); |
---|
| 129 | } |
---|
[15342] | 130 | |
---|
[20386] | 131 | // ページonload時のJavaScript設定 |
---|
| 132 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); |
---|
| 133 | break; |
---|
[18863] | 134 | |
---|
[20386] | 135 | case 'edit': |
---|
[20970] | 136 | // パラメーター初期化, 取得 |
---|
[20386] | 137 | $this->lfInitFormParam($objFormParam, $_POST); |
---|
| 138 | $arrForm = $objFormParam->getHashArray(); |
---|
| 139 | // エラーチェック |
---|
| 140 | $this->arrErr = $this->lfCheckError_Edit($objFormParam, $objUpFile, $objDownFile, $arrForm); |
---|
| 141 | if(count($this->arrErr) == 0) { |
---|
| 142 | // 確認画面表示設定 |
---|
| 143 | $this->tpl_mainpage = 'products/confirm.tpl'; |
---|
| 144 | $this->arrCatList = $this->lfGetCategoryList_Edit(); |
---|
| 145 | $this->arrForm = $this->lfSetViewParam_ConfirmPage($objUpFile, $objDownFile, $arrForm); |
---|
| 146 | } else { |
---|
| 147 | // 入力画面表示設定 |
---|
| 148 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
| 149 | // ページonload時のJavaScript設定 |
---|
| 150 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); |
---|
| 151 | } |
---|
| 152 | break; |
---|
[15342] | 153 | |
---|
[20386] | 154 | case 'complete': |
---|
[20970] | 155 | // パラメーター初期化, 取得 |
---|
[20386] | 156 | $this->lfInitFormParam($objFormParam, $_POST); |
---|
| 157 | $arrForm = $this->lfGetFormParam_Complete($objFormParam); |
---|
| 158 | // エラーチェック |
---|
| 159 | $this->arrErr = $this->lfCheckError_Edit($objFormParam, $objUpFile, $objDownFile, $arrForm); |
---|
| 160 | if(count($this->arrErr) == 0) { |
---|
| 161 | // DBへデータ登録 |
---|
| 162 | $product_id = $this->lfRegistProduct($objUpFile, $objDownFile, $arrForm); |
---|
[15342] | 163 | |
---|
[17902] | 164 | // 件数カウントバッチ実行 |
---|
[20507] | 165 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[20386] | 166 | $objDb = new SC_Helper_DB_Ex(); |
---|
[20032] | 167 | $objDb->sfCountCategory($objQuery); |
---|
| 168 | $objDb->sfCountMaker($objQuery); |
---|
[20386] | 169 | |
---|
[21202] | 170 | // ダウンロード商品の複製時に、ダウンロード商品用ファイルを |
---|
| 171 | // 変更すると、複製元のファイルが削除されるのを回避。 |
---|
| 172 | if (!empty($arrForm['copy_product_id'])) { |
---|
| 173 | $objDownFile->save_file = array(); |
---|
| 174 | } |
---|
| 175 | |
---|
[17902] | 176 | // 一時ファイルを本番ディレクトリに移動する |
---|
[20386] | 177 | $this->lfSaveUploadFiles($objUpFile, $objDownFile, $product_id); |
---|
[15342] | 178 | |
---|
[20386] | 179 | $this->tpl_mainpage = 'products/complete.tpl'; |
---|
| 180 | $this->arrForm['product_id'] = $product_id; |
---|
| 181 | } else { |
---|
| 182 | // 入力画面表示設定 |
---|
| 183 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
| 184 | // ページonload時のJavaScript設定 |
---|
| 185 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); |
---|
| 186 | } |
---|
| 187 | break; |
---|
[15342] | 188 | |
---|
[20386] | 189 | // 画像のアップロード |
---|
| 190 | case 'upload_image': |
---|
| 191 | case 'delete_image': |
---|
[20970] | 192 | // パラメーター初期化 |
---|
[20386] | 193 | $this->lfInitFormParam_UploadImage($objFormParam); |
---|
| 194 | $this->lfInitFormParam($objFormParam, $_POST); |
---|
| 195 | $arrForm = $objFormParam->getHashArray(); |
---|
[15342] | 196 | |
---|
[20386] | 197 | switch($mode) { |
---|
| 198 | case 'upload_image': |
---|
| 199 | // ファイルを一時ディレクトリにアップロード |
---|
| 200 | $this->arrErr[$arrForm['image_key']] = $objUpFile->makeTempFile($arrForm['image_key'], IMAGE_RENAME); |
---|
| 201 | if($this->arrErr[$arrForm['image_key']] == "") { |
---|
| 202 | // 縮小画像作成 |
---|
| 203 | $this->lfSetScaleImage($objUpFile, $arrForm['image_key']); |
---|
| 204 | } |
---|
[17902] | 205 | break; |
---|
| 206 | case 'delete_image': |
---|
[20386] | 207 | // ファイル削除 |
---|
| 208 | $this->lfDeleteTempFile($objUpFile, $arrForm['image_key']); |
---|
[17902] | 209 | break; |
---|
[20386] | 210 | } |
---|
| 211 | |
---|
| 212 | // 入力画面表示設定 |
---|
| 213 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
| 214 | // ページonload時のJavaScript設定 |
---|
| 215 | $anchor_hash = $this->getAnchorHash($arrForm['image_key']); |
---|
| 216 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage($anchor_hash); |
---|
| 217 | break; |
---|
| 218 | |
---|
| 219 | // ダウンロード商品ファイルアップロード |
---|
| 220 | case 'upload_down': |
---|
| 221 | case 'delete_down': |
---|
[20970] | 222 | // パラメーター初期化 |
---|
[20386] | 223 | $this->lfInitFormParam_UploadDown($objFormParam); |
---|
| 224 | $this->lfInitFormParam($objFormParam, $_POST); |
---|
| 225 | $arrForm = $objFormParam->getHashArray(); |
---|
| 226 | |
---|
| 227 | switch($mode) { |
---|
[18777] | 228 | case 'upload_down': |
---|
[20386] | 229 | // ファイルを一時ディレクトリにアップロード |
---|
| 230 | $this->arrErr[$arrForm['down_key']] = $objDownFile->makeTempDownFile(); |
---|
[18777] | 231 | break; |
---|
| 232 | case 'delete_down': |
---|
[20386] | 233 | // ファイル削除 |
---|
| 234 | $objDownFile->deleteFile($arrForm['down_key']); |
---|
[18777] | 235 | break; |
---|
[20386] | 236 | } |
---|
[15342] | 237 | |
---|
[20386] | 238 | // 入力画面表示設定 |
---|
| 239 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
| 240 | // ページonload時のJavaScript設定 |
---|
| 241 | $anchor_hash = $this->getAnchorHash($arrForm['down_key']); |
---|
| 242 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage($anchor_hash); |
---|
| 243 | break; |
---|
[15342] | 244 | |
---|
[20386] | 245 | // 関連商品選択 |
---|
| 246 | case 'recommend_select' : |
---|
[20970] | 247 | // パラメーター初期化 |
---|
[20386] | 248 | $this->lfInitFormParam_RecommendSelect($objFormParam); |
---|
| 249 | $this->lfInitFormParam($objFormParam, $_POST); |
---|
| 250 | $arrForm = $objFormParam->getHashArray(); |
---|
| 251 | // 入力画面表示設定 |
---|
| 252 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
[20638] | 253 | |
---|
| 254 | // 選択された関連商品IDがすでに登録している関連商品と重複していないかチェック |
---|
| 255 | $this->lfCheckError_RecommendSelect($this->arrForm, $this->arrErr); |
---|
| 256 | |
---|
[20386] | 257 | // ページonload時のJavaScript設定 |
---|
[20638] | 258 | $anchor_hash = $this->getAnchorHash($this->arrForm['anchor_key']); |
---|
[20386] | 259 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage($anchor_hash); |
---|
| 260 | break; |
---|
[15342] | 261 | |
---|
[20386] | 262 | // 確認ページからの戻り |
---|
| 263 | case 'confirm_return': |
---|
[20970] | 264 | // パラメーター初期化 |
---|
[20386] | 265 | $this->lfInitFormParam($objFormParam, $_POST); |
---|
| 266 | $arrForm = $objFormParam->getHashArray(); |
---|
| 267 | // 入力画面表示設定 |
---|
| 268 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
| 269 | // ページonload時のJavaScript設定 |
---|
| 270 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); |
---|
| 271 | break; |
---|
| 272 | |
---|
| 273 | default: |
---|
| 274 | // 入力画面表示設定 |
---|
| 275 | $arrForm = array(); |
---|
| 276 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
| 277 | // ページonload時のJavaScript設定 |
---|
| 278 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); |
---|
| 279 | break; |
---|
[17902] | 280 | } |
---|
[18777] | 281 | |
---|
[20386] | 282 | // 関連商品の読み込み |
---|
| 283 | $this->arrRecommend = $this->lfGetRecommendProducts($this->arrForm); |
---|
[17902] | 284 | } |
---|
[15342] | 285 | |
---|
[17902] | 286 | /** |
---|
| 287 | * デストラクタ. |
---|
| 288 | * |
---|
| 289 | * @return void |
---|
| 290 | */ |
---|
| 291 | function destroy() { |
---|
| 292 | parent::destroy(); |
---|
| 293 | } |
---|
[15342] | 294 | |
---|
[18378] | 295 | /** |
---|
[20970] | 296 | * パラメーター情報の初期化 |
---|
[20386] | 297 | * - 編集/複製モード |
---|
[18378] | 298 | * |
---|
[20386] | 299 | * @param object $objFormParam SC_FormParamインスタンス |
---|
| 300 | * @param array $arrPost $_POSTデータ |
---|
| 301 | * @return void |
---|
[18378] | 302 | */ |
---|
[20386] | 303 | function lfInitFormParam_PreEdit(&$objFormParam, $arrPost) { |
---|
[20538] | 304 | $objFormParam->addParam("商品ID", "product_id", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
[20386] | 305 | $objFormParam->setParam($arrPost); |
---|
| 306 | $objFormParam->convParam(); |
---|
| 307 | } |
---|
[15342] | 308 | |
---|
[20386] | 309 | /** |
---|
[20970] | 310 | * パラメーター情報の初期化 |
---|
[20386] | 311 | * |
---|
| 312 | * @param object $objFormParam SC_FormParamインスタンス |
---|
| 313 | * @param array $arrPost $_POSTデータ |
---|
| 314 | * @return void |
---|
| 315 | */ |
---|
| 316 | function lfInitFormParam(&$objFormParam, $arrPost) { |
---|
[20538] | 317 | $objFormParam->addParam("商品ID", "product_id", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 318 | $objFormParam->addParam("商品名", 'name', STEXT_LEN, 'KVa', array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 319 | $objFormParam->addParam("商品カテゴリ", "category_id", INT_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 320 | $objFormParam->addParam("公開・非公開", 'status', INT_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 321 | $objFormParam->addParam("商品ステータス", "product_status", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
[15556] | 322 | |
---|
[20386] | 323 | if($this->lfGetProductClassFlag($arrPost['has_product_class']) == false) { |
---|
| 324 | // 新規登録, 規格なし商品の編集の場合 |
---|
[20538] | 325 | $objFormParam->addParam("商品種別", "product_type_id", INT_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 326 | $objFormParam->addParam("ダウンロード商品ファイル名", "down_filename", STEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 327 | $objFormParam->addParam("ダウンロード商品実ファイル名", "down_realfilename", MTEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
[20386] | 328 | $objFormParam->addParam("temp_down_file", "temp_down_file", '', "", array()); |
---|
| 329 | $objFormParam->addParam("save_down_file", "save_down_file", '', "", array()); |
---|
[20538] | 330 | $objFormParam->addParam("商品コード", "product_code", STEXT_LEN, 'KVna', array("EXIST_CHECK", "SPTAB_CHECK","MAX_LENGTH_CHECK")); |
---|
| 331 | $objFormParam->addParam(NORMAL_PRICE_TITLE, "price01", PRICE_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 332 | $objFormParam->addParam(SALE_PRICE_TITLE, "price02", PRICE_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 333 | $objFormParam->addParam("在庫数", 'stock', AMOUNT_LEN, 'n', array("SPTAB_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 334 | $objFormParam->addParam("在庫無制限", "stock_unlimited", INT_LEN, 'n', array("SPTAB_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
[20386] | 335 | } |
---|
[20538] | 336 | $objFormParam->addParam("商品送料", "deliv_fee", PRICE_LEN, 'n', array("NUM_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 337 | $objFormParam->addParam("ポイント付与率", "point_rate", PERCENTAGE_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 338 | $objFormParam->addParam("発送日目安", "deliv_date_id", INT_LEN, 'n', array("NUM_CHECK")); |
---|
[21352] | 339 | $objFormParam->addParam("販売制限数", "sale_limit", AMOUNT_LEN, 'n', array("SPTAB_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
[20538] | 340 | $objFormParam->addParam("メーカー", "maker_id", INT_LEN, 'n', array("NUM_CHECK")); |
---|
| 341 | $objFormParam->addParam("メーカーURL", "comment1", URL_LEN, 'a', array("SPTAB_CHECK", "URL_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 342 | $objFormParam->addParam("検索ワード", "comment3", LLTEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 343 | $objFormParam->addParam("備考欄(SHOP専用)", 'note', LLTEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 344 | $objFormParam->addParam("一覧-メインコメント", "main_list_comment", MTEXT_LEN, 'KVa', array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 345 | $objFormParam->addParam("詳細-メインコメント", "main_comment", LLTEXT_LEN, 'KVa', array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
[20386] | 346 | $objFormParam->addParam("save_main_list_image", "save_main_list_image", '', "", array()); |
---|
| 347 | $objFormParam->addParam("save_main_image", "save_main_image", '', "", array()); |
---|
| 348 | $objFormParam->addParam("save_main_large_image", "save_main_large_image", '', "", array()); |
---|
| 349 | $objFormParam->addParam("temp_main_list_image", "temp_main_list_image", '', "", array()); |
---|
| 350 | $objFormParam->addParam("temp_main_image", "temp_main_image", '', "", array()); |
---|
| 351 | $objFormParam->addParam("temp_main_large_image", "temp_main_large_image", '', "", array()); |
---|
| 352 | |
---|
| 353 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
[20538] | 354 | $objFormParam->addParam("詳細-サブタイトル" . $cnt, "sub_title" . $cnt, STEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 355 | $objFormParam->addParam("詳細-サブコメント" . $cnt, "sub_comment" . $cnt, LLTEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
[20386] | 356 | $objFormParam->addParam("save_sub_image" . $cnt, "save_sub_image" . $cnt, '', "", array()); |
---|
| 357 | $objFormParam->addParam("save_sub_large_image" . $cnt, "save_sub_large_image" . $cnt, '', "", array()); |
---|
| 358 | $objFormParam->addParam("temp_sub_image" . $cnt, "temp_sub_image" . $cnt, '', "", array()); |
---|
| 359 | $objFormParam->addParam("temp_sub_large_image" . $cnt, "temp_sub_large_image" . $cnt, '', "", array()); |
---|
| 360 | } |
---|
| 361 | |
---|
| 362 | for ($cnt = 1; $cnt <= RECOMMEND_PRODUCT_MAX; $cnt++) { |
---|
[20538] | 363 | $objFormParam->addParam("関連商品コメント" . $cnt, "recommend_comment" . $cnt, LTEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 364 | $objFormParam->addParam("関連商品ID" . $cnt, "recommend_id" . $cnt, INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 365 | $objFormParam->addParam("recommend_delete" . $cnt, "recommend_delete" . $cnt, '', 'n', array()); |
---|
[20386] | 366 | } |
---|
| 367 | |
---|
[20638] | 368 | $objFormParam->addParam("商品ID", "copy_product_id", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
[20386] | 369 | |
---|
[20538] | 370 | $objFormParam->addParam("has_product_class", "has_product_class", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 371 | $objFormParam->addParam("product_class_id", "product_class_id", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
[20386] | 372 | |
---|
| 373 | $objFormParam->setParam($arrPost); |
---|
| 374 | $objFormParam->convParam(); |
---|
| 375 | } |
---|
| 376 | |
---|
| 377 | /** |
---|
[20970] | 378 | * パラメーター情報の初期化 |
---|
[20386] | 379 | * - 画像ファイルアップロードモード |
---|
| 380 | * |
---|
| 381 | * @param object $objFormParam SC_FormParamインスタンス |
---|
| 382 | * @return void |
---|
| 383 | */ |
---|
| 384 | function lfInitFormParam_UploadImage(&$objFormParam) { |
---|
| 385 | $objFormParam->addParam("image_key", "image_key", "", "", array()); |
---|
| 386 | } |
---|
| 387 | |
---|
| 388 | /** |
---|
[20970] | 389 | * パラメーター情報の初期化 |
---|
[20386] | 390 | * - ダウンロード商品ファイルアップロードモード |
---|
| 391 | * |
---|
| 392 | * @param object $objFormParam SC_FormParamインスタンス |
---|
| 393 | * @return void |
---|
| 394 | */ |
---|
| 395 | function lfInitFormParam_UploadDown(&$objFormParam) { |
---|
| 396 | $objFormParam->addParam("down_key", "down_key", "", "", array()); |
---|
| 397 | } |
---|
| 398 | |
---|
| 399 | /** |
---|
[20970] | 400 | * パラメーター情報の初期化 |
---|
[20386] | 401 | * - 関連商品追加モード |
---|
| 402 | * |
---|
| 403 | * @param object $objFormParam SC_FormParamインスタンス |
---|
| 404 | * @return void |
---|
| 405 | */ |
---|
| 406 | function lfInitFormParam_RecommendSelect(&$objFormParam) { |
---|
| 407 | $objFormParam->addParam("anchor_key", "anchor_key", "", "", array()); |
---|
[20638] | 408 | $objFormParam->addParam("select_recommend_no", "select_recommend_no", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
[20386] | 409 | } |
---|
| 410 | |
---|
| 411 | /** |
---|
[20970] | 412 | * アップロードファイルパラメーター情報の初期化 |
---|
[20386] | 413 | * - 画像ファイル用 |
---|
| 414 | * |
---|
| 415 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
| 416 | * @return void |
---|
| 417 | */ |
---|
| 418 | function lfInitFile(&$objUpFile) { |
---|
| 419 | $objUpFile->addFile("一覧-メイン画像", 'main_list_image', array('jpg', 'gif', 'png'),IMAGE_SIZE, false, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); |
---|
| 420 | $objUpFile->addFile("詳細-メイン画像", 'main_image', array('jpg', 'gif', 'png'), IMAGE_SIZE, false, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT); |
---|
| 421 | $objUpFile->addFile("詳細-メイン拡大画像", 'main_large_image', array('jpg', 'gif', 'png'), IMAGE_SIZE, false, LARGE_IMAGE_WIDTH, LARGE_IMAGE_HEIGHT); |
---|
| 422 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
| 423 | $objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg', 'gif', 'png'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_WIDTH, NORMAL_SUBIMAGE_HEIGHT); |
---|
| 424 | $objUpFile->addFile("詳細-サブ拡大画像$cnt", "sub_large_image$cnt", array('jpg', 'gif', 'png'), IMAGE_SIZE, false, LARGE_SUBIMAGE_WIDTH, LARGE_SUBIMAGE_HEIGHT); |
---|
| 425 | } |
---|
| 426 | } |
---|
| 427 | |
---|
| 428 | /** |
---|
[20970] | 429 | * アップロードファイルパラメーター情報の初期化 |
---|
[20386] | 430 | * - ダウンロード商品ファイル用 |
---|
| 431 | * |
---|
| 432 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
| 433 | * @return void |
---|
| 434 | */ |
---|
| 435 | function lfInitDownFile(&$objDownFile) { |
---|
| 436 | $objDownFile->addFile("ダウンロード販売用ファイル", 'down_file', explode(",", DOWNLOAD_EXTENSION),DOWN_SIZE, true, 0, 0); |
---|
| 437 | } |
---|
| 438 | |
---|
| 439 | /** |
---|
[20970] | 440 | * フォーム入力パラメーターのエラーチェック |
---|
[20386] | 441 | * |
---|
| 442 | * @param object $objFormParam SC_FormParamインスタンス |
---|
| 443 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
| 444 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
[20970] | 445 | * @param array $arrForm フォーム入力パラメーター配列 |
---|
[20386] | 446 | * @return array エラー情報を格納した連想配列 |
---|
| 447 | */ |
---|
| 448 | function lfCheckError_Edit(&$objFormParam, &$objUpFile, &$objDownFile, $arrForm) { |
---|
[20503] | 449 | $objErr = new SC_CheckError_Ex($arrForm); |
---|
[20386] | 450 | $arrErr = array(); |
---|
| 451 | |
---|
[20970] | 452 | // 入力パラメーターチェック |
---|
[20386] | 453 | $arrErr = $objFormParam->checkError(); |
---|
| 454 | |
---|
| 455 | // アップロードファイル必須チェック |
---|
| 456 | $arrErr = array_merge((array)$arrErr, (array)$objUpFile->checkEXISTS()); |
---|
| 457 | |
---|
| 458 | // HTMLタグ許可チェック |
---|
| 459 | $objErr->doFunc(array("詳細-メインコメント", "main_comment", $this->arrAllowedTag), array("HTML_TAG_CHECK")); |
---|
| 460 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
| 461 | $objErr->doFunc(array("詳細-サブコメント" . $cnt, "sub_comment" . $cnt, $this->arrAllowedTag), array("HTML_TAG_CHECK")); |
---|
| 462 | } |
---|
| 463 | |
---|
| 464 | // 規格情報がない商品の場合のチェック |
---|
| 465 | if($arrForm['has_product_class'] != true) { |
---|
| 466 | // 在庫必須チェック(在庫無制限ではない場合) |
---|
| 467 | if(!isset($arrForm['stock_unlimited']) && $arrForm['stock_unlimited'] != UNLIMITED_FLG_UNLIMITED) { |
---|
[20538] | 468 | $objErr->doFunc(array("在庫数", 'stock'), array("EXIST_CHECK")); |
---|
[17902] | 469 | } |
---|
[20386] | 470 | // ダウンロード商品ファイル必須チェック(ダウンロード商品の場合) |
---|
| 471 | if($arrForm['product_type_id'] == PRODUCT_TYPE_DOWNLOAD) { |
---|
| 472 | $arrErr = array_merge((array)$arrErr, (array)$objDownFile->checkEXISTS()); |
---|
[21261] | 473 | $objErr->doFunc(array("ダウンロード商品ファイル名", 'down_filename'), array("EXIST_CHECK")); |
---|
[20386] | 474 | } |
---|
[17902] | 475 | } |
---|
[20386] | 476 | |
---|
| 477 | $arrErr = array_merge((array)$arrErr, (array)$objErr->arrErr); |
---|
| 478 | return $arrErr; |
---|
[17902] | 479 | } |
---|
[15342] | 480 | |
---|
[20386] | 481 | /** |
---|
[20638] | 482 | * 関連商品の重複登録チェック、エラーチェック |
---|
| 483 | * |
---|
| 484 | * 関連商品の重複があった場合はエラーメッセージを格納し、該当の商品IDをリセットする |
---|
| 485 | * |
---|
| 486 | * @param array $arrForm 入力値の配列 |
---|
| 487 | * @param array $arrErr エラーメッセージの配列 |
---|
| 488 | * @return void |
---|
| 489 | */ |
---|
| 490 | function lfCheckError_RecommendSelect(&$arrForm, &$arrErr) { |
---|
| 491 | $select_recommend_no = $arrForm['select_recommend_no']; |
---|
| 492 | $select_recommend_id = $arrForm['recommend_id' . $select_recommend_no]; |
---|
| 493 | |
---|
| 494 | foreach(array_keys($arrForm) as $key) { |
---|
| 495 | if(preg_match('/^recommend_id/', $key)) { |
---|
| 496 | if($select_recommend_no == preg_replace('/^recommend_id/', '', $key)) { |
---|
| 497 | continue; |
---|
| 498 | } |
---|
| 499 | |
---|
| 500 | if($select_recommend_id == $arrForm[$key]) { |
---|
| 501 | // 重複した場合、選択されたデータをリセットする |
---|
| 502 | $arrForm['recommend_id' . $select_recommend_no] = ''; |
---|
| 503 | $arrErr['recommend_comment' . $select_recommend_no] = '※ すでに登録されている関連商品です。<br />'; |
---|
| 504 | break; |
---|
| 505 | } |
---|
| 506 | } |
---|
| 507 | } |
---|
| 508 | } |
---|
| 509 | |
---|
| 510 | /** |
---|
[20970] | 511 | * 検索パラメーター引き継ぎ用配列取得 |
---|
[20386] | 512 | * |
---|
| 513 | * @param array $arrPost $_POSTデータ |
---|
[20970] | 514 | * @return array 検索パラメーター配列 |
---|
[20386] | 515 | */ |
---|
| 516 | function lfGetSearchParam($arrPost) { |
---|
| 517 | $arrSearchParam = array(); |
---|
[20501] | 518 | $objFormParam = new SC_FormParam_Ex(); |
---|
[15556] | 519 | |
---|
[20386] | 520 | parent::lfInitParam($objFormParam); |
---|
| 521 | $objFormParam->setParam($arrPost); |
---|
| 522 | $arrSearchParam = $objFormParam->getSearchArray(); |
---|
[15556] | 523 | |
---|
[20386] | 524 | return $arrSearchParam; |
---|
| 525 | } |
---|
| 526 | |
---|
| 527 | /** |
---|
[20970] | 528 | * フォームパラメーター取得 |
---|
[20386] | 529 | * - 編集/複製モード |
---|
| 530 | * |
---|
| 531 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
| 532 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
| 533 | * @param integer $product_id 商品ID |
---|
[20970] | 534 | * @return array フォームパラメーター配列 |
---|
[20386] | 535 | */ |
---|
| 536 | function lfGetFormParam_PreEdit(&$objUpFile, &$objDownFile, $product_id) { |
---|
| 537 | $arrForm = array(); |
---|
| 538 | |
---|
| 539 | // DBから商品データ取得 |
---|
| 540 | $arrForm = $this->lfGetProductData_FromDB($product_id); |
---|
| 541 | // DBデータから画像ファイル名の読込 |
---|
| 542 | $objUpFile->setDBFileList($arrForm); |
---|
| 543 | // DBデータからダウンロードファイル名の読込 |
---|
| 544 | $objDownFile->setDBDownFile($arrForm); |
---|
| 545 | |
---|
| 546 | return $arrForm; |
---|
| 547 | } |
---|
| 548 | |
---|
| 549 | /** |
---|
[20970] | 550 | * フォームパラメーター取得 |
---|
[20386] | 551 | * - 登録モード |
---|
| 552 | * |
---|
| 553 | * @param object $objFormParam SC_FormParamインスタンス |
---|
[20970] | 554 | * @return array フォームパラメーター配列 |
---|
[20386] | 555 | */ |
---|
| 556 | function lfGetFormParam_Complete(&$objFormParam) { |
---|
| 557 | $arrForm = $objFormParam->getHashArray(); |
---|
| 558 | $arrForm['category_id'] = unserialize($arrForm['category_id']); |
---|
| 559 | $objFormParam->setValue('category_id', $arrForm['category_id']); |
---|
| 560 | |
---|
| 561 | return $arrForm; |
---|
| 562 | } |
---|
| 563 | |
---|
| 564 | /** |
---|
[20970] | 565 | * 表示用フォームパラメーター取得 |
---|
[20386] | 566 | * - 入力画面 |
---|
| 567 | * |
---|
| 568 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
| 569 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
[20970] | 570 | * @param array $arrForm フォーム入力パラメーター配列 |
---|
| 571 | * @return array 表示用フォームパラメーター配列 |
---|
[20386] | 572 | */ |
---|
| 573 | function lfSetViewParam_InputPage(&$objUpFile, &$objDownFile, &$arrForm) { |
---|
[20970] | 574 | // カテゴリマスターデータ取得 |
---|
[20386] | 575 | $objDb = new SC_Helper_DB_Ex(); |
---|
| 576 | list($this->arrCatVal, $this->arrCatOut) = $objDb->sfGetLevelCatList(false); |
---|
| 577 | |
---|
| 578 | if (isset($arrForm['category_id']) && !is_array($arrForm['category_id'])) { |
---|
| 579 | $arrForm['category_id'] = unserialize($arrForm['category_id']); |
---|
| 580 | } |
---|
| 581 | if($arrForm['status'] == "") { |
---|
| 582 | $arrForm['status'] = DEFAULT_PRODUCT_DISP; |
---|
| 583 | } |
---|
| 584 | if($arrForm['product_type_id'] == "") { |
---|
| 585 | $arrForm['product_type_id'] = DEFAULT_PRODUCT_DOWN; |
---|
| 586 | } |
---|
| 587 | // アップロードファイル情報取得(Hidden用) |
---|
| 588 | $arrHidden = $objUpFile->getHiddenFileList(); |
---|
| 589 | $arrForm['arrHidden'] = array_merge((array)$arrHidden, (array)$objDownFile->getHiddenFileList()); |
---|
| 590 | |
---|
| 591 | // 画像ファイル表示用データ取得 |
---|
| 592 | $arrForm['arrFile'] = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH); |
---|
| 593 | |
---|
| 594 | // ダウンロード商品実ファイル名取得 |
---|
| 595 | $arrForm['down_realfilename'] = $objDownFile->getFormDownFile(); |
---|
| 596 | |
---|
| 597 | // 基本情報(デフォルトポイントレート用) |
---|
[20484] | 598 | $arrForm['arrInfo'] = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
[20386] | 599 | |
---|
| 600 | // サブ情報ありなしフラグ |
---|
| 601 | $arrForm['sub_find'] = $this->hasSubProductData($arrForm); |
---|
| 602 | |
---|
| 603 | return $arrForm; |
---|
| 604 | } |
---|
| 605 | |
---|
| 606 | /** |
---|
[20970] | 607 | * 表示用フォームパラメーター取得 |
---|
[20386] | 608 | * - 確認画面 |
---|
| 609 | * |
---|
| 610 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
| 611 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
[20970] | 612 | * @param array $arrForm フォーム入力パラメーター配列 |
---|
| 613 | * @return array 表示用フォームパラメーター配列 |
---|
[20386] | 614 | */ |
---|
| 615 | function lfSetViewParam_ConfirmPage(&$objUpFile, &$objDownFile, &$arrForm) { |
---|
| 616 | // カテゴリ表示用 |
---|
| 617 | $arrForm['arrCategoryId'] = $arrForm['category_id']; |
---|
| 618 | // hidden に渡す値は serialize する |
---|
| 619 | $arrForm['category_id'] = serialize($arrForm['category_id']); |
---|
| 620 | // 画像ファイル用データ取得 |
---|
| 621 | $arrForm['arrFile'] = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH); |
---|
| 622 | // ダウンロード商品実ファイル名取得 |
---|
| 623 | $arrForm['down_realfilename'] = $objDownFile->getFormDownFile(); |
---|
| 624 | |
---|
| 625 | return $arrForm; |
---|
| 626 | } |
---|
| 627 | |
---|
| 628 | /** |
---|
| 629 | * 縮小した画像をセットする |
---|
| 630 | * |
---|
| 631 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
| 632 | * @param string $image_key 画像ファイルキー |
---|
| 633 | * @return void |
---|
| 634 | */ |
---|
| 635 | function lfSetScaleImage(&$objUpFile, $image_key){ |
---|
| 636 | $subno = str_replace("sub_large_image", "", $image_key); |
---|
| 637 | switch ($image_key){ |
---|
| 638 | case "main_large_image": |
---|
| 639 | // 詳細メイン画像 |
---|
| 640 | $this->lfMakeScaleImage($objUpFile, $image_key, "main_image"); |
---|
| 641 | case "main_image": |
---|
| 642 | // 一覧メイン画像 |
---|
| 643 | $this->lfMakeScaleImage($objUpFile, $image_key, "main_list_image"); |
---|
| 644 | break; |
---|
| 645 | case "sub_large_image" . $subno: |
---|
| 646 | // サブメイン画像 |
---|
| 647 | $this->lfMakeScaleImage($objUpFile, $_POST['image_key'], "sub_image" . $subno); |
---|
| 648 | break; |
---|
| 649 | default: |
---|
| 650 | break; |
---|
| 651 | } |
---|
| 652 | } |
---|
| 653 | |
---|
| 654 | /** |
---|
| 655 | * 画像ファイルのコピー |
---|
| 656 | * |
---|
| 657 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
| 658 | * @return void |
---|
| 659 | */ |
---|
| 660 | function lfCopyProductImageFiles(&$objUpFile) { |
---|
| 661 | $arrKey = $objUpFile->keyname; |
---|
| 662 | $arrSaveFile = $objUpFile->save_file; |
---|
| 663 | |
---|
| 664 | foreach($arrSaveFile as $key => $val){ |
---|
| 665 | $this->lfMakeScaleImage($objUpFile, $arrKey[$key], $arrKey[$key], true); |
---|
| 666 | } |
---|
| 667 | } |
---|
| 668 | |
---|
| 669 | /** |
---|
| 670 | * 縮小画像生成 |
---|
| 671 | * |
---|
| 672 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
| 673 | * @param string $from_key 元画像ファイルキー |
---|
| 674 | * @param string $to_key 縮小画像ファイルキー |
---|
| 675 | * @param boolean $forced |
---|
| 676 | * @return void |
---|
| 677 | */ |
---|
| 678 | function lfMakeScaleImage(&$objUpFile, $from_key, $to_key, $forced = false){ |
---|
| 679 | $arrImageKey = array_flip($objUpFile->keyname); |
---|
| 680 | $from_path = ""; |
---|
| 681 | |
---|
| 682 | if($objUpFile->temp_file[$arrImageKey[$from_key]]) { |
---|
| 683 | $from_path = $objUpFile->temp_dir . $objUpFile->temp_file[$arrImageKey[$from_key]]; |
---|
| 684 | } elseif($objUpFile->save_file[$arrImageKey[$from_key]]){ |
---|
| 685 | $from_path = $objUpFile->save_dir . $objUpFile->save_file[$arrImageKey[$from_key]]; |
---|
| 686 | } |
---|
| 687 | |
---|
| 688 | if(file_exists($from_path)) { |
---|
| 689 | // 生成先の画像サイズを取得 |
---|
| 690 | $to_w = $objUpFile->width[$arrImageKey[$to_key]]; |
---|
| 691 | $to_h = $objUpFile->height[$arrImageKey[$to_key]]; |
---|
| 692 | |
---|
| 693 | if($forced) $objUpFile->save_file[$arrImageKey[$to_key]] = ""; |
---|
| 694 | |
---|
| 695 | if(empty($objUpFile->temp_file[$arrImageKey[$to_key]]) |
---|
| 696 | && empty($objUpFile->save_file[$arrImageKey[$to_key]])) { |
---|
| 697 | // リネームする際は、自動生成される画像名に一意となるように、Suffixを付ける |
---|
| 698 | $dst_file = $objUpFile->lfGetTmpImageName(IMAGE_RENAME, "", $objUpFile->temp_file[$arrImageKey[$from_key]]) . $this->lfGetAddSuffix($to_key); |
---|
| 699 | $path = $objUpFile->makeThumb($from_path, $to_w, $to_h, $dst_file); |
---|
| 700 | $objUpFile->temp_file[$arrImageKey[$to_key]] = basename($path); |
---|
[17902] | 701 | } |
---|
| 702 | } |
---|
| 703 | } |
---|
[15342] | 704 | |
---|
[18378] | 705 | /** |
---|
[20970] | 706 | * アップロードファイルパラメーター情報から削除 |
---|
[20386] | 707 | * 一時ディレクトリに保存されている実ファイルも削除する |
---|
[18378] | 708 | * |
---|
[20386] | 709 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
| 710 | * @param string $image_key 画像ファイルキー |
---|
[18378] | 711 | * @return void |
---|
| 712 | */ |
---|
[20386] | 713 | function lfDeleteTempFile(&$objUpFile, $image_key) { |
---|
| 714 | // TODO: SC_UploadFile::deleteFileの画像削除条件見直し要 |
---|
| 715 | $arrTempFile = $objUpFile->temp_file; |
---|
| 716 | $arrKeyName = $objUpFile->keyname; |
---|
[15342] | 717 | |
---|
[20386] | 718 | foreach($arrKeyName as $key => $keyname) { |
---|
| 719 | if($keyname != $image_key) continue; |
---|
| 720 | |
---|
| 721 | if(!empty($arrTempFile[$key])) { |
---|
| 722 | $temp_file = $arrTempFile[$key]; |
---|
| 723 | $arrTempFile[$key] = ''; |
---|
| 724 | |
---|
| 725 | if(!in_array($temp_file, $arrTempFile)) { |
---|
| 726 | $objUpFile->deleteFile($image_key); |
---|
| 727 | } else { |
---|
| 728 | $objUpFile->temp_file[$key] = ''; |
---|
| 729 | $objUpFile->save_file[$key] = ''; |
---|
| 730 | } |
---|
| 731 | } else { |
---|
| 732 | $objUpFile->temp_file[$key] = ''; |
---|
| 733 | $objUpFile->save_file[$key] = ''; |
---|
| 734 | } |
---|
[17902] | 735 | } |
---|
| 736 | } |
---|
[15342] | 737 | |
---|
[20386] | 738 | /** |
---|
| 739 | * アップロードファイルを保存する |
---|
| 740 | * |
---|
| 741 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
| 742 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
| 743 | * @param integer $product_id 商品ID |
---|
| 744 | * @return void |
---|
| 745 | */ |
---|
| 746 | function lfSaveUploadFiles(&$objUpFile, &$objDownFile, $product_id) { |
---|
| 747 | // TODO: SC_UploadFile::moveTempFileの画像削除条件見直し要 |
---|
[20498] | 748 | $objImage = new SC_Image_Ex($objUpFile->temp_dir); |
---|
[20386] | 749 | $arrKeyName = $objUpFile->keyname; |
---|
| 750 | $arrTempFile = $objUpFile->temp_file; |
---|
| 751 | $arrSaveFile = $objUpFile->save_file; |
---|
| 752 | $arrImageKey = array(); |
---|
| 753 | foreach($arrTempFile as $key => $temp_file) { |
---|
| 754 | if($temp_file) { |
---|
| 755 | $objImage->moveTempImage($temp_file, $objUpFile->save_dir); |
---|
| 756 | $arrImageKey[] = $arrKeyName[$key]; |
---|
| 757 | if(!empty($arrSaveFile[$key]) |
---|
| 758 | && !$this->lfHasSameProductImage($product_id, $arrImageKey, $arrSaveFile[$key]) |
---|
| 759 | && !in_array($temp_file, $arrSaveFile)) { |
---|
| 760 | $objImage->deleteImage($arrSaveFile[$key], $objUpFile->save_dir); |
---|
| 761 | } |
---|
| 762 | } |
---|
| 763 | } |
---|
| 764 | $objDownFile->moveTempDownFile(); |
---|
| 765 | } |
---|
| 766 | |
---|
| 767 | /** |
---|
| 768 | * 同名画像ファイル登録の有無を確認する. |
---|
| 769 | * |
---|
| 770 | * 画像ファイルの削除可否判定用。 |
---|
| 771 | * 同名ファイルの登録がある場合には画像ファイルの削除を行わない。 |
---|
[20532] | 772 | * 戻り値: 同名ファイル有り(true) 同名ファイル無し(false) |
---|
[20386] | 773 | * |
---|
| 774 | * @param string $product_id 商品ID |
---|
| 775 | * @param string $arrImageKey 対象としない画像カラム名 |
---|
| 776 | * @param string $image_file_name 画像ファイル名 |
---|
| 777 | * @return boolean |
---|
| 778 | */ |
---|
| 779 | function lfHasSameProductImage($product_id, $arrImageKey, $image_file_name) { |
---|
| 780 | if (!SC_Utils_Ex::sfIsInt($product_id)) return false; |
---|
| 781 | if (!$arrImageKey) return false; |
---|
| 782 | if (!$image_file_name) return false; |
---|
| 783 | |
---|
| 784 | $arrWhere = array(); |
---|
| 785 | $sqlval = array('0', $product_id); |
---|
| 786 | foreach ($arrImageKey as $image_key) { |
---|
| 787 | $arrWhere[] = "{$image_key} = ?"; |
---|
| 788 | $sqlval[] = $image_file_name; |
---|
| 789 | } |
---|
| 790 | $where = implode(" OR ", $arrWhere); |
---|
| 791 | $where = "del_flg = ? AND ((product_id <> ? AND ({$where}))"; |
---|
| 792 | |
---|
| 793 | $arrKeyName = $this->objUpFile->keyname; |
---|
| 794 | foreach ($arrKeyName as $key => $keyname) { |
---|
| 795 | if (in_array($keyname, $arrImageKey)) continue; |
---|
| 796 | $where .= " OR {$keyname} = ?"; |
---|
| 797 | $sqlval[] = $image_file_name; |
---|
| 798 | } |
---|
| 799 | $where .= ")"; |
---|
| 800 | |
---|
[20507] | 801 | $objQuery = new SC_Query_Ex(); |
---|
[20386] | 802 | $count = $objQuery->count('dtb_products', $where, $sqlval); |
---|
| 803 | if (!$count) return false; |
---|
| 804 | return true; |
---|
| 805 | } |
---|
[18435] | 806 | |
---|
[20386] | 807 | /** |
---|
| 808 | * DBから商品データを取得する |
---|
| 809 | * |
---|
| 810 | * @param integer $product_id 商品ID |
---|
| 811 | * @return array 商品データ配列 |
---|
| 812 | */ |
---|
| 813 | function lfGetProductData_FromDB($product_id) { |
---|
[20507] | 814 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[20386] | 815 | $arrProduct = array(); |
---|
| 816 | |
---|
| 817 | // 商品データ取得 |
---|
[17902] | 818 | $col = "*"; |
---|
[18815] | 819 | $table = <<< __EOF__ |
---|
| 820 | dtb_products AS T1 |
---|
| 821 | LEFT JOIN ( |
---|
| 822 | SELECT product_id AS product_id_sub, |
---|
| 823 | product_code, |
---|
| 824 | price01, |
---|
| 825 | price02, |
---|
[20386] | 826 | deliv_fee, |
---|
[18815] | 827 | stock, |
---|
| 828 | stock_unlimited, |
---|
| 829 | sale_limit, |
---|
[18819] | 830 | point_rate, |
---|
[18882] | 831 | product_type_id, |
---|
[18819] | 832 | down_filename, |
---|
| 833 | down_realfilename |
---|
[20386] | 834 | FROM dtb_products_class |
---|
[18815] | 835 | ) AS T2 |
---|
| 836 | ON T1.product_id = T2.product_id_sub |
---|
| 837 | __EOF__; |
---|
[17902] | 838 | $where = "product_id = ?"; |
---|
[20602] | 839 | $objQuery->setLimit('1'); |
---|
[20386] | 840 | $arrProduct = $objQuery->select($col, $table, $where, array($product_id)); |
---|
[15342] | 841 | |
---|
[20386] | 842 | // カテゴリID取得 |
---|
| 843 | $col = "category_id"; |
---|
| 844 | $table = "dtb_product_categories"; |
---|
| 845 | $where = "product_id = ?"; |
---|
[20796] | 846 | $objQuery->setOption(''); |
---|
[20386] | 847 | $arrProduct[0]['category_id'] = $objQuery->getCol($col, $table, $where, array($product_id)); |
---|
[15342] | 848 | |
---|
[20386] | 849 | // 規格情報ありなしフラグ取得 |
---|
| 850 | $objDb = new SC_Helper_DB_Ex(); |
---|
| 851 | $arrProduct[0]['has_product_class'] = $objDb->sfHasProductClass($product_id); |
---|
| 852 | |
---|
| 853 | // 規格が登録されていなければ規格ID取得 |
---|
| 854 | if ($arrProduct[0]['has_product_class'] == false) { |
---|
[20484] | 855 | $arrProduct[0]['product_class_id'] = SC_Utils_Ex::sfGetProductClassId($product_id,"0","0"); |
---|
[17902] | 856 | } |
---|
[20386] | 857 | |
---|
| 858 | // 商品ステータス取得 |
---|
[20487] | 859 | $objProduct = new SC_Product_Ex(); |
---|
[20386] | 860 | $productStatus = $objProduct->getProductStatus(array($product_id)); |
---|
| 861 | $arrProduct[0]['product_status'] = $productStatus[$product_id]; |
---|
| 862 | |
---|
| 863 | // 関連商品データ取得 |
---|
| 864 | $arrRecommend = $this->lfGetRecommendProductsData_FromDB($product_id); |
---|
| 865 | $arrProduct[0] = array_merge($arrProduct[0], $arrRecommend); |
---|
| 866 | |
---|
| 867 | return $arrProduct[0]; |
---|
[17902] | 868 | } |
---|
[15342] | 869 | |
---|
[20386] | 870 | /** |
---|
| 871 | * DBから関連商品データを取得する |
---|
| 872 | * |
---|
| 873 | * @param integer $product_id 商品ID |
---|
| 874 | * @return array 関連商品データ配列 |
---|
| 875 | */ |
---|
| 876 | function lfGetRecommendProductsData_FromDB($product_id) { |
---|
[20507] | 877 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[20386] | 878 | $arrRecommendProducts = array(); |
---|
[15342] | 879 | |
---|
[20386] | 880 | $col = 'recommend_product_id,'; |
---|
| 881 | $col.= 'comment'; |
---|
| 882 | $table = 'dtb_recommend_products'; |
---|
| 883 | $where = 'product_id = ?'; |
---|
| 884 | $objQuery->setOrder("rank DESC"); |
---|
| 885 | $arrRet = $objQuery->select($col, $table, $where, array($product_id)); |
---|
[15342] | 886 | |
---|
[20386] | 887 | $no = 1; |
---|
| 888 | foreach ($arrRet as $arrVal) { |
---|
| 889 | $arrRecommendProducts['recommend_id' . $no] = $arrVal['recommend_product_id']; |
---|
| 890 | $arrRecommendProducts['recommend_comment' . $no] = $arrVal['comment']; |
---|
| 891 | $no++; |
---|
[17902] | 892 | } |
---|
[15342] | 893 | |
---|
[20386] | 894 | return $arrRecommendProducts; |
---|
| 895 | } |
---|
[15342] | 896 | |
---|
[20386] | 897 | /** |
---|
| 898 | * 関連商品データ表示用配列を取得する |
---|
| 899 | * |
---|
[20970] | 900 | * @param string $arrForm フォーム入力パラメーター配列 |
---|
[20386] | 901 | * @return array 関連商品データ配列 |
---|
| 902 | */ |
---|
| 903 | function lfGetRecommendProducts(&$arrForm) { |
---|
| 904 | $arrRecommend = array(); |
---|
[15342] | 905 | |
---|
[20386] | 906 | for($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) { |
---|
| 907 | $keyname = "recommend_id" . $i; |
---|
| 908 | $delkey = "recommend_delete" . $i; |
---|
| 909 | $commentkey = "recommend_comment" . $i; |
---|
| 910 | |
---|
| 911 | if (!isset($arrForm[$delkey])) $arrForm[$delkey] = null; |
---|
| 912 | |
---|
| 913 | if((isset($arrForm[$keyname]) && !empty($arrForm[$keyname])) && $arrForm[$delkey] != 1) { |
---|
[20487] | 914 | $objProduct = new SC_Product_Ex(); |
---|
[20386] | 915 | $arrRecommend[$i] = $objProduct->getDetail($arrForm[$keyname]); |
---|
| 916 | $arrRecommend[$i]['product_id'] = $arrForm[$keyname]; |
---|
| 917 | $arrRecommend[$i]['comment'] = $arrForm[$commentkey]; |
---|
| 918 | } |
---|
[17902] | 919 | } |
---|
[20386] | 920 | return $arrRecommend; |
---|
| 921 | } |
---|
[15342] | 922 | |
---|
[20386] | 923 | /** |
---|
[20970] | 924 | * 表示用カテゴリマスターデータ配列を取得する |
---|
[20386] | 925 | * - 編集モード |
---|
| 926 | * |
---|
| 927 | * @param void |
---|
[20970] | 928 | * @return array カテゴリマスターデータ配列 |
---|
[20386] | 929 | */ |
---|
| 930 | function lfGetCategoryList_Edit() { |
---|
| 931 | $objDb = new SC_Helper_DB_Ex(); |
---|
| 932 | $arrCategoryList = array(); |
---|
| 933 | |
---|
| 934 | list($arrCatVal, $arrCatOut) = $objDb->sfGetLevelCatList(false); |
---|
| 935 | for ($i = 0; $i < count($arrCatVal); $i++) { |
---|
| 936 | $arrCategoryList[$arrCatVal[$i]] = $arrCatOut[$i]; |
---|
| 937 | } |
---|
| 938 | |
---|
| 939 | return $arrCategoryList; |
---|
[17902] | 940 | } |
---|
[15342] | 941 | |
---|
[20386] | 942 | /** |
---|
[20970] | 943 | * 入力フォームパラメーターの規格ありなしフラグを判定 |
---|
[20386] | 944 | * |
---|
[20970] | 945 | * @param string $has_product_class 入力フォームパラメーターの規格ありなしフラグ |
---|
[20386] | 946 | * @return boolean true: 規格あり, false: 規格なし |
---|
| 947 | */ |
---|
| 948 | function lfGetProductClassFlag($has_product_class) { |
---|
| 949 | if($has_product_class == '1') { |
---|
| 950 | return true; |
---|
| 951 | } else { |
---|
| 952 | return false; |
---|
[17902] | 953 | } |
---|
| 954 | } |
---|
[15342] | 955 | |
---|
[20386] | 956 | /** |
---|
| 957 | * ページonload用JavaScriptを取得する |
---|
| 958 | * - 入力画面 |
---|
| 959 | * |
---|
| 960 | * @param string $anchor_hash アンカー用ハッシュ文字列(省略可) |
---|
| 961 | * @return string ページonload用JavaScript |
---|
| 962 | */ |
---|
| 963 | function lfSetOnloadJavaScript_InputPage($anchor_hash = "") { |
---|
| 964 | return "fnCheckStockLimit('" . DISABLED_RGB . "'); fnMoveSelect('category_id_unselect', 'category_id');" . $anchor_hash; |
---|
| 965 | } |
---|
| 966 | |
---|
| 967 | /** |
---|
| 968 | * DBに商品データを登録する |
---|
| 969 | * |
---|
| 970 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
| 971 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
[20970] | 972 | * @param array $arrList フォーム入力パラメーター配列 |
---|
[20386] | 973 | * @return integer 登録商品ID |
---|
| 974 | */ |
---|
| 975 | function lfRegistProduct(&$objUpFile, &$objDownFile, $arrList) { |
---|
[20507] | 976 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[17902] | 977 | $objDb = new SC_Helper_DB_Ex(); |
---|
[15342] | 978 | |
---|
[17902] | 979 | // 配列の添字を定義 |
---|
[20538] | 980 | $checkArray = array('name', 'status', |
---|
[18815] | 981 | "main_list_comment", "main_comment", |
---|
[15342] | 982 | "deliv_fee", "comment1", "comment2", "comment3", |
---|
| 983 | "comment4", "comment5", "comment6", "main_list_comment", |
---|
[20538] | 984 | "sale_limit", "deliv_date_id", "maker_id", 'note'); |
---|
[17902] | 985 | $arrList = SC_Utils_Ex::arrayDefineIndexes($arrList, $checkArray); |
---|
[15342] | 986 | |
---|
[17902] | 987 | // INSERTする値を作成する。 |
---|
| 988 | $sqlval['name'] = $arrList['name']; |
---|
| 989 | $sqlval['status'] = $arrList['status']; |
---|
| 990 | $sqlval['main_list_comment'] = $arrList['main_list_comment']; |
---|
| 991 | $sqlval['main_comment'] = $arrList['main_comment']; |
---|
| 992 | $sqlval['comment1'] = $arrList['comment1']; |
---|
| 993 | $sqlval['comment2'] = $arrList['comment2']; |
---|
| 994 | $sqlval['comment3'] = $arrList['comment3']; |
---|
| 995 | $sqlval['comment4'] = $arrList['comment4']; |
---|
| 996 | $sqlval['comment5'] = $arrList['comment5']; |
---|
| 997 | $sqlval['comment6'] = $arrList['comment6']; |
---|
| 998 | $sqlval['main_list_comment'] = $arrList['main_list_comment']; |
---|
| 999 | $sqlval['deliv_date_id'] = $arrList['deliv_date_id']; |
---|
| 1000 | $sqlval['maker_id'] = $arrList['maker_id']; |
---|
| 1001 | $sqlval['note'] = $arrList['note']; |
---|
[21185] | 1002 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
[17902] | 1003 | $sqlval['creator_id'] = $_SESSION['member_id']; |
---|
[20386] | 1004 | $arrRet = $objUpFile->getDBFileList(); |
---|
[17902] | 1005 | $sqlval = array_merge($sqlval, $arrRet); |
---|
[15342] | 1006 | |
---|
[20386] | 1007 | for($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
[17902] | 1008 | $sqlval['sub_title'.$cnt] = $arrList['sub_title'.$cnt]; |
---|
| 1009 | $sqlval['sub_comment'.$cnt] = $arrList['sub_comment'.$cnt]; |
---|
| 1010 | } |
---|
[15342] | 1011 | |
---|
[20386] | 1012 | $objQuery->begin(); |
---|
| 1013 | |
---|
[18435] | 1014 | // 新規登録(複製時を含む) |
---|
[20386] | 1015 | if($arrList['product_id'] == "") { |
---|
[18788] | 1016 | $product_id = $objQuery->nextVal("dtb_products_product_id"); |
---|
| 1017 | $sqlval['product_id'] = $product_id; |
---|
[17579] | 1018 | |
---|
[17902] | 1019 | // INSERTの実行 |
---|
[21185] | 1020 | $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
[17902] | 1021 | $objQuery->insert("dtb_products", $sqlval); |
---|
[17579] | 1022 | |
---|
[18435] | 1023 | $arrList['product_id'] = $product_id; |
---|
| 1024 | |
---|
[17902] | 1025 | // カテゴリを更新 |
---|
| 1026 | $objDb->updateProductCategories($arrList['category_id'], $product_id); |
---|
[16546] | 1027 | |
---|
[18435] | 1028 | // 複製商品の場合には規格も複製する |
---|
[20386] | 1029 | if($arrList["copy_product_id"] != "" && SC_Utils_Ex::sfIsInt($arrList["copy_product_id"])) { |
---|
[20556] | 1030 | if($this->lfGetProductClassFlag($arrList["has_product_class"]) == false) { |
---|
[18435] | 1031 | //規格なしの場合、複製は価格等の入力が発生しているため、その内容で追加登録を行う |
---|
[17902] | 1032 | $this->lfCopyProductClass($arrList, $objQuery); |
---|
[20386] | 1033 | } else { |
---|
[18435] | 1034 | //規格がある場合の複製は複製元の内容で追加登録を行う |
---|
[17902] | 1035 | // dtb_products_class のカラムを取得 |
---|
| 1036 | $dbFactory = SC_DB_DBFactory_Ex::getInstance(); |
---|
[20784] | 1037 | $arrColList = $objQuery->listTableFields('dtb_products_class'); |
---|
[17902] | 1038 | $arrColList_tmp = array_flip($arrColList); |
---|
[15342] | 1039 | |
---|
[18435] | 1040 | // 複製しない列 |
---|
[17902] | 1041 | unset($arrColList[$arrColList_tmp["product_class_id"]]); //規格ID |
---|
[17903] | 1042 | unset($arrColList[$arrColList_tmp["product_id"]]); //商品ID |
---|
[17902] | 1043 | unset($arrColList[$arrColList_tmp["create_date"]]); |
---|
[15342] | 1044 | |
---|
[20556] | 1045 | // 複製元商品の規格データ取得 |
---|
[17902] | 1046 | $col = SC_Utils_Ex::sfGetCommaList($arrColList); |
---|
[20556] | 1047 | $table = 'dtb_products_class'; |
---|
| 1048 | $where = 'product_id = ?'; |
---|
| 1049 | $objQuery->setOrder('product_class_id'); |
---|
| 1050 | $arrProductsClass = $objQuery->select($col, $table, $where, array($arrList["copy_product_id"])); |
---|
| 1051 | |
---|
[20616] | 1052 | // 複製元商品の規格組み合わせデータ登録 |
---|
| 1053 | // 登録した組み合わせIDを取得 |
---|
| 1054 | $arrRetCombinationId = $this->lfRegistClassCombination($arrProductsClass); |
---|
| 1055 | |
---|
[20556] | 1056 | // 規格データ登録 |
---|
[20616] | 1057 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[20556] | 1058 | foreach($arrProductsClass as $arrData) { |
---|
| 1059 | $sqlval = array(); |
---|
| 1060 | $sqlval['product_class_id'] = $objQuery->nextVal('dtb_products_class_product_class_id'); |
---|
| 1061 | $sqlval['product_id'] = $product_id; |
---|
[21185] | 1062 | $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
[20616] | 1063 | $sqlval['class_combination_id'] = $arrRetCombinationId[$arrData['class_combination_id']]; |
---|
[20556] | 1064 | $sqlval['product_type_id'] = $arrData['product_type_id']; |
---|
| 1065 | $sqlval['product_code'] = $arrData['product_code']; |
---|
| 1066 | $sqlval['stock'] = $arrData['stock']; |
---|
| 1067 | $sqlval['stock_unlimited'] = $arrData['stock_unlimited']; |
---|
| 1068 | $sqlval['sale_limit'] = $arrData['sale_limit']; |
---|
| 1069 | $sqlval['price01'] = $arrData['price01']; |
---|
| 1070 | $sqlval['price02'] = $arrData['price02']; |
---|
| 1071 | $sqlval['deliv_fee'] = $arrData['deliv_fee']; |
---|
| 1072 | $sqlval['point_rate'] = $arrData['point_rate']; |
---|
| 1073 | $sqlval['creator_id'] = $arrData['creator_id']; |
---|
[21185] | 1074 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
[20556] | 1075 | $sqlval['down_filename'] = $arrData['down_filename']; |
---|
| 1076 | $sqlval['down_realfilename'] = $arrData['down_realfilename']; |
---|
| 1077 | $sqlval['del_flg'] = $arrData['del_flg']; |
---|
| 1078 | $objQuery->insert($table, $sqlval); |
---|
| 1079 | } |
---|
[17902] | 1080 | } |
---|
| 1081 | } |
---|
[18435] | 1082 | // 更新 |
---|
[20386] | 1083 | } else { |
---|
[17902] | 1084 | $product_id = $arrList['product_id']; |
---|
| 1085 | // 削除要求のあった既存ファイルの削除 |
---|
[20386] | 1086 | $arrRet = $this->lfGetProductData_FromDB($arrList['product_id']); |
---|
[19948] | 1087 | // TODO: SC_UploadFile::deleteDBFileの画像削除条件見直し要 |
---|
[20498] | 1088 | $objImage = new SC_Image_Ex($objUpFile->temp_dir); |
---|
[20386] | 1089 | $arrKeyName = $objUpFile->keyname; |
---|
| 1090 | $arrSaveFile = $objUpFile->save_file; |
---|
[19948] | 1091 | $arrImageKey = array(); |
---|
| 1092 | foreach ($arrKeyName as $key => $keyname) { |
---|
| 1093 | if ($arrRet[$keyname] && !$arrSaveFile[$key]) { |
---|
| 1094 | $arrImageKey[] = $keyname; |
---|
| 1095 | $has_same_image = $this->lfHasSameProductImage($arrList['product_id'], $arrImageKey, $arrRet[$keyname]); |
---|
| 1096 | if (!$has_same_image) { |
---|
[20386] | 1097 | $objImage->deleteImage($arrRet[$keyname], $objUpFile->save_dir); |
---|
[19948] | 1098 | } |
---|
| 1099 | } |
---|
| 1100 | } |
---|
[20386] | 1101 | $objDownFile->deleteDBDownFile($arrRet); |
---|
[17902] | 1102 | // UPDATEの実行 |
---|
| 1103 | $where = "product_id = ?"; |
---|
| 1104 | $objQuery->update("dtb_products", $sqlval, $where, array($product_id)); |
---|
[16546] | 1105 | |
---|
[17902] | 1106 | // カテゴリを更新 |
---|
| 1107 | $objDb->updateProductCategories($arrList['category_id'], $product_id); |
---|
| 1108 | } |
---|
[15342] | 1109 | |
---|
[20602] | 1110 | // 商品登録の時は規格を生成する。複製の場合は規格も複製されるのでこの処理は不要。 |
---|
[20386] | 1111 | if($arrList["copy_product_id"] == "") { |
---|
[17902] | 1112 | // 規格登録 |
---|
[20602] | 1113 | if ($objDb->sfHasProductClass($product_id)) { |
---|
[20970] | 1114 | // 規格あり商品(商品規格テーブルのうち、商品登録フォームで設定するパラメーターのみ更新) |
---|
[20602] | 1115 | $this->lfUpdateProductClass($arrList); |
---|
| 1116 | } else { |
---|
| 1117 | // 規格なし商品(商品規格テーブルの更新) |
---|
| 1118 | $this->lfInsertDummyProductClass($arrList); |
---|
| 1119 | } |
---|
[17902] | 1120 | } |
---|
[15342] | 1121 | |
---|
[21182] | 1122 | // 商品ステータス設定 |
---|
[20487] | 1123 | $objProduct = new SC_Product_Ex(); |
---|
[18863] | 1124 | $objProduct->setProductStatus($product_id, $arrList['product_status']); |
---|
| 1125 | |
---|
[17902] | 1126 | // 関連商品登録 |
---|
| 1127 | $this->lfInsertRecommendProducts($objQuery, $arrList, $product_id); |
---|
[15342] | 1128 | |
---|
[17902] | 1129 | $objQuery->commit(); |
---|
| 1130 | return $product_id; |
---|
| 1131 | } |
---|
[15342] | 1132 | |
---|
[20386] | 1133 | /** |
---|
| 1134 | * 規格を設定していない商品を商品規格テーブルに登録 |
---|
| 1135 | * |
---|
| 1136 | * @param array $arrList |
---|
| 1137 | * @return void |
---|
| 1138 | */ |
---|
| 1139 | function lfInsertDummyProductClass($arrList) { |
---|
[20507] | 1140 | $objQuery = new SC_Query_Ex(); |
---|
[20386] | 1141 | $objDb = new SC_Helper_DB_Ex(); |
---|
[15342] | 1142 | |
---|
[20386] | 1143 | $product_id = $arrList['product_id']; |
---|
[15342] | 1144 | |
---|
[20386] | 1145 | // 配列の添字を定義 |
---|
| 1146 | $checkArray = array('product_class_id', 'product_id', 'product_code', 'stock', 'stock_unlimited', 'price01', 'price02', 'sale_limit', 'deliv_fee', 'point_rate' ,'product_type_id', 'down_filename', 'down_realfilename'); |
---|
| 1147 | $sqlval = SC_Utils_Ex::sfArrayIntersectKeys($arrList, $checkArray); |
---|
| 1148 | $sqlval = SC_Utils_Ex::arrayDefineIndexes($sqlval, $checkArray); |
---|
[15342] | 1149 | |
---|
[20386] | 1150 | $sqlval['stock_unlimited'] = $sqlval['stock_unlimited'] ? UNLIMITED_FLG_UNLIMITED : UNLIMITED_FLG_LIMITED; |
---|
| 1151 | $sqlval['creator_id'] = strlen($_SESSION['member_id']) >= 1 ? $_SESSION['member_id'] : '0'; |
---|
[15342] | 1152 | |
---|
[20386] | 1153 | if (strlen($sqlval['product_class_id']) == 0) { |
---|
| 1154 | $sqlval['product_class_id'] = $objQuery->nextVal('dtb_products_class_product_class_id'); |
---|
[21185] | 1155 | $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
| 1156 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
[20386] | 1157 | // INSERTの実行 |
---|
| 1158 | $objQuery->insert('dtb_products_class', $sqlval); |
---|
[17902] | 1159 | } else { |
---|
[21185] | 1160 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
[20386] | 1161 | // UPDATEの実行 |
---|
| 1162 | $objQuery->update('dtb_products_class', $sqlval, "product_class_id = ?", array($sqlval['product_class_id'])); |
---|
[16546] | 1163 | |
---|
[17902] | 1164 | } |
---|
| 1165 | } |
---|
[15342] | 1166 | |
---|
[20386] | 1167 | /** |
---|
[20616] | 1168 | * 規格を設定している商品の商品規格テーブルを更新 |
---|
[20602] | 1169 | * (deliv_fee, point_rate, sale_limit) |
---|
| 1170 | * |
---|
| 1171 | * @param array $arrList |
---|
| 1172 | * @return void |
---|
| 1173 | */ |
---|
| 1174 | function lfUpdateProductClass($arrList) { |
---|
| 1175 | $objQuery = new SC_Query_Ex(); |
---|
| 1176 | $sqlval = array(); |
---|
| 1177 | |
---|
| 1178 | $sqlval['deliv_fee'] = $arrList['deliv_fee']; |
---|
| 1179 | $sqlval['point_rate'] = $arrList['point_rate']; |
---|
| 1180 | $sqlval['sale_limit'] = $arrList['sale_limit']; |
---|
| 1181 | $where = 'product_id = ?'; |
---|
| 1182 | $objQuery->update('dtb_products_class', $sqlval, $where, array($arrList['product_id'])); |
---|
| 1183 | } |
---|
| 1184 | |
---|
| 1185 | /** |
---|
[20386] | 1186 | * DBに関連商品データを登録する |
---|
| 1187 | * |
---|
| 1188 | * @param object $objQuery SC_Queryインスタンス |
---|
[20970] | 1189 | * @param string $arrList フォーム入力パラメーター配列 |
---|
[20386] | 1190 | * @param integer $product_id 登録する商品ID |
---|
| 1191 | * @return void |
---|
| 1192 | */ |
---|
[20616] | 1193 | function lfInsertRecommendProducts(&$objQuery, $arrList, $product_id) { |
---|
[20386] | 1194 | // 一旦関連商品をすべて削除する |
---|
| 1195 | $objQuery->delete("dtb_recommend_products", "product_id = ?", array($product_id)); |
---|
| 1196 | $sqlval['product_id'] = $product_id; |
---|
| 1197 | $rank = RECOMMEND_PRODUCT_MAX; |
---|
| 1198 | for($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) { |
---|
| 1199 | $keyname = "recommend_id" . $i; |
---|
| 1200 | $commentkey = "recommend_comment" . $i; |
---|
| 1201 | $deletekey = "recommend_delete" . $i; |
---|
[15342] | 1202 | |
---|
[20386] | 1203 | if (!isset($arrList[$deletekey])) $arrList[$deletekey] = null; |
---|
[15342] | 1204 | |
---|
[20386] | 1205 | if($arrList[$keyname] != "" && $arrList[$deletekey] != '1') { |
---|
| 1206 | $sqlval['recommend_product_id'] = $arrList[$keyname]; |
---|
| 1207 | $sqlval['comment'] = $arrList[$commentkey]; |
---|
| 1208 | $sqlval['rank'] = $rank; |
---|
| 1209 | $sqlval['creator_id'] = $_SESSION['member_id']; |
---|
[21185] | 1210 | $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
| 1211 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
[20386] | 1212 | $objQuery->insert("dtb_recommend_products", $sqlval); |
---|
| 1213 | $rank--; |
---|
[17902] | 1214 | } |
---|
| 1215 | } |
---|
| 1216 | } |
---|
[18171] | 1217 | |
---|
[17902] | 1218 | /** |
---|
[20386] | 1219 | * 規格データをコピーする |
---|
| 1220 | * |
---|
[20970] | 1221 | * @param array $arrList フォーム入力パラメーター配列 |
---|
[20386] | 1222 | * @param object $objQuery SC_Queryインスタンス |
---|
| 1223 | * @return boolean エラーフラグ |
---|
[18171] | 1224 | */ |
---|
[20616] | 1225 | function lfCopyProductClass($arrList, &$objQuery) { |
---|
[18304] | 1226 | // 複製元のdtb_products_classを取得(規格なしのため、1件のみの取得) |
---|
[17902] | 1227 | $col = "*"; |
---|
| 1228 | $table = "dtb_products_class"; |
---|
| 1229 | $where = "product_id = ?"; |
---|
| 1230 | $arrProductClass = $objQuery->select($col, $table, $where, array($arrList["copy_product_id"])); |
---|
[17840] | 1231 | |
---|
[17902] | 1232 | //トランザクション開始 |
---|
| 1233 | $objQuery->begin(); |
---|
| 1234 | $err_flag = false; |
---|
[18435] | 1235 | //非編集項目は複製、編集項目は上書きして登録 |
---|
[20386] | 1236 | foreach($arrProductClass as $records) { |
---|
| 1237 | foreach($records as $key => $value) { |
---|
| 1238 | if(isset($arrList[$key])) { |
---|
[20556] | 1239 | switch($key) { |
---|
| 1240 | case 'stock_unlimited': |
---|
| 1241 | $records[$key] = (int)$arrList[$key]; |
---|
| 1242 | break; |
---|
| 1243 | default: |
---|
| 1244 | $records[$key] = $arrList[$key]; |
---|
| 1245 | break; |
---|
| 1246 | } |
---|
[17902] | 1247 | } |
---|
| 1248 | } |
---|
[18788] | 1249 | |
---|
| 1250 | $records["product_class_id"] = $objQuery->nextVal('dtb_products_class_product_class_id'); |
---|
[21185] | 1251 | $records["update_date"] = 'CURRENT_TIMESTAMP'; |
---|
| 1252 | $records["create_date"] = 'CURRENT_TIMESTAMP'; |
---|
[17902] | 1253 | $objQuery->insert($table, $records); |
---|
| 1254 | //エラー発生時は中断 |
---|
[20386] | 1255 | if($objQuery->isError()) { |
---|
[17902] | 1256 | $err_flag = true; |
---|
| 1257 | continue; |
---|
| 1258 | } |
---|
| 1259 | } |
---|
| 1260 | //トランザクション終了 |
---|
[20386] | 1261 | if($err_flag) { |
---|
[17902] | 1262 | $objQuery->rollback(); |
---|
[20386] | 1263 | } else { |
---|
[17902] | 1264 | $objQuery->commit(); |
---|
| 1265 | } |
---|
| 1266 | return !$err_flag; |
---|
| 1267 | } |
---|
[18435] | 1268 | |
---|
| 1269 | /** |
---|
[20616] | 1270 | * 商品規格データを元に、規格組み合わせデータを複製登録する |
---|
| 1271 | * |
---|
| 1272 | * @param array $arrProductsClass 商品規格データ配列 |
---|
| 1273 | * @return array 登録した規格組み合わせID配列 |
---|
| 1274 | */ |
---|
| 1275 | function lfRegistClassCombination($arrProductsClass) { |
---|
| 1276 | $arrRetCombinationId = array(); |
---|
| 1277 | |
---|
| 1278 | // 規格組み合わせデータを取得 |
---|
| 1279 | $arrClassCombination = $this->lfGetClassCombination($arrProductsClass); |
---|
| 1280 | |
---|
| 1281 | // 規格2を持っているかチェック |
---|
| 1282 | $has_class2 = $this->lfHasClass2($arrClassCombination); |
---|
| 1283 | |
---|
| 1284 | // 規格組み合わせデータを複製登録 |
---|
| 1285 | if($has_class2 == true) { |
---|
| 1286 | // 規格2を持っている場合、規格1の組み合わせデータも取得 |
---|
| 1287 | $arrClassCombinationParent = $this->lfGetClassCombination($arrClassCombination, true); |
---|
| 1288 | |
---|
| 1289 | // 親組み合わせデータを複製登録 |
---|
| 1290 | $arrRetCombinationId = $this->lfInsertClassCombination($arrClassCombinationParent); |
---|
| 1291 | // 子組み合わせデータを複製登録 |
---|
| 1292 | $arrRetCombinationId = $this->lfInsertClassCombination($arrClassCombination, $arrRetCombinationId); |
---|
| 1293 | } else { |
---|
| 1294 | // 規格1のみの場合、複製登録 |
---|
| 1295 | $arrRetCombinationId = $this->lfInsertClassCombination($arrClassCombination); |
---|
| 1296 | } |
---|
| 1297 | |
---|
| 1298 | return $arrRetCombinationId; |
---|
| 1299 | } |
---|
| 1300 | |
---|
| 1301 | /** |
---|
| 1302 | * 規格2を持っている規格組み合わせデータであるか判定する |
---|
| 1303 | * |
---|
| 1304 | * @param array $arrClassCombination 規格組み合わせデータ配列 |
---|
| 1305 | * @return boolean true: 規格2を持っている, false: 規格1のみ |
---|
| 1306 | */ |
---|
| 1307 | function lfHasClass2($arrClassCombination) { |
---|
| 1308 | $has_class2 = false; |
---|
| 1309 | |
---|
| 1310 | foreach($arrClassCombination as $arrVal) { |
---|
| 1311 | if($arrVal['level'] == '2') { |
---|
| 1312 | $has_class2 = true; |
---|
| 1313 | break; |
---|
| 1314 | } |
---|
| 1315 | } |
---|
| 1316 | |
---|
| 1317 | return $has_class2; |
---|
| 1318 | } |
---|
| 1319 | |
---|
| 1320 | /** |
---|
| 1321 | * 規格組み合わせデータを取得する |
---|
| 1322 | * |
---|
| 1323 | * @param array $arrData 組み合わせIDを含むデータ配列 |
---|
| 1324 | * @param boolean $is_parent 親規格IDから抽出するフラグ(省略時: false) |
---|
| 1325 | * @return array 規格組み合わせデータ配列 |
---|
| 1326 | */ |
---|
| 1327 | function lfGetClassCombination($arrData, $is_parent = false) { |
---|
| 1328 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
| 1329 | $key = 'class_combination_id'; |
---|
| 1330 | if($is_parent == true) { |
---|
| 1331 | $key = 'parent_class_combination_id'; |
---|
| 1332 | } |
---|
| 1333 | |
---|
| 1334 | $where = 'class_combination_id IN ('; |
---|
| 1335 | $arrParam = array(); |
---|
| 1336 | foreach($arrData as $arrVal) { |
---|
| 1337 | if(SC_Utils_Ex::isBlank($arrVal[$key]) == true) { |
---|
| 1338 | continue; |
---|
| 1339 | } |
---|
| 1340 | $where .= '?,'; |
---|
| 1341 | $arrParam[] = $arrVal[$key]; |
---|
| 1342 | } |
---|
| 1343 | $where = preg_replace('/,$/', ')', $where); |
---|
| 1344 | $arrClassCombination = $objQuery->select('*', 'dtb_class_combination', $where, $arrParam); |
---|
| 1345 | |
---|
| 1346 | return $arrClassCombination; |
---|
| 1347 | } |
---|
| 1348 | |
---|
| 1349 | /** |
---|
| 1350 | * 規格組み合わせデータを複製登録する |
---|
| 1351 | * |
---|
| 1352 | * @param array $arrClassCombination 複製元の規格組み合わせデータ配列 |
---|
| 1353 | * @param array $arrParentCombinationId 登録する親組み合わせID配列 (省略可) |
---|
| 1354 | * @return array 登録した規格組み合わせID配列 |
---|
| 1355 | */ |
---|
| 1356 | function lfInsertClassCombination($arrClassCombination, $arrParentCombinationId = array()) { |
---|
| 1357 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
| 1358 | $arrRetCombinationId = array(); |
---|
| 1359 | |
---|
| 1360 | // 親組み合わせIDの指定がある場合、指定された親組み合わせIDで複製登録 |
---|
| 1361 | if(count($arrParentCombinationId) > 0) { |
---|
| 1362 | foreach($arrClassCombination as $key => $arrVal) { |
---|
| 1363 | $arrClassCombination[$key]['parent_class_combination_id'] = $arrParentCombinationId[$arrVal['parent_class_combination_id']]; |
---|
| 1364 | } |
---|
| 1365 | } |
---|
| 1366 | |
---|
| 1367 | foreach($arrClassCombination as $arrVal) { |
---|
| 1368 | $sqlval = array(); |
---|
| 1369 | $sqlval['class_combination_id'] = $objQuery->nextVal('dtb_class_combination_class_combination_id'); |
---|
| 1370 | $sqlval['parent_class_combination_id'] = $arrVal['parent_class_combination_id']; |
---|
| 1371 | $sqlval['classcategory_id'] = $arrVal['classcategory_id']; |
---|
| 1372 | $sqlval['level'] = $arrVal['level']; |
---|
| 1373 | $objQuery->insert('dtb_class_combination', $sqlval); |
---|
| 1374 | |
---|
| 1375 | $arrRetCombinationId[$arrVal['class_combination_id']] = $sqlval['class_combination_id']; |
---|
| 1376 | } |
---|
| 1377 | |
---|
| 1378 | return $arrRetCombinationId; |
---|
| 1379 | } |
---|
| 1380 | |
---|
| 1381 | /** |
---|
[20386] | 1382 | * リネームする際は、自動生成される画像名に一意となるように、Suffixを付ける |
---|
| 1383 | * |
---|
| 1384 | * @param string $to_key |
---|
| 1385 | * @return string |
---|
[18435] | 1386 | */ |
---|
[20386] | 1387 | function lfGetAddSuffix($to_key){ |
---|
| 1388 | if( IMAGE_RENAME === true ) return ; |
---|
[18435] | 1389 | |
---|
[20386] | 1390 | // 自動生成される画像名 |
---|
| 1391 | $dist_name = ""; |
---|
| 1392 | switch($to_key) { |
---|
| 1393 | case "main_list_image": |
---|
| 1394 | $dist_name = '_s'; |
---|
| 1395 | break; |
---|
| 1396 | case "main_image": |
---|
| 1397 | $dist_name = '_m'; |
---|
| 1398 | break; |
---|
| 1399 | default: |
---|
| 1400 | $arrRet = explode('sub_image', $to_key); |
---|
| 1401 | $dist_name = '_sub' .$arrRet[1]; |
---|
| 1402 | break; |
---|
| 1403 | } |
---|
| 1404 | return $dist_name; |
---|
| 1405 | } |
---|
[18435] | 1406 | |
---|
[20386] | 1407 | /** |
---|
| 1408 | * サブ情報の登録があるかを取得する |
---|
| 1409 | * タイトル, コメント, 画像のいずれかに登録があれば「あり」と判定する |
---|
| 1410 | * |
---|
| 1411 | * @param array $arrSubProductData サブ情報配列 |
---|
| 1412 | * @return boolean true: サブ情報あり, false: サブ情報なし |
---|
| 1413 | */ |
---|
| 1414 | function hasSubProductData($arrSubProductData) { |
---|
| 1415 | $has_subproduct_data = false; |
---|
[18435] | 1416 | |
---|
[20386] | 1417 | for($i = 1; $i <= PRODUCTSUB_MAX; $i++) { |
---|
| 1418 | if(SC_Utils_Ex::isBlank($arrSubProductData['sub_title'.$i]) == false |
---|
| 1419 | || SC_Utils_Ex::isBlank($arrSubProductData['sub_comment'.$i]) == false |
---|
| 1420 | || SC_Utils_Ex::isBlank($arrSubProductData['sub_image'.$i]) == false |
---|
| 1421 | || SC_Utils_Ex::isBlank($arrSubProductData['sub_large_image'.$i]) == false |
---|
| 1422 | || SC_Utils_Ex::isBlank($arrSubProductData['temp_sub_image'.$i]) == false |
---|
| 1423 | || SC_Utils_Ex::isBlank($arrSubProductData['temp_sub_large_image'.$i]) == false) { |
---|
| 1424 | $has_subproduct_data = true; |
---|
| 1425 | break; |
---|
| 1426 | } |
---|
[18435] | 1427 | } |
---|
| 1428 | |
---|
[20386] | 1429 | return $has_subproduct_data; |
---|
[18777] | 1430 | } |
---|
[19948] | 1431 | |
---|
| 1432 | /** |
---|
[20386] | 1433 | * アンカーハッシュ文字列を取得する |
---|
| 1434 | * アンカーキーをサニタイジングする |
---|
| 1435 | * |
---|
[20970] | 1436 | * @param string $anchor_key フォーム入力パラメーターで受け取ったアンカーキー |
---|
[20386] | 1437 | * @return <type> |
---|
[19948] | 1438 | */ |
---|
[20386] | 1439 | function getAnchorHash($anchor_key) { |
---|
| 1440 | if($anchor_key != "") { |
---|
| 1441 | return "location.hash='#" . htmlspecialchars($anchor_key) . "'"; |
---|
| 1442 | } else { |
---|
| 1443 | return ""; |
---|
[19948] | 1444 | } |
---|
| 1445 | } |
---|
[15342] | 1446 | } |
---|
| 1447 | ?> |
---|