[15559] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[18701] | 5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
[15559] | 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. |
---|
[15559] | 22 | */ |
---|
| 23 | |
---|
| 24 | // {{{ requires |
---|
[19805] | 25 | require_once(CLASS_REALDIR . "pages/admin/LC_Page_Admin.php"); |
---|
[15559] | 26 | |
---|
| 27 | /** |
---|
[17364] | 28 | * 商品登録(商品規格)のページクラス. |
---|
[15559] | 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author LOCKON CO.,LTD. |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
[19661] | 34 | class LC_Page_Admin_Products_ProductClass extends LC_Page_Admin { |
---|
[15559] | 35 | |
---|
| 36 | // }}} |
---|
| 37 | // {{{ functions |
---|
[18819] | 38 | /** ダウンロード用ファイル管理クラスのインスタンス */ |
---|
| 39 | var $objDownFile; |
---|
[15559] | 40 | |
---|
[18819] | 41 | /** hidden 項目の配列 */ |
---|
| 42 | var $arrHidden; |
---|
| 43 | |
---|
[15559] | 44 | /** |
---|
| 45 | * Page を初期化する. |
---|
| 46 | * |
---|
| 47 | * @return void |
---|
| 48 | */ |
---|
| 49 | function init() { |
---|
| 50 | parent::init(); |
---|
| 51 | $this->tpl_mainpage = 'products/product_class.tpl'; |
---|
| 52 | $this->tpl_subnavi = 'products/subnavi.tpl'; |
---|
| 53 | $this->tpl_mainno = 'products'; |
---|
| 54 | $this->tpl_subno = 'product'; |
---|
[17509] | 55 | $this->tpl_subtitle = '商品登録(商品規格)'; |
---|
[19993] | 56 | $masterData = new SC_DB_MasterData_Ex(); |
---|
| 57 | $this->arrProductType = $masterData->getMasterData("mtb_product_type"); |
---|
[19695] | 58 | $this->arrPayments = SC_Helper_DB_Ex::sfGetIDValueList("dtb_payment", "payment_id", "payment_method"); |
---|
[15559] | 59 | } |
---|
| 60 | |
---|
[18819] | 61 | function lfInitDownFile() { |
---|
| 62 | $i = 1; |
---|
| 63 | while (isset($_POST['classcategory_id1:' . $i])) { |
---|
| 64 | //ファイル系処理 |
---|
[19993] | 65 | $this->objDownFile->addFile("ダウンロード販売用ファイル", 'down_realfilename'. ":" . $i, explode(",", DOWNLOAD_EXTENSION),DOWN_SIZE, true, 0, 0); |
---|
[18819] | 66 | $i++; |
---|
| 67 | } |
---|
| 68 | } |
---|
| 69 | |
---|
[19661] | 70 | /** |
---|
| 71 | * Page のプロセス. |
---|
| 72 | * |
---|
| 73 | * @return void |
---|
| 74 | */ |
---|
[15559] | 75 | function process() { |
---|
[19661] | 76 | $this->action(); |
---|
| 77 | $this->sendResponse(); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | /** |
---|
| 81 | * Page のアクション. |
---|
| 82 | * |
---|
| 83 | * @return void |
---|
| 84 | */ |
---|
| 85 | function action() { |
---|
[18815] | 86 | $this->authorization(); |
---|
[15559] | 87 | |
---|
[18815] | 88 | $this->arrSearchHidden = $this->createSearchParams($_POST); |
---|
[15559] | 89 | |
---|
[18819] | 90 | // FORMデータの引き継ぎ |
---|
| 91 | $this->arrForm = $_POST; |
---|
| 92 | |
---|
[15559] | 93 | $this->tpl_product_id = |
---|
| 94 | isset($_POST['product_id']) ? $_POST['product_id'] : "" ; |
---|
| 95 | $this->tpl_pageno = isset($_POST['pageno']) ? $_POST['pageno'] : ""; |
---|
| 96 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
| 97 | |
---|
[18819] | 98 | // Downファイル管理クラス |
---|
[19805] | 99 | $this->objDownFile = new SC_UploadFile(DOWN_TEMP_REALDIR, DOWN_SAVE_REALDIR); |
---|
[19993] | 100 | $this->lfInitDownFile(); |
---|
[18815] | 101 | switch ($_POST['mode']) { |
---|
| 102 | case 'edit': |
---|
| 103 | // 入力値の変換 |
---|
| 104 | $this->arrForm = $this->lfConvertParam($_POST); |
---|
| 105 | // エラーチェック |
---|
| 106 | $this->arrErr = $this->lfProductClassError($this->arrForm); |
---|
[19993] | 107 | if (empty($this->arrErr)){ |
---|
[18819] | 108 | $this->tpl_mainpage = 'products/product_class_confirm.tpl'; |
---|
[18815] | 109 | $this->lfProductConfirmPage(); // 確認ページ表示 |
---|
| 110 | } else { |
---|
[19993] | 111 | $this->doPreEdit(false ,true); |
---|
[18819] | 112 | // Hiddenからのデータを引き継ぐ |
---|
| 113 | $this->objDownFile->setHiddenFileList($_POST); |
---|
| 114 | // HIDDEN用に配列を渡す。 |
---|
| 115 | $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objDownFile->getHiddenFileList()); |
---|
| 116 | // Form用に配列を渡す。 |
---|
| 117 | $this->arrForm = array_merge((array)$this->arrForm, (array)$this->objDownFile->getFormKikakuDownFile()); |
---|
[19993] | 118 | $this->doDisp(); |
---|
[15559] | 119 | } |
---|
| 120 | break; |
---|
| 121 | |
---|
[18815] | 122 | case 'delete': |
---|
| 123 | $this->doDelete(); |
---|
| 124 | break; |
---|
| 125 | |
---|
[15559] | 126 | case 'pre_edit': |
---|
[18815] | 127 | $this->doPreEdit(); |
---|
[18819] | 128 | // HIDDEN用に配列を渡す。 |
---|
| 129 | $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objDownFile->getHiddenFileList()); |
---|
[18815] | 130 | break; |
---|
[15559] | 131 | |
---|
| 132 | case 'disp': |
---|
[18815] | 133 | $this->doDisp(); |
---|
[15559] | 134 | break; |
---|
[18819] | 135 | // ダウンロード商品ファイルアップロード |
---|
| 136 | case 'upload_down': |
---|
[19993] | 137 | $this->doPreEdit(true); |
---|
[18819] | 138 | // Hiddenからのデータを引き継ぐ |
---|
| 139 | $this->objDownFile->setHiddenKikakuFileList($_POST); |
---|
| 140 | // ファイル存在チェック |
---|
| 141 | $this->arrErr = array_merge((array)$this->arrErr, (array)$this->objDownFile->checkEXISTS($_POST['down_key'])); |
---|
| 142 | // ファイル保存処理 |
---|
| 143 | $this->arrErr[$_POST['down_key']] = $this->objDownFile->makeTempDownFile($_POST['down_key']); |
---|
| 144 | // HIDDEN用に配列を渡す。 |
---|
| 145 | $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objDownFile->getHiddenFileList()); |
---|
| 146 | // Form用に配列を渡す。 |
---|
| 147 | $this->arrForm = array_merge((array)$this->arrForm, (array)$this->objDownFile->getFormKikakuDownFile()); |
---|
[19993] | 148 | $this->doDisp(); |
---|
[18819] | 149 | break; |
---|
| 150 | // ダウンロードファイルの削除 |
---|
| 151 | case 'delete_down': |
---|
[19993] | 152 | $this->doPreEdit(true); |
---|
[18819] | 153 | // Hiddenからのデータを引き継ぐ |
---|
| 154 | $this->objDownFile->setHiddenKikakuFileList($_POST); |
---|
| 155 | // ファイル削除処理 |
---|
| 156 | $this->objDownFile->deleteKikakuFile($_POST['down_key']); |
---|
| 157 | // HIDDEN用に配列を渡す。 |
---|
| 158 | $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objDownFile->getHiddenFileList()); |
---|
| 159 | // Form用に配列を渡す。 |
---|
| 160 | $this->arrForm = array_merge((array)$this->arrForm, (array)$this->objDownFile->getFormKikakuDownFile()); |
---|
[19993] | 161 | $this->doDisp(); |
---|
[18819] | 162 | break; |
---|
[15559] | 163 | case 'confirm_return': |
---|
| 164 | // フォームパラメータの引き継ぎ |
---|
| 165 | $this->arrForm = $_POST; |
---|
| 166 | // 規格の選択情報は引き継がない。 |
---|
| 167 | $this->arrForm['select_class_id1'] = ""; |
---|
| 168 | $this->arrForm['select_class_id2'] = ""; |
---|
[18819] | 169 | $this->doPreEdit(false,true); |
---|
| 170 | // Hiddenからのデータを引き継ぐ |
---|
| 171 | $this->objDownFile->setHiddenFileList($_POST); |
---|
| 172 | // HIDDEN用に配列を渡す。 |
---|
| 173 | $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objDownFile->getHiddenFileList()); |
---|
| 174 | // Form用に配列を渡す。 |
---|
| 175 | $this->arrForm = array_merge((array)$this->arrForm, (array)$this->objDownFile->getFormKikakuDownFile()); |
---|
[19993] | 176 | $this->doDisp(); |
---|
[15559] | 177 | break; |
---|
| 178 | case 'complete': |
---|
| 179 | // 完了ページ設定 |
---|
| 180 | $this->tpl_mainpage = 'products/product_class_complete.tpl'; |
---|
[18819] | 181 | // ファイル情報の初期化 |
---|
| 182 | $this->lfInitDownFile(); |
---|
| 183 | // Hiddenからのデータを引き継ぐ |
---|
| 184 | $this->objDownFile->setHiddenFileList($_POST); |
---|
[15559] | 185 | // 商品規格の登録 |
---|
[18815] | 186 | $this->registerProductClass($_POST, $_POST['product_id']); |
---|
[18819] | 187 | // 一時ファイルを本番ディレクトリに移動する |
---|
| 188 | $this->objDownFile->moveTempDownFile(); |
---|
[15559] | 189 | break; |
---|
[18815] | 190 | |
---|
[15559] | 191 | default: |
---|
| 192 | } |
---|
[18815] | 193 | $this->arrClass = $this->getAllClass(); |
---|
| 194 | $this->arrForm['product_name'] = $this->getProductName($_POST['product_id']); |
---|
[15559] | 195 | } |
---|
| 196 | |
---|
| 197 | /** |
---|
| 198 | * デストラクタ. |
---|
| 199 | * |
---|
| 200 | * @return void |
---|
| 201 | */ |
---|
| 202 | function destroy() { |
---|
| 203 | parent::destroy(); |
---|
| 204 | } |
---|
| 205 | |
---|
[17581] | 206 | /** |
---|
[18815] | 207 | * 規格の登録または更新を行う. |
---|
[17581] | 208 | * |
---|
[18815] | 209 | * TODO dtb_class_combination は, dtb_product_categories に倣って, |
---|
| 210 | * DELETE to INSERT だが, UPDATE を検討する. |
---|
| 211 | * |
---|
| 212 | * @param array $arrList 入力フォームの内容 |
---|
| 213 | * @param integer $product_id 登録を行う商品ID |
---|
[17581] | 214 | */ |
---|
[18815] | 215 | function registerProductClass($arrList, $product_id) { |
---|
| 216 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
| 217 | $objDb = new SC_Helper_DB_Ex(); |
---|
[15559] | 218 | |
---|
[18815] | 219 | $objQuery->begin(); |
---|
[15559] | 220 | |
---|
[18815] | 221 | $productsClass = $objQuery->select("*", "dtb_products_class", "product_id = ?", array($product_id)); |
---|
[15559] | 222 | |
---|
[18815] | 223 | $exists = array(); |
---|
| 224 | foreach ($productsClass as $val) { |
---|
| 225 | $exists[$val['product_class_id']] = $val; |
---|
[15559] | 226 | } |
---|
[18815] | 227 | $i = 1; |
---|
[19993] | 228 | while (isset($arrList['check:' . $i])) { |
---|
[18815] | 229 | $pVal = array(); |
---|
| 230 | $pVal['product_id'] = $product_id;; |
---|
| 231 | $pVal['product_code'] = $arrList["product_code:".$i]; |
---|
| 232 | $pVal['stock'] = $arrList["stock:".$i]; |
---|
| 233 | $pVal['stock_unlimited'] = ($arrList["stock_unlimited:".$i]) ? '1' : '0'; |
---|
| 234 | $pVal['price01'] = $arrList['price01:'.$i]; |
---|
| 235 | $pVal['price02'] = $arrList['price02:'.$i]; |
---|
[18882] | 236 | $pVal['product_type_id'] = $arrList['product_type_id:'.$i]; |
---|
[18819] | 237 | $pVal['down_filename'] = $arrList['down_filename:'.$i]; |
---|
| 238 | $pVal['down_realfilename'] = $arrList['down_realfilename:'.$i]; |
---|
[18815] | 239 | $pVal['creator_id'] = $_SESSION['member_id']; |
---|
| 240 | $pVal['update_date'] = "now()"; |
---|
[15559] | 241 | |
---|
[18815] | 242 | if($arrList["check:".$i] == 1) { |
---|
| 243 | $pVal['del_flg'] = 0; |
---|
| 244 | } else { |
---|
| 245 | $pVal['del_flg'] = 1; |
---|
| 246 | } |
---|
[15559] | 247 | |
---|
[18815] | 248 | // 更新 or 登録 |
---|
| 249 | $isUpdate = false; |
---|
| 250 | if (!SC_Utils_Ex::isBlank($arrList["product_class_id:".$i])) { |
---|
| 251 | $isUpdate = true; |
---|
| 252 | // 更新の場合は規格組み合わせを検索し, 削除しておく |
---|
| 253 | $class_combination_id = $exists[$arrList["product_class_id:".$i]]['class_combination_id']; |
---|
[19731] | 254 | $existsCombi = $objQuery->getRow( |
---|
| 255 | "*", |
---|
| 256 | "dtb_class_combination", |
---|
| 257 | "class_combination_id = ?", |
---|
| 258 | array($class_combination_id) |
---|
| 259 | ); |
---|
[15559] | 260 | |
---|
[18815] | 261 | $objQuery->delete("dtb_class_combination", |
---|
| 262 | "class_combination_id IN (?, ?)", |
---|
| 263 | array($existsCombi['class_combination_id'], |
---|
| 264 | $existsCombi['parent_class_combination_id'])); |
---|
| 265 | } |
---|
[15559] | 266 | |
---|
[18815] | 267 | // 規格組み合わせを登録 |
---|
| 268 | $cVal1['class_combination_id'] = $objQuery->nextVal('dtb_class_combination_class_combination_id'); |
---|
[15559] | 269 | |
---|
[18815] | 270 | $cVal1['classcategory_id'] = $arrList["classcategory_id1:".$i]; |
---|
| 271 | $cVal1['level'] = 1; |
---|
| 272 | $objQuery->insert("dtb_class_combination", $cVal1); |
---|
[15559] | 273 | |
---|
[18815] | 274 | $pVal['class_combination_id'] = $cVal1['class_combination_id']; |
---|
[15559] | 275 | |
---|
[18815] | 276 | // 規格2も登録する場合 |
---|
| 277 | if (!SC_Utils_Ex::isBlank($arrList["classcategory_id2:".$i])) { |
---|
| 278 | $cVal2['class_combination_id'] = $objQuery->nextVal('dtb_class_combination_class_combination_id'); |
---|
| 279 | $cVal2['classcategory_id'] = $arrList["classcategory_id2:".$i]; |
---|
| 280 | $cVal2['parent_class_combination_id'] = $cVal1['class_combination_id']; |
---|
| 281 | $cVal2['level'] = 2; |
---|
| 282 | $objQuery->insert("dtb_class_combination", $cVal2); |
---|
[15559] | 283 | |
---|
[18815] | 284 | $pVal['class_combination_id'] = $cVal2['class_combination_id']; |
---|
| 285 | } |
---|
[15559] | 286 | |
---|
[18815] | 287 | // 更新 |
---|
| 288 | if ($isUpdate) { |
---|
| 289 | $pVal['product_class_id'] = $arrList["product_class_id:".$i]; |
---|
| 290 | $objQuery->update("dtb_products_class", $pVal, |
---|
| 291 | "product_class_id = ?", |
---|
| 292 | array($pVal['product_class_id'])); |
---|
[15559] | 293 | } |
---|
[18815] | 294 | // 新規登録 |
---|
| 295 | else { |
---|
| 296 | $pVal['create_date'] = "now()"; |
---|
| 297 | $pVal['product_class_id'] = $objQuery->nextVal('dtb_products_class_product_class_id'); |
---|
| 298 | $objQuery->insert("dtb_products_class", $pVal); |
---|
| 299 | } |
---|
[19695] | 300 | |
---|
| 301 | // 支払方法登録 |
---|
| 302 | $objProduct = new SC_Product(); |
---|
| 303 | $objProduct->setPaymentOptions($pVal['product_class_id'], $arrList['payment_ids:'.$i]); |
---|
[18815] | 304 | $i++; |
---|
[15559] | 305 | } |
---|
| 306 | |
---|
[18815] | 307 | // 規格無し用の商品規格を非表示に |
---|
| 308 | $bVal['del_flg'] = 1; |
---|
| 309 | $bVal['update_date'] = 'now()'; |
---|
| 310 | $objQuery->update("dtb_products_class", $bVal, |
---|
| 311 | "product_class_id = ? AND class_combination_id IS NULL", |
---|
| 312 | array($pVal['product_class_id'])); |
---|
[15559] | 313 | |
---|
[17509] | 314 | // 件数カウントバッチ実行 |
---|
[20032] | 315 | $objDb->sfCountCategory($objQuery); |
---|
[15559] | 316 | $objQuery->commit(); |
---|
| 317 | } |
---|
| 318 | |
---|
| 319 | // 規格選択エラーチェック |
---|
| 320 | function lfClassError() { |
---|
| 321 | $objErr = new SC_CheckError(); |
---|
| 322 | $objErr->doFunc(array("規格1", "select_class_id1"), array("EXIST_CHECK")); |
---|
| 323 | $objErr->doFunc(array("規格", "select_class_id1", "select_class_id2"), array("TOP_EXIST_CHECK")); |
---|
| 324 | $objErr->doFunc(array("規格1", "規格2", "select_class_id1", "select_class_id2"), array("DIFFERENT_CHECK")); |
---|
| 325 | return $objErr->arrErr; |
---|
| 326 | } |
---|
| 327 | |
---|
| 328 | /* 取得文字列の変換 */ |
---|
| 329 | function lfConvertParam($array) { |
---|
| 330 | /* |
---|
| 331 | * 文字列の変換 |
---|
| 332 | * K : 「半角(ハンカク)片仮名」を「全角片仮名」に変換 |
---|
| 333 | * C : 「全角ひら仮名」を「全角かた仮名」に変換 |
---|
| 334 | * V : 濁点付きの文字を一文字に変換。"K","H"と共に使用します |
---|
| 335 | * n : 「全角」数字を「半角(ハンカク)」に変換 |
---|
| 336 | */ |
---|
| 337 | |
---|
[15900] | 338 | $no = 1; // FIXME 未定義変数の修正 |
---|
[15559] | 339 | while($array["classcategory_id1:".$no] != "") { |
---|
| 340 | $arrConvList["product_code:".$no] = "KVa"; |
---|
| 341 | $arrConvList["price01:".$no] = "n"; |
---|
| 342 | $arrConvList["price02:".$no] = "n"; |
---|
| 343 | $arrConvList["stock:".$no] = "n"; |
---|
| 344 | $no++; |
---|
| 345 | } |
---|
| 346 | |
---|
| 347 | // 文字変換 |
---|
| 348 | foreach ($arrConvList as $key => $val) { |
---|
| 349 | // POSTされてきた値のみ変換する。 |
---|
| 350 | if(isset($array[$key])) { |
---|
| 351 | $array[$key] = mb_convert_kana($array[$key] ,$val); |
---|
| 352 | } |
---|
| 353 | } |
---|
| 354 | return $array; |
---|
| 355 | } |
---|
| 356 | |
---|
| 357 | // 商品規格エラーチェック |
---|
| 358 | function lfProductClassError($array) { |
---|
| 359 | $objErr = new SC_CheckError($array); |
---|
[15900] | 360 | $no = 1; // FIXME 未定義変数の修正 |
---|
[15559] | 361 | while($array["classcategory_id1:".$no] != "") { |
---|
| 362 | if($array["check:".$no] == 1) { |
---|
| 363 | $objErr->doFunc(array("商品コード", "product_code:".$no, STEXT_LEN), array("MAX_LENGTH_CHECK")); |
---|
[17757] | 364 | $objErr->doFunc(array(NORMAL_PRICE_TITLE, "price01:".$no, PRICE_LEN), array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 365 | $objErr->doFunc(array(SALE_PRICE_TITLE, "price02:".$no, PRICE_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
[15559] | 366 | |
---|
| 367 | if($array["stock_unlimited:".$no] != '1') { |
---|
| 368 | $objErr->doFunc(array("在庫数", "stock:".$no, AMOUNT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 369 | } |
---|
[18819] | 370 | |
---|
[19993] | 371 | // 商品種別チェック |
---|
| 372 | if (empty($array['product_type_id:' . $no])) { |
---|
| 373 | $objErr->arrErr['product_type_id:' . $no] = "※ 商品種別は、いずれかを選択してください。<br />"; |
---|
| 374 | } |
---|
| 375 | |
---|
[19695] | 376 | // 支払方法チェック |
---|
| 377 | if (empty($array['payment_ids:' . $no])) { |
---|
| 378 | $objErr->arrErr['payment_ids:' . $no] = "※ 支払方法は、いずれかを選択してください。<br />"; |
---|
| 379 | } |
---|
| 380 | |
---|
[18819] | 381 | //ダウンロード商品チェック |
---|
[18882] | 382 | if($array["product_type_id:".$no] == PRODUCT_TYPE_DOWNLOAD) { |
---|
[18819] | 383 | $objErr->doFunc(array("ダウンロードファイル名", "down_filename:".$no, STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 384 | if($array["down_realfilename:".$no] == "") { |
---|
| 385 | $objErr->arrErr["down_realfilename:".$no] = "※ ダウンロード商品の場合はダウンロード商品用ファイルをアップロードしてください。<br />"; |
---|
| 386 | } |
---|
| 387 | } |
---|
| 388 | //実商品チェック |
---|
[18882] | 389 | else if($array["product_type_id:".$no] == PRODUCT_TYPE_DOWNLOAD) { |
---|
[18819] | 390 | if($array["down_filename:".$no] != "") { |
---|
| 391 | $objErr->arrErr["down_filename:".$no] = "※ 実商品の場合はダウンロードファイル名を設定できません。<br />"; |
---|
| 392 | } |
---|
| 393 | if($array["down_realfilename:".$no] != "") { |
---|
| 394 | $objErr->arrErr["down_realfilename:".$no] = "※ 実商品の場合はダウンロード商品用ファイルをアップロードできません。<br />ファイルを取り消してください。<br />"; |
---|
| 395 | } |
---|
| 396 | } |
---|
[15559] | 397 | } |
---|
| 398 | if(count($objErr->arrErr) > 0) { |
---|
[19993] | 399 | $objErr->arrErr["error:".$no] = $objErr->arrErr["product_type_id:".$no]; |
---|
| 400 | $objErr->arrErr["error:".$no] .= $objErr->arrErr["payment_ids:".$no]; |
---|
| 401 | $objErr->arrErr["error:".$no] .= $objErr->arrErr["product_code:".$no]; |
---|
| 402 | $objErr->arrErr["error:".$no] .= $objErr->arrErr["price01:".$no]; |
---|
| 403 | $objErr->arrErr["error:".$no] .= $objErr->arrErr["price02:".$no]; |
---|
| 404 | $objErr->arrErr["error:".$no] .= $objErr->arrErr["stock:".$no]; |
---|
| 405 | $objErr->arrErr["error:".$no] .= $objErr->arrErr["stock:".$no]; |
---|
| 406 | $objErr->arrErr["error:".$no] .= $objErr->arrErr["down_filename:".$no]; |
---|
| 407 | $objErr->arrErr["error:".$no] .= $objErr->arrErr["down_realfilename:".$no]; |
---|
| 408 | |
---|
[15559] | 409 | } |
---|
| 410 | $no++; |
---|
| 411 | } |
---|
| 412 | return $objErr->arrErr; |
---|
| 413 | } |
---|
| 414 | |
---|
| 415 | /* 確認ページ表示用 */ |
---|
| 416 | function lfProductConfirmPage() { |
---|
| 417 | $objDb = new SC_Helper_DB_Ex(); |
---|
| 418 | $this->arrForm['mode'] = 'complete'; |
---|
| 419 | $this->arrClass = $objDb->sfGetIDValueList("dtb_class", 'class_id', 'name'); |
---|
| 420 | $cnt = 0; |
---|
| 421 | $check = 0; |
---|
| 422 | $no = 1; |
---|
| 423 | while($_POST["classcategory_id1:".$no] != "") { |
---|
| 424 | if($_POST["check:".$no] != "") { |
---|
| 425 | $check++; |
---|
| 426 | } |
---|
| 427 | $no++; |
---|
| 428 | $cnt++; |
---|
| 429 | } |
---|
| 430 | $this->tpl_check = $check; |
---|
| 431 | $this->tpl_count = $cnt; |
---|
| 432 | } |
---|
[18815] | 433 | |
---|
| 434 | /** |
---|
| 435 | * 規格の組み合わせ一覧を表示する. |
---|
| 436 | * |
---|
| 437 | * 1. 規格1, 規格2を組み合わせた場合の妥当性を検証する. |
---|
| 438 | * 2. 規格1, 規格2における規格分類のすべての組み合わせを取得し, |
---|
| 439 | * 該当商品の商品規格の内容を取得し, フォームに設定する. |
---|
| 440 | */ |
---|
| 441 | function doDisp() { |
---|
| 442 | $this->arrForm['select_class_id1'] = $_POST['select_class_id1']; |
---|
| 443 | $this->arrForm['select_class_id2'] = $_POST['select_class_id2']; |
---|
[19993] | 444 | $dispError = $this->lfClassError(); |
---|
| 445 | if (SC_Utils_Ex::isBlank($dispError)) { |
---|
[18815] | 446 | $this->arrClassCat = $this->getAllClassCategory($_POST['select_class_id1'], $_POST['select_class_id2']); |
---|
| 447 | |
---|
| 448 | $productsClass = $this->getProductsClass($_POST['product_id']); |
---|
| 449 | |
---|
| 450 | $total = count($this->arrClassCat); |
---|
| 451 | for ($i = 1; $i <= $total; $i++) { |
---|
| 452 | foreach ($productsClass as $key => $val) { |
---|
| 453 | $this->arrForm[$key . ":" . $i] = $val; |
---|
| 454 | } |
---|
| 455 | } |
---|
| 456 | } |
---|
[19993] | 457 | $this->arrErr = array_merge((array) $this->arrErr, $dispError); |
---|
[18815] | 458 | $this->tpl_onload.= "fnCheckAllStockLimit('$total', '" . DISABLED_RGB . "');"; |
---|
| 459 | } |
---|
| 460 | |
---|
| 461 | /** |
---|
| 462 | * 規格編集画面を表示する. |
---|
| 463 | */ |
---|
[18819] | 464 | function doPreEdit($existsValue = true,$usepostValue = false) { |
---|
[18815] | 465 | $existsProductsClass = $this->getProductsClassAndClasscategory($_POST['product_id']); |
---|
| 466 | $productsClass = $this->getProductsClass($_POST['product_id']); |
---|
| 467 | $this->arrForm["class_id1"] = $existsProductsClass[0]['class_id1']; |
---|
| 468 | $this->arrForm["class_id2"] = $existsProductsClass[0]['class_id2']; |
---|
| 469 | $this->arrForm['select_class_id1'] = $this->arrForm["class_id1"]; |
---|
| 470 | $this->arrForm['select_class_id2'] = $this->arrForm["class_id2"]; |
---|
| 471 | $this->arrClassCat = $this->getAllClassCategory($this->arrForm["class_id1"], $this->arrForm["class_id2"]); |
---|
[19695] | 472 | $objProduct = new SC_Product(); |
---|
[18815] | 473 | $total = count($this->arrClassCat); |
---|
[19695] | 474 | // XXX $i = 1 にすれば ($i+1) は $i で良い? |
---|
[18828] | 475 | for ($i = 0; $i < $total; $i++) { |
---|
[18815] | 476 | if ($existsValue) { |
---|
| 477 | foreach ($productsClass as $key => $val) { |
---|
[19695] | 478 | if(!$usepostValue){ |
---|
| 479 | $this->arrForm[$key . ":" . ($i+1)] = $val; |
---|
| 480 | } |
---|
[18815] | 481 | } |
---|
| 482 | } |
---|
| 483 | foreach ($existsProductsClass[$i] as $key => $val) { |
---|
[19695] | 484 | if(!$usepostValue){ |
---|
| 485 | $this->arrForm[$key . ":" . ($i+1)] = $val; |
---|
| 486 | } |
---|
| 487 | |
---|
| 488 | switch ($key) { |
---|
| 489 | case 'down': |
---|
[18819] | 490 | $this->objDownFile->addFile("ダウンロード販売用ファイル". ":" . ($i+1), 'down_realfilename'. ":" . ($i+1), explode(",", DOWNLOAD_EXTENSION),DOWN_SIZE, true, 0, 0); |
---|
[19695] | 491 | break; |
---|
| 492 | |
---|
| 493 | case 'product_class_id': |
---|
| 494 | $this->arrForm["payment_ids:" . ($i+1)] = $objProduct->getEnablePaymentIds(array($val)); |
---|
| 495 | break; |
---|
| 496 | default: |
---|
[18819] | 497 | } |
---|
| 498 | } |
---|
[18828] | 499 | if (!SC_Utils_Ex::isBlank($this->arrForm['product_id:' . ($i+1)]) |
---|
| 500 | && $this->arrForm["del_flg:" . ($i+1)] == 0) { |
---|
| 501 | $line .= "'check:" . ($i+1) . "',"; |
---|
| 502 | } |
---|
[18819] | 503 | } |
---|
[18815] | 504 | |
---|
| 505 | $line = preg_replace("/,$/", "", $line); |
---|
| 506 | $this->tpl_javascript = "list = new Array($line);"; |
---|
| 507 | $color = DISABLED_RGB; |
---|
| 508 | $this->tpl_onload.= "fnListCheck(list); fnCheckAllStockLimit('$total', '$color');"; |
---|
[18819] | 509 | |
---|
| 510 | // DBデータからダウンロードファイル名の読込 |
---|
| 511 | $this->objDownFile->setDBFileList($this->arrForm); |
---|
| 512 | // PostデータからダウンロードTempファイル名の読込 |
---|
| 513 | $this->objDownFile->setPostFileList($_POST,$this->arrForm); |
---|
[18815] | 514 | } |
---|
| 515 | |
---|
| 516 | function doDelete() { |
---|
| 517 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
| 518 | |
---|
| 519 | $objQuery->begin(); |
---|
| 520 | $val['del_flg'] = 0; |
---|
| 521 | $objQuery->update("dtb_products_class", $val, "product_id = ? AND class_combination_id IS NULL", array($_POST['product_id'])); |
---|
| 522 | |
---|
| 523 | $val['del_flg'] = 1; |
---|
| 524 | $objQuery->update("dtb_products_class", $val, "product_id = ? AND class_combination_id IS NOT NULL", array($_POST['product_id'])); |
---|
| 525 | |
---|
| 526 | $objQuery->commit(); |
---|
| 527 | |
---|
| 528 | // 在庫無し商品の非表示対応 |
---|
| 529 | if (NOSTOCK_HIDDEN === true) { |
---|
| 530 | // 件数カウントバッチ実行 |
---|
[20032] | 531 | $objDb->sfCountCategory($objQuery); |
---|
[18815] | 532 | } |
---|
| 533 | } |
---|
| 534 | |
---|
| 535 | /** |
---|
| 536 | * 規格ID1, 規格ID2の規格分類すべてを取得する. |
---|
| 537 | * |
---|
| 538 | * @param integer $class_id1 規格ID1 |
---|
| 539 | * @param integer $class_id2 規格ID2 |
---|
| 540 | * @return array 規格と規格分類の配列 |
---|
| 541 | */ |
---|
| 542 | function getAllClassCategory($class_id1, $class_id2 = null) { |
---|
| 543 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
| 544 | |
---|
| 545 | $col = "T1.class_id AS class_id1, " |
---|
| 546 | . " T1.classcategory_id AS classcategory_id1, " |
---|
| 547 | . " T1.name AS name1, " |
---|
| 548 | . " T1.rank AS rank1 "; |
---|
| 549 | |
---|
| 550 | if(SC_Utils_Ex::isBlank($class_id2)) { |
---|
| 551 | $table = "dtb_classcategory T1 "; |
---|
[19755] | 552 | $objQuery->setWhere("T1.class_id = ?"); |
---|
| 553 | $objQuery->setOrder("T1.rank DESC"); |
---|
[18815] | 554 | $val = array($class_id1); |
---|
| 555 | } else { |
---|
| 556 | $col .= "," |
---|
| 557 | . "T2.class_id AS class_id2," |
---|
| 558 | . "T2.classcategory_id AS classcategory_id2," |
---|
| 559 | . "T2.name AS name2," |
---|
| 560 | . "T2.rank AS rank2"; |
---|
| 561 | $table = "dtb_classcategory AS T1, dtb_classcategory AS T2"; |
---|
[19755] | 562 | $objQuery->setWhere("T1.class_id = ? AND T2.class_id = ?"); |
---|
| 563 | $objQuery->setOrder("T1.rank DESC, T2.rank DESC"); |
---|
[18815] | 564 | $val = array($class_id1, $class_id2); |
---|
| 565 | } |
---|
| 566 | return $objQuery->select($col, $table, "", $val); |
---|
| 567 | } |
---|
| 568 | |
---|
| 569 | /** |
---|
| 570 | * 商品名を取得する. |
---|
| 571 | * |
---|
| 572 | * @access private |
---|
| 573 | * @param integer $product_id 商品ID |
---|
| 574 | * @return string 商品名の文字列 |
---|
| 575 | */ |
---|
| 576 | function getProductName($product_id) { |
---|
| 577 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
| 578 | return $objQuery->getOne("SELECT name FROM dtb_products WHERE product_id = ?", array($product_id)); |
---|
| 579 | } |
---|
| 580 | |
---|
| 581 | /** |
---|
| 582 | * 検索パラメータを生成する. |
---|
| 583 | * |
---|
| 584 | * "search_" で始まるパラメータのみを生成して返す. |
---|
| 585 | * |
---|
| 586 | * TODO パラメータの妥当性検証 |
---|
| 587 | * |
---|
| 588 | * @access private |
---|
| 589 | * @param array $params 生成元の POST パラメータ |
---|
| 590 | * @return array View にアサインするパラメータの配列 |
---|
| 591 | */ |
---|
| 592 | function createSearchParams($params) { |
---|
| 593 | $results = array(); |
---|
| 594 | foreach ($params as $key => $val) { |
---|
| 595 | if (substr($key, 0, 7) == "search_") { |
---|
| 596 | $results[$key] = $val; |
---|
| 597 | } |
---|
| 598 | } |
---|
| 599 | return $results; |
---|
| 600 | } |
---|
| 601 | |
---|
| 602 | /** |
---|
| 603 | * 規格分類の登録された, すべての規格を取得する. |
---|
| 604 | * |
---|
| 605 | * @access private |
---|
| 606 | * @return array 規格分類の登録された, すべての規格 |
---|
| 607 | */ |
---|
| 608 | function getAllClass() { |
---|
| 609 | $objDb = new SC_Helper_DB_Ex(); |
---|
| 610 | $arrClass = $objDb->sfGetIDValueList("dtb_class", 'class_id', 'name'); |
---|
| 611 | |
---|
| 612 | // 規格分類が登録されていない規格は表示しないようにする。 |
---|
| 613 | $arrClassCatCount = SC_Utils_Ex::sfGetClassCatCount(); |
---|
| 614 | |
---|
| 615 | $results = array(); |
---|
| 616 | if (!SC_Utils_Ex::isBlank($arrClass)) { |
---|
| 617 | foreach($arrClass as $key => $val) { |
---|
| 618 | if($arrClassCatCount[$key] > 0) { |
---|
| 619 | $results[$key] = $arrClass[$key]; |
---|
| 620 | } |
---|
| 621 | } |
---|
| 622 | } |
---|
| 623 | return $results; |
---|
| 624 | } |
---|
| 625 | |
---|
| 626 | /** |
---|
| 627 | * 商品IDをキーにして, 商品規格を取得する. |
---|
| 628 | * |
---|
| 629 | * @param integer $product_id 商品ID |
---|
| 630 | * @return array 商品規格の配列 |
---|
| 631 | */ |
---|
| 632 | function getProductsClass($product_id) { |
---|
| 633 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
[19755] | 634 | $col = <<< __EOS__ |
---|
| 635 | product_id, product_code, price01, price02, stock, |
---|
| 636 | stock_unlimited, point_rate |
---|
| 637 | __EOS__; |
---|
| 638 | return $objQuery->getRow($col, "dtb_products_class", "product_id = ?", array($product_id)); |
---|
[18815] | 639 | } |
---|
| 640 | |
---|
| 641 | /** |
---|
| 642 | * 登録済みの商品規格, 規格, 規格分類を取得する. |
---|
| 643 | * |
---|
| 644 | * @param integer $product_id 商品ID |
---|
| 645 | * @return array 商品規格, 規格, 規格分類の配列 |
---|
| 646 | */ |
---|
| 647 | function getProductsClassAndClasscategory($productId) { |
---|
| 648 | $objProduct = new SC_Product(); |
---|
| 649 | return $objProduct->getProductsClassFullByProductId($productId); |
---|
| 650 | } |
---|
| 651 | |
---|
| 652 | /** |
---|
| 653 | * @access private |
---|
| 654 | */ |
---|
| 655 | function authorization() { |
---|
| 656 | SC_Utils_Ex::sfIsSuccess(new SC_Session()); |
---|
| 657 | } |
---|
[15559] | 658 | } |
---|
| 659 | ?> |
---|