[15559] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[22206] | 5 | * Copyright(c) 2000-2013 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 | |
---|
[20534] | 24 | require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php'; |
---|
[15559] | 25 | |
---|
| 26 | /** |
---|
[17364] | 27 | * 商品登録(商品規格)のページクラス. |
---|
[15559] | 28 | * |
---|
| 29 | * @package Page |
---|
| 30 | * @author LOCKON CO.,LTD. |
---|
| 31 | * @version $Id$ |
---|
| 32 | */ |
---|
[22856] | 33 | class LC_Page_Admin_Products_ProductClass extends LC_Page_Admin_Ex |
---|
[22567] | 34 | { |
---|
[15559] | 35 | /** |
---|
| 36 | * Page を初期化する. |
---|
| 37 | * |
---|
| 38 | * @return void |
---|
| 39 | */ |
---|
[23124] | 40 | public function init() |
---|
[22567] | 41 | { |
---|
[15559] | 42 | parent::init(); |
---|
| 43 | $this->tpl_mainpage = 'products/product_class.tpl'; |
---|
| 44 | $this->tpl_mainno = 'products'; |
---|
| 45 | $this->tpl_subno = 'product'; |
---|
[20911] | 46 | $this->tpl_maintitle = '商品管理'; |
---|
[17509] | 47 | $this->tpl_subtitle = '商品登録(商品規格)'; |
---|
[19993] | 48 | $masterData = new SC_DB_MasterData_Ex(); |
---|
[21481] | 49 | $this->arrProductType = $masterData->getMasterData('mtb_product_type'); |
---|
[20595] | 50 | // 規格プルダウンのリスト |
---|
| 51 | $this->arrClass = $this->getAllClass(); |
---|
[15559] | 52 | } |
---|
| 53 | |
---|
[19661] | 54 | /** |
---|
| 55 | * Page のプロセス. |
---|
| 56 | * |
---|
| 57 | * @return void |
---|
| 58 | */ |
---|
[23124] | 59 | public function process() |
---|
[22567] | 60 | { |
---|
[19661] | 61 | $this->action(); |
---|
| 62 | $this->sendResponse(); |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | /** |
---|
| 66 | * Page のアクション. |
---|
| 67 | * |
---|
| 68 | * @return void |
---|
| 69 | */ |
---|
[23124] | 70 | public function action() |
---|
[22567] | 71 | { |
---|
[20970] | 72 | // 商品マスターの検索条件パラメーターを初期化 |
---|
[20501] | 73 | $objFormParam = new SC_FormParam_Ex(); |
---|
[20410] | 74 | $this->initParam($objFormParam); |
---|
[15559] | 75 | |
---|
[20410] | 76 | $objFormParam->setParam($_POST); |
---|
| 77 | $objFormParam->convParam(); |
---|
[18819] | 78 | |
---|
[20410] | 79 | $this->arrSearchHidden = $objFormParam->getSearchArray(); |
---|
[15559] | 80 | |
---|
[20041] | 81 | switch ($this->getMode()) { |
---|
[21526] | 82 | // 編集実行 |
---|
| 83 | case 'edit': |
---|
| 84 | $this->arrErr = $this->lfCheckProductsClass($objFormParam); |
---|
[20612] | 85 | |
---|
[21526] | 86 | // エラーの無い場合は確認画面を表示 |
---|
| 87 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
| 88 | $this->tpl_mainpage = 'products/product_class_confirm.tpl'; |
---|
| 89 | $this->doDisp($objFormParam); |
---|
| 90 | $this->fillCheckboxesValue('stock_unlimited', $_POST['total']); |
---|
| 91 | $objFormParam->setParam($_POST); |
---|
| 92 | $objFormParam->convParam(); |
---|
| 93 | } |
---|
| 94 | // エラーが発生した場合 |
---|
| 95 | else { |
---|
| 96 | $objFormParam->setParam($_POST); |
---|
| 97 | $objFormParam->convParam(); |
---|
| 98 | } |
---|
| 99 | break; |
---|
| 100 | |
---|
| 101 | // 削除 |
---|
| 102 | case 'delete': |
---|
| 103 | $this->doDelete($objFormParam->getValue('product_id')); |
---|
| 104 | $objFormParam->setValue('class_id1', ''); |
---|
| 105 | $objFormParam->setValue('class_id2', ''); |
---|
[20595] | 106 | $this->doDisp($objFormParam); |
---|
[21526] | 107 | break; |
---|
[15559] | 108 | |
---|
[21526] | 109 | // 初期表示 |
---|
| 110 | case 'pre_edit': |
---|
| 111 | $this->doPreEdit($objFormParam); |
---|
| 112 | break; |
---|
[18815] | 113 | |
---|
[21526] | 114 | // 「表示する」ボタン押下時 |
---|
| 115 | case 'disp': |
---|
| 116 | $this->arrErr = $this->lfCheckSelectClass(); |
---|
| 117 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
| 118 | $this->doDisp($objFormParam); |
---|
| 119 | $this->initDispParam($objFormParam); |
---|
| 120 | } |
---|
| 121 | break; |
---|
[15559] | 122 | |
---|
[21526] | 123 | // ダウンロード商品ファイルアップロード |
---|
| 124 | case 'file_upload': |
---|
| 125 | $this->doFileUpload($objFormParam); |
---|
| 126 | break; |
---|
[20410] | 127 | |
---|
[21526] | 128 | // ダウンロードファイルの削除 |
---|
| 129 | case 'file_delete': |
---|
| 130 | $this->doFileDelete($objFormParam); |
---|
| 131 | break; |
---|
[20410] | 132 | |
---|
[21526] | 133 | // 確認画面からの戻り |
---|
| 134 | case 'confirm_return': |
---|
| 135 | $this->doPreEdit($objFormParam); |
---|
| 136 | $objFormParam->setParam($_POST); |
---|
| 137 | $objFormParam->convParam(); |
---|
| 138 | break; |
---|
[20410] | 139 | |
---|
[21526] | 140 | case 'complete': |
---|
| 141 | $this->tpl_mainpage = 'products/product_class_complete.tpl'; |
---|
| 142 | $this->doUploadComplete($objFormParam); |
---|
| 143 | $this->registerProductClass($objFormParam->getHashArray(), |
---|
| 144 | $objFormParam->getValue('product_id'), |
---|
| 145 | $objFormParam->getValue('total')); |
---|
| 146 | break; |
---|
[20595] | 147 | |
---|
[21526] | 148 | default: |
---|
| 149 | break; |
---|
[15559] | 150 | } |
---|
[20410] | 151 | |
---|
| 152 | // 登録対象の商品名を取得 |
---|
[20595] | 153 | $objFormParam->setValue('product_name', |
---|
| 154 | $this->getProductName($objFormParam->getValue('product_id'))); |
---|
| 155 | $this->arrForm = $objFormParam->getFormParamList(); |
---|
[15559] | 156 | } |
---|
| 157 | |
---|
| 158 | /** |
---|
[20970] | 159 | * パラメーター初期化 |
---|
[20410] | 160 | * |
---|
[23124] | 161 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
[20595] | 162 | * @return void |
---|
[20410] | 163 | */ |
---|
[23124] | 164 | public function initParam(&$objFormParam) |
---|
[22567] | 165 | { |
---|
[20970] | 166 | // 商品マスター検索パラメーター引き継ぎ |
---|
[21183] | 167 | $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 168 | $objFormParam->addParam('カテゴリID', 'category_id', STEXT_LEN, 'n', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 169 | $objFormParam->addParam('ページ送り番号','search_pageno', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 170 | $objFormParam->addParam('表示件数', 'search_page_max', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 171 | $objFormParam->addParam('商品ID', 'search_product_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 172 | $objFormParam->addParam('商品コード', 'search_product_code', STEXT_LEN, 'KVna', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 173 | $objFormParam->addParam('商品名', 'search_name', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 174 | $objFormParam->addParam('カテゴリ', 'search_category_id', STEXT_LEN, 'n', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 175 | $objFormParam->addParam('種別', 'search_status', INT_LEN, 'n', array('MAX_LENGTH_CHECK')); |
---|
| 176 | $objFormParam->addParam('開始年', 'search_startyear', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 177 | $objFormParam->addParam('開始月', 'search_startmonth', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 178 | $objFormParam->addParam('開始日', 'search_startday', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 179 | $objFormParam->addParam('終了年', 'search_endyear', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 180 | $objFormParam->addParam('終了月', 'search_endmonth', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 181 | $objFormParam->addParam('終了日', 'search_endday', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 182 | $objFormParam->addParam('商品ステータス', 'search_product_statuses', INT_LEN, 'n', array('MAX_LENGTH_CHECK')); |
---|
[15559] | 183 | |
---|
[20410] | 184 | // 規格プルダウン |
---|
[21183] | 185 | $objFormParam->addParam('規格1', 'class_id1', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 186 | $objFormParam->addParam('規格2', 'class_id2', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
[20410] | 187 | |
---|
[20595] | 188 | // 商品規格 |
---|
[21183] | 189 | $objFormParam->addParam('商品規格数', 'total', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 190 | $objFormParam->addParam('商品名', 'product_name', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK')); |
---|
| 191 | $objFormParam->addParam('商品コード', 'product_code', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK')); |
---|
| 192 | $objFormParam->addParam('規格ID1', 'classcategory_id1', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 193 | $objFormParam->addParam('規格ID2', 'classcategory_id2', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 194 | $objFormParam->addParam('規格名1', 'classcategory_name1', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK')); |
---|
| 195 | $objFormParam->addParam('規格名2', 'classcategory_name2', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK')); |
---|
| 196 | $objFormParam->addParam('商品規格ID', 'product_class_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 197 | $objFormParam->addParam('在庫数', 'stock', AMOUNT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 198 | $objFormParam->addParam('在庫数', 'stock_unlimited', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 199 | $objFormParam->addParam(NORMAL_PRICE_TITLE, 'price01', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 200 | $objFormParam->addParam(SALE_PRICE_TITLE, 'price02', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[23230] | 201 | if(OPTION_PRODUCT_TAX_RULE) { |
---|
| 202 | $objFormParam->addParam('消費税率', 'tax_rate', PERCENTAGE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 203 | } |
---|
[21183] | 204 | $objFormParam->addParam('商品種別', 'product_type_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 205 | $objFormParam->addParam('削除フラグ', 'del_flg', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 206 | $objFormParam->addParam('ダウンロード販売用ファイル名', 'down_filename', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK')); |
---|
| 207 | $objFormParam->addParam('ダウンロード販売用ファイル名', 'down_realfilename', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK')); |
---|
| 208 | $objFormParam->addParam('チェックボックス', 'check', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 209 | $objFormParam->addParam('ファイルアップロード用キー', 'upload_index', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK')); |
---|
[20410] | 210 | } |
---|
| 211 | |
---|
[17581] | 212 | /** |
---|
[18815] | 213 | * 規格の登録または更新を行う. |
---|
[17581] | 214 | * |
---|
[23124] | 215 | * @param array $arrList 入力フォームの内容 |
---|
[18815] | 216 | * @param integer $product_id 登録を行う商品ID |
---|
[17581] | 217 | */ |
---|
[23124] | 218 | public function registerProductClass($arrList, $product_id, $total) |
---|
[22567] | 219 | { |
---|
[20507] | 220 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[18815] | 221 | $objDb = new SC_Helper_DB_Ex(); |
---|
[15559] | 222 | |
---|
[18815] | 223 | $objQuery->begin(); |
---|
[15559] | 224 | |
---|
[21515] | 225 | $arrProductsClass = $objQuery->select('*', 'dtb_products_class', 'product_id = ?', array($product_id)); |
---|
[20595] | 226 | $arrExists = array(); |
---|
| 227 | foreach ($arrProductsClass as $val) { |
---|
| 228 | $arrExists[$val['product_class_id']] = $val; |
---|
[15559] | 229 | } |
---|
| 230 | |
---|
[20595] | 231 | // デフォルト値として設定する値を取得しておく |
---|
| 232 | $arrDefault = $this->getProductsClass($product_id); |
---|
| 233 | |
---|
[21502] | 234 | $objQuery->delete('dtb_products_class', 'product_id = ? AND (classcategory_id1 <> 0 OR classcategory_id2 <> 0)', array($product_id)); |
---|
[20754] | 235 | |
---|
[20595] | 236 | for ($i = 0; $i < $total; $i++) { |
---|
| 237 | $del_flg = SC_Utils_Ex::isBlank($arrList['check'][$i]) ? 1 : 0; |
---|
[20746] | 238 | $price02 = SC_Utils_Ex::isBlank($arrList['price02'][$i]) ? 0 : $arrList['price02'][$i]; |
---|
[20595] | 239 | // dtb_products_class 登録/更新用 |
---|
[21502] | 240 | $registerKeys = array( |
---|
| 241 | 'classcategory_id1', 'classcategory_id2', |
---|
| 242 | 'product_code', 'stock', 'price01', 'product_type_id', |
---|
| 243 | 'down_filename', 'down_realfilename', |
---|
| 244 | ); |
---|
[20595] | 245 | |
---|
| 246 | $arrPC = array(); |
---|
| 247 | foreach ($registerKeys as $key) { |
---|
[20754] | 248 | $arrPC[$key] = $arrList[$key][$i]; |
---|
[18815] | 249 | } |
---|
[20595] | 250 | $arrPC['product_id'] = $product_id; |
---|
| 251 | $arrPC['sale_limit'] = $arrDefault['sale_limit']; |
---|
| 252 | $arrPC['deliv_fee'] = $arrDefault['deliv_fee']; |
---|
| 253 | $arrPC['point_rate'] = $arrDefault['point_rate']; |
---|
[22095] | 254 | if ($arrList['stock_unlimited'][$i] == 1) { |
---|
| 255 | $arrPC['stock_unlimited'] = 1; |
---|
| 256 | $arrPC['stock'] = null; |
---|
| 257 | } else { |
---|
| 258 | $arrPC['stock_unlimited'] = 0; |
---|
| 259 | } |
---|
[20746] | 260 | $arrPC['price02'] = $price02; |
---|
[15559] | 261 | |
---|
[20595] | 262 | // 該当関数が無いため, セッションの値を直接代入 |
---|
| 263 | $arrPC['creator_id'] = $_SESSION['member_id']; |
---|
[21185] | 264 | $arrPC['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
[20595] | 265 | $arrPC['del_flg'] = $del_flg; |
---|
| 266 | |
---|
[21185] | 267 | $arrPC['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
[21225] | 268 | // 更新の場合は, product_class_id を使い回す |
---|
| 269 | if (!SC_Utils_Ex::isBlank($arrList['product_class_id'][$i])) { |
---|
| 270 | $arrPC['product_class_id'] = $arrList['product_class_id'][$i]; |
---|
| 271 | } else { |
---|
| 272 | $arrPC['product_class_id'] = $objQuery->nextVal('dtb_products_class_product_class_id'); |
---|
| 273 | } |
---|
| 274 | |
---|
[20754] | 275 | /* |
---|
| 276 | * チェックを入れない商品は product_type_id が NULL になるので, 0 を入れる |
---|
| 277 | */ |
---|
| 278 | $arrPC['product_type_id'] = SC_Utils_Ex::isBlank($arrPC['product_type_id']) ? 0 : $arrPC['product_type_id']; |
---|
| 279 | |
---|
[21481] | 280 | $objQuery->insert('dtb_products_class', $arrPC); |
---|
[22856] | 281 | |
---|
[22736] | 282 | // 税情報登録/更新 |
---|
[23230] | 283 | if (OPTION_PRODUCT_TAX_RULE) { |
---|
| 284 | SC_Helper_TaxRule_Ex::setTaxRuleForProduct($arrList['tax_rate'][$i], $arrPC['product_id'], $arrPC['product_class_id']); |
---|
| 285 | } |
---|
[15559] | 286 | } |
---|
| 287 | |
---|
[18815] | 288 | // 規格無し用の商品規格を非表示に |
---|
[20595] | 289 | $arrBlank['del_flg'] = 1; |
---|
[21185] | 290 | $arrBlank['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
[21481] | 291 | $objQuery->update('dtb_products_class', $arrBlank, |
---|
[21514] | 292 | 'product_id = ? AND classcategory_id1 = 0 AND classcategory_id2 = 0', |
---|
[20595] | 293 | array($product_id)); |
---|
[15559] | 294 | |
---|
[17509] | 295 | // 件数カウントバッチ実行 |
---|
[20032] | 296 | $objDb->sfCountCategory($objQuery); |
---|
[15559] | 297 | $objQuery->commit(); |
---|
| 298 | } |
---|
| 299 | |
---|
[20410] | 300 | /** |
---|
| 301 | * 規格選択エラーチェックを行う |
---|
| 302 | * |
---|
| 303 | * ※SC_FormParamで対応していないエラーチェックのため, SC_CheckErrorを使用している. |
---|
| 304 | * |
---|
| 305 | * @return array エラーの配列 |
---|
| 306 | */ |
---|
[23124] | 307 | public function lfCheckSelectClass() |
---|
[22567] | 308 | { |
---|
[20503] | 309 | $objErr = new SC_CheckError_Ex(); |
---|
[21514] | 310 | $objErr->doFunc(array('規格1', 'class_id1'), array('EXIST_CHECK')); |
---|
| 311 | $objErr->doFunc(array('規格', 'class_id1', 'select_class_id2'), array('TOP_EXIST_CHECK')); |
---|
| 312 | $objErr->doFunc(array('規格1', '規格2', 'class_id1', 'class_id2'), array('DIFFERENT_CHECK')); |
---|
[22856] | 313 | |
---|
[15559] | 314 | return $objErr->arrErr; |
---|
| 315 | } |
---|
| 316 | |
---|
[20612] | 317 | /** |
---|
| 318 | * 商品規格エラーチェック. |
---|
| 319 | * |
---|
[23124] | 320 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 321 | * @return array エラー結果の配列 |
---|
[20612] | 322 | */ |
---|
[23124] | 323 | public function lfCheckProductsClass(&$objFormParam) |
---|
[22567] | 324 | { |
---|
[20612] | 325 | $arrValues = $objFormParam->getHashArray(); |
---|
| 326 | $arrErr = $objFormParam->checkError(); |
---|
| 327 | $total = $objFormParam->getValue('total'); |
---|
[15559] | 328 | |
---|
[20612] | 329 | if (SC_Utils_Ex::isBlank($arrValues['check'])) { |
---|
[21523] | 330 | $arrErr['check_empty'] = '※ 規格が選択されていません。<br />'; |
---|
[20612] | 331 | } |
---|
| 332 | |
---|
| 333 | for ($i = 0; $i < $total; $i++) { |
---|
| 334 | /* |
---|
| 335 | * チェックボックスの入っている項目のみ, 必須チェックを行う. |
---|
| 336 | * エラーを配列で返す必要があるため, SC_CheckError を使用しない. |
---|
| 337 | */ |
---|
| 338 | if (!SC_Utils_Ex::isBlank($arrValues['check'][$i])) { |
---|
| 339 | /* |
---|
| 340 | * 販売価格の必須チェック |
---|
| 341 | */ |
---|
| 342 | if (SC_Utils_Ex::isBlank($arrValues['price02'][$i])) { |
---|
| 343 | $arrErr['price02'][$i] = '※ ' . SALE_PRICE_TITLE . 'が入力されていません。<br />'; |
---|
[15559] | 344 | } |
---|
[20612] | 345 | /* |
---|
| 346 | * 在庫数の必須チェック |
---|
| 347 | */ |
---|
[21527] | 348 | if ((SC_Utils_Ex::isBlank($arrValues['stock_unlimited'][$i]) || $arrValues['stock_unlimited'][$i] != 1) |
---|
| 349 | && SC_Utils_Ex::isBlank($arrValues['stock'][$i]) |
---|
| 350 | ) { |
---|
[20612] | 351 | $arrErr['stock'][$i] = '※ 在庫数が入力されていません。<br />'; |
---|
[19993] | 352 | } |
---|
[20612] | 353 | /* |
---|
[22736] | 354 | * 消費税率の必須チェック |
---|
| 355 | */ |
---|
[23230] | 356 | if (OPTION_PRODUCT_TAX_RULE && SC_Utils_Ex::isBlank($arrValues['tax_rate'][$i])) { |
---|
[22736] | 357 | $arrErr['tax_rate'][$i] = '※ 消費税率が入力されていません。<br />'; |
---|
| 358 | } |
---|
| 359 | /* |
---|
[20612] | 360 | * 商品種別の必須チェック |
---|
| 361 | */ |
---|
| 362 | if (SC_Utils_Ex::isBlank($arrValues['product_type_id'][$i])) { |
---|
[21514] | 363 | $arrErr['product_type_id'][$i] = '※ 商品種別は、いずれかを選択してください。<br />'; |
---|
[20612] | 364 | } |
---|
| 365 | /* |
---|
| 366 | * ダウンロード商品の必須チェック |
---|
| 367 | */ |
---|
[21441] | 368 | if ($arrValues['product_type_id'][$i] == PRODUCT_TYPE_DOWNLOAD) { |
---|
[20612] | 369 | if (SC_Utils_Ex::isBlank($arrValues['down_filename'][$i])) { |
---|
[21514] | 370 | $arrErr['down_filename'][$i] = '※ ダウンロード商品の場合はダウンロードファイル名を入力してください。<br />'; |
---|
[18819] | 371 | } |
---|
[20612] | 372 | if (SC_Utils_Ex::isBlank($arrValues['down_realfilename'][$i])) { |
---|
[21514] | 373 | $arrErr['down_realfilename'][$i] = '※ ダウンロード商品の場合はダウンロード商品用ファイルをアップロードしてください。<br />'; |
---|
[20612] | 374 | } |
---|
[18819] | 375 | } |
---|
[20612] | 376 | /* |
---|
| 377 | * 通常商品チェック |
---|
| 378 | */ |
---|
[22298] | 379 | else if ($arrValues['product_type_id'][$i] != PRODUCT_TYPE_DOWNLOAD) { |
---|
[20612] | 380 | if (!SC_Utils_Ex::isBlank($arrValues['down_filename'][$i])) { |
---|
[22298] | 381 | $arrErr['down_filename'][$i] = '※ ダウンロード商品ではない場合、ダウンロードファイル名を設定できません。<br />'; |
---|
[18819] | 382 | } |
---|
[20612] | 383 | if (!SC_Utils_Ex::isBlank($arrValues['down_realfilename'][$i])) { |
---|
[22298] | 384 | $arrErr['down_realfilename'][$i] = '※ ダウンロード商品ではない場合、ダウンロード商品用ファイルをアップロードできません。<br />ファイルを取り消してください。<br />'; |
---|
[18819] | 385 | } |
---|
| 386 | } |
---|
[15559] | 387 | } |
---|
| 388 | } |
---|
[22856] | 389 | |
---|
[20612] | 390 | return $arrErr; |
---|
[15559] | 391 | } |
---|
| 392 | |
---|
[20410] | 393 | /** |
---|
[18815] | 394 | * 規格の組み合わせ一覧を表示する. |
---|
| 395 | * |
---|
[22960] | 396 | * 規格1, 規格2における規格分類の全ての組み合わせを取得し, |
---|
[20595] | 397 | * 該当商品の商品規格の内容を取得後, フォームに設定する. |
---|
| 398 | * |
---|
[23124] | 399 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
[20595] | 400 | * @return void |
---|
[18815] | 401 | */ |
---|
[23124] | 402 | public function doDisp(&$objFormParam) |
---|
[22567] | 403 | { |
---|
[20595] | 404 | $product_id = $objFormParam->getValue('product_id'); |
---|
[20617] | 405 | $class_id1 = $objFormParam->getValue('class_id1'); |
---|
| 406 | $class_id2 = $objFormParam->getValue('class_id2'); |
---|
[18815] | 407 | |
---|
[22960] | 408 | // 全ての組み合わせを取得し, フォームに設定 |
---|
[20617] | 409 | $arrClassCat = $this->getAllClassCategory($class_id1, $class_id2); |
---|
[20595] | 410 | $total = count($arrClassCat); |
---|
| 411 | $objFormParam->setValue('total', $total); |
---|
| 412 | $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrClassCat)); |
---|
| 413 | |
---|
[20617] | 414 | // class_id1, class_id2 を, 入力値で上書き |
---|
| 415 | $objFormParam->setValue('class_id1', $class_id1); |
---|
| 416 | $objFormParam->setValue('class_id2', $class_id2); |
---|
[20595] | 417 | |
---|
| 418 | // 商品情報を取得し, フォームに設定 |
---|
| 419 | $arrProductsClass = $this->getProductsClass($product_id); |
---|
| 420 | |
---|
| 421 | foreach ($arrProductsClass as $key => $val) { |
---|
| 422 | // 組み合わせ数分の値の配列を生成する |
---|
| 423 | $arrValues = array(); |
---|
| 424 | for ($i = 0; $i < $total; $i++) { |
---|
| 425 | $arrValues[] = $val; |
---|
[18815] | 426 | } |
---|
[20595] | 427 | $objFormParam->setValue($key, $arrValues); |
---|
[18815] | 428 | } |
---|
[20636] | 429 | // 商品種別を 1 に初期化 |
---|
| 430 | $objFormParam->setValue('product_type_id', array_pad(array(), $total, 1)); |
---|
[18815] | 431 | } |
---|
| 432 | |
---|
| 433 | /** |
---|
[20970] | 434 | * 「表示する」ボタンをクリックされたときのパラメーター初期化処理 |
---|
[20751] | 435 | * |
---|
[23124] | 436 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
[20751] | 437 | * @return void |
---|
| 438 | */ |
---|
[23124] | 439 | public function initDispParam(&$objFormParam) |
---|
[22567] | 440 | { |
---|
[22960] | 441 | // 登録チェックボックス初期化(全てチェックを外す) |
---|
[20751] | 442 | $objFormParam->setValue('check', ''); |
---|
| 443 | |
---|
| 444 | // 規格2が選択されていない場合、規格2名称初期化 |
---|
| 445 | $class_id2 = $objFormParam->getValue('class_id2'); |
---|
[21441] | 446 | if (SC_Utils_Ex::isBlank($class_id2) == true) { |
---|
[20751] | 447 | $objFormParam->setValue('classcategory_name2', ''); |
---|
| 448 | } |
---|
| 449 | } |
---|
| 450 | |
---|
| 451 | /** |
---|
[20410] | 452 | * 規格編集画面を表示する |
---|
| 453 | * |
---|
[23124] | 454 | * @param integer $product_id 商品ID |
---|
| 455 | * @param bool $existsValue |
---|
| 456 | * @param bool $usepostValue |
---|
[18815] | 457 | */ |
---|
[23124] | 458 | public function doPreEdit(&$objFormParam) |
---|
[22567] | 459 | { |
---|
[20595] | 460 | $product_id = $objFormParam->getValue('product_id'); |
---|
[20612] | 461 | $objProduct = new SC_Product_Ex(); |
---|
[21502] | 462 | $existsProductsClass = $objProduct->getProductsClassFullByProductId($product_id); |
---|
[20410] | 463 | |
---|
[22960] | 464 | // 規格のデフォルト値(全ての組み合わせ)を取得し, フォームに反映 |
---|
[20595] | 465 | $class_id1 = $existsProductsClass[0]['class_id1']; |
---|
| 466 | $class_id2 = $existsProductsClass[0]['class_id2']; |
---|
| 467 | $objFormParam->setValue('class_id1', $class_id1); |
---|
| 468 | $objFormParam->setValue('class_id2', $class_id2); |
---|
| 469 | $this->doDisp($objFormParam); |
---|
[20410] | 470 | |
---|
[21527] | 471 | /* |
---|
[20760] | 472 | * 登録済みのデータで, フォームの値を上書きする. |
---|
| 473 | * |
---|
| 474 | * 登録済みデータと, フォームの値は, 配列の形式が違うため, |
---|
| 475 | * 同じ形式の配列を生成し, マージしてフォームの値を上書きする |
---|
[21527] | 476 | */ |
---|
[20760] | 477 | $arrKeys = array('classcategory_id1', 'classcategory_id2','product_code', |
---|
[21527] | 478 | 'classcategory_name1', 'classcategory_name2', 'stock', |
---|
| 479 | 'stock_unlimited', 'price01', 'price02', |
---|
[22736] | 480 | 'product_type_id', 'down_filename', 'down_realfilename', 'upload_index', 'tax_rate' |
---|
[21527] | 481 | ); |
---|
[20760] | 482 | $arrFormValues = $objFormParam->getSwapArray($arrKeys); |
---|
| 483 | // フォームの規格1, 規格2をキーにした配列を生成 |
---|
| 484 | $arrClassCatKey = array(); |
---|
| 485 | foreach ($arrFormValues as $formValue) { |
---|
| 486 | $arrClassCatKey[$formValue['classcategory_id1']][$formValue['classcategory_id2']] = $formValue; |
---|
| 487 | } |
---|
| 488 | // 登録済みデータをマージ |
---|
| 489 | foreach ($existsProductsClass as $existsValue) { |
---|
| 490 | $arrClassCatKey[$existsValue['classcategory_id1']][$existsValue['classcategory_id2']] = $existsValue; |
---|
| 491 | } |
---|
| 492 | |
---|
| 493 | // 規格のデフォルト値に del_flg をつけてマージ後の1次元配列を生成 |
---|
| 494 | $arrMergeProductsClass = array(); |
---|
| 495 | foreach ($arrClassCatKey as $arrC1) { |
---|
| 496 | foreach ($arrC1 as $arrValues) { |
---|
| 497 | $arrValues['del_flg'] = (string) $arrValues['del_flg']; |
---|
| 498 | if (SC_Utils_Ex::isBlank($arrValues['del_flg']) |
---|
| 499 | || $arrValues['del_flg'] === '1') { |
---|
| 500 | $arrValues['del_flg'] = '1'; |
---|
| 501 | } else { |
---|
| 502 | $arrValues['del_flg'] = '0'; |
---|
| 503 | } |
---|
[23230] | 504 | |
---|
[22736] | 505 | // 消費税率を設定 |
---|
[23230] | 506 | if (OPTION_PRODUCT_TAX_RULE) { |
---|
| 507 | $arrRet = SC_Helper_TaxRule_Ex::getTaxRule($arrValues['product_id'], $arrValues['product_class_id']); |
---|
| 508 | $arrValues['tax_rate'] = $arrRet['tax_rate']; |
---|
| 509 | } |
---|
[22856] | 510 | |
---|
[20760] | 511 | $arrMergeProductsClass[] = $arrValues; |
---|
| 512 | } |
---|
| 513 | } |
---|
| 514 | |
---|
[20595] | 515 | // 登録済みのデータで上書き |
---|
[20760] | 516 | $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrMergeProductsClass)); |
---|
[20595] | 517 | |
---|
[20760] | 518 | // $arrMergeProductsClass で product_id が配列になってしまうため数値で上書き |
---|
[20595] | 519 | $objFormParam->setValue('product_id', $product_id); |
---|
| 520 | |
---|
| 521 | // check を設定 |
---|
| 522 | $arrChecks = array(); |
---|
| 523 | $index = 0; |
---|
| 524 | foreach ($objFormParam->getValue('del_flg') as $key => $val) { |
---|
[20760] | 525 | if ($val === '0') { |
---|
[20595] | 526 | $arrChecks[$index] = 1; |
---|
[18815] | 527 | } |
---|
[20595] | 528 | $index++; |
---|
[18819] | 529 | } |
---|
[20595] | 530 | $objFormParam->setValue('check', $arrChecks); |
---|
[18815] | 531 | |
---|
[20617] | 532 | // class_id1, class_id2 を取得値で上書き |
---|
[20612] | 533 | $objFormParam->setValue('class_id1', $class_id1); |
---|
| 534 | $objFormParam->setValue('class_id2', $class_id2); |
---|
[18815] | 535 | } |
---|
| 536 | |
---|
[20410] | 537 | /** |
---|
| 538 | * 規格の削除を実行する |
---|
| 539 | * |
---|
| 540 | * @param $product_id |
---|
| 541 | * @return void |
---|
| 542 | */ |
---|
[23124] | 543 | public function doDelete($product_id) |
---|
[22567] | 544 | { |
---|
[20507] | 545 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[18815] | 546 | |
---|
| 547 | $objQuery->begin(); |
---|
[20755] | 548 | |
---|
[21502] | 549 | // 商品規格なしデータの復元 |
---|
| 550 | $where = 'product_id = ? AND classcategory_id1 = 0 AND classcategory_id2 = 0'; |
---|
[21514] | 551 | $objQuery->update('dtb_products_class', array('del_flg' => 0), $where, array($product_id)); |
---|
[20755] | 552 | |
---|
[21502] | 553 | // 商品規格データの削除 |
---|
| 554 | $where = 'product_id = ? AND (classcategory_id1 <> 0 OR classcategory_id2 <> 0)'; |
---|
[21514] | 555 | $objQuery->delete('dtb_products_class', $where, array($product_id)); |
---|
[21502] | 556 | |
---|
[18815] | 557 | $objQuery->commit(); |
---|
| 558 | |
---|
| 559 | // 在庫無し商品の非表示対応 |
---|
[21319] | 560 | if (NOSTOCK_HIDDEN) { |
---|
[18815] | 561 | // 件数カウントバッチ実行 |
---|
[20410] | 562 | $objDb = new SC_Helper_DB_Ex(); |
---|
[20032] | 563 | $objDb->sfCountCategory($objQuery); |
---|
[18815] | 564 | } |
---|
| 565 | } |
---|
| 566 | |
---|
| 567 | /** |
---|
[20617] | 568 | * ファイルアップロードを行う. |
---|
| 569 | * |
---|
| 570 | * 以下のチェックを行い, ファイルを一時領域へアップロードする. |
---|
| 571 | * 1. ファイルサイズチェック |
---|
| 572 | * 2. 拡張子チェック |
---|
| 573 | * |
---|
| 574 | * TODO |
---|
| 575 | * SC_CheckError クラスや, SC_UploadFile クラスが多次元配列に対応して |
---|
| 576 | * いないため, 独自のロジックを使用している. |
---|
| 577 | * |
---|
[23124] | 578 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
[20617] | 579 | * @return void |
---|
| 580 | */ |
---|
[23124] | 581 | public function doFileUpload(&$objFormParam) |
---|
[22567] | 582 | { |
---|
[20617] | 583 | $index = $objFormParam->getValue('upload_index'); |
---|
| 584 | $arrDownRealFiles = $objFormParam->getValue('down_realfilename'); |
---|
| 585 | |
---|
| 586 | if ($_FILES['down_realfilename']['size'][$index] <= 0) { |
---|
| 587 | $this->arrErr['down_realfilename'][$index] = '※ ファイルがアップロードされていません'; |
---|
[23124] | 588 | } elseif ($_FILES['down_realfilename']['size'][$index] > DOWN_SIZE * 1024) { |
---|
[20617] | 589 | $size = DOWN_SIZE; |
---|
| 590 | $byte = 'KB'; |
---|
| 591 | if ($size >= 1000) { |
---|
| 592 | $size = $size / 1000; |
---|
| 593 | $byte = 'MB'; |
---|
| 594 | } |
---|
[21515] | 595 | $this->arrErr['down_realfilename'][$index] = '※ ダウンロード販売用ファイル名のファイルサイズは' . $size . $byte . '以下のものを使用してください。<br />'; |
---|
[20617] | 596 | } else { |
---|
[21586] | 597 | // SC_CheckError::FILE_EXT_CHECK とのソース互換を強めるための配列 |
---|
| 598 | $value = array( |
---|
| 599 | 0 => 'ダウンロード販売用ファイル名', |
---|
| 600 | 1 => 'down_realfilename', |
---|
| 601 | 2 => explode(',', DOWNLOAD_EXTENSION), |
---|
| 602 | ); |
---|
| 603 | // ▼SC_CheckError::FILE_EXT_CHECK から移植 |
---|
| 604 | $match = false; |
---|
| 605 | if (strlen($_FILES[$value[1]]['name'][$index]) >= 1) { |
---|
| 606 | $filename = $_FILES[$value[1]]['name'][$index]; |
---|
[20617] | 607 | |
---|
[21586] | 608 | foreach ($value[2] as $check_ext) { |
---|
| 609 | $match = preg_match('/' . preg_quote('.' . $check_ext) . '$/i', $filename) >= 1; |
---|
| 610 | if ($match === true) { |
---|
| 611 | break 1; |
---|
[20617] | 612 | } |
---|
| 613 | } |
---|
| 614 | } |
---|
[21598] | 615 | |
---|
[21586] | 616 | if ($match === false) { |
---|
| 617 | $str_ext = implode('・', $value[2]); |
---|
| 618 | $this->arrErr[$value[1]][$index] = '※ ' . $value[0] . 'で許可されている形式は、' . $str_ext . 'です。<br />'; |
---|
| 619 | // ▲SC_CheckError::FILE_EXT_CHECK から移植 |
---|
[21608] | 620 | } else { |
---|
[21598] | 621 | $uniqname = date('mdHi') . '_' . uniqid('').'.'; |
---|
| 622 | $temp_file = preg_replace("/^.*\./", $uniqname, $_FILES['down_realfilename']['name'][$index]); |
---|
[20617] | 623 | |
---|
[21598] | 624 | if (move_uploaded_file($_FILES['down_realfilename']['tmp_name'][$index], DOWN_TEMP_REALDIR . $temp_file)) { |
---|
| 625 | $arrDownRealFiles[$index] = $temp_file; |
---|
| 626 | $objFormParam->setValue('down_realfilename', $arrDownRealFiles); |
---|
| 627 | GC_Utils_Ex::gfPrintLog($_FILES['down_realfilename']['name'][$index] .' -> '. realpath(DOWN_TEMP_REALDIR . $temp_file)); |
---|
| 628 | } else { |
---|
| 629 | $objErr->arrErr[$keyname] = '※ ファイルのアップロードに失敗しました。<br />'; |
---|
| 630 | GC_Utils_Ex::gfPrintLog('File Upload Error!: ' . $_FILES['down_realfilename']['name'][$index] . ' -> ' . DOWN_TEMP_REALDIR . $temp_file); |
---|
| 631 | } |
---|
[20617] | 632 | } |
---|
| 633 | } |
---|
| 634 | } |
---|
| 635 | |
---|
| 636 | /** |
---|
| 637 | * アップロードしたファイルを削除する. |
---|
| 638 | * |
---|
| 639 | * TODO 一時ファイルの削除 |
---|
| 640 | * |
---|
[23124] | 641 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
[20617] | 642 | * @return void |
---|
| 643 | */ |
---|
[23124] | 644 | public function doFileDelete(&$objFormParam) |
---|
[22567] | 645 | { |
---|
[20617] | 646 | $objImage = new SC_Image_Ex(DOWN_TEMP_REALDIR); |
---|
| 647 | $arrRealFileName = $objFormParam->getValue('down_realfilename'); |
---|
| 648 | $index = $objFormParam->getValue('upload_index'); |
---|
| 649 | $objImage->deleteImage($arrRealFileName[$index], DOWN_SAVE_REALDIR); |
---|
| 650 | $arrRealFileName[$index] = ''; |
---|
| 651 | $objFormParam->setValue('down_realfilename', $arrRealFileName); |
---|
| 652 | } |
---|
| 653 | |
---|
| 654 | /** |
---|
| 655 | * アップロードした一時ファイルを保存する. |
---|
| 656 | * |
---|
[23124] | 657 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
[20617] | 658 | * @return void |
---|
| 659 | */ |
---|
[23124] | 660 | public function doUploadComplete(&$objFormParam) |
---|
[22567] | 661 | { |
---|
[20617] | 662 | $objImage = new SC_Image_Ex(DOWN_TEMP_REALDIR); |
---|
| 663 | $arrRealFileName = $objFormParam->getValue('down_realfilename'); |
---|
[21905] | 664 | if (is_array($arrRealFileName)) { |
---|
| 665 | foreach ($arrRealFileName as $real_file_name) { |
---|
| 666 | $objImage->moveTempImage($real_file_name, DOWN_SAVE_REALDIR); |
---|
| 667 | } |
---|
[20617] | 668 | } |
---|
| 669 | } |
---|
| 670 | |
---|
| 671 | /** |
---|
[22960] | 672 | * 規格ID1, 規格ID2の規格分類全てを取得する. |
---|
[18815] | 673 | * |
---|
[23124] | 674 | * @param integer $class_id1 規格ID1 |
---|
| 675 | * @param integer $class_id2 規格ID2 |
---|
| 676 | * @return array 規格と規格分類の配列 |
---|
[18815] | 677 | */ |
---|
[23124] | 678 | public function getAllClassCategory($class_id1, $class_id2 = null) |
---|
[22567] | 679 | { |
---|
[20507] | 680 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[18815] | 681 | |
---|
[20612] | 682 | $col = <<< __EOF__ |
---|
| 683 | T1.class_id AS class_id1, |
---|
| 684 | T1.classcategory_id AS classcategory_id1, |
---|
| 685 | T1.name AS classcategory_name1, |
---|
| 686 | T1.rank AS rank1 |
---|
| 687 | __EOF__; |
---|
[20410] | 688 | $table = ''; |
---|
| 689 | $arrParams = array(); |
---|
[21441] | 690 | if (SC_Utils_Ex::isBlank($class_id2)) { |
---|
[21532] | 691 | $col .= ',0 AS classcategory_id2'; |
---|
[21514] | 692 | $table = 'dtb_classcategory T1 '; |
---|
| 693 | $objQuery->setWhere('T1.class_id = ?'); |
---|
| 694 | $objQuery->setOrder('T1.rank DESC'); |
---|
[20410] | 695 | $arrParams = array($class_id1); |
---|
[18815] | 696 | } else { |
---|
[20612] | 697 | $col .= <<< __EOF__ |
---|
| 698 | , |
---|
| 699 | T2.class_id AS class_id2, |
---|
| 700 | T2.classcategory_id AS classcategory_id2, |
---|
| 701 | T2.name AS classcategory_name2, |
---|
| 702 | T2.rank AS rank2 |
---|
| 703 | __EOF__; |
---|
[21514] | 704 | $table = 'dtb_classcategory AS T1, dtb_classcategory AS T2'; |
---|
| 705 | $objQuery->setWhere('T1.class_id = ? AND T2.class_id = ?'); |
---|
| 706 | $objQuery->setOrder('T1.rank DESC, T2.rank DESC'); |
---|
[20410] | 707 | $arrParams = array($class_id1, $class_id2); |
---|
[18815] | 708 | } |
---|
[22856] | 709 | |
---|
[21514] | 710 | return $objQuery->select($col, $table, '', $arrParams); |
---|
[18815] | 711 | } |
---|
| 712 | |
---|
| 713 | /** |
---|
| 714 | * 商品名を取得する. |
---|
| 715 | * |
---|
| 716 | * @access private |
---|
[23124] | 717 | * @param integer $product_id 商品ID |
---|
| 718 | * @return string 商品名の文字列 |
---|
[18815] | 719 | */ |
---|
[23124] | 720 | public function getProductName($product_id) |
---|
[22567] | 721 | { |
---|
[20507] | 722 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[22856] | 723 | |
---|
[20595] | 724 | return $objQuery->get('name', 'dtb_products', 'product_id = ?', array($product_id)); |
---|
[18815] | 725 | } |
---|
| 726 | |
---|
| 727 | /** |
---|
[22960] | 728 | * 規格分類の登録された, 全ての規格を取得する. |
---|
[18815] | 729 | * |
---|
| 730 | * @access private |
---|
[22960] | 731 | * @return array 規格分類の登録された, 全ての規格 |
---|
[18815] | 732 | */ |
---|
[23124] | 733 | public function getAllClass() |
---|
[22567] | 734 | { |
---|
[21481] | 735 | $arrClass = SC_Helper_DB_Ex::sfGetIDValueList('dtb_class', 'class_id', 'name'); |
---|
[18815] | 736 | |
---|
| 737 | // 規格分類が登録されていない規格は表示しないようにする。 |
---|
| 738 | $arrClassCatCount = SC_Utils_Ex::sfGetClassCatCount(); |
---|
| 739 | |
---|
| 740 | $results = array(); |
---|
| 741 | if (!SC_Utils_Ex::isBlank($arrClass)) { |
---|
[21441] | 742 | foreach ($arrClass as $key => $val) { |
---|
| 743 | if ($arrClassCatCount[$key] > 0) { |
---|
[18815] | 744 | $results[$key] = $arrClass[$key]; |
---|
| 745 | } |
---|
| 746 | } |
---|
| 747 | } |
---|
[22856] | 748 | |
---|
[18815] | 749 | return $results; |
---|
| 750 | } |
---|
| 751 | |
---|
| 752 | /** |
---|
[20595] | 753 | * 商品IDをキーにして, 商品規格の初期値を取得する. |
---|
[18815] | 754 | * |
---|
[20595] | 755 | * 商品IDをキーにし, デフォルトに設定されている商品規格を取得する. |
---|
| 756 | * |
---|
[23124] | 757 | * @param integer $product_id 商品ID |
---|
| 758 | * @return array 商品規格の配列 |
---|
[18815] | 759 | */ |
---|
[23124] | 760 | public function getProductsClass($product_id) |
---|
[22567] | 761 | { |
---|
[20507] | 762 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[21514] | 763 | $col = 'product_code, price01, price02, stock, stock_unlimited, sale_limit, deliv_fee, point_rate'; |
---|
[21502] | 764 | $where = 'product_id = ? AND classcategory_id1 = 0 AND classcategory_id2 = 0'; |
---|
[22856] | 765 | |
---|
[21502] | 766 | return $objQuery->getRow($col, 'dtb_products_class', $where, array($product_id)); |
---|
[18815] | 767 | } |
---|
[20873] | 768 | |
---|
| 769 | /** |
---|
| 770 | * チェックボックスの値を埋める. |
---|
| 771 | * |
---|
[22960] | 772 | * チェックボックスが, 全て空で submit されると, $_POST の値が全く渡らない |
---|
[20873] | 773 | * ため, SC_FormParam::getValue() で取得できない. |
---|
| 774 | * これを防ぐため, $_POST[$key] を直接操作し, 指定の長さで空白の配列を作成する |
---|
| 775 | * |
---|
[23124] | 776 | * @param string $key $_POST のキー |
---|
| 777 | * @param integer $size 作成する配列のサイズ |
---|
[20873] | 778 | * @return void |
---|
| 779 | */ |
---|
[23124] | 780 | public function fillCheckboxesValue($key, $size) |
---|
[22567] | 781 | { |
---|
[20873] | 782 | if (empty($_POST[$key])) { |
---|
| 783 | $_POST[$key] = array_pad(array(), $size, ''); |
---|
| 784 | } |
---|
| 785 | } |
---|
[15559] | 786 | } |
---|