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