| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | * This file is part of EC-CUBE |
|---|
| 4 | * |
|---|
| 5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
|---|
| 6 | * |
|---|
| 7 | * http://www.lockon.co.jp/ |
|---|
| 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. |
|---|
| 22 | */ |
|---|
| 23 | |
|---|
| 24 | /** |
|---|
| 25 | * DB関連のヘルパークラス. |
|---|
| 26 | * |
|---|
| 27 | * @package Helper |
|---|
| 28 | * @author LOCKON CO.,LTD. |
|---|
| 29 | * @version $Id:SC_Helper_DB.php 15532 2007-08-31 14:39:46Z nanasess $ |
|---|
| 30 | */ |
|---|
| 31 | class SC_Helper_DB { |
|---|
| 32 | |
|---|
| 33 | // {{{ properties |
|---|
| 34 | |
|---|
| 35 | /** ルートカテゴリ取得フラグ */ |
|---|
| 36 | var $g_root_on; |
|---|
| 37 | |
|---|
| 38 | /** ルートカテゴリID */ |
|---|
| 39 | var $g_root_id; |
|---|
| 40 | |
|---|
| 41 | /** 選択中カテゴリ取得フラグ */ |
|---|
| 42 | var $g_category_on; |
|---|
| 43 | |
|---|
| 44 | /** 選択中カテゴリID */ |
|---|
| 45 | var $g_category_id; |
|---|
| 46 | |
|---|
| 47 | // }}} |
|---|
| 48 | // {{{ functions |
|---|
| 49 | |
|---|
| 50 | /** |
|---|
| 51 | * データベースのバージョンを所得する. |
|---|
| 52 | * |
|---|
| 53 | * @param string $dsn データソース名 |
|---|
| 54 | * @return string データベースのバージョン |
|---|
| 55 | */ |
|---|
| 56 | function sfGetDBVersion($dsn = "") { |
|---|
| 57 | $dbFactory = SC_DB_DBFactory_Ex::getInstance(); |
|---|
| 58 | return $dbFactory->sfGetDBVersion($dsn); |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | /** |
|---|
| 62 | * テーブルの存在をチェックする. |
|---|
| 63 | * |
|---|
| 64 | * @param string $table_name チェック対象のテーブル名 |
|---|
| 65 | * @param string $dsn データソース名 |
|---|
| 66 | * @return テーブルが存在する場合 true |
|---|
| 67 | */ |
|---|
| 68 | function sfTabaleExists($table_name, $dsn = "") { |
|---|
| 69 | $dbFactory = SC_DB_DBFactory_Ex::getInstance(); |
|---|
| 70 | $dsn = $dbFactory->getDSN($dsn); |
|---|
| 71 | |
|---|
| 72 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 73 | // 正常に接続されている場合 |
|---|
| 74 | if(!$objQuery->isError()) { |
|---|
| 75 | list($db_type) = split(":", $dsn); |
|---|
| 76 | /* |
|---|
| 77 | * XXX MySQL で, 何故かブレースホルダが使えない. |
|---|
| 78 | */ |
|---|
| 79 | $sql = $dbFactory->getTableExistsSql($table_name); |
|---|
| 80 | $arrRet = $objQuery->getAll($sql); |
|---|
| 81 | if(count($arrRet) > 0) { |
|---|
| 82 | return true; |
|---|
| 83 | } |
|---|
| 84 | } |
|---|
| 85 | return false; |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | /** |
|---|
| 89 | * カラムの存在チェックと作成を行う. |
|---|
| 90 | * |
|---|
| 91 | * チェック対象のテーブルに, 該当のカラムが存在するかチェックする. |
|---|
| 92 | * 引数 $add が true の場合, 該当のカラムが存在しない場合は, カラムの生成を行う. |
|---|
| 93 | * カラムの生成も行う場合は, $col_type も必須となる. |
|---|
| 94 | * |
|---|
| 95 | * @param string $table_name テーブル名 |
|---|
| 96 | * @param string $column_name カラム名 |
|---|
| 97 | * @param string $col_type カラムのデータ型 |
|---|
| 98 | * @param string $dsn データソース名 |
|---|
| 99 | * @param bool $add カラムの作成も行う場合 true |
|---|
| 100 | * @return bool カラムが存在する場合とカラムの生成に成功した場合 true, |
|---|
| 101 | * テーブルが存在しない場合 false, |
|---|
| 102 | * 引数 $add == false でカラムが存在しない場合 false |
|---|
| 103 | */ |
|---|
| 104 | function sfColumnExists($table_name, $col_name, $col_type = "", $dsn = "", $add = false) { |
|---|
| 105 | $dbFactory = SC_DB_DBFactory_Ex::getInstance(); |
|---|
| 106 | $dsn = $dbFactory->getDSN($dsn); |
|---|
| 107 | |
|---|
| 108 | // テーブルが無ければエラー |
|---|
| 109 | if(!$this->sfTabaleExists($table_name, $dsn)) return false; |
|---|
| 110 | |
|---|
| 111 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 112 | // 正常に接続されている場合 |
|---|
| 113 | if(!$objQuery->isError()) { |
|---|
| 114 | list($db_type) = split(":", $dsn); |
|---|
| 115 | |
|---|
| 116 | // カラムリストを取得 |
|---|
| 117 | $arrRet = $dbFactory->sfGetColumnList($table_name); |
|---|
| 118 | if(count($arrRet) > 0) { |
|---|
| 119 | if(in_array($col_name, $arrRet)){ |
|---|
| 120 | return true; |
|---|
| 121 | } |
|---|
| 122 | } |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | // カラムを追加する |
|---|
| 126 | if($add){ |
|---|
| 127 | $objQuery->query("ALTER TABLE $table_name ADD $col_name $col_type "); |
|---|
| 128 | return true; |
|---|
| 129 | } |
|---|
| 130 | return false; |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | /** |
|---|
| 134 | * インデックスの存在チェックと作成を行う. |
|---|
| 135 | * |
|---|
| 136 | * チェック対象のテーブルに, 該当のインデックスが存在するかチェックする. |
|---|
| 137 | * 引数 $add が true の場合, 該当のインデックスが存在しない場合は, インデックスの生成を行う. |
|---|
| 138 | * インデックスの生成も行う場合で, DB_TYPE が mysql の場合は, $length も必須となる. |
|---|
| 139 | * |
|---|
| 140 | * @param string $table_name テーブル名 |
|---|
| 141 | * @param string $column_name カラム名 |
|---|
| 142 | * @param string $index_name インデックス名 |
|---|
| 143 | * @param integer|string $length インデックスを作成するデータ長 |
|---|
| 144 | * @param string $dsn データソース名 |
|---|
| 145 | * @param bool $add インデックスの生成もする場合 true |
|---|
| 146 | * @return bool インデックスが存在する場合とインデックスの生成に成功した場合 true, |
|---|
| 147 | * テーブルが存在しない場合 false, |
|---|
| 148 | * 引数 $add == false でインデックスが存在しない場合 false |
|---|
| 149 | */ |
|---|
| 150 | function sfIndexExists($table_name, $col_name, $index_name, $length = "", $dsn = "", $add = false) { |
|---|
| 151 | $dbFactory = SC_DB_DBFactory_Ex::getInstance(); |
|---|
| 152 | $dsn = $dbFactory->getDSN($dsn); |
|---|
| 153 | |
|---|
| 154 | // テーブルが無ければエラー |
|---|
| 155 | if (!$this->sfTabaleExists($table_name, $dsn)) return false; |
|---|
| 156 | |
|---|
| 157 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 158 | $arrRet = $dbFactory->getTableIndex($index_name, $table_name); |
|---|
| 159 | |
|---|
| 160 | // すでにインデックスが存在する場合 |
|---|
| 161 | if(count($arrRet) > 0) { |
|---|
| 162 | return true; |
|---|
| 163 | } |
|---|
| 164 | |
|---|
| 165 | // インデックスを作成する |
|---|
| 166 | if($add){ |
|---|
| 167 | $dbFactory->createTableIndex($index_name, $table_name, $col_name, $length()); |
|---|
| 168 | return true; |
|---|
| 169 | } |
|---|
| 170 | return false; |
|---|
| 171 | } |
|---|
| 172 | |
|---|
| 173 | /** |
|---|
| 174 | * データの存在チェックを行う. |
|---|
| 175 | * |
|---|
| 176 | * @param string $table_name テーブル名 |
|---|
| 177 | * @param string $where データを検索する WHERE 句 |
|---|
| 178 | * @param string $dsn データソース名 |
|---|
| 179 | * @param string $sql データの追加を行う場合の SQL文 |
|---|
| 180 | * @param bool $add データの追加も行う場合 true |
|---|
| 181 | * @return bool データが存在する場合 true, データの追加に成功した場合 true, |
|---|
| 182 | * $add == false で, データが存在しない場合 false |
|---|
| 183 | */ |
|---|
| 184 | function sfDataExists($table_name, $where, $arrval, $dsn = "", $sql = "", $add = false) { |
|---|
| 185 | $dbFactory = SC_DB_DBFactory_Ex::getInstance(); |
|---|
| 186 | $dsn = $dbFactory->getDSN($dsn); |
|---|
| 187 | |
|---|
| 188 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 189 | $count = $objQuery->count($table_name, $where, $arrval); |
|---|
| 190 | |
|---|
| 191 | if($count > 0) { |
|---|
| 192 | $ret = true; |
|---|
| 193 | } else { |
|---|
| 194 | $ret = false; |
|---|
| 195 | } |
|---|
| 196 | // データを追加する |
|---|
| 197 | if(!$ret && $add) { |
|---|
| 198 | $objQuery->exec($sql); |
|---|
| 199 | } |
|---|
| 200 | return $ret; |
|---|
| 201 | } |
|---|
| 202 | |
|---|
| 203 | /** |
|---|
| 204 | * 店舗基本情報を取得する. |
|---|
| 205 | * |
|---|
| 206 | * @param boolean $force 強制的にDB取得するか |
|---|
| 207 | * @return array 店舗基本情報の配列 |
|---|
| 208 | */ |
|---|
| 209 | function sf_getBasisData($force = false) { |
|---|
| 210 | static $data; |
|---|
| 211 | |
|---|
| 212 | if ($force || !isset($data)) { |
|---|
| 213 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 214 | $arrRet = $objQuery->select('*', 'dtb_baseinfo'); |
|---|
| 215 | |
|---|
| 216 | if (isset($arrRet[0])) { |
|---|
| 217 | $data = $arrRet[0]; |
|---|
| 218 | } else { |
|---|
| 219 | $data = array(); |
|---|
| 220 | } |
|---|
| 221 | } |
|---|
| 222 | |
|---|
| 223 | return $data; |
|---|
| 224 | } |
|---|
| 225 | |
|---|
| 226 | /* 選択中のアイテムのルートカテゴリIDを取得する */ |
|---|
| 227 | function sfGetRootId() { |
|---|
| 228 | |
|---|
| 229 | if(!$this->g_root_on) { |
|---|
| 230 | $this->g_root_on = true; |
|---|
| 231 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 232 | |
|---|
| 233 | if (!isset($_GET['product_id'])) $_GET['product_id'] = ""; |
|---|
| 234 | if (!isset($_GET['category_id'])) $_GET['category_id'] = ""; |
|---|
| 235 | |
|---|
| 236 | if(!empty($_GET['product_id']) || !empty($_GET['category_id'])) { |
|---|
| 237 | // 選択中のカテゴリIDを判定する |
|---|
| 238 | $category_id = $this->sfGetCategoryId($_GET['product_id'], $_GET['category_id']); |
|---|
| 239 | // ROOTカテゴリIDの取得 |
|---|
| 240 | $arrRet = $this->sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $category_id); |
|---|
| 241 | $root_id = isset($arrRet[0]) ? $arrRet[0] : ""; |
|---|
| 242 | } else { |
|---|
| 243 | // ROOTカテゴリIDをなしに設定する |
|---|
| 244 | $root_id = ""; |
|---|
| 245 | } |
|---|
| 246 | $this->g_root_id = $root_id; |
|---|
| 247 | } |
|---|
| 248 | return $this->g_root_id; |
|---|
| 249 | } |
|---|
| 250 | |
|---|
| 251 | /** |
|---|
| 252 | * 商品規格情報を取得する. |
|---|
| 253 | * |
|---|
| 254 | * @param array $arrID 規格ID |
|---|
| 255 | * @param boolean $includePrivateProducts 非公開商品を含むか |
|---|
| 256 | * @return array 規格情報の配列 |
|---|
| 257 | */ |
|---|
| 258 | function sfGetProductsClass($arrID, $includePrivateProducts = false) { |
|---|
| 259 | list($product_id, $classcategory_id1, $classcategory_id2) = $arrID; |
|---|
| 260 | |
|---|
| 261 | if (strlen($classcategory_id1) == 0) { |
|---|
| 262 | $classcategory_id1 = '0'; |
|---|
| 263 | } |
|---|
| 264 | if (strlen($classcategory_id2) == 0) { |
|---|
| 265 | $classcategory_id2 = '0'; |
|---|
| 266 | } |
|---|
| 267 | |
|---|
| 268 | // 商品規格取得 |
|---|
| 269 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 270 | $col = 'product_id, deliv_fee, name, product_code, main_list_image, main_image, price01, price02, point_rate, product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited, sale_limit'; |
|---|
| 271 | $table = 'vw_product_class AS prdcls'; |
|---|
| 272 | $where = 'product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?'; |
|---|
| 273 | if (!$includePrivateProducts) { |
|---|
| 274 | $where .= ' AND status = 1'; |
|---|
| 275 | } |
|---|
| 276 | $arrRet = $objQuery->select($col, $table, $where, array($product_id, $classcategory_id1, $classcategory_id2)); |
|---|
| 277 | return $arrRet[0]; |
|---|
| 278 | } |
|---|
| 279 | |
|---|
| 280 | /** |
|---|
| 281 | * 支払い方法を取得する. |
|---|
| 282 | * |
|---|
| 283 | * @return void |
|---|
| 284 | */ |
|---|
| 285 | function sfGetPayment() { |
|---|
| 286 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 287 | // 購入金額が条件額以下の項目を取得 |
|---|
| 288 | $where = "del_flg = 0"; |
|---|
| 289 | $objQuery->setOrder("fix, rank DESC"); |
|---|
| 290 | $arrRet = $objQuery->select("payment_id, payment_method, rule", "dtb_payment", $where); |
|---|
| 291 | return $arrRet; |
|---|
| 292 | } |
|---|
| 293 | |
|---|
| 294 | /** |
|---|
| 295 | * カート内商品の集計処理を行う. |
|---|
| 296 | * |
|---|
| 297 | * 管理機能での利用は想定していないので注意。(非公開商品は除外される。) |
|---|
| 298 | * |
|---|
| 299 | * @param LC_Page $objPage ページクラスのインスタンス |
|---|
| 300 | * @param SC_CartSession $objCartSess カートセッションのインスタンス |
|---|
| 301 | * @param null $dummy1 互換性確保用(決済モジュール互換のため) |
|---|
| 302 | * @return LC_Page 集計処理後のページクラスインスタンス |
|---|
| 303 | */ |
|---|
| 304 | function sfTotalCart(&$objPage, $objCartSess, $dummy1 = null) { |
|---|
| 305 | |
|---|
| 306 | // 規格名一覧 |
|---|
| 307 | $arrClassName = $this->sfGetIDValueList("dtb_class", "class_id", "name"); |
|---|
| 308 | // 規格分類名一覧 |
|---|
| 309 | $arrClassCatName = $this->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); |
|---|
| 310 | |
|---|
| 311 | $objPage->tpl_total_pretax = 0; // 費用合計(税込み) |
|---|
| 312 | $objPage->tpl_total_tax = 0; // 消費税合計 |
|---|
| 313 | $objPage->tpl_total_point = 0; // ポイント合計 |
|---|
| 314 | |
|---|
| 315 | // カート内情報の取得 |
|---|
| 316 | $arrQuantityInfo_by_product = array(); |
|---|
| 317 | $cnt = 0; |
|---|
| 318 | foreach ($objCartSess->getCartList() as $arrCart) { |
|---|
| 319 | // 商品規格情報の取得 |
|---|
| 320 | $arrData = $this->sfGetProductsClass($arrCart['id']); |
|---|
| 321 | $limit = null; |
|---|
| 322 | // DBに存在する商品 |
|---|
| 323 | if (count($arrData) > 0) { |
|---|
| 324 | |
|---|
| 325 | // 購入制限数を求める。 |
|---|
| 326 | if ($arrData['stock_unlimited'] != '1' && SC_Utils_Ex::sfIsInt($arrData['sale_limit'])) { |
|---|
| 327 | $limit = min($arrData['sale_limit'], $arrData['stock']); |
|---|
| 328 | } elseif (SC_Utils_Ex::sfIsInt($arrData['sale_limit'])) { |
|---|
| 329 | $limit = $arrData['sale_limit']; |
|---|
| 330 | } elseif ($arrData['stock_unlimited'] != '1') { |
|---|
| 331 | $limit = $arrData['stock']; |
|---|
| 332 | } |
|---|
| 333 | |
|---|
| 334 | if (!is_null($limit) && $arrCart['quantity'] > $limit) { |
|---|
| 335 | if ($limit > 0) { |
|---|
| 336 | // カート内商品数を制限に合わせる |
|---|
| 337 | $objCartSess->setProductValue($arrCart['id'], 'quantity', $limit); |
|---|
| 338 | $quantity = $limit; |
|---|
| 339 | $objPage->tpl_message .= "※「" . $arrData['name'] . "」は販売制限(または在庫が不足)しております。一度に数量{$limit}以上の購入はできません。\n"; |
|---|
| 340 | } else { |
|---|
| 341 | // 売り切れ商品をカートから削除する |
|---|
| 342 | $objCartSess->delProduct($arrCart['cart_no']); |
|---|
| 343 | $objPage->tpl_message .= "※「" . $arrData['name'] . "」は売り切れました。\n"; |
|---|
| 344 | continue; |
|---|
| 345 | } |
|---|
| 346 | } else { |
|---|
| 347 | $quantity = $arrCart['quantity']; |
|---|
| 348 | } |
|---|
| 349 | |
|---|
| 350 | // (商品規格単位でなく)商品単位での評価のための準備 |
|---|
| 351 | $product_id = $arrCart['id'][0]; |
|---|
| 352 | $arrQuantityInfo_by_product[$product_id]['quantity'] += $quantity; |
|---|
| 353 | $arrQuantityInfo_by_product[$product_id]['sale_limit'] = $arrData['sale_limit']; |
|---|
| 354 | $arrQuantityInfo_by_product[$product_id]['name'] = $arrData['name']; |
|---|
| 355 | |
|---|
| 356 | $objPage->arrProductsClass[$cnt] = $arrData; |
|---|
| 357 | $objPage->arrProductsClass[$cnt]['quantity'] = $quantity; |
|---|
| 358 | $objPage->arrProductsClass[$cnt]['cart_no'] = $arrCart['cart_no']; |
|---|
| 359 | $objPage->arrProductsClass[$cnt]['class_name1'] = |
|---|
| 360 | isset($arrClassName[$arrData['class_id1']]) |
|---|
| 361 | ? $arrClassName[$arrData['class_id1']] : ""; |
|---|
| 362 | |
|---|
| 363 | $objPage->arrProductsClass[$cnt]['class_name2'] = |
|---|
| 364 | isset($arrClassName[$arrData['class_id2']]) |
|---|
| 365 | ? $arrClassName[$arrData['class_id2']] : ""; |
|---|
| 366 | |
|---|
| 367 | $objPage->arrProductsClass[$cnt]['classcategory_name1'] = |
|---|
| 368 | $arrClassCatName[$arrData['classcategory_id1']]; |
|---|
| 369 | |
|---|
| 370 | $objPage->arrProductsClass[$cnt]['classcategory_name2'] = |
|---|
| 371 | $arrClassCatName[$arrData['classcategory_id2']]; |
|---|
| 372 | |
|---|
| 373 | // 価格の登録 |
|---|
| 374 | if ($arrData['price02'] != "") { |
|---|
| 375 | $objCartSess->setProductValue($arrCart['id'], 'price', $arrData['price02']); |
|---|
| 376 | $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price02']; |
|---|
| 377 | } else { |
|---|
| 378 | $objCartSess->setProductValue($arrCart['id'], 'price', $arrData['price01']); |
|---|
| 379 | $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price01']; |
|---|
| 380 | } |
|---|
| 381 | // ポイント付与率の登録 |
|---|
| 382 | if (USE_POINT !== false) { |
|---|
| 383 | $objCartSess->setProductValue($arrCart['id'], 'point_rate', $arrData['point_rate']); |
|---|
| 384 | } |
|---|
| 385 | // 商品ごとの合計金額 |
|---|
| 386 | $objPage->arrProductsClass[$cnt]['total_pretax'] = $objCartSess->getProductTotal($arrCart['id']); |
|---|
| 387 | // 送料の合計を計算する |
|---|
| 388 | $objPage->tpl_total_deliv_fee+= ($arrData['deliv_fee'] * $arrCart['quantity']); |
|---|
| 389 | $cnt++; |
|---|
| 390 | } else { // DBに商品が見つからない場合、 |
|---|
| 391 | $objPage->tpl_message .= "※ 現時点で販売していない商品が含まれておりました。該当商品をカートから削除しました。\n"; |
|---|
| 392 | // カート商品の削除 |
|---|
| 393 | $objCartSess->delProduct($arrCart['cart_no']); |
|---|
| 394 | } |
|---|
| 395 | } |
|---|
| 396 | |
|---|
| 397 | foreach ($arrQuantityInfo_by_product as $product_id => $quantityInfo) { |
|---|
| 398 | if (SC_Utils_Ex::sfIsInt($quantityInfo['sale_limit']) && $quantityInfo['quantity'] > $quantityInfo['sale_limit']) { |
|---|
| 399 | $objPage->tpl_error = "※「{$quantityInfo['name']}」は数量「{$quantityInfo['sale_limit']}」以下に販売制限しております。一度にこれ以上の購入はできません。\n"; |
|---|
| 400 | // 販売制限に引っかかった商品をマークする |
|---|
| 401 | foreach (array_keys($objPage->arrProductsClass) as $key) { |
|---|
| 402 | $ProductsClass =& $objPage->arrProductsClass[$key]; |
|---|
| 403 | if ($ProductsClass['product_id'] == $product_id) { |
|---|
| 404 | $ProductsClass['error'] = true; |
|---|
| 405 | } |
|---|
| 406 | } |
|---|
| 407 | } |
|---|
| 408 | } |
|---|
| 409 | |
|---|
| 410 | // 全商品合計金額(税込み) |
|---|
| 411 | $objPage->tpl_total_pretax = $objCartSess->getAllProductsTotal(); |
|---|
| 412 | // 全商品合計消費税 |
|---|
| 413 | $objPage->tpl_total_tax = $objCartSess->getAllProductsTax(); |
|---|
| 414 | // 全商品合計ポイント |
|---|
| 415 | if (USE_POINT !== false) { |
|---|
| 416 | $objPage->tpl_total_point = $objCartSess->getAllProductsPoint(); |
|---|
| 417 | } |
|---|
| 418 | |
|---|
| 419 | return $objPage; |
|---|
| 420 | } |
|---|
| 421 | |
|---|
| 422 | /** |
|---|
| 423 | * 受注一時テーブルへの書き込み処理を行う. |
|---|
| 424 | * |
|---|
| 425 | * @param string $uniqid ユニークID |
|---|
| 426 | * @param array $sqlval SQLの値の配列 |
|---|
| 427 | * @return void |
|---|
| 428 | */ |
|---|
| 429 | function sfRegistTempOrder($uniqid, $sqlval) { |
|---|
| 430 | if($uniqid != "") { |
|---|
| 431 | // 既存データのチェック |
|---|
| 432 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 433 | $where = "order_temp_id = ?"; |
|---|
| 434 | $cnt = $objQuery->count("dtb_order_temp", $where, array($uniqid)); |
|---|
| 435 | // 既存データがない場合 |
|---|
| 436 | if ($cnt == 0) { |
|---|
| 437 | // 初回書き込み時に会員の登録済み情報を取り込む |
|---|
| 438 | $sqlval = $this->sfGetCustomerSqlVal($uniqid, $sqlval); |
|---|
| 439 | $sqlval['create_date'] = "now()"; |
|---|
| 440 | $objQuery->insert("dtb_order_temp", $sqlval); |
|---|
| 441 | } else { |
|---|
| 442 | $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid)); |
|---|
| 443 | } |
|---|
| 444 | |
|---|
| 445 | // 受注_Tempテーブルの名称列を更新 |
|---|
| 446 | // ・決済モジュールに対応するため、static メソッドとして扱う |
|---|
| 447 | SC_Helper_DB_Ex::sfUpdateOrderNameCol($uniqid, true); |
|---|
| 448 | } |
|---|
| 449 | } |
|---|
| 450 | |
|---|
| 451 | /** |
|---|
| 452 | * 会員情報から SQL文の値を生成する. |
|---|
| 453 | * |
|---|
| 454 | * @param string $uniqid ユニークID |
|---|
| 455 | * @param array $sqlval SQL の値の配列 |
|---|
| 456 | * @return array 会員情報を含んだ SQL の値の配列 |
|---|
| 457 | */ |
|---|
| 458 | function sfGetCustomerSqlVal($uniqid, $sqlval) { |
|---|
| 459 | $objCustomer = new SC_Customer(); |
|---|
| 460 | // 会員情報登録処理 |
|---|
| 461 | if ($objCustomer->isLoginSuccess(true)) { |
|---|
| 462 | // 登録データの作成 |
|---|
| 463 | $sqlval['order_temp_id'] = $uniqid; |
|---|
| 464 | $sqlval['update_date'] = 'Now()'; |
|---|
| 465 | $sqlval['customer_id'] = $objCustomer->getValue('customer_id'); |
|---|
| 466 | $sqlval['order_name01'] = $objCustomer->getValue('name01'); |
|---|
| 467 | $sqlval['order_name02'] = $objCustomer->getValue('name02'); |
|---|
| 468 | $sqlval['order_kana01'] = $objCustomer->getValue('kana01'); |
|---|
| 469 | $sqlval['order_kana02'] = $objCustomer->getValue('kana02'); |
|---|
| 470 | $sqlval['order_sex'] = $objCustomer->getValue('sex'); |
|---|
| 471 | $sqlval['order_zip01'] = $objCustomer->getValue('zip01'); |
|---|
| 472 | $sqlval['order_zip02'] = $objCustomer->getValue('zip02'); |
|---|
| 473 | $sqlval['order_pref'] = $objCustomer->getValue('pref'); |
|---|
| 474 | $sqlval['order_addr01'] = $objCustomer->getValue('addr01'); |
|---|
| 475 | $sqlval['order_addr02'] = $objCustomer->getValue('addr02'); |
|---|
| 476 | $sqlval['order_tel01'] = $objCustomer->getValue('tel01'); |
|---|
| 477 | $sqlval['order_tel02'] = $objCustomer->getValue('tel02'); |
|---|
| 478 | $sqlval['order_tel03'] = $objCustomer->getValue('tel03'); |
|---|
| 479 | if (defined('MOBILE_SITE')) { |
|---|
| 480 | $email_mobile = $objCustomer->getValue('email_mobile'); |
|---|
| 481 | if (empty($email_mobile)) { |
|---|
| 482 | $sqlval['order_email'] = $objCustomer->getValue('email'); |
|---|
| 483 | } else { |
|---|
| 484 | $sqlval['order_email'] = $email_mobile; |
|---|
| 485 | } |
|---|
| 486 | } else { |
|---|
| 487 | $sqlval['order_email'] = $objCustomer->getValue('email'); |
|---|
| 488 | } |
|---|
| 489 | $sqlval['order_job'] = $objCustomer->getValue('job'); |
|---|
| 490 | $sqlval['order_birth'] = $objCustomer->getValue('birth'); |
|---|
| 491 | } |
|---|
| 492 | return $sqlval; |
|---|
| 493 | } |
|---|
| 494 | |
|---|
| 495 | /** |
|---|
| 496 | * 会員編集登録処理を行う. |
|---|
| 497 | * |
|---|
| 498 | * @param array $array パラメータの配列 |
|---|
| 499 | * @param array $arrRegistColumn 登録するカラムの配列 |
|---|
| 500 | * @return void |
|---|
| 501 | */ |
|---|
| 502 | function sfEditCustomerData($array, $arrRegistColumn) { |
|---|
| 503 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 504 | |
|---|
| 505 | foreach ($arrRegistColumn as $data) { |
|---|
| 506 | if ($data["column"] != "password") { |
|---|
| 507 | if($array[ $data['column'] ] != "") { |
|---|
| 508 | $arrRegist[ $data["column"] ] = $array[ $data["column"] ]; |
|---|
| 509 | } else { |
|---|
| 510 | $arrRegist[ $data['column'] ] = NULL; |
|---|
| 511 | } |
|---|
| 512 | } |
|---|
| 513 | } |
|---|
| 514 | if (strlen($array["year"]) > 0 && strlen($array["month"]) > 0 && strlen($array["day"]) > 0) { |
|---|
| 515 | $arrRegist["birth"] = $array["year"] ."/". $array["month"] ."/". $array["day"] ." 00:00:00"; |
|---|
| 516 | } else { |
|---|
| 517 | $arrRegist["birth"] = NULL; |
|---|
| 518 | } |
|---|
| 519 | |
|---|
| 520 | //-- パスワードの更新がある場合は暗号化。(更新がない場合はUPDATE文を構成しない) |
|---|
| 521 | if ($array["password"] != DEFAULT_PASSWORD) $arrRegist["password"] = sha1($array["password"] . ":" . AUTH_MAGIC); |
|---|
| 522 | $arrRegist["update_date"] = "NOW()"; |
|---|
| 523 | |
|---|
| 524 | //-- 編集登録実行 |
|---|
| 525 | $objQuery->update("dtb_customer", $arrRegist, "customer_id = ? ", array($array['customer_id'])); |
|---|
| 526 | } |
|---|
| 527 | |
|---|
| 528 | /** |
|---|
| 529 | * 注文番号、利用ポイント、加算ポイントから最終ポイントを取得する. |
|---|
| 530 | * |
|---|
| 531 | * @param integer $order_id 注文番号 |
|---|
| 532 | * @param integer $use_point 利用ポイント |
|---|
| 533 | * @param integer $add_point 加算ポイント |
|---|
| 534 | * @return array 最終ポイントの配列 |
|---|
| 535 | */ |
|---|
| 536 | function sfGetCustomerPoint($order_id, $use_point, $add_point) { |
|---|
| 537 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 538 | $arrRet = $objQuery->select("customer_id", "dtb_order", "order_id = ?", array($order_id)); |
|---|
| 539 | $customer_id = $arrRet[0]['customer_id']; |
|---|
| 540 | if ($customer_id != "" && $customer_id >= 1) { |
|---|
| 541 | if (USE_POINT !== false) { |
|---|
| 542 | $arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id)); |
|---|
| 543 | $point = $arrRet[0]['point']; |
|---|
| 544 | $total_point = $arrRet[0]['point'] - $use_point + $add_point; |
|---|
| 545 | } else { |
|---|
| 546 | $total_point = 0; |
|---|
| 547 | $point = 0; |
|---|
| 548 | } |
|---|
| 549 | } else { |
|---|
| 550 | $total_point = ""; |
|---|
| 551 | $point = ""; |
|---|
| 552 | } |
|---|
| 553 | return array($point, $total_point); |
|---|
| 554 | } |
|---|
| 555 | |
|---|
| 556 | /** |
|---|
| 557 | * 顧客番号、利用ポイント、加算ポイントから最終ポイントを取得する. |
|---|
| 558 | * |
|---|
| 559 | * @param integer $customer_id 顧客番号 |
|---|
| 560 | * @param integer $use_point 利用ポイント |
|---|
| 561 | * @param integer $add_point 加算ポイント |
|---|
| 562 | * @return array 最終ポイントの配列 |
|---|
| 563 | */ |
|---|
| 564 | function sfGetCustomerPointFromCid($customer_id, $use_point, $add_point) { |
|---|
| 565 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 566 | if (USE_POINT !== false) { |
|---|
| 567 | $arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id)); |
|---|
| 568 | $point = $arrRet[0]['point']; |
|---|
| 569 | $total_point = $arrRet[0]['point'] - $use_point + $add_point; |
|---|
| 570 | } else { |
|---|
| 571 | $total_point = 0; |
|---|
| 572 | $point = 0; |
|---|
| 573 | } |
|---|
| 574 | return array($point, $total_point); |
|---|
| 575 | } |
|---|
| 576 | /** |
|---|
| 577 | * カテゴリツリーの取得を行う. |
|---|
| 578 | * |
|---|
| 579 | * @param integer $parent_category_id 親カテゴリID |
|---|
| 580 | * @param bool $count_check 登録商品数のチェックを行う場合 true |
|---|
| 581 | * @return array カテゴリツリーの配列 |
|---|
| 582 | */ |
|---|
| 583 | function sfGetCatTree($parent_category_id, $count_check = false) { |
|---|
| 584 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 585 | $col = ""; |
|---|
| 586 | $col .= " cat.category_id,"; |
|---|
| 587 | $col .= " cat.category_name,"; |
|---|
| 588 | $col .= " cat.parent_category_id,"; |
|---|
| 589 | $col .= " cat.level,"; |
|---|
| 590 | $col .= " cat.rank,"; |
|---|
| 591 | $col .= " cat.creator_id,"; |
|---|
| 592 | $col .= " cat.create_date,"; |
|---|
| 593 | $col .= " cat.update_date,"; |
|---|
| 594 | $col .= " cat.del_flg, "; |
|---|
| 595 | $col .= " ttl.product_count"; |
|---|
| 596 | $from = "dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id"; |
|---|
| 597 | // 登録商品数のチェック |
|---|
| 598 | if($count_check) { |
|---|
| 599 | $where = "del_flg = 0 AND product_count > 0"; |
|---|
| 600 | } else { |
|---|
| 601 | $where = "del_flg = 0"; |
|---|
| 602 | } |
|---|
| 603 | $objQuery->setOption("ORDER BY rank DESC"); |
|---|
| 604 | $arrRet = $objQuery->select($col, $from, $where); |
|---|
| 605 | |
|---|
| 606 | $arrParentID = $this->sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $parent_category_id); |
|---|
| 607 | |
|---|
| 608 | foreach($arrRet as $key => $array) { |
|---|
| 609 | foreach($arrParentID as $val) { |
|---|
| 610 | if($array['category_id'] == $val) { |
|---|
| 611 | $arrRet[$key]['display'] = 1; |
|---|
| 612 | break; |
|---|
| 613 | } |
|---|
| 614 | } |
|---|
| 615 | } |
|---|
| 616 | |
|---|
| 617 | return $arrRet; |
|---|
| 618 | } |
|---|
| 619 | |
|---|
| 620 | /** |
|---|
| 621 | * カテゴリツリーの取得を複数カテゴリーで行う. |
|---|
| 622 | * |
|---|
| 623 | * @param integer $product_id 商品ID |
|---|
| 624 | * @param bool $count_check 登録商品数のチェックを行う場合 true |
|---|
| 625 | * @return array カテゴリツリーの配列 |
|---|
| 626 | */ |
|---|
| 627 | function sfGetMultiCatTree($product_id, $count_check = false) { |
|---|
| 628 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 629 | $col = ""; |
|---|
| 630 | $col .= " cat.category_id,"; |
|---|
| 631 | $col .= " cat.category_name,"; |
|---|
| 632 | $col .= " cat.parent_category_id,"; |
|---|
| 633 | $col .= " cat.level,"; |
|---|
| 634 | $col .= " cat.rank,"; |
|---|
| 635 | $col .= " cat.creator_id,"; |
|---|
| 636 | $col .= " cat.create_date,"; |
|---|
| 637 | $col .= " cat.update_date,"; |
|---|
| 638 | $col .= " cat.del_flg, "; |
|---|
| 639 | $col .= " ttl.product_count"; |
|---|
| 640 | $from = "dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id"; |
|---|
| 641 | // 登録商品数のチェック |
|---|
| 642 | if($count_check) { |
|---|
| 643 | $where = "del_flg = 0 AND product_count > 0"; |
|---|
| 644 | } else { |
|---|
| 645 | $where = "del_flg = 0"; |
|---|
| 646 | } |
|---|
| 647 | $objQuery->setOption("ORDER BY rank DESC"); |
|---|
| 648 | $arrRet = $objQuery->select($col, $from, $where); |
|---|
| 649 | |
|---|
| 650 | $arrCategory_id = $this->sfGetCategoryId($product_id); |
|---|
| 651 | |
|---|
| 652 | $arrCatTree = array(); |
|---|
| 653 | foreach ($arrCategory_id as $pkey => $parent_category_id) { |
|---|
| 654 | $arrParentID = $this->sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $parent_category_id); |
|---|
| 655 | |
|---|
| 656 | foreach($arrParentID as $pid) { |
|---|
| 657 | foreach($arrRet as $key => $array) { |
|---|
| 658 | if($array['category_id'] == $pid) { |
|---|
| 659 | $arrCatTree[$pkey][] = $arrRet[$key]; |
|---|
| 660 | break; |
|---|
| 661 | } |
|---|
| 662 | } |
|---|
| 663 | } |
|---|
| 664 | } |
|---|
| 665 | |
|---|
| 666 | return $arrCatTree; |
|---|
| 667 | } |
|---|
| 668 | |
|---|
| 669 | /** |
|---|
| 670 | * 親カテゴリーを連結した文字列を取得する. |
|---|
| 671 | * |
|---|
| 672 | * @param integer $category_id カテゴリID |
|---|
| 673 | * @return string 親カテゴリーを連結した文字列 |
|---|
| 674 | */ |
|---|
| 675 | function sfGetCatCombName($category_id){ |
|---|
| 676 | // 商品が属するカテゴリIDを縦に取得 |
|---|
| 677 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 678 | $arrCatID = $this->sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id); |
|---|
| 679 | $ConbName = ""; |
|---|
| 680 | |
|---|
| 681 | // カテゴリー名称を取得する |
|---|
| 682 | foreach($arrCatID as $key => $val){ |
|---|
| 683 | $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; |
|---|
| 684 | $arrVal = array($val); |
|---|
| 685 | $CatName = $objQuery->getOne($sql,$arrVal); |
|---|
| 686 | $ConbName .= $CatName . ' | '; |
|---|
| 687 | } |
|---|
| 688 | // 最後の | をカットする |
|---|
| 689 | $ConbName = substr_replace($ConbName, "", strlen($ConbName) - 2, 2); |
|---|
| 690 | |
|---|
| 691 | return $ConbName; |
|---|
| 692 | } |
|---|
| 693 | |
|---|
| 694 | /** |
|---|
| 695 | * 指定したカテゴリーIDのカテゴリーを取得する. |
|---|
| 696 | * |
|---|
| 697 | * @param integer $category_id カテゴリID |
|---|
| 698 | * @return array 指定したカテゴリーIDのカテゴリー |
|---|
| 699 | */ |
|---|
| 700 | function sfGetCat($category_id){ |
|---|
| 701 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 702 | |
|---|
| 703 | // カテゴリーを取得する |
|---|
| 704 | $arrVal = array($category_id); |
|---|
| 705 | $res = $objQuery->select('category_id AS id, category_name AS name', 'dtb_category', 'category_id = ?', $arrVal); |
|---|
| 706 | |
|---|
| 707 | return $res[0]; |
|---|
| 708 | } |
|---|
| 709 | |
|---|
| 710 | /** |
|---|
| 711 | * 指定したカテゴリーIDの大カテゴリーを取得する. |
|---|
| 712 | * |
|---|
| 713 | * @param integer $category_id カテゴリID |
|---|
| 714 | * @return array 指定したカテゴリーIDの大カテゴリー |
|---|
| 715 | */ |
|---|
| 716 | function sfGetFirstCat($category_id){ |
|---|
| 717 | // 商品が属するカテゴリIDを縦に取得 |
|---|
| 718 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 719 | $arrRet = array(); |
|---|
| 720 | $arrCatID = $this->sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id); |
|---|
| 721 | $arrRet['id'] = $arrCatID[0]; |
|---|
| 722 | |
|---|
| 723 | // カテゴリー名称を取得する |
|---|
| 724 | $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; |
|---|
| 725 | $arrVal = array($arrRet['id']); |
|---|
| 726 | $arrRet['name'] = $objQuery->getOne($sql,$arrVal); |
|---|
| 727 | |
|---|
| 728 | return $arrRet; |
|---|
| 729 | } |
|---|
| 730 | |
|---|
| 731 | /** |
|---|
| 732 | * カテゴリツリーの取得を行う. |
|---|
| 733 | * |
|---|
| 734 | * $products_check:true商品登録済みのものだけ取得する |
|---|
| 735 | * |
|---|
| 736 | * @param string $addwhere 追加する WHERE 句 |
|---|
| 737 | * @param bool $products_check 商品の存在するカテゴリのみ取得する場合 true |
|---|
| 738 | * @param string $head カテゴリ名のプレフィックス文字列 |
|---|
| 739 | * @return array カテゴリツリーの配列 |
|---|
| 740 | */ |
|---|
| 741 | function sfGetCategoryList($addwhere = "", $products_check = false, $head = CATEGORY_HEAD) { |
|---|
| 742 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 743 | $where = "del_flg = 0"; |
|---|
| 744 | |
|---|
| 745 | if($addwhere != "") { |
|---|
| 746 | $where.= " AND $addwhere"; |
|---|
| 747 | } |
|---|
| 748 | |
|---|
| 749 | $objQuery->setOption("ORDER BY rank DESC"); |
|---|
| 750 | |
|---|
| 751 | if($products_check) { |
|---|
| 752 | $col = "T1.category_id, category_name, level"; |
|---|
| 753 | $from = "dtb_category AS T1 LEFT JOIN dtb_category_total_count AS T2 ON T1.category_id = T2.category_id"; |
|---|
| 754 | $where .= " AND product_count > 0"; |
|---|
| 755 | } else { |
|---|
| 756 | $col = "category_id, category_name, level"; |
|---|
| 757 | $from = "dtb_category"; |
|---|
| 758 | } |
|---|
| 759 | |
|---|
| 760 | $arrRet = $objQuery->select($col, $from, $where); |
|---|
| 761 | |
|---|
| 762 | $max = count($arrRet); |
|---|
| 763 | for($cnt = 0; $cnt < $max; $cnt++) { |
|---|
| 764 | $id = $arrRet[$cnt]['category_id']; |
|---|
| 765 | $name = $arrRet[$cnt]['category_name']; |
|---|
| 766 | $arrList[$id] = str_repeat($head, $arrRet[$cnt]['level']) . $name; |
|---|
| 767 | } |
|---|
| 768 | return $arrList; |
|---|
| 769 | } |
|---|
| 770 | |
|---|
| 771 | /** |
|---|
| 772 | * カテゴリーツリーの取得を行う. |
|---|
| 773 | * |
|---|
| 774 | * 親カテゴリの Value=0 を対象とする |
|---|
| 775 | * |
|---|
| 776 | * @param bool $parent_zero 親カテゴリの Value=0 の場合 true |
|---|
| 777 | * @return array カテゴリツリーの配列 |
|---|
| 778 | */ |
|---|
| 779 | function sfGetLevelCatList($parent_zero = true) { |
|---|
| 780 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 781 | |
|---|
| 782 | // カテゴリ名リストを取得 |
|---|
| 783 | $col = "category_id, parent_category_id, category_name"; |
|---|
| 784 | $where = "del_flg = 0"; |
|---|
| 785 | $objQuery->setOption("ORDER BY level"); |
|---|
| 786 | $arrRet = $objQuery->select($col, "dtb_category", $where); |
|---|
| 787 | $arrCatName = array(); |
|---|
| 788 | foreach ($arrRet as $arrTmp) { |
|---|
| 789 | $arrCatName[$arrTmp['category_id']] = |
|---|
| 790 | (($arrTmp['parent_category_id'] > 0)? |
|---|
| 791 | $arrCatName[$arrTmp['parent_category_id']] : "") |
|---|
| 792 | . CATEGORY_HEAD . $arrTmp['category_name']; |
|---|
| 793 | } |
|---|
| 794 | |
|---|
| 795 | $col = "category_id, parent_category_id, category_name, level"; |
|---|
| 796 | $where = "del_flg = 0"; |
|---|
| 797 | $objQuery->setOption("ORDER BY rank DESC"); |
|---|
| 798 | $arrRet = $objQuery->select($col, "dtb_category", $where); |
|---|
| 799 | $max = count($arrRet); |
|---|
| 800 | |
|---|
| 801 | for($cnt = 0; $cnt < $max; $cnt++) { |
|---|
| 802 | if($parent_zero) { |
|---|
| 803 | if($arrRet[$cnt]['level'] == LEVEL_MAX) { |
|---|
| 804 | $arrValue[$cnt] = $arrRet[$cnt]['category_id']; |
|---|
| 805 | } else { |
|---|
| 806 | $arrValue[$cnt] = ""; |
|---|
| 807 | } |
|---|
| 808 | } else { |
|---|
| 809 | $arrValue[$cnt] = $arrRet[$cnt]['category_id']; |
|---|
| 810 | } |
|---|
| 811 | |
|---|
| 812 | $arrOutput[$cnt] = $arrCatName[$arrRet[$cnt]['category_id']]; |
|---|
| 813 | } |
|---|
| 814 | |
|---|
| 815 | return array($arrValue, $arrOutput); |
|---|
| 816 | } |
|---|
| 817 | |
|---|
| 818 | /** |
|---|
| 819 | * 選択中の商品のカテゴリを取得する. |
|---|
| 820 | * |
|---|
| 821 | * @param integer $product_id プロダクトID |
|---|
| 822 | * @param integer $category_id カテゴリID |
|---|
| 823 | * @return array 選択中の商品のカテゴリIDの配列 |
|---|
| 824 | * |
|---|
| 825 | */ |
|---|
| 826 | function sfGetCategoryId($product_id, $category_id = 0, $closed = false) { |
|---|
| 827 | if ($closed) { |
|---|
| 828 | $status = ""; |
|---|
| 829 | } else { |
|---|
| 830 | $status = "status = 1"; |
|---|
| 831 | } |
|---|
| 832 | |
|---|
| 833 | if(!$this->g_category_on) { |
|---|
| 834 | $this->g_category_on = true; |
|---|
| 835 | $category_id = (int) $category_id; |
|---|
| 836 | $product_id = (int) $product_id; |
|---|
| 837 | if (SC_Utils_Ex::sfIsInt($category_id) && $category_id != 0 && $this->sfIsRecord("dtb_category","category_id", $category_id)) { |
|---|
| 838 | $this->g_category_id = array($category_id); |
|---|
| 839 | } else if (SC_Utils_Ex::sfIsInt($product_id) && $product_id != 0 && $this->sfIsRecord("dtb_products","product_id", $product_id, $status)) { |
|---|
| 840 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 841 | $where = "product_id = ?"; |
|---|
| 842 | $category_id = $objQuery->getCol("dtb_product_categories", "category_id", "product_id = ?", array($product_id)); |
|---|
| 843 | $this->g_category_id = $category_id; |
|---|
| 844 | } else { |
|---|
| 845 | // 不正な場合は、空の配列を返す。 |
|---|
| 846 | $this->g_category_id = array(); |
|---|
| 847 | } |
|---|
| 848 | } |
|---|
| 849 | return $this->g_category_id; |
|---|
| 850 | } |
|---|
| 851 | |
|---|
| 852 | /** |
|---|
| 853 | * 商品をカテゴリの先頭に追加する. |
|---|
| 854 | * |
|---|
| 855 | * @param integer $category_id カテゴリID |
|---|
| 856 | * @param integer $product_id プロダクトID |
|---|
| 857 | * @return void |
|---|
| 858 | */ |
|---|
| 859 | function addProductBeforCategories($category_id, $product_id) { |
|---|
| 860 | |
|---|
| 861 | $sqlval = array("category_id" => $category_id, |
|---|
| 862 | "product_id" => $product_id); |
|---|
| 863 | |
|---|
| 864 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 865 | |
|---|
| 866 | // 現在の商品カテゴリを取得 |
|---|
| 867 | $arrCat = $objQuery->select("product_id, category_id, rank", |
|---|
| 868 | "dtb_product_categories", |
|---|
| 869 | "category_id = ?", |
|---|
| 870 | array($category_id)); |
|---|
| 871 | |
|---|
| 872 | $max = "0"; |
|---|
| 873 | foreach ($arrCat as $val) { |
|---|
| 874 | // 同一商品が存在する場合は登録しない |
|---|
| 875 | if ($val["product_id"] == $product_id) { |
|---|
| 876 | return; |
|---|
| 877 | } |
|---|
| 878 | // 最上位ランクを取得 |
|---|
| 879 | $max = ($max < $val["rank"]) ? $val["rank"] : $max; |
|---|
| 880 | } |
|---|
| 881 | $sqlval["rank"] = $max + 1; |
|---|
| 882 | $objQuery->insert("dtb_product_categories", $sqlval); |
|---|
| 883 | } |
|---|
| 884 | |
|---|
| 885 | /** |
|---|
| 886 | * 商品をカテゴリの末尾に追加する. |
|---|
| 887 | * |
|---|
| 888 | * @param integer $category_id カテゴリID |
|---|
| 889 | * @param integer $product_id プロダクトID |
|---|
| 890 | * @return void |
|---|
| 891 | */ |
|---|
| 892 | function addProductAfterCategories($category_id, $product_id) { |
|---|
| 893 | $sqlval = array("category_id" => $category_id, |
|---|
| 894 | "product_id" => $product_id); |
|---|
| 895 | |
|---|
| 896 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 897 | |
|---|
| 898 | // 現在の商品カテゴリを取得 |
|---|
| 899 | $arrCat = $objQuery->select("product_id, category_id, rank", |
|---|
| 900 | "dtb_product_categories", |
|---|
| 901 | "category_id = ?", |
|---|
| 902 | array($category_id)); |
|---|
| 903 | |
|---|
| 904 | $min = 0; |
|---|
| 905 | foreach ($arrCat as $val) { |
|---|
| 906 | // 同一商品が存在する場合は登録しない |
|---|
| 907 | if ($val["product_id"] == $product_id) { |
|---|
| 908 | return; |
|---|
| 909 | } |
|---|
| 910 | // 最下位ランクを取得 |
|---|
| 911 | $min = ($min < $val["rank"]) ? $val["rank"] : $min; |
|---|
| 912 | } |
|---|
| 913 | $sqlval["rank"] = $min; |
|---|
| 914 | $objQuery->insert("dtb_product_categories", $sqlval); |
|---|
| 915 | } |
|---|
| 916 | |
|---|
| 917 | /** |
|---|
| 918 | * 商品をカテゴリから削除する. |
|---|
| 919 | * |
|---|
| 920 | * @param integer $category_id カテゴリID |
|---|
| 921 | * @param integer $product_id プロダクトID |
|---|
| 922 | * @return void |
|---|
| 923 | */ |
|---|
| 924 | function removeProductByCategories($category_id, $product_id) { |
|---|
| 925 | $sqlval = array("category_id" => $category_id, |
|---|
| 926 | "product_id" => $product_id); |
|---|
| 927 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 928 | $objQuery->delete("dtb_product_categories", |
|---|
| 929 | "category_id = ? AND product_id = ?", $sqlval); |
|---|
| 930 | } |
|---|
| 931 | |
|---|
| 932 | /** |
|---|
| 933 | * 商品カテゴリを更新する. |
|---|
| 934 | * |
|---|
| 935 | * @param array $arrCategory_id 登録するカテゴリIDの配列 |
|---|
| 936 | * @param integer $product_id プロダクトID |
|---|
| 937 | * @return void |
|---|
| 938 | */ |
|---|
| 939 | function updateProductCategories($arrCategory_id, $product_id) { |
|---|
| 940 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 941 | |
|---|
| 942 | // 現在のカテゴリ情報を取得 |
|---|
| 943 | $arrCurrentCat = $objQuery->select("product_id, category_id, rank", |
|---|
| 944 | "dtb_product_categories", |
|---|
| 945 | "product_id = ?", |
|---|
| 946 | array($product_id)); |
|---|
| 947 | |
|---|
| 948 | // 登録するカテゴリ情報と比較 |
|---|
| 949 | foreach ($arrCurrentCat as $val) { |
|---|
| 950 | |
|---|
| 951 | // 登録しないカテゴリを削除 |
|---|
| 952 | if (!in_array($val["category_id"], $arrCategory_id)) { |
|---|
| 953 | $this->removeProductByCategories($val["category_id"], $product_id); |
|---|
| 954 | } |
|---|
| 955 | } |
|---|
| 956 | |
|---|
| 957 | // カテゴリを登録 |
|---|
| 958 | foreach ($arrCategory_id as $category_id) { |
|---|
| 959 | $this->addProductBeforCategories($category_id, $product_id); |
|---|
| 960 | } |
|---|
| 961 | } |
|---|
| 962 | |
|---|
| 963 | /** |
|---|
| 964 | * カテゴリ数の登録を行う. |
|---|
| 965 | * |
|---|
| 966 | * @param SC_Query $objQuery SC_Query インスタンス |
|---|
| 967 | * @return void |
|---|
| 968 | */ |
|---|
| 969 | function sfCategory_Count($objQuery){ |
|---|
| 970 | |
|---|
| 971 | //テーブル内容の削除 |
|---|
| 972 | $objQuery->query("DELETE FROM dtb_category_count"); |
|---|
| 973 | $objQuery->query("DELETE FROM dtb_category_total_count"); |
|---|
| 974 | |
|---|
| 975 | $sql_where .= 'alldtl.del_flg = 0 AND alldtl.status = 1'; |
|---|
| 976 | // 在庫無し商品の非表示 |
|---|
| 977 | if (NOSTOCK_HIDDEN === true) { |
|---|
| 978 | $sql_where .= ' AND (alldtl.stock_max >= 1 OR alldtl.stock_unlimited_max = 1)'; |
|---|
| 979 | } |
|---|
| 980 | |
|---|
| 981 | //各カテゴリ内の商品数を数えて格納 |
|---|
| 982 | $sql = <<< __EOS__ |
|---|
| 983 | INSERT INTO dtb_category_count(category_id, product_count, create_date) |
|---|
| 984 | SELECT T1.category_id, count(T2.category_id), now() |
|---|
| 985 | FROM dtb_category AS T1 |
|---|
| 986 | LEFT JOIN dtb_product_categories AS T2 |
|---|
| 987 | ON T1.category_id = T2.category_id |
|---|
| 988 | LEFT JOIN vw_products_allclass_detail AS alldtl |
|---|
| 989 | ON T2.product_id = alldtl.product_id |
|---|
| 990 | WHERE $sql_where |
|---|
| 991 | GROUP BY T1.category_id, T2.category_id |
|---|
| 992 | __EOS__; |
|---|
| 993 | |
|---|
| 994 | $objQuery->query($sql); |
|---|
| 995 | |
|---|
| 996 | //子カテゴリ内の商品数を集計する |
|---|
| 997 | |
|---|
| 998 | // カテゴリ情報を取得 |
|---|
| 999 | $arrCat = $objQuery->select('category_id', 'dtb_category'); |
|---|
| 1000 | |
|---|
| 1001 | foreach ($arrCat as $row) { |
|---|
| 1002 | $category_id = $row['category_id']; |
|---|
| 1003 | $arrval = array(); |
|---|
| 1004 | |
|---|
| 1005 | $arrval[] = $category_id; |
|---|
| 1006 | |
|---|
| 1007 | list($tmp_where, $tmp_arrval) = $this->sfGetCatWhere($category_id); |
|---|
| 1008 | if ($tmp_where != "") { |
|---|
| 1009 | $sql_where_product_ids = "alldtl.product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")"; |
|---|
| 1010 | $arrval = array_merge((array)$arrval, (array)$tmp_arrval); |
|---|
| 1011 | } else { |
|---|
| 1012 | $sql_where_product_ids = '0<>0'; // 一致させない |
|---|
| 1013 | } |
|---|
| 1014 | |
|---|
| 1015 | $sql = <<< __EOS__ |
|---|
| 1016 | INSERT INTO dtb_category_total_count (category_id, product_count, create_date) |
|---|
| 1017 | SELECT |
|---|
| 1018 | ? |
|---|
| 1019 | ,count(*) |
|---|
| 1020 | ,now() |
|---|
| 1021 | FROM vw_products_allclass_detail AS alldtl |
|---|
| 1022 | WHERE ($sql_where) AND ($sql_where_product_ids) |
|---|
| 1023 | __EOS__; |
|---|
| 1024 | |
|---|
| 1025 | $objQuery->query($sql, $arrval); |
|---|
| 1026 | } |
|---|
| 1027 | } |
|---|
| 1028 | |
|---|
| 1029 | /** |
|---|
| 1030 | * 子IDの配列を返す. |
|---|
| 1031 | * |
|---|
| 1032 | * @param string $table テーブル名 |
|---|
| 1033 | * @param string $pid_name 親ID名 |
|---|
| 1034 | * @param string $id_name ID名 |
|---|
| 1035 | * @param integer $id ID |
|---|
| 1036 | * @param array 子ID の配列 |
|---|
| 1037 | */ |
|---|
| 1038 | function sfGetChildsID($table, $pid_name, $id_name, $id) { |
|---|
| 1039 | $arrRet = $this->sfGetChildrenArray($table, $pid_name, $id_name, $id); |
|---|
| 1040 | return $arrRet; |
|---|
| 1041 | } |
|---|
| 1042 | |
|---|
| 1043 | /** |
|---|
| 1044 | * 階層構造のテーブルから子ID配列を取得する. |
|---|
| 1045 | * |
|---|
| 1046 | * @param string $table テーブル名 |
|---|
| 1047 | * @param string $pid_name 親ID名 |
|---|
| 1048 | * @param string $id_name ID名 |
|---|
| 1049 | * @param integer $id ID番号 |
|---|
| 1050 | * @return array 子IDの配列 |
|---|
| 1051 | */ |
|---|
| 1052 | function sfGetChildrenArray($table, $pid_name, $id_name, $id) { |
|---|
| 1053 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1054 | $col = $pid_name . "," . $id_name; |
|---|
| 1055 | $arrData = $objQuery->select($col, $table); |
|---|
| 1056 | |
|---|
| 1057 | $arrPID = array(); |
|---|
| 1058 | $arrPID[] = $id; |
|---|
| 1059 | $arrChildren = array(); |
|---|
| 1060 | $arrChildren[] = $id; |
|---|
| 1061 | |
|---|
| 1062 | $arrRet = $this->sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID); |
|---|
| 1063 | |
|---|
| 1064 | while(count($arrRet) > 0) { |
|---|
| 1065 | $arrChildren = array_merge($arrChildren, $arrRet); |
|---|
| 1066 | $arrRet = $this->sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrRet); |
|---|
| 1067 | } |
|---|
| 1068 | |
|---|
| 1069 | return $arrChildren; |
|---|
| 1070 | } |
|---|
| 1071 | |
|---|
| 1072 | /** |
|---|
| 1073 | * 親ID直下の子IDをすべて取得する. |
|---|
| 1074 | * |
|---|
| 1075 | * @param array $arrData 親カテゴリの配列 |
|---|
| 1076 | * @param string $pid_name 親ID名 |
|---|
| 1077 | * @param string $id_name ID名 |
|---|
| 1078 | * @param array $arrPID 親IDの配列 |
|---|
| 1079 | * @return array 子IDの配列 |
|---|
| 1080 | */ |
|---|
| 1081 | function sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID) { |
|---|
| 1082 | $arrChildren = array(); |
|---|
| 1083 | $max = count($arrData); |
|---|
| 1084 | |
|---|
| 1085 | for($i = 0; $i < $max; $i++) { |
|---|
| 1086 | foreach($arrPID as $val) { |
|---|
| 1087 | if($arrData[$i][$pid_name] == $val) { |
|---|
| 1088 | $arrChildren[] = $arrData[$i][$id_name]; |
|---|
| 1089 | } |
|---|
| 1090 | } |
|---|
| 1091 | } |
|---|
| 1092 | return $arrChildren; |
|---|
| 1093 | } |
|---|
| 1094 | |
|---|
| 1095 | /** |
|---|
| 1096 | * 所属するすべての階層の親IDを配列で返す. |
|---|
| 1097 | * |
|---|
| 1098 | * @param SC_Query $objQuery SC_Query インスタンス |
|---|
| 1099 | * @param string $table テーブル名 |
|---|
| 1100 | * @param string $pid_name 親ID名 |
|---|
| 1101 | * @param string $id_name ID名 |
|---|
| 1102 | * @param integer $id ID |
|---|
| 1103 | * @return array 親IDの配列 |
|---|
| 1104 | */ |
|---|
| 1105 | function sfGetParents($objQuery, $table, $pid_name, $id_name, $id) { |
|---|
| 1106 | $arrRet = $this->sfGetParentsArray($table, $pid_name, $id_name, $id); |
|---|
| 1107 | // 配列の先頭1つを削除する。 |
|---|
| 1108 | array_shift($arrRet); |
|---|
| 1109 | return $arrRet; |
|---|
| 1110 | } |
|---|
| 1111 | |
|---|
| 1112 | /** |
|---|
| 1113 | * 階層構造のテーブルから親ID配列を取得する. |
|---|
| 1114 | * |
|---|
| 1115 | * @param string $table テーブル名 |
|---|
| 1116 | * @param string $pid_name 親ID名 |
|---|
| 1117 | * @param string $id_name ID名 |
|---|
| 1118 | * @param integer $id ID |
|---|
| 1119 | * @return array 親IDの配列 |
|---|
| 1120 | */ |
|---|
| 1121 | function sfGetParentsArray($table, $pid_name, $id_name, $id) { |
|---|
| 1122 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1123 | $col = $pid_name . "," . $id_name; |
|---|
| 1124 | $arrData = $objQuery->select($col, $table); |
|---|
| 1125 | |
|---|
| 1126 | $arrParents = array(); |
|---|
| 1127 | $arrParents[] = $id; |
|---|
| 1128 | $child = $id; |
|---|
| 1129 | |
|---|
| 1130 | $ret = SC_Utils::sfGetParentsArraySub($arrData, $pid_name, $id_name, $child); |
|---|
| 1131 | |
|---|
| 1132 | while($ret != "") { |
|---|
| 1133 | $arrParents[] = $ret; |
|---|
| 1134 | $ret = SC_Utils::sfGetParentsArraySub($arrData, $pid_name, $id_name, $ret); |
|---|
| 1135 | } |
|---|
| 1136 | |
|---|
| 1137 | $arrParents = array_reverse($arrParents); |
|---|
| 1138 | |
|---|
| 1139 | return $arrParents; |
|---|
| 1140 | } |
|---|
| 1141 | |
|---|
| 1142 | /** |
|---|
| 1143 | * カテゴリから商品を検索する場合のWHERE文と値を返す. |
|---|
| 1144 | * |
|---|
| 1145 | * @param integer $category_id カテゴリID |
|---|
| 1146 | * @return array 商品を検索する場合の配列 |
|---|
| 1147 | */ |
|---|
| 1148 | function sfGetCatWhere($category_id) { |
|---|
| 1149 | // 子カテゴリIDの取得 |
|---|
| 1150 | $arrRet = $this->sfGetChildsID("dtb_category", "parent_category_id", "category_id", $category_id); |
|---|
| 1151 | $tmp_where = ""; |
|---|
| 1152 | foreach ($arrRet as $val) { |
|---|
| 1153 | if($tmp_where == "") { |
|---|
| 1154 | $tmp_where.= "category_id IN ( ?"; |
|---|
| 1155 | } else { |
|---|
| 1156 | $tmp_where.= ",? "; |
|---|
| 1157 | } |
|---|
| 1158 | $arrval[] = $val; |
|---|
| 1159 | } |
|---|
| 1160 | $tmp_where.= " ) "; |
|---|
| 1161 | return array($tmp_where, $arrval); |
|---|
| 1162 | } |
|---|
| 1163 | |
|---|
| 1164 | /** |
|---|
| 1165 | * 受注一時テーブルから情報を取得する. |
|---|
| 1166 | * |
|---|
| 1167 | * @param integer $order_temp_id 受注一時ID |
|---|
| 1168 | * @return array 受注一時情報の配列 |
|---|
| 1169 | */ |
|---|
| 1170 | function sfGetOrderTemp($order_temp_id) { |
|---|
| 1171 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1172 | $where = "order_temp_id = ?"; |
|---|
| 1173 | $arrRet = $objQuery->select("*", "dtb_order_temp", $where, array($order_temp_id)); |
|---|
| 1174 | return $arrRet[0]; |
|---|
| 1175 | } |
|---|
| 1176 | |
|---|
| 1177 | /** |
|---|
| 1178 | * SELECTボックス用リストを作成する. |
|---|
| 1179 | * |
|---|
| 1180 | * @param string $table テーブル名 |
|---|
| 1181 | * @param string $keyname プライマリーキーのカラム名 |
|---|
| 1182 | * @param string $valname データ内容のカラム名 |
|---|
| 1183 | * @return array SELECT ボックス用リストの配列 |
|---|
| 1184 | */ |
|---|
| 1185 | function sfGetIDValueList($table, $keyname, $valname) { |
|---|
| 1186 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1187 | $col = "$keyname, $valname"; |
|---|
| 1188 | $objQuery->setWhere("del_flg = 0"); |
|---|
| 1189 | $objQuery->setOrder("rank DESC"); |
|---|
| 1190 | $arrList = $objQuery->select($col, $table); |
|---|
| 1191 | $count = count($arrList); |
|---|
| 1192 | for($cnt = 0; $cnt < $count; $cnt++) { |
|---|
| 1193 | $key = $arrList[$cnt][$keyname]; |
|---|
| 1194 | $val = $arrList[$cnt][$valname]; |
|---|
| 1195 | $arrRet[$key] = $val; |
|---|
| 1196 | } |
|---|
| 1197 | return $arrRet; |
|---|
| 1198 | } |
|---|
| 1199 | |
|---|
| 1200 | /** |
|---|
| 1201 | * ランキングを上げる. |
|---|
| 1202 | * |
|---|
| 1203 | * @param string $table テーブル名 |
|---|
| 1204 | * @param string $colname カラム名 |
|---|
| 1205 | * @param string|integer $id テーブルのキー |
|---|
| 1206 | * @param string $andwhere SQL の AND 条件である WHERE 句 |
|---|
| 1207 | * @return void |
|---|
| 1208 | */ |
|---|
| 1209 | function sfRankUp($table, $colname, $id, $andwhere = "") { |
|---|
| 1210 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1211 | $objQuery->begin(); |
|---|
| 1212 | $where = "$colname = ?"; |
|---|
| 1213 | if($andwhere != "") { |
|---|
| 1214 | $where.= " AND $andwhere"; |
|---|
| 1215 | } |
|---|
| 1216 | // 対象項目のランクを取得 |
|---|
| 1217 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
|---|
| 1218 | // ランクの最大値を取得 |
|---|
| 1219 | $maxrank = $objQuery->max($table, "rank", $andwhere); |
|---|
| 1220 | // ランクが最大値よりも小さい場合に実行する。 |
|---|
| 1221 | if($rank < $maxrank) { |
|---|
| 1222 | // ランクが一つ上のIDを取得する。 |
|---|
| 1223 | $where = "rank = ?"; |
|---|
| 1224 | if($andwhere != "") { |
|---|
| 1225 | $where.= " AND $andwhere"; |
|---|
| 1226 | } |
|---|
| 1227 | $uprank = $rank + 1; |
|---|
| 1228 | $up_id = $objQuery->get($table, $colname, $where, array($uprank)); |
|---|
| 1229 | // ランク入れ替えの実行 |
|---|
| 1230 | $sqlup = "UPDATE $table SET rank = ? WHERE $colname = ?"; |
|---|
| 1231 | if($andwhere != "") { |
|---|
| 1232 | $sqlup.= " AND $andwhere"; |
|---|
| 1233 | } |
|---|
| 1234 | $objQuery->exec($sqlup, array($rank + 1, $id)); |
|---|
| 1235 | $objQuery->exec($sqlup, array($rank, $up_id)); |
|---|
| 1236 | } |
|---|
| 1237 | $objQuery->commit(); |
|---|
| 1238 | } |
|---|
| 1239 | |
|---|
| 1240 | /** |
|---|
| 1241 | * ランキングを下げる. |
|---|
| 1242 | * |
|---|
| 1243 | * @param string $table テーブル名 |
|---|
| 1244 | * @param string $colname カラム名 |
|---|
| 1245 | * @param string|integer $id テーブルのキー |
|---|
| 1246 | * @param string $andwhere SQL の AND 条件である WHERE 句 |
|---|
| 1247 | * @return void |
|---|
| 1248 | */ |
|---|
| 1249 | function sfRankDown($table, $colname, $id, $andwhere = "") { |
|---|
| 1250 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1251 | $objQuery->begin(); |
|---|
| 1252 | $where = "$colname = ?"; |
|---|
| 1253 | if($andwhere != "") { |
|---|
| 1254 | $where.= " AND $andwhere"; |
|---|
| 1255 | } |
|---|
| 1256 | // 対象項目のランクを取得 |
|---|
| 1257 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
|---|
| 1258 | |
|---|
| 1259 | // ランクが1(最小値)よりも大きい場合に実行する。 |
|---|
| 1260 | if($rank > 1) { |
|---|
| 1261 | // ランクが一つ下のIDを取得する。 |
|---|
| 1262 | $where = "rank = ?"; |
|---|
| 1263 | if($andwhere != "") { |
|---|
| 1264 | $where.= " AND $andwhere"; |
|---|
| 1265 | } |
|---|
| 1266 | $downrank = $rank - 1; |
|---|
| 1267 | $down_id = $objQuery->get($table, $colname, $where, array($downrank)); |
|---|
| 1268 | // ランク入れ替えの実行 |
|---|
| 1269 | $sqlup = "UPDATE $table SET rank = ? WHERE $colname = ?"; |
|---|
| 1270 | if($andwhere != "") { |
|---|
| 1271 | $sqlup.= " AND $andwhere"; |
|---|
| 1272 | } |
|---|
| 1273 | $objQuery->exec($sqlup, array($rank - 1, $id)); |
|---|
| 1274 | $objQuery->exec($sqlup, array($rank, $down_id)); |
|---|
| 1275 | } |
|---|
| 1276 | $objQuery->commit(); |
|---|
| 1277 | } |
|---|
| 1278 | |
|---|
| 1279 | /** |
|---|
| 1280 | * 指定順位へ移動する. |
|---|
| 1281 | * |
|---|
| 1282 | * @param string $tableName テーブル名 |
|---|
| 1283 | * @param string $keyIdColumn キーを保持するカラム名 |
|---|
| 1284 | * @param string|integer $keyId キーの値 |
|---|
| 1285 | * @param integer $pos 指定順位 |
|---|
| 1286 | * @param string $where SQL の AND 条件である WHERE 句 |
|---|
| 1287 | * @return void |
|---|
| 1288 | */ |
|---|
| 1289 | function sfMoveRank($tableName, $keyIdColumn, $keyId, $pos, $where = "") { |
|---|
| 1290 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1291 | $objQuery->begin(); |
|---|
| 1292 | |
|---|
| 1293 | // 自身のランクを取得する |
|---|
| 1294 | if($where != "") { |
|---|
| 1295 | $getWhere = "$keyIdColumn = ? AND " . $where; |
|---|
| 1296 | } else { |
|---|
| 1297 | $getWhere = "$keyIdColumn = ?"; |
|---|
| 1298 | } |
|---|
| 1299 | $rank = $objQuery->get($tableName, "rank", $getWhere, array($keyId)); |
|---|
| 1300 | |
|---|
| 1301 | $max = $objQuery->max($tableName, "rank", $where); |
|---|
| 1302 | |
|---|
| 1303 | // 値の調整(逆順) |
|---|
| 1304 | if($pos > $max) { |
|---|
| 1305 | $position = 1; |
|---|
| 1306 | } else if($pos < 1) { |
|---|
| 1307 | $position = $max; |
|---|
| 1308 | } else { |
|---|
| 1309 | $position = $max - $pos + 1; |
|---|
| 1310 | } |
|---|
| 1311 | |
|---|
| 1312 | //入れ替え先の順位が入れ換え元の順位より大きい場合 |
|---|
| 1313 | if( $position > $rank ) $term = "rank - 1"; |
|---|
| 1314 | |
|---|
| 1315 | //入れ替え先の順位が入れ換え元の順位より小さい場合 |
|---|
| 1316 | if( $position < $rank ) $term = "rank + 1"; |
|---|
| 1317 | |
|---|
| 1318 | // XXX 入れ替え先の順位が入れ替え元の順位と同じ場合 |
|---|
| 1319 | if (!isset($term)) $term = "rank"; |
|---|
| 1320 | |
|---|
| 1321 | // 指定した順位の商品から移動させる商品までのrankを1つずらす |
|---|
| 1322 | $sql = "UPDATE $tableName SET rank = $term WHERE rank BETWEEN ? AND ?"; |
|---|
| 1323 | if($where != "") { |
|---|
| 1324 | $sql.= " AND $where"; |
|---|
| 1325 | } |
|---|
| 1326 | |
|---|
| 1327 | if( $position > $rank ) $objQuery->exec( $sql, array( $rank + 1, $position )); |
|---|
| 1328 | if( $position < $rank ) $objQuery->exec( $sql, array( $position, $rank - 1 )); |
|---|
| 1329 | |
|---|
| 1330 | // 指定した順位へrankを書き換える。 |
|---|
| 1331 | $sql = "UPDATE $tableName SET rank = ? WHERE $keyIdColumn = ? "; |
|---|
| 1332 | if($where != "") { |
|---|
| 1333 | $sql.= " AND $where"; |
|---|
| 1334 | } |
|---|
| 1335 | |
|---|
| 1336 | $objQuery->exec( $sql, array( $position, $keyId ) ); |
|---|
| 1337 | $objQuery->commit(); |
|---|
| 1338 | } |
|---|
| 1339 | |
|---|
| 1340 | /** |
|---|
| 1341 | * ランクを含むレコードを削除する. |
|---|
| 1342 | * |
|---|
| 1343 | * レコードごと削除する場合は、$deleteをtrueにする |
|---|
| 1344 | * |
|---|
| 1345 | * @param string $table テーブル名 |
|---|
| 1346 | * @param string $colname カラム名 |
|---|
| 1347 | * @param string|integer $id テーブルのキー |
|---|
| 1348 | * @param string $andwhere SQL の AND 条件である WHERE 句 |
|---|
| 1349 | * @param bool $delete レコードごと削除する場合 true, |
|---|
| 1350 | * レコードごと削除しない場合 false |
|---|
| 1351 | * @return void |
|---|
| 1352 | */ |
|---|
| 1353 | function sfDeleteRankRecord($table, $colname, $id, $andwhere = "", |
|---|
| 1354 | $delete = false) { |
|---|
| 1355 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1356 | $objQuery->begin(); |
|---|
| 1357 | // 削除レコードのランクを取得する。 |
|---|
| 1358 | $where = "$colname = ?"; |
|---|
| 1359 | if($andwhere != "") { |
|---|
| 1360 | $where.= " AND $andwhere"; |
|---|
| 1361 | } |
|---|
| 1362 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
|---|
| 1363 | |
|---|
| 1364 | if(!$delete) { |
|---|
| 1365 | // ランクを最下位にする、DELフラグON |
|---|
| 1366 | $sqlup = "UPDATE $table SET rank = 0, del_flg = 1 "; |
|---|
| 1367 | $sqlup.= "WHERE $colname = ?"; |
|---|
| 1368 | // UPDATEの実行 |
|---|
| 1369 | $objQuery->exec($sqlup, array($id)); |
|---|
| 1370 | } else { |
|---|
| 1371 | $objQuery->delete($table, "$colname = ?", array($id)); |
|---|
| 1372 | } |
|---|
| 1373 | |
|---|
| 1374 | // 追加レコードのランクより上のレコードを一つずらす。 |
|---|
| 1375 | $where = "rank > ?"; |
|---|
| 1376 | if($andwhere != "") { |
|---|
| 1377 | $where.= " AND $andwhere"; |
|---|
| 1378 | } |
|---|
| 1379 | $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where"; |
|---|
| 1380 | $objQuery->exec($sqlup, array($rank)); |
|---|
| 1381 | $objQuery->commit(); |
|---|
| 1382 | } |
|---|
| 1383 | |
|---|
| 1384 | /** |
|---|
| 1385 | * 親IDの配列を元に特定のカラムを取得する. |
|---|
| 1386 | * |
|---|
| 1387 | * @param SC_Query $objQuery SC_Query インスタンス |
|---|
| 1388 | * @param string $table テーブル名 |
|---|
| 1389 | * @param string $id_name ID名 |
|---|
| 1390 | * @param string $col_name カラム名 |
|---|
| 1391 | * @param array $arrId IDの配列 |
|---|
| 1392 | * @return array 特定のカラムの配列 |
|---|
| 1393 | */ |
|---|
| 1394 | function sfGetParentsCol($objQuery, $table, $id_name, $col_name, $arrId ) { |
|---|
| 1395 | $col = $col_name; |
|---|
| 1396 | $len = count($arrId); |
|---|
| 1397 | $where = ""; |
|---|
| 1398 | |
|---|
| 1399 | for($cnt = 0; $cnt < $len; $cnt++) { |
|---|
| 1400 | if($where == "") { |
|---|
| 1401 | $where = "$id_name = ?"; |
|---|
| 1402 | } else { |
|---|
| 1403 | $where.= " OR $id_name = ?"; |
|---|
| 1404 | } |
|---|
| 1405 | } |
|---|
| 1406 | |
|---|
| 1407 | $objQuery->setOrder("level"); |
|---|
| 1408 | $arrRet = $objQuery->select($col, $table, $where, $arrId); |
|---|
| 1409 | return $arrRet; |
|---|
| 1410 | } |
|---|
| 1411 | |
|---|
| 1412 | /** |
|---|
| 1413 | * カテゴリ変更時の移動処理を行う. |
|---|
| 1414 | * |
|---|
| 1415 | * @param SC_Query $objQuery SC_Query インスタンス |
|---|
| 1416 | * @param string $table テーブル名 |
|---|
| 1417 | * @param string $id_name ID名 |
|---|
| 1418 | * @param string $cat_name カテゴリ名 |
|---|
| 1419 | * @param integer $old_catid 旧カテゴリID |
|---|
| 1420 | * @param integer $new_catid 新カテゴリID |
|---|
| 1421 | * @param integer $id ID |
|---|
| 1422 | * @return void |
|---|
| 1423 | */ |
|---|
| 1424 | function sfMoveCatRank($objQuery, $table, $id_name, $cat_name, $old_catid, $new_catid, $id) { |
|---|
| 1425 | if ($old_catid == $new_catid) { |
|---|
| 1426 | return; |
|---|
| 1427 | } |
|---|
| 1428 | // 旧カテゴリでのランク削除処理 |
|---|
| 1429 | // 移動レコードのランクを取得する。 |
|---|
| 1430 | $where = "$id_name = ?"; |
|---|
| 1431 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
|---|
| 1432 | // 削除レコードのランクより上のレコードを一つ下にずらす。 |
|---|
| 1433 | $where = "rank > ? AND $cat_name = ?"; |
|---|
| 1434 | $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where"; |
|---|
| 1435 | $objQuery->exec($sqlup, array($rank, $old_catid)); |
|---|
| 1436 | // 新カテゴリでの登録処理 |
|---|
| 1437 | // 新カテゴリの最大ランクを取得する。 |
|---|
| 1438 | $max_rank = $objQuery->max($table, "rank", "$cat_name = ?", array($new_catid)) + 1; |
|---|
| 1439 | $where = "$id_name = ?"; |
|---|
| 1440 | $sqlup = "UPDATE $table SET rank = ? WHERE $where"; |
|---|
| 1441 | $objQuery->exec($sqlup, array($max_rank, $id)); |
|---|
| 1442 | } |
|---|
| 1443 | |
|---|
| 1444 | /** |
|---|
| 1445 | * お届け時間を取得する. |
|---|
| 1446 | * |
|---|
| 1447 | * @param integer $payment_id 支払い方法ID |
|---|
| 1448 | * @return array お届け時間の配列 |
|---|
| 1449 | */ |
|---|
| 1450 | function sfGetDelivTime($payment_id = "") { |
|---|
| 1451 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1452 | |
|---|
| 1453 | $deliv_id = ""; |
|---|
| 1454 | $arrRet = array(); |
|---|
| 1455 | |
|---|
| 1456 | if($payment_id != "") { |
|---|
| 1457 | $where = "del_flg = 0 AND payment_id = ?"; |
|---|
| 1458 | $arrRet = $objQuery->select("deliv_id", "dtb_payment", $where, array($payment_id)); |
|---|
| 1459 | $deliv_id = $arrRet[0]['deliv_id']; |
|---|
| 1460 | } |
|---|
| 1461 | |
|---|
| 1462 | if($deliv_id != "") { |
|---|
| 1463 | $objQuery->setOrder("time_id"); |
|---|
| 1464 | $where = "deliv_id = ?"; |
|---|
| 1465 | $arrRet= $objQuery->select("time_id, deliv_time", "dtb_delivtime", $where, array($deliv_id)); |
|---|
| 1466 | } |
|---|
| 1467 | |
|---|
| 1468 | return $arrRet; |
|---|
| 1469 | } |
|---|
| 1470 | |
|---|
| 1471 | /** |
|---|
| 1472 | * 都道府県、支払い方法から配送料金を取得する. |
|---|
| 1473 | * |
|---|
| 1474 | * @param array $arrData 各種情報 |
|---|
| 1475 | * @return string 指定の都道府県, 支払い方法の配送料金 |
|---|
| 1476 | */ |
|---|
| 1477 | function sfGetDelivFee($arrData) { |
|---|
| 1478 | $pref = $arrData['deliv_pref']; |
|---|
| 1479 | $payment_id = isset($arrData['payment_id']) ? $arrData['payment_id'] : ""; |
|---|
| 1480 | |
|---|
| 1481 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1482 | |
|---|
| 1483 | $deliv_id = ""; |
|---|
| 1484 | |
|---|
| 1485 | // 支払い方法が指定されている場合は、対応した配送業者を取得する |
|---|
| 1486 | if($payment_id != "") { |
|---|
| 1487 | $where = "del_flg = 0 AND payment_id = ?"; |
|---|
| 1488 | $arrRet = $objQuery->select("deliv_id", "dtb_payment", $where, array($payment_id)); |
|---|
| 1489 | $deliv_id = $arrRet[0]['deliv_id']; |
|---|
| 1490 | // 支払い方法が指定されていない場合は、先頭の配送業者を取得する |
|---|
| 1491 | } else { |
|---|
| 1492 | $where = "del_flg = 0"; |
|---|
| 1493 | $objQuery->setOrder("rank DESC"); |
|---|
| 1494 | $objQuery->setLimitOffset(1); |
|---|
| 1495 | $arrRet = $objQuery->select("deliv_id", "dtb_deliv", $where); |
|---|
| 1496 | $deliv_id = $arrRet[0]['deliv_id']; |
|---|
| 1497 | } |
|---|
| 1498 | |
|---|
| 1499 | // 配送業者から配送料を取得 |
|---|
| 1500 | if($deliv_id != "") { |
|---|
| 1501 | |
|---|
| 1502 | // 都道府県が指定されていない場合は、東京都の番号を指定しておく |
|---|
| 1503 | if($pref == "") { |
|---|
| 1504 | $pref = 13; |
|---|
| 1505 | } |
|---|
| 1506 | |
|---|
| 1507 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1508 | $where = "deliv_id = ? AND pref = ?"; |
|---|
| 1509 | $arrRet= $objQuery->select("fee", "dtb_delivfee", $where, array($deliv_id, $pref)); |
|---|
| 1510 | } |
|---|
| 1511 | return $arrRet[0]['fee']; |
|---|
| 1512 | } |
|---|
| 1513 | |
|---|
| 1514 | /** |
|---|
| 1515 | * 集計情報を元に最終計算を行う. |
|---|
| 1516 | * |
|---|
| 1517 | * @param array $arrData 各種情報 |
|---|
| 1518 | * @param LC_Page $objPage LC_Page インスタンス |
|---|
| 1519 | * @param SC_CartSession $objCartSess SC_CartSession インスタンス |
|---|
| 1520 | * @param null $dummy1 互換性確保用(決済モジュール互換のため) |
|---|
| 1521 | * @param SC_Customer $objCustomer SC_Customer インスタンス |
|---|
| 1522 | * @return array 最終計算後の配列 |
|---|
| 1523 | */ |
|---|
| 1524 | function sfTotalConfirm($arrData, &$objPage, &$objCartSess, $dummy1 = null, $objCustomer = "") { |
|---|
| 1525 | // 店舗基本情報を取得する |
|---|
| 1526 | $arrInfo = SC_Helper_DB_Ex::sf_getBasisData(); |
|---|
| 1527 | |
|---|
| 1528 | // 未定義変数を定義 |
|---|
| 1529 | if (!isset($arrData['deliv_pref'])) $arrData['deliv_pref'] = ""; |
|---|
| 1530 | if (!isset($arrData['payment_id'])) $arrData['payment_id'] = ""; |
|---|
| 1531 | if (!isset($arrData['charge'])) $arrData['charge'] = ""; |
|---|
| 1532 | if (!isset($arrData['use_point'])) $arrData['use_point'] = ""; |
|---|
| 1533 | if (!isset($arrData['add_point'])) $arrData['add_point'] = 0; |
|---|
| 1534 | |
|---|
| 1535 | // 税金の取得 |
|---|
| 1536 | $arrData['tax'] = $objPage->tpl_total_tax; |
|---|
| 1537 | // 小計の取得 |
|---|
| 1538 | $arrData['subtotal'] = $objPage->tpl_total_pretax; |
|---|
| 1539 | |
|---|
| 1540 | // 合計送料の取得 |
|---|
| 1541 | $arrData['deliv_fee'] = 0; |
|---|
| 1542 | |
|---|
| 1543 | // 商品ごとの送料が有効の場合 |
|---|
| 1544 | if (OPTION_PRODUCT_DELIV_FEE == 1) { |
|---|
| 1545 | // 全商品の合計送料を加算する |
|---|
| 1546 | $this->lfAddAllProductsDelivFee($arrData, $objPage, $objCartSess); |
|---|
| 1547 | } |
|---|
| 1548 | |
|---|
| 1549 | // 配送業者の送料が有効の場合 |
|---|
| 1550 | if (OPTION_DELIV_FEE == 1) { |
|---|
| 1551 | // 都道府県、支払い方法から配送料金を加算する |
|---|
| 1552 | $this->lfAddDelivFee($arrData); |
|---|
| 1553 | } |
|---|
| 1554 | |
|---|
| 1555 | // 送料無料の購入数が設定されている場合 |
|---|
| 1556 | if (DELIV_FREE_AMOUNT > 0) { |
|---|
| 1557 | // 商品の合計数量 |
|---|
| 1558 | $total_quantity = $objCartSess->getTotalQuantity(true); |
|---|
| 1559 | |
|---|
| 1560 | if($total_quantity >= DELIV_FREE_AMOUNT) { |
|---|
| 1561 | $arrData['deliv_fee'] = 0; |
|---|
| 1562 | } |
|---|
| 1563 | } |
|---|
| 1564 | |
|---|
| 1565 | // ダウンロード商品のみの場合は送料無料 |
|---|
| 1566 | if($this->chkCartDown($objCartSess)==2){ |
|---|
| 1567 | $arrData['deliv_fee'] = 0; |
|---|
| 1568 | } |
|---|
| 1569 | |
|---|
| 1570 | // 送料無料条件が設定されている場合 |
|---|
| 1571 | if($arrInfo['free_rule'] > 0) { |
|---|
| 1572 | // 小計が無料条件を超えている場合 |
|---|
| 1573 | if($arrData['subtotal'] >= $arrInfo['free_rule']) { |
|---|
| 1574 | $arrData['deliv_fee'] = 0; |
|---|
| 1575 | } |
|---|
| 1576 | } |
|---|
| 1577 | |
|---|
| 1578 | // 合計の計算 |
|---|
| 1579 | $arrData['total'] = $objPage->tpl_total_pretax; // 商品合計 |
|---|
| 1580 | $arrData['total']+= $arrData['deliv_fee']; // 送料 |
|---|
| 1581 | $arrData['total']+= $arrData['charge']; // 手数料 |
|---|
| 1582 | // お支払い合計 |
|---|
| 1583 | $arrData['payment_total'] = $arrData['total'] - ($arrData['use_point'] * POINT_VALUE); |
|---|
| 1584 | // 加算ポイントの計算 |
|---|
| 1585 | if (USE_POINT !== false) { |
|---|
| 1586 | $arrData['add_point'] = SC_Helper_DB_Ex::sfGetAddPoint($objPage->tpl_total_point, $arrData['use_point']); |
|---|
| 1587 | |
|---|
| 1588 | if($objCustomer != "") { |
|---|
| 1589 | // 誕生日月であった場合 |
|---|
| 1590 | if($objCustomer->isBirthMonth()) { |
|---|
| 1591 | $arrData['birth_point'] = BIRTH_MONTH_POINT; |
|---|
| 1592 | $arrData['add_point'] += $arrData['birth_point']; |
|---|
| 1593 | } |
|---|
| 1594 | } |
|---|
| 1595 | } |
|---|
| 1596 | |
|---|
| 1597 | if($arrData['add_point'] < 0) { |
|---|
| 1598 | $arrData['add_point'] = 0; |
|---|
| 1599 | } |
|---|
| 1600 | return $arrData; |
|---|
| 1601 | } |
|---|
| 1602 | |
|---|
| 1603 | /** |
|---|
| 1604 | * レコードの存在チェックを行う. |
|---|
| 1605 | * |
|---|
| 1606 | * @param string $table テーブル名 |
|---|
| 1607 | * @param string $col カラム名 |
|---|
| 1608 | * @param array $arrval 要素の配列 |
|---|
| 1609 | * @param array $addwhere SQL の AND 条件である WHERE 句 |
|---|
| 1610 | * @return bool レコードが存在する場合 true |
|---|
| 1611 | */ |
|---|
| 1612 | function sfIsRecord($table, $col, $arrval, $addwhere = "") { |
|---|
| 1613 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1614 | $arrCol = split("[, ]", $col); |
|---|
| 1615 | |
|---|
| 1616 | $where = "del_flg = 0"; |
|---|
| 1617 | |
|---|
| 1618 | if($addwhere != "") { |
|---|
| 1619 | $where.= " AND $addwhere"; |
|---|
| 1620 | } |
|---|
| 1621 | |
|---|
| 1622 | foreach($arrCol as $val) { |
|---|
| 1623 | if($val != "") { |
|---|
| 1624 | if($where == "") { |
|---|
| 1625 | $where = "$val = ?"; |
|---|
| 1626 | } else { |
|---|
| 1627 | $where.= " AND $val = ?"; |
|---|
| 1628 | } |
|---|
| 1629 | } |
|---|
| 1630 | } |
|---|
| 1631 | $ret = $objQuery->get($table, $col, $where, $arrval); |
|---|
| 1632 | |
|---|
| 1633 | if($ret != "") { |
|---|
| 1634 | return true; |
|---|
| 1635 | } |
|---|
| 1636 | return false; |
|---|
| 1637 | } |
|---|
| 1638 | |
|---|
| 1639 | /** |
|---|
| 1640 | * メーカー商品数数の登録を行う. |
|---|
| 1641 | * |
|---|
| 1642 | * @param SC_Query $objQuery SC_Query インスタンス |
|---|
| 1643 | * @return void |
|---|
| 1644 | */ |
|---|
| 1645 | function sfMaker_Count($objQuery){ |
|---|
| 1646 | $sql = ""; |
|---|
| 1647 | |
|---|
| 1648 | //テーブル内容の削除 |
|---|
| 1649 | $objQuery->query("DELETE FROM dtb_maker_count"); |
|---|
| 1650 | |
|---|
| 1651 | //各メーカーの商品数を数えて格納 |
|---|
| 1652 | $sql = " INSERT INTO dtb_maker_count(maker_id, product_count, create_date) "; |
|---|
| 1653 | $sql .= " SELECT T1.maker_id, count(T2.maker_id), now() "; |
|---|
| 1654 | $sql .= " FROM dtb_maker AS T1 LEFT JOIN dtb_products AS T2"; |
|---|
| 1655 | $sql .= " ON T1.maker_id = T2.maker_id "; |
|---|
| 1656 | $sql .= " WHERE T2.del_flg = 0 AND T2.status = 1 "; |
|---|
| 1657 | $sql .= " GROUP BY T1.maker_id, T2.maker_id "; |
|---|
| 1658 | $objQuery->query($sql); |
|---|
| 1659 | } |
|---|
| 1660 | |
|---|
| 1661 | /** |
|---|
| 1662 | * 選択中の商品のメーカーを取得する. |
|---|
| 1663 | * |
|---|
| 1664 | * @param integer $product_id プロダクトID |
|---|
| 1665 | * @param integer $maker_id メーカーID |
|---|
| 1666 | * @return array 選択中の商品のメーカーIDの配列 |
|---|
| 1667 | * |
|---|
| 1668 | */ |
|---|
| 1669 | function sfGetMakerId($product_id, $maker_id = 0, $closed = false) { |
|---|
| 1670 | if ($closed) { |
|---|
| 1671 | $status = ""; |
|---|
| 1672 | } else { |
|---|
| 1673 | $status = "status = 1"; |
|---|
| 1674 | } |
|---|
| 1675 | |
|---|
| 1676 | if (!$this->g_maker_on) { |
|---|
| 1677 | $this->g_maker_on = true; |
|---|
| 1678 | $maker_id = (int) $maker_id; |
|---|
| 1679 | $product_id = (int) $product_id; |
|---|
| 1680 | if (SC_Utils_Ex::sfIsInt($maker_id) && $maker_id != 0 && $this->sfIsRecord("dtb_maker","maker_id", $maker_id)) { |
|---|
| 1681 | $this->g_maker_id = array($maker_id); |
|---|
| 1682 | } else if (SC_Utils_Ex::sfIsInt($product_id) && $product_id != 0 && $this->sfIsRecord("dtb_products","product_id", $product_id, $status)) { |
|---|
| 1683 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1684 | $where = "product_id = ?"; |
|---|
| 1685 | $maker_id = $objQuery->getCol("dtb_products", "maker_id", "product_id = ?", array($product_id)); |
|---|
| 1686 | $this->g_maker_id = $maker_id; |
|---|
| 1687 | } else { |
|---|
| 1688 | // 不正な場合は、空の配列を返す。 |
|---|
| 1689 | $this->g_maker_id = array(); |
|---|
| 1690 | } |
|---|
| 1691 | } |
|---|
| 1692 | return $this->g_maker_id; |
|---|
| 1693 | } |
|---|
| 1694 | |
|---|
| 1695 | /** |
|---|
| 1696 | * メーカーの取得を行う. |
|---|
| 1697 | * |
|---|
| 1698 | * $products_check:true商品登録済みのものだけ取得する |
|---|
| 1699 | * |
|---|
| 1700 | * @param string $addwhere 追加する WHERE 句 |
|---|
| 1701 | * @param bool $products_check 商品の存在するカテゴリのみ取得する場合 true |
|---|
| 1702 | * @return array カテゴリツリーの配列 |
|---|
| 1703 | */ |
|---|
| 1704 | function sfGetMakerList($addwhere = "", $products_check = false) { |
|---|
| 1705 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1706 | $where = "del_flg = 0"; |
|---|
| 1707 | |
|---|
| 1708 | if($addwhere != "") { |
|---|
| 1709 | $where.= " AND $addwhere"; |
|---|
| 1710 | } |
|---|
| 1711 | |
|---|
| 1712 | $objQuery->setOption("ORDER BY rank DESC"); |
|---|
| 1713 | |
|---|
| 1714 | if($products_check) { |
|---|
| 1715 | $col = "T1.maker_id, name"; |
|---|
| 1716 | $from = "dtb_maker AS T1 LEFT JOIN dtb_maker_count AS T2 ON T1.maker_id = T2.maker_id"; |
|---|
| 1717 | $where .= " AND product_count > 0"; |
|---|
| 1718 | } else { |
|---|
| 1719 | $col = "maker_id, name"; |
|---|
| 1720 | $from = "dtb_maker"; |
|---|
| 1721 | } |
|---|
| 1722 | |
|---|
| 1723 | $arrRet = $objQuery->select($col, $from, $where); |
|---|
| 1724 | |
|---|
| 1725 | $max = count($arrRet); |
|---|
| 1726 | for($cnt = 0; $cnt < $max; $cnt++) { |
|---|
| 1727 | $id = $arrRet[$cnt]['maker_id']; |
|---|
| 1728 | $name = $arrRet[$cnt]['name']; |
|---|
| 1729 | $arrList[$id].= $name; |
|---|
| 1730 | } |
|---|
| 1731 | return $arrList; |
|---|
| 1732 | } |
|---|
| 1733 | |
|---|
| 1734 | /** |
|---|
| 1735 | * 全商品の合計送料を加算する |
|---|
| 1736 | */ |
|---|
| 1737 | function lfAddAllProductsDelivFee(&$arrData, &$objPage, &$objCartSess) { |
|---|
| 1738 | $arrData['deliv_fee'] += $this->lfCalcAllProductsDelivFee($arrData, $objCartSess); |
|---|
| 1739 | } |
|---|
| 1740 | |
|---|
| 1741 | /** |
|---|
| 1742 | * 全商品の合計送料を計算する |
|---|
| 1743 | */ |
|---|
| 1744 | function lfCalcAllProductsDelivFee(&$arrData, &$objCartSess) { |
|---|
| 1745 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1746 | $deliv_fee_total = 0; |
|---|
| 1747 | $max = $objCartSess->getMax(); |
|---|
| 1748 | for ($i = 0; $i <= $max; $i++) { |
|---|
| 1749 | // 商品送料 |
|---|
| 1750 | $deliv_fee = $objQuery->getOne('SELECT deliv_fee FROM dtb_products WHERE product_id = ?', array($_SESSION[$objCartSess->key][$i]['id'][0])); |
|---|
| 1751 | // 数量 |
|---|
| 1752 | $quantity = $_SESSION[$objCartSess->key][$i]['quantity']; |
|---|
| 1753 | // 累積 |
|---|
| 1754 | $deliv_fee_total += $deliv_fee * $quantity; |
|---|
| 1755 | } |
|---|
| 1756 | return $deliv_fee_total; |
|---|
| 1757 | } |
|---|
| 1758 | |
|---|
| 1759 | /** |
|---|
| 1760 | * 都道府県、支払い方法から配送料金を加算する. |
|---|
| 1761 | * |
|---|
| 1762 | * @param array $arrData 各種情報 |
|---|
| 1763 | */ |
|---|
| 1764 | function lfAddDelivFee(&$arrData) { |
|---|
| 1765 | $arrData['deliv_fee'] += $this->sfGetDelivFee($arrData); |
|---|
| 1766 | } |
|---|
| 1767 | |
|---|
| 1768 | /** |
|---|
| 1769 | * 受注の名称列を更新する |
|---|
| 1770 | * |
|---|
| 1771 | * @param integer $order_id 更新対象の注文番号 |
|---|
| 1772 | * @param boolean $temp_table 更新対象は「受注_Temp」か |
|---|
| 1773 | * @static |
|---|
| 1774 | */ |
|---|
| 1775 | function sfUpdateOrderNameCol($order_id, $temp_table = false) { |
|---|
| 1776 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1777 | |
|---|
| 1778 | if ($temp_table) { |
|---|
| 1779 | $tgt_table = 'dtb_order_temp'; |
|---|
| 1780 | $sql_where = 'WHERE order_temp_id = ?'; |
|---|
| 1781 | } else { |
|---|
| 1782 | $tgt_table = 'dtb_order'; |
|---|
| 1783 | $sql_where = 'WHERE order_id = ?'; |
|---|
| 1784 | } |
|---|
| 1785 | |
|---|
| 1786 | $sql = <<< __EOS__ |
|---|
| 1787 | UPDATE |
|---|
| 1788 | {$tgt_table} |
|---|
| 1789 | SET |
|---|
| 1790 | payment_method = (SELECT payment_method FROM dtb_payment WHERE payment_id = {$tgt_table}.payment_id) |
|---|
| 1791 | ,deliv_time = (SELECT deliv_time FROM dtb_delivtime WHERE time_id = {$tgt_table}.deliv_time_id AND deliv_id = {$tgt_table}.deliv_id) |
|---|
| 1792 | $sql_where |
|---|
| 1793 | __EOS__; |
|---|
| 1794 | |
|---|
| 1795 | $objQuery->query($sql, array($order_id)); |
|---|
| 1796 | } |
|---|
| 1797 | |
|---|
| 1798 | /** |
|---|
| 1799 | * 店舗基本情報に基づいて税金額を返す |
|---|
| 1800 | * |
|---|
| 1801 | * @param integer $price 計算対象の金額 |
|---|
| 1802 | * @return integer 税金額 |
|---|
| 1803 | */ |
|---|
| 1804 | function sfTax($price) { |
|---|
| 1805 | // 店舗基本情報を取得 |
|---|
| 1806 | $CONF = SC_Helper_DB_Ex::sf_getBasisData(); |
|---|
| 1807 | |
|---|
| 1808 | return SC_Utils_Ex::sfTax($price, $CONF['tax'], $CONF['tax_rule']); |
|---|
| 1809 | } |
|---|
| 1810 | |
|---|
| 1811 | /** |
|---|
| 1812 | * 店舗基本情報に基づいて税金付与した金額を返す |
|---|
| 1813 | * |
|---|
| 1814 | * @param integer $price 計算対象の金額 |
|---|
| 1815 | * @return integer 税金付与した金額 |
|---|
| 1816 | */ |
|---|
| 1817 | function sfPreTax($price, $tax = null, $tax_rule = null) { |
|---|
| 1818 | // 店舗基本情報を取得 |
|---|
| 1819 | $CONF = SC_Helper_DB_Ex::sf_getBasisData(); |
|---|
| 1820 | |
|---|
| 1821 | return SC_Utils_Ex::sfPreTax($price, $CONF['tax'], $CONF['tax_rule']); |
|---|
| 1822 | } |
|---|
| 1823 | |
|---|
| 1824 | /** |
|---|
| 1825 | * 店舗基本情報に基づいて加算ポイントを返す |
|---|
| 1826 | * |
|---|
| 1827 | * @param integer $totalpoint |
|---|
| 1828 | * @param integer $use_point |
|---|
| 1829 | * @return integer 加算ポイント |
|---|
| 1830 | */ |
|---|
| 1831 | function sfGetAddPoint($totalpoint, $use_point) { |
|---|
| 1832 | // 店舗基本情報を取得 |
|---|
| 1833 | $CONF = SC_Helper_DB_Ex::sf_getBasisData(); |
|---|
| 1834 | |
|---|
| 1835 | return SC_Utils_Ex::sfGetAddPoint($totalpoint, $use_point, $CONF['point_rate']); |
|---|
| 1836 | } |
|---|
| 1837 | |
|---|
| 1838 | /** |
|---|
| 1839 | * 受注.対応状況の更新 |
|---|
| 1840 | * |
|---|
| 1841 | * ・必ず呼び出し元でトランザクションブロックを開いておくこと。 |
|---|
| 1842 | * |
|---|
| 1843 | * @param integer $orderId 注文番号 |
|---|
| 1844 | * @param integer|null $newStatus 対応状況 (null=変更無し) |
|---|
| 1845 | * @param integer|null $newAddPoint 加算ポイント (null=変更無し) |
|---|
| 1846 | * @param integer|null $newUsePoint 使用ポイント (null=変更無し) |
|---|
| 1847 | * @return void |
|---|
| 1848 | */ |
|---|
| 1849 | function sfUpdateOrderStatus($orderId, $newStatus = null, $newAddPoint = null, $newUsePoint = null) { |
|---|
| 1850 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1851 | |
|---|
| 1852 | $arrOrderOld = $objQuery->getRow('dtb_order', 'status, add_point, use_point, customer_id', 'order_id = ?', array($orderId)); |
|---|
| 1853 | |
|---|
| 1854 | // 対応状況が変更無しの場合、DB値を引き継ぐ |
|---|
| 1855 | if (is_null($newStatus)) { |
|---|
| 1856 | $newStatus = $arrOrderOld['status']; |
|---|
| 1857 | } |
|---|
| 1858 | |
|---|
| 1859 | // 使用ポイント、DB値を引き継ぐ |
|---|
| 1860 | if (is_null($newUsePoint)) { |
|---|
| 1861 | $newUsePoint = $arrOrderOld['use_point']; |
|---|
| 1862 | } |
|---|
| 1863 | |
|---|
| 1864 | // 加算ポイント、DB値を引き継ぐ |
|---|
| 1865 | if (is_null($newAddPoint)) { |
|---|
| 1866 | $newAddPoint = $arrOrderOld['add_point']; |
|---|
| 1867 | } |
|---|
| 1868 | |
|---|
| 1869 | if (USE_POINT !== false) { |
|---|
| 1870 | // 顧客.ポイントの加減値 |
|---|
| 1871 | $addCustomerPoint = 0; |
|---|
| 1872 | |
|---|
| 1873 | // ▼使用ポイント |
|---|
| 1874 | // 変更前の対応状況が利用対象の場合、変更前の使用ポイント分を戻す |
|---|
| 1875 | if (SC_Utils_Ex::sfIsUsePoint($arrOrderOld['status'])) { |
|---|
| 1876 | $addCustomerPoint += $arrOrderOld['use_point']; |
|---|
| 1877 | } |
|---|
| 1878 | |
|---|
| 1879 | // 変更後の対応状況が利用対象の場合、変更後の使用ポイント分を引く |
|---|
| 1880 | if (SC_Utils_Ex::sfIsUsePoint($newStatus)) { |
|---|
| 1881 | $addCustomerPoint -= $newUsePoint; |
|---|
| 1882 | } |
|---|
| 1883 | // ▲使用ポイント |
|---|
| 1884 | |
|---|
| 1885 | // ▼加算ポイント |
|---|
| 1886 | // 変更前の対応状況が加算対象の場合、変更前の加算ポイント分を戻す |
|---|
| 1887 | if (SC_Utils_Ex::sfIsAddPoint($arrOrderOld['status'])) { |
|---|
| 1888 | $addCustomerPoint -= $arrOrderOld['add_point']; |
|---|
| 1889 | } |
|---|
| 1890 | |
|---|
| 1891 | // 変更後の対応状況が加算対象の場合、変更後の加算ポイント分を足す |
|---|
| 1892 | if (SC_Utils_Ex::sfIsAddPoint($newStatus)) { |
|---|
| 1893 | $addCustomerPoint += $newAddPoint; |
|---|
| 1894 | } |
|---|
| 1895 | // ▲加算ポイント |
|---|
| 1896 | |
|---|
| 1897 | if ($addCustomerPoint != 0) { |
|---|
| 1898 | // ▼顧客テーブルの更新 |
|---|
| 1899 | $sqlval = array(); |
|---|
| 1900 | $where = ''; |
|---|
| 1901 | $arrVal = array(); |
|---|
| 1902 | $arrRawSql = array(); |
|---|
| 1903 | $arrRawSqlVal = array(); |
|---|
| 1904 | |
|---|
| 1905 | $sqlval['update_date'] = 'Now()'; |
|---|
| 1906 | $arrRawSql['point'] = 'point + ?'; |
|---|
| 1907 | $arrRawSqlVal[] = $addCustomerPoint; |
|---|
| 1908 | $where .= 'customer_id = ?'; |
|---|
| 1909 | $arrVal[] = $arrOrderOld['customer_id']; |
|---|
| 1910 | |
|---|
| 1911 | $objQuery->update('dtb_customer', $sqlval, $where, $arrVal, $arrRawSql, $arrRawSqlVal); |
|---|
| 1912 | // ▲顧客テーブルの更新 |
|---|
| 1913 | |
|---|
| 1914 | // 顧客.ポイントをマイナスした場合、 |
|---|
| 1915 | if ($addCustomerPoint < 0) { |
|---|
| 1916 | $sql = 'SELECT point FROM dtb_customer WHERE customer_id = ?'; |
|---|
| 1917 | $point = $objQuery->getOne($sql, array($arrOrderOld['customer_id'])); |
|---|
| 1918 | // 変更後の顧客.ポイントがマイナスの場合、 |
|---|
| 1919 | if ($point < 0) { |
|---|
| 1920 | // ロールバック |
|---|
| 1921 | $objQuery->rollback(); |
|---|
| 1922 | // エラー |
|---|
| 1923 | SC_Utils_Ex::sfDispSiteError(LACK_POINT); |
|---|
| 1924 | } |
|---|
| 1925 | } |
|---|
| 1926 | } |
|---|
| 1927 | } |
|---|
| 1928 | |
|---|
| 1929 | // ▼受注テーブルの更新 |
|---|
| 1930 | $sqlval = array(); |
|---|
| 1931 | if (USE_POINT !== false) { |
|---|
| 1932 | $sqlval['add_point'] = $newAddPoint; |
|---|
| 1933 | $sqlval['use_point'] = $newUsePoint; |
|---|
| 1934 | } |
|---|
| 1935 | // ステータスが発送済みに変更の場合、発送日を更新 |
|---|
| 1936 | if ($arrOrderOld['status'] != ORDER_DELIV && $newStatus == ORDER_DELIV) { |
|---|
| 1937 | $sqlval['commit_date'] = 'Now()'; |
|---|
| 1938 | } |
|---|
| 1939 | $sqlval['status'] = $newStatus; |
|---|
| 1940 | $sqlval['update_date'] = 'Now()'; |
|---|
| 1941 | |
|---|
| 1942 | $objQuery->update('dtb_order', $sqlval, 'order_id = ?', array($orderId)); |
|---|
| 1943 | // ▲受注テーブルの更新 |
|---|
| 1944 | } |
|---|
| 1945 | |
|---|
| 1946 | /** |
|---|
| 1947 | * 指定ファイルが存在する場合 SQL として実行 |
|---|
| 1948 | * |
|---|
| 1949 | * ・MySQL の場合、文字「;」を区切りとして、分割実行。 |
|---|
| 1950 | * XXX プラグイン用に追加。将来消すかも。 |
|---|
| 1951 | * |
|---|
| 1952 | * @param string $sqlFilePath SQL ファイルのパス |
|---|
| 1953 | * @return void |
|---|
| 1954 | */ |
|---|
| 1955 | function sfExecSqlByFile($sqlFilePath) { |
|---|
| 1956 | if (file_exists($sqlFilePath)) { |
|---|
| 1957 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1958 | |
|---|
| 1959 | $sqls = file_get_contents($sqlFilePath); |
|---|
| 1960 | if ($sqls === false) SC_Utils_Ex::sfDispException('ファイルは存在するが読み込めない'); |
|---|
| 1961 | |
|---|
| 1962 | if (DB_TYPE == 'mysql') { |
|---|
| 1963 | foreach (explode(';', $sqls) as $sql) { |
|---|
| 1964 | $sql = trim($sql); |
|---|
| 1965 | if (strlen($sql) == 0) continue; |
|---|
| 1966 | $objQuery->query($sql); |
|---|
| 1967 | } |
|---|
| 1968 | } else { |
|---|
| 1969 | $objQuery->query($sqls); |
|---|
| 1970 | } |
|---|
| 1971 | } |
|---|
| 1972 | } |
|---|
| 1973 | |
|---|
| 1974 | /** |
|---|
| 1975 | * 商品規格を設定しているか |
|---|
| 1976 | * |
|---|
| 1977 | * @param integer $product_id 商品ID |
|---|
| 1978 | * @return bool 商品規格が存在する場合:true, それ以外:false |
|---|
| 1979 | */ |
|---|
| 1980 | function sfHasProductClass($product_id) { |
|---|
| 1981 | if (!SC_Utils_Ex::sfIsInt($product_id)) return false; |
|---|
| 1982 | |
|---|
| 1983 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1984 | $where = 'product_id = ? AND (classcategory_id1 <> 0 OR classcategory_id2 <> 0)'; |
|---|
| 1985 | $count = $objQuery->count('dtb_products_class', $where, array($product_id)); |
|---|
| 1986 | |
|---|
| 1987 | return $count >= 1; |
|---|
| 1988 | } |
|---|
| 1989 | /** |
|---|
| 1990 | * カート内の商品の販売方法判定処理 |
|---|
| 1991 | * |
|---|
| 1992 | * @param $objCartSess SC_CartSession カートセッション |
|---|
| 1993 | * @return bool 0:ダウンロード販売無 1:ダウンロード販売無 2:全てダウンロード販売 |
|---|
| 1994 | */ |
|---|
| 1995 | function chkCartDown($objCartSess) { |
|---|
| 1996 | $objQuery =& SC_Query::getSingletonInstance(); |
|---|
| 1997 | $down = false; |
|---|
| 1998 | $nodown = false; |
|---|
| 1999 | $ret = 0; |
|---|
| 2000 | $arrID = $objCartSess->getAllProductID(); |
|---|
| 2001 | if(!is_null($arrID)){ |
|---|
| 2002 | //カート内のIDから販売方法を取得 |
|---|
| 2003 | foreach ($arrID as $rec) { |
|---|
| 2004 | $arrRet = $objQuery->select("down", "dtb_products", "product_id = " . $rec); |
|---|
| 2005 | if ($arrRet[0]['down'] == "2"){ |
|---|
| 2006 | $down = true; |
|---|
| 2007 | }else{ |
|---|
| 2008 | $nodown = true; |
|---|
| 2009 | } |
|---|
| 2010 | } |
|---|
| 2011 | } |
|---|
| 2012 | //混在 |
|---|
| 2013 | if($nodown && $down){ |
|---|
| 2014 | $ret = 1; |
|---|
| 2015 | //全てダウンロード商品 |
|---|
| 2016 | }else if(!$nodown && $down){ |
|---|
| 2017 | $ret = 2; |
|---|
| 2018 | } |
|---|
| 2019 | return $ret; |
|---|
| 2020 | } |
|---|
| 2021 | |
|---|
| 2022 | /* 会員情報の住所を一時受注テーブルへ */ |
|---|
| 2023 | function sfRegistDelivData($uniqid, $objCustomer) { |
|---|
| 2024 | |
|---|
| 2025 | // 登録データの作成 |
|---|
| 2026 | $sqlval['order_temp_id'] = $uniqid; |
|---|
| 2027 | $sqlval['update_date'] = 'Now()'; |
|---|
| 2028 | $sqlval['customer_id'] = $objCustomer->getValue('customer_id'); |
|---|
| 2029 | $sqlval['deliv_check'] = '-1'; |
|---|
| 2030 | $sqlval['order_name01'] = $objCustomer->getValue('name01'); |
|---|
| 2031 | $sqlval['order_name02'] = $objCustomer->getValue('name02'); |
|---|
| 2032 | $sqlval['order_kana01'] = $objCustomer->getValue('kana01'); |
|---|
| 2033 | $sqlval['order_kana02'] = $objCustomer->getValue('kana02'); |
|---|
| 2034 | $sqlval['order_zip01'] = $objCustomer->getValue('zip01'); |
|---|
| 2035 | $sqlval['order_zip02'] = $objCustomer->getValue('zip02'); |
|---|
| 2036 | $sqlval['order_pref'] = $objCustomer->getValue('pref'); |
|---|
| 2037 | $sqlval['order_addr01'] = $objCustomer->getValue('addr01'); |
|---|
| 2038 | $sqlval['order_addr02'] = $objCustomer->getValue('addr02'); |
|---|
| 2039 | $sqlval['order_tel01'] = $objCustomer->getValue('tel01'); |
|---|
| 2040 | $sqlval['order_tel02'] = $objCustomer->getValue('tel02'); |
|---|
| 2041 | $sqlval['order_tel03'] = $objCustomer->getValue('tel03'); |
|---|
| 2042 | $sqlval['order_fax01'] = $objCustomer->getValue('fax01'); |
|---|
| 2043 | $sqlval['order_fax02'] = $objCustomer->getValue('fax02'); |
|---|
| 2044 | $sqlval['order_fax03'] = $objCustomer->getValue('fax03'); |
|---|
| 2045 | $sqlval['deliv_name01'] = $objCustomer->getValue('name01'); |
|---|
| 2046 | $sqlval['deliv_name02'] = $objCustomer->getValue('name02'); |
|---|
| 2047 | $sqlval['deliv_kana01'] = $objCustomer->getValue('kana01'); |
|---|
| 2048 | $sqlval['deliv_kana02'] = $objCustomer->getValue('kana02'); |
|---|
| 2049 | $sqlval['deliv_zip01'] = $objCustomer->getValue('zip01'); |
|---|
| 2050 | $sqlval['deliv_zip02'] = $objCustomer->getValue('zip02'); |
|---|
| 2051 | $sqlval['deliv_pref'] = $objCustomer->getValue('pref'); |
|---|
| 2052 | $sqlval['deliv_addr01'] = $objCustomer->getValue('addr01'); |
|---|
| 2053 | $sqlval['deliv_addr02'] = $objCustomer->getValue('addr02'); |
|---|
| 2054 | $sqlval['deliv_tel01'] = $objCustomer->getValue('tel01'); |
|---|
| 2055 | $sqlval['deliv_tel02'] = $objCustomer->getValue('tel02'); |
|---|
| 2056 | $sqlval['deliv_tel03'] = $objCustomer->getValue('tel03'); |
|---|
| 2057 | $sqlval['deliv_fax01'] = $objCustomer->getValue('fax01'); |
|---|
| 2058 | $sqlval['deliv_fax02'] = $objCustomer->getValue('fax02'); |
|---|
| 2059 | $sqlval['deliv_fax03'] = $objCustomer->getValue('fax03'); |
|---|
| 2060 | |
|---|
| 2061 | $this->sfRegistTempOrder($uniqid, $sqlval); |
|---|
| 2062 | } |
|---|
| 2063 | |
|---|
| 2064 | |
|---|
| 2065 | } |
|---|
| 2066 | ?> |
|---|