/**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $conn = new SC_DBConn();
     $objView = new SC_AdminView();
     $objSess = new SC_Session();
     $objDb = new SC_Helper_DB_Ex();
     // 認証可否の判定
     SC_Utils_Ex::sfIsSuccess($objSess);
     // ファイル管理クラス
     $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR);
     // ファイル情報の初期化
     $this->lfInitFile();
     // パラメータ管理クラス
     $this->objFormParam = new SC_FormParam();
     // パラメータ情報の初期化
     $this->lfInitParam();
     $colmax = $this->objFormParam->getCount();
     $this->objFormParam->setHtmlDispNameArray();
     $this->arrTitle = $this->objFormParam->getHtmlDispNameArray();
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     switch ($_POST['mode']) {
         case 'csv_upload':
             $err = false;
             // エラーチェック
             $arrErr['csv_file'] = $this->objUpFile->makeTempFile('csv_file');
             if ($arrErr['css_file'] == "") {
                 $arrErr = $this->objUpFile->checkEXISTS();
             }
             // 実行時間を制限しない
             set_time_limit(0);
             // 出力をバッファリングしない(==日本語自動変換もしない)
             ob_end_clean();
             // IEのために256バイト空文字出力
             echo str_pad('', 256);
             if (empty($arrErr['csv_file'])) {
                 // 一時ファイル名の取得
                 $filepath = $this->objUpFile->getTempFilePath('csv_file');
                 // エンコード
                 $enc_filepath = SC_Utils_Ex::sfEncodeFile($filepath, CHAR_CODE, CSV_TEMP_DIR);
                 // レコード数を得る
                 $rec_count = $this->lfCSVRecordCount($enc_filepath);
                 $fp = fopen($enc_filepath, "r");
                 $line = 0;
                 // 行数
                 $regist = 0;
                 // 登録数
                 $objQuery = new SC_Query();
                 $objQuery->begin();
                 echo "■ CSV登録進捗状況 <br/><br/>\n";
                 while (!feof($fp) && !$err) {
                     $arrCSV = fgetcsv($fp, CSV_LINE_MAX);
                     // 行カウント
                     $line++;
                     if ($line <= 1) {
                         continue;
                     }
                     // 項目数カウント
                     $max = count($arrCSV);
                     // 項目数が1以下の場合は無視する
                     if ($max <= 1) {
                         continue;
                     }
                     // 項目数チェック
                     if ($max != $colmax) {
                         echo "※ 項目数が" . $max . "個検出されました。項目数は" . $colmax . "個になります。</br>\n";
                         $err = true;
                     } else {
                         // シーケンス配列を格納する。
                         $this->objFormParam->setParam($arrCSV, true);
                         $arrRet = $this->objFormParam->getHashArray();
                         $this->objFormParam->setParam($arrRet);
                         // 入力値の変換
                         $this->objFormParam->convParam();
                         // <br>なしでエラー取得する。
                         $arrCSVErr = $this->lfCheckError();
                     }
                     // 入力エラーチェック
                     if (count($arrCSVErr) > 0) {
                         echo "<font color=\"red\">■" . $line . "行目でエラーが発生しました。</font></br>\n";
                         foreach ($arrCSVErr as $val) {
                             $this->printError($val);
                         }
                         $err = true;
                     }
                     if (!$err) {
                         $this->lfRegistProduct($objQuery, $line);
                         $regist++;
                     }
                     $arrParam = $this->objFormParam->getHashArray();
                     if (!$err) {
                         echo $line . " / " . $rec_count . "行目 (カテゴリID:" . $arrParam['category_id'] . " / カテゴリ名:" . $arrParam['category_name'] . ")\n<br />";
                     }
                     flush();
                 }
                 fclose($fp);
                 if (!$err) {
                     $objQuery->commit();
                     echo "■" . $regist . "件のレコードを登録しました。";
                     // カテゴリ件数カウント関数の実行
                     $objDb->sfCategory_Count($objQuery);
                 } else {
                     $objQuery->rollback();
                 }
             } else {
                 foreach ($arrErr as $val) {
                     $this->printError($val);
                 }
             }
             echo "<br/><a href=\"javascript:window.close()\">→閉じる</a>";
             flush();
             exit;
             break;
         default:
             break;
     }
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
예제 #2
0
    /**
     * カテゴリ数の登録を行う.
     *
     *
     * @param  SC_Query $objQuery           SC_Query インスタンス
     * @param  boolean  $is_force_all_count 全カテゴリの集計を強制する場合 true
     * @return void
     */
    public function sfCountCategory($objQuery = NULL, $is_force_all_count = false)
    {
        $objProduct = new SC_Product_Ex();
        if ($objQuery == NULL) {
            $objQuery =& SC_Query_Ex::getSingletonInstance();
        }
        $is_out_trans = false;
        if (!$objQuery->inTransaction()) {
            $objQuery->begin();
            $is_out_trans = true;
        }
        //共通のfrom/where文の構築
        $sql_where = SC_Product_Ex::getProductDispConditions('alldtl');
        // 在庫無し商品の非表示
        if (NOSTOCK_HIDDEN) {
            $where_products_class = '(stock >= 1 OR stock_unlimited = 1)';
            $from = $objProduct->alldtlSQL($where_products_class);
        } else {
            $from = 'dtb_products as alldtl';
        }
        //dtb_category_countの構成
        // 各カテゴリに所属する商品の数を集計。集計対象には子カテゴリを含まない。
        //まずテーブル内容の元を取得
        if (!$is_force_all_count) {
            $arrCategoryCountOld = $objQuery->select('category_id,product_count', 'dtb_category_count');
        } else {
            $arrCategoryCountOld = array();
        }
        //各カテゴリ内の商品数を数えて取得
        $sql = <<<__EOS__
            SELECT T1.category_id, count(T2.category_id) as product_count
            FROM dtb_category AS T1
                LEFT JOIN dtb_product_categories AS T2
                    ON T1.category_id = T2.category_id
                LEFT JOIN {$from}
                    ON T2.product_id = alldtl.product_id
            WHERE {$sql_where}
            GROUP BY T1.category_id, T2.category_id
__EOS__;
        $arrCategoryCountNew = $objQuery->getAll($sql);
        // 各カテゴリに所属する商品の数を集計。集計対象には子カテゴリを「含む」。
        //差分を取得して、更新対象カテゴリだけを確認する。
        //各カテゴリ毎のデータ値において以前との差を見る
        //古いデータの構造入れ替え
        $arrOld = array();
        foreach ($arrCategoryCountOld as $item) {
            $arrOld[$item['category_id']] = $item['product_count'];
        }
        //新しいデータの構造入れ替え
        $arrNew = array();
        foreach ($arrCategoryCountNew as $item) {
            $arrNew[$item['category_id']] = $item['product_count'];
        }
        unset($arrCategoryCountOld);
        unset($arrCategoryCountNew);
        $arrDiffCategory_id = array();
        //新しいカテゴリ一覧から見て商品数が異なるデータが無いか確認
        foreach ($arrNew as $cid => $count) {
            if ($arrOld[$cid] != $count) {
                $arrDiffCategory_id[] = $cid;
            }
        }
        //削除カテゴリを想定して、古いカテゴリ一覧から見て商品数が異なるデータが無いか確認。
        foreach ($arrOld as $cid => $count) {
            if ($arrNew[$cid] != $count && $count > 0) {
                $arrDiffCategory_id[] = $cid;
            }
        }
        //対象IDが無ければ終了
        if (count($arrDiffCategory_id) == 0) {
            if ($is_out_trans) {
                $objQuery->commit();
            }
            return;
        }
        //差分対象カテゴリIDの重複を除去
        $arrDiffCategory_id = array_unique($arrDiffCategory_id);
        //dtb_category_countの更新 差分のあったカテゴリだけ更新する。
        foreach ($arrDiffCategory_id as $cid) {
            $sqlval = array();
            $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
            $sqlval['product_count'] = (string) $arrNew[$cid];
            if ($sqlval['product_count'] == '') {
                $sqlval['product_count'] = (string) '0';
            }
            if (isset($arrOld[$cid])) {
                $objQuery->update('dtb_category_count', $sqlval, 'category_id = ?', array($cid));
            } else {
                if ($is_force_all_count) {
                    $ret = $objQuery->update('dtb_category_count', $sqlval, 'category_id = ?', array($cid));
                    if ($ret > 0) {
                        continue;
                    }
                }
                $sqlval['category_id'] = $cid;
                $objQuery->insert('dtb_category_count', $sqlval);
            }
        }
        unset($arrOld);
        unset($arrNew);
        //差分があったIDとその親カテゴリIDのリストを取得する
        $arrTgtCategory_id = array();
        foreach ($arrDiffCategory_id as $parent_category_id) {
            $arrTgtCategory_id[] = $parent_category_id;
            $arrParentID = $this->sfGetParents('dtb_category', 'parent_category_id', 'category_id', $parent_category_id);
            $arrTgtCategory_id = array_unique(array_merge($arrTgtCategory_id, $arrParentID));
        }
        unset($arrDiffCategory_id);
        //dtb_category_total_count 集計処理開始
        //更新対象カテゴリIDだけ集計しなおす。
        $arrUpdateData = array();
        $where_products_class = '';
        if (NOSTOCK_HIDDEN) {
            $where_products_class .= '(stock >= 1 OR stock_unlimited = 1)';
        }
        $from = $objProduct->alldtlSQL($where_products_class);
        foreach ($arrTgtCategory_id as $category_id) {
            $arrWhereVal = array();
            list($tmp_where, $arrTmpVal) = $this->sfGetCatWhere($category_id);
            if ($tmp_where != '') {
                $sql_where_product_ids = 'product_id IN (SELECT product_id FROM dtb_product_categories WHERE ' . $tmp_where . ')';
                $arrWhereVal = $arrTmpVal;
            } else {
                $sql_where_product_ids = '0<>0';
                // 一致させない
            }
            $where = "({$sql_where}) AND ({$sql_where_product_ids})";
            $arrUpdateData[$category_id] = $objQuery->count($from, $where, $arrWhereVal);
        }
        unset($arrTgtCategory_id);
        // 更新対象だけを更新。
        foreach ($arrUpdateData as $cid => $count) {
            $sqlval = array();
            $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
            $sqlval['product_count'] = $count;
            if ($sqlval['product_count'] == '') {
                $sqlval['product_count'] = (string) '0';
            }
            $ret = $objQuery->update('dtb_category_total_count', $sqlval, 'category_id = ?', array($cid));
            if (!$ret) {
                $sqlval['category_id'] = $cid;
                $objQuery->insert('dtb_category_total_count', $sqlval);
            }
        }
        // トランザクション終了処理
        if ($is_out_trans) {
            $objQuery->commit();
        }
    }
 function lfInsertClass()
 {
     $objQuery = new SC_Query();
     $objQuery->begin();
     // 親規格IDの存在チェック
     $where = "del_flg <> 1 AND class_id = ?";
     $ret = $objQuery->get("dtb_class", "class_id", $where, array($_POST['class_id']));
     if ($ret != "") {
         // INSERTする値を作成する。
         $sqlval['name'] = $_POST['name'];
         $sqlval['class_id'] = $_POST['class_id'];
         $sqlval['creator_id'] = $_SESSION['member_id'];
         $sqlval['rank'] = $objQuery->max("dtb_classcategory", "rank", $where, array($_POST['class_id'])) + 1;
         $sqlval['create_date'] = "now()";
         $sqlval['update_date'] = "now()";
         // INSERTの実行
         $ret = $objQuery->insert("dtb_classcategory", $sqlval);
     }
     $objQuery->commit();
     return $ret;
 }
예제 #4
0
<?php

/*
 * This file is part of EC-CUBE
 *
 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
 *
 * http://www.lockon.co.jp/
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
require_once "../../require.php";
$objQuery = new SC_Query();
$objQuery->begin();
$arrCustomerMail = $objQuery->getAll("\nUPDATE dtb_customer\nSET mailmaga_flg = (\nSELECT mail_flag\nFROM dtb_customer_mail\nWHERE dtb_customer.email = dtb_customer_mail.email\n)");
$objQuery->commit();
echo "正常に移行が完了致しました。";
 function lfRegistProduct($arrList)
 {
     $objQuery = new SC_Query();
     $objDb = new SC_Helper_DB_Ex();
     $objQuery->begin();
     // 配列の添字を定義
     $checkArray = array("name", "status", "product_flag", "main_list_comment", "main_comment", "point_rate", "deliv_fee", "comment1", "comment2", "comment3", "comment4", "comment5", "comment6", "main_list_comment", "sale_limit", "sale_unlimited", "deliv_date_id", "note");
     $arrList = SC_Utils_Ex::arrayDefineIndexes($arrList, $checkArray);
     // INSERTする値を作成する。
     $sqlval['name'] = $arrList['name'];
     $sqlval['status'] = $arrList['status'];
     $sqlval['product_flag'] = $arrList['product_flag'];
     $sqlval['main_list_comment'] = $arrList['main_list_comment'];
     $sqlval['main_comment'] = $arrList['main_comment'];
     $sqlval['point_rate'] = $arrList['point_rate'];
     $sqlval['deliv_fee'] = $arrList['deliv_fee'];
     $sqlval['comment1'] = $arrList['comment1'];
     $sqlval['comment2'] = $arrList['comment2'];
     $sqlval['comment3'] = $arrList['comment3'];
     $sqlval['comment4'] = $arrList['comment4'];
     $sqlval['comment5'] = $arrList['comment5'];
     $sqlval['comment6'] = $arrList['comment6'];
     $sqlval['main_list_comment'] = $arrList['main_list_comment'];
     $sqlval['sale_limit'] = $arrList['sale_limit'];
     $sqlval['sale_unlimited'] = $arrList['sale_unlimited'];
     $sqlval['deliv_date_id'] = $arrList['deliv_date_id'];
     $sqlval['note'] = $arrList['note'];
     $sqlval['update_date'] = "Now()";
     $sqlval['creator_id'] = $_SESSION['member_id'];
     $arrRet = $this->objUpFile->getDBFileList();
     $sqlval = array_merge($sqlval, $arrRet);
     $arrList['category_id'] = unserialize($arrList['category_id']);
     for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
         $sqlval['sub_title' . $cnt] = $arrList['sub_title' . $cnt];
         $sqlval['sub_comment' . $cnt] = $arrList['sub_comment' . $cnt];
     }
     if ($arrList['product_id'] == "") {
         // product_id 取得(PostgreSQLの場合)
         if (DB_TYPE == 'pgsql') {
             $product_id = $objQuery->nextval("dtb_products", "product_id");
             $sqlval['product_id'] = $product_id;
         }
         // INSERTの実行
         $sqlval['create_date'] = "Now()";
         $objQuery->insert("dtb_products", $sqlval);
         // product_id 取得(MySQLの場合)
         if (DB_TYPE == 'mysql') {
             $product_id = $objQuery->nextval("dtb_products", "product_id");
         }
         // カテゴリを更新
         $objDb->updateProductCategories($arrList['category_id'], $product_id);
         // コピー商品の場合には規格もコピーする
         if ($_POST["copy_product_id"] != "" and SC_Utils_Ex::sfIsInt($_POST["copy_product_id"])) {
             if ($this->tpl_nonclass) {
                 //規格なしの場合、コピーは価格等の入力が発生しているため、その内容で追加登録を行う
                 $arrList['product_id'] = $product_id;
                 $this->lfCopyProductClass($arrList, $objQuery);
             } else {
                 //規格がある場合のコピーは複製元の内容で追加登録を行う
                 // dtb_products_class のカラムを取得
                 $dbFactory = SC_DB_DBFactory_Ex::getInstance();
                 $arrColList = $dbFactory->sfGetColumnList("dtb_products_class", $objQuery);
                 $arrColList_tmp = array_flip($arrColList);
                 // コピーしない列
                 unset($arrColList[$arrColList_tmp["product_class_id"]]);
                 //規格ID
                 unset($arrColList[$arrColList_tmp["product_id"]]);
                 //商品ID
                 unset($arrColList[$arrColList_tmp["create_date"]]);
                 $col = SC_Utils_Ex::sfGetCommaList($arrColList);
                 $objQuery->query("INSERT INTO dtb_products_class (product_id, create_date, " . $col . ") SELECT ?, now(), " . $col . " FROM dtb_products_class WHERE product_id = ? ORDER BY product_class_id", array($product_id, $_POST["copy_product_id"]));
             }
         }
     } else {
         $product_id = $arrList['product_id'];
         // 削除要求のあった既存ファイルの削除
         $arrRet = $this->lfGetProduct($arrList['product_id']);
         $this->objUpFile->deleteDBFile($arrRet);
         // UPDATEの実行
         $where = "product_id = ?";
         $objQuery->update("dtb_products", $sqlval, $where, array($product_id));
         // カテゴリを更新
         $objDb->updateProductCategories($arrList['category_id'], $product_id);
     }
     //商品登録の時は規格を生成する。複製の場合は規格も複製されるのでこの処理は不要。
     if ($_POST["copy_product_id"] == "") {
         // 規格登録
         SC_Utils_Ex::sfInsertProductClass($objQuery, $arrList, $product_id, $arrList['product_class_id']);
     }
     // おすすめ商品登録
     $this->lfInsertRecommendProducts($objQuery, $arrList, $product_id);
     $objQuery->commit();
     return $product_id;
 }
 function lfInsertCat($parent_category_id)
 {
     $objQuery = new SC_Query();
     $objQuery->begin();
     // トランザクションの開始
     if ($parent_category_id == 0) {
         // ROOT階層で最大のランクを取得する。
         $where = "parent_category_id = ?";
         $rank = $objQuery->max("dtb_category", "rank", $where, array($parent_category_id)) + 1;
     } else {
         // 親のランクを自分のランクとする。
         $where = "category_id = ?";
         $rank = $objQuery->get("dtb_category", "rank", $where, array($parent_category_id));
         // 追加レコードのランク以上のレコードを一つあげる。
         $sqlup = "UPDATE dtb_category SET rank = (rank + 1) WHERE rank >= ?";
         $objQuery->exec($sqlup, array($rank));
     }
     $where = "category_id = ?";
     // 自分のレベルを取得する(親のレベル + 1)
     $level = $objQuery->get("dtb_category", "level", $where, array($parent_category_id)) + 1;
     // 入力データを渡す。
     $sqlval = $this->objFormParam->getHashArray();
     $sqlval['create_date'] = "Now()";
     $sqlval['update_date'] = "Now()";
     $sqlval['creator_id'] = $_SESSION['member_id'];
     $sqlval['parent_category_id'] = $parent_category_id;
     $sqlval['rank'] = $rank;
     $sqlval['level'] = $level;
     // INSERTの実行
     $objQuery->insert("dtb_category", $sqlval);
     $objQuery->commit();
     // トランザクションの終了
 }
예제 #7
0
 function lfRegistRecommendData($array, $arrRegistColumn)
 {
     // 仮登録
     foreach ($arrRegistColumn as $data) {
         if (strlen($array[$data["column"]]) > 0) {
             $arrRegist[$data["column"]] = $array[$data["column"]];
         }
     }
     $arrRegist['create_date'] = 'now()';
     $arrRegist['update_date'] = 'now()';
     $arrRegist['creator_id'] = '0';
     //-- 登録実行
     $objQuery = new SC_Query();
     $objQuery->begin();
     $objQuery->insert("dtb_review", $arrRegist);
     $objQuery->commit();
 }
 function lfRegistNewData()
 {
     $objQuery = new SC_Query();
     $objQuery->begin();
     // 入力データを渡す。
     $arrRet = $this->objFormParam->getHashArray();
     foreach ($arrRet as $key => $val) {
         // 配列は登録しない
         if (!is_array($val)) {
             $sqlval[$key] = $val;
         }
     }
     // postgresqlとmysqlとで処理を分ける
     if (DB_TYPE == "pgsql") {
         $order_id = $objQuery->nextval("dtb_order", "order_id");
     } elseif (DB_TYPE == "mysql") {
         $order_id = $objQuery->get_auto_increment("dtb_order");
     }
     $sqlval['order_id'] = $order_id;
     $sqlval['create_date'] = "Now()";
     // 注文ステータス:指定が無ければ新規受付に設定
     if ($sqlval["status"] == "") {
         $sqlval['status'] = '1';
     }
     // customer_id
     if ($sqlval["customer_id"] == "") {
         $sqlval['customer_id'] = '0';
     }
     unset($sqlval['total_point']);
     unset($sqlval['point']);
     $where = "order_id = ?";
     // 受注ステータスの判定
     if ($sqlval['status'] == ODERSTATUS_COMMIT) {
         // 受注テーブルの発送済み日を更新する
         $sqlval['commit_date'] = "Now()";
     }
     // 受注テーブルの登録
     $objQuery->insert("dtb_order", $sqlval);
     $sql = "";
     $sql .= " UPDATE";
     $sql .= "     dtb_order";
     $sql .= " SET";
     $sql .= "     payment_method = (SELECT payment_method FROM dtb_payment WHERE payment_id = ?)";
     $sql .= "     ,deliv_time = (SELECT deliv_time FROM dtb_delivtime WHERE time_id = ? AND deliv_id = (SELECT deliv_id FROM dtb_payment WHERE payment_id = ? ))";
     $sql .= " WHERE order_id = ?";
     if ($arrRet['deliv_time_id'] == "") {
         $deliv_time_id = 0;
     } else {
         $deliv_time_id = $arrRet['deliv_time_id'];
     }
     $arrUpdData = array($arrRet['payment_id'], $deliv_time_id, $arrRet['payment_id'], $order_id);
     $objQuery->query($sql, $arrUpdData);
     // 受注詳細データの更新
     $arrDetail = $this->objFormParam->getSwapArray(array("product_id", "product_code", "product_name", "price", "quantity", "point_rate", "classcategory_id1", "classcategory_id2", "classcategory_name1", "classcategory_name2"));
     $objQuery->delete("dtb_order_detail", $where, array($order_id));
     $max = count($arrDetail);
     for ($i = 0; $i < $max; $i++) {
         $sqlval = array();
         $sqlval['order_id'] = $order_id;
         $sqlval['product_id'] = $arrDetail[$i]['product_id'];
         $sqlval['product_code'] = $arrDetail[$i]['product_code'];
         $sqlval['product_name'] = $arrDetail[$i]['product_name'];
         $sqlval['price'] = $arrDetail[$i]['price'];
         $sqlval['quantity'] = $arrDetail[$i]['quantity'];
         $sqlval['point_rate'] = $arrDetail[$i]['point_rate'];
         $sqlval['classcategory_id1'] = $arrDetail[$i]['classcategory_id1'];
         $sqlval['classcategory_id2'] = $arrDetail[$i]['classcategory_id2'];
         $sqlval['classcategory_name1'] = $arrDetail[$i]['classcategory_name1'];
         $sqlval['classcategory_name2'] = $arrDetail[$i]['classcategory_name2'];
         $objQuery->insert("dtb_order_detail", $sqlval);
     }
     $objQuery->commit();
     return $order_id;
 }
예제 #9
0
 function lfRegistFavoriteProduct($customer_id, $product_id)
 {
     $objQuery = new SC_Query();
     $objConn = new SC_DbConn();
     $count = $objConn->getOne("SELECT COUNT(*) FROM dtb_customer_favorite_products WHERE customer_id = ? AND product_id = ?", array($customer_id, $product_id));
     if ($count == 0) {
         $sqlval['customer_id'] = $customer_id;
         $sqlval['product_id'] = $product_id;
         $sqlval['update_date'] = "now()";
         $sqlval['create_date'] = "now()";
         $objQuery->begin();
         $objQuery->insert('dtb_customer_favorite_products', $sqlval);
         $objQuery->commit();
     }
 }
 /**
  * 規格データをコピーする
  *
  * @param  array   $arrList  フォーム入力パラメーター配列
  * @param  SC_Query  $objQuery SC_Queryインスタンス
  * @return boolean エラーフラグ
  */
 public function lfCopyProductClass($arrList, &$objQuery)
 {
     // 複製元のdtb_products_classを取得(規格なしのため、1件のみの取得)
     $col = '*';
     $table = 'dtb_products_class';
     $where = 'product_id = ?';
     $arrProductClass = $objQuery->select($col, $table, $where, array($arrList['copy_product_id']));
     //トランザクション開始
     $objQuery->begin();
     $err_flag = false;
     //非編集項目は複製、編集項目は上書きして登録
     foreach ($arrProductClass as $records) {
         foreach ($records as $key => $value) {
             if (isset($arrList[$key])) {
                 switch ($key) {
                     case 'stock_unlimited':
                         $records[$key] = (int) $arrList[$key];
                         break;
                     default:
                         $records[$key] = $arrList[$key];
                         break;
                 }
             }
         }
         $records['product_class_id'] = $objQuery->nextVal('dtb_products_class_product_class_id');
         $records['update_date'] = 'CURRENT_TIMESTAMP';
         $records['create_date'] = 'CURRENT_TIMESTAMP';
         $objQuery->insert($table, $records);
         //エラー発生時は中断
         if ($objQuery->isError()) {
             $err_flag = true;
             continue;
         }
     }
     //トランザクション終了
     if ($err_flag) {
         $objQuery->rollback();
     } else {
         $objQuery->commit();
     }
     return !$err_flag;
 }
예제 #11
0
 /**
  * ランクを含むレコードを削除する.
  *
  * レコードごと削除する場合は、$deleteをtrueにする
  *
  * @param string $table テーブル名
  * @param string $colname カラム名
  * @param string|integer $id テーブルのキー
  * @param string $andwhere SQL の AND 条件である WHERE 句
  * @param bool $delete レコードごと削除する場合 true,
  *                     レコードごと削除しない場合 false
  * @return void
  */
 function sfDeleteRankRecord($table, $colname, $id, $andwhere = "", $delete = false)
 {
     $objQuery = new SC_Query();
     $objQuery->begin();
     // 削除レコードのランクを取得する。
     $where = "{$colname} = ?";
     if ($andwhere != "") {
         $where .= " AND {$andwhere}";
     }
     $rank = $objQuery->get($table, "rank", $where, array($id));
     if (!$delete) {
         // ランクを最下位にする、DELフラグON
         $sqlup = "UPDATE {$table} SET rank = 0, del_flg = 1 ";
         $sqlup .= "WHERE {$colname} = ?";
         // UPDATEの実行
         $objQuery->exec($sqlup, array($id));
     } else {
         $objQuery->delete($table, "{$colname} = ?", array($id));
     }
     // 追加レコードのランクより上のレコードを一つずらす。
     $where = "rank > ?";
     if ($andwhere != "") {
         $where .= " AND {$andwhere}";
     }
     $sqlup = "UPDATE {$table} SET rank = (rank - 1) WHERE {$where}";
     $objQuery->exec($sqlup, array($rank));
     $objQuery->commit();
 }
예제 #12
0
 function lfRegistData($array)
 {
     $objQuery = new SC_Query();
     $this->arrInfo;
     do {
         $secret = SC_Utils_Ex::sfGetUniqRandomId("r");
     } while (($result = $objQuery->getOne("SELECT COUNT(*) FROM dtb_customer WHERE secret_key = ?", array($secret))) != 0);
     $sql = "SELECT email FROM dtb_customer WHERE secret_key = ? AND status = 1";
     $email = $objQuery->getOne($sql, array($array["id"]));
     $objQuery->begin();
     $arrRegist["secret_key"] = $secret;
     // 本登録ID発行
     $arrRegist["status"] = 2;
     $arrRegist["update_date"] = "NOW()";
     $where = "secret_key = ? AND status = 1";
     $arrRet = $objQuery->select("point", "dtb_customer", $where, array($array["id"]));
     // 会員登録時の加算ポイント(購入時会員登録の場合は、ポイント加算)
     $arrRegist['point'] = $arrRet[0]['point'] + $arrInfo['welcome_point'];
     $objQuery->update("dtb_customer", $arrRegist, $where, array($array["id"]));
     /* 購入時の自動会員登録は行わないためDEL
        // 購入時登録の場合、その回の購入を会員購入とみなす。
        // 会員情報の読み込み
        $where1 = "secret_key = ? AND status = 2";
        $customer = $objQuery->select("*", "dtb_customer", $where1, array($secret));
        // 初回購入情報の読み込み
        $order_temp_id = $objQuery->get("dtb_order_temp", "order_temp_id");
        // 購入情報の更新
        if ($order_temp_id != null) {
            $arrCustomer['customer_id'] = $customer[0]['customer_id'];
            $where3 = "order_temp_id = ?";
            $objQuery->update("dtb_order_temp", $arrCustomer, $where3, array($order_temp_id));
            $objQuery->update("dtb_order", $arrCustomer, $where3, array($order_temp_id));
        }
        */
     $sql = "SELECT mailmaga_flg FROM dtb_customer WHERE email = ?";
     $result = $objQuery->getOne($sql, array($email));
     switch ($result) {
         // 仮HTML
         case '4':
             $arrRegistMail["mailmaga_flg"] = 1;
             break;
             // 仮TEXT
         // 仮TEXT
         case '5':
             $arrRegistMail["mailmaga_flg"] = 2;
             break;
             // 仮なし
         // 仮なし
         case '6':
             $arrRegistMail["mailmaga_flg"] = 3;
             break;
         default:
             $arrRegistMail["mailmaga_flg"] = $result;
             break;
     }
     $objQuery->update("dtb_customer", $arrRegistMail, "email = " . SC_Utils_Ex::sfQuoteSmart($email) . " AND del_flg = 0");
     $objQuery->commit();
     return $secret;
     // 本登録IDを返す
 }
 function lfRestore($bkup_name)
 {
     $objQuery = new SC_Query("", false);
     $csv_data = "";
     $err = true;
     $bkup_dir = $this->bkup_dir . $bkup_name . "/";
     //バックアップフォルダに移動する
     chdir($this->bkup_dir);
     //圧縮フラグTRUEはgzip解凍をおこなう
     $tar = new Archive_Tar($bkup_name . ".tar.gz", TRUE);
     //指定されたフォルダ内に解凍する
     $err = $tar->extract("./");
     // 無事解凍できれば、リストアを行う
     if ($err) {
         // トランザクション開始
         $objQuery->begin();
         // DBをクリア
         $err = $this->lfDeleteAll($objQuery);
         // INSERT実行
         if ($err) {
             $err = $this->lfExeInsertSQL($objQuery, $bkup_dir . "bkup_data.csv");
         }
         // 自動採番の値をセット
         if ($err) {
             $this->lfSetAutoInc($objQuery, $bkup_dir . "autoinc_data.csv");
         }
         // 各種ファイルのコピー
         /**
                     if ($err) {
                         // 画像のコピー
                         $image_dir = $bkup_dir . "save_image/";
                         $copy_mess = "";
                         $copy_mess = SC_Utils_Ex::sfCopyDir($image_dir, "../../upload/save_image/", $copy_mess, true);
         
                         // テンプレートのコピー
                         $tmp_dir = $bkup_dir . "templates/";
                         $copy_mess = "";
                         $copy_mess = SC_Utils_Ex::sfCopyDir($tmp_dir, "../../user_data/templates/", $copy_mess, true);
         
                         // インクルードファイルのコピー
                         $inc_dir = $bkup_dir . "include/";
                         $copy_mess = "";
                         $copy_mess = SC_Utils_Ex::sfCopyDir($inc_dir, "../../user_data/include/", $copy_mess, true);
         
                         // CSSのコピー
                         $css_dir = $bkup_dir . "css/";
                         $copy_mess = "";
                         $copy_mess = SC_Utils_Ex::sfCopyDir($css_dir, "../../user_data/css/", $copy_mess, true);
         
                         // バックアップデータの削除
                         SC_Utils_Ex::sfDelFile($bkup_dir);
                     }**/
         // リストア成功ならコミット失敗ならロールバック
         if ($err) {
             $objQuery->commit();
             $this->restore_msg = "リストア終了しました。";
             $this->restore_err = true;
         } else {
             $objQuery->rollback();
             $this->restore_msg = "リストアに失敗しました。";
             $this->restore_name = $bkup_name;
             $this->restore_err = false;
         }
     }
 }
 /**
  * Page のプロセス(モバイル).
  *
  * @return void
  */
 function mobileProcess()
 {
     $conn = new SC_DBConn();
     $objView = new SC_MobileView();
     $this->objSiteSess = new SC_SiteSession();
     $this->objCartSess = new SC_CartSession();
     $objSiteInfo = $objView->objSiteInfo;
     $this->arrInfo = $objSiteInfo->data;
     $this->objCustomer = new SC_Customer();
     $mailHelper = new SC_Helper_Mail_Ex();
     // 前のページで正しく登録手続きが行われたか判定
     SC_Utils_Ex::sfIsPrePage($this->objSiteSess, true);
     // ユーザユニークIDの取得と購入状態の正当性をチェック
     $uniqid = SC_Utils_Ex::sfCheckNormalAccess($this->objSiteSess, $this->objCartSess);
     if ($uniqid != "") {
         // 完了処理
         $objQuery = new SC_Query();
         $objQuery->begin();
         $order_id = $this->lfDoComplete($objQuery, $uniqid);
         $objQuery->commit();
         // セッションに保管されている情報を更新する
         $this->objCustomer->updateSession();
         // 完了メール送信
         if ($order_id != "") {
             $mailHelper->sfSendOrderMail($order_id, '2');
         }
         //その他情報の取得
         $other_data = $objQuery->get("dtb_order", "memo02", "order_id = ? ", array($order_id));
         if ($other_data != "") {
             $arrOther = unserialize($other_data);
             // データを編集
             foreach ($arrOther as $key => $val) {
                 // URLの場合にはリンクつきで表示させる
                 if (preg_match('/^(https?|ftp)(:\\/\\/[-_.!~*\'()a-zA-Z0-9;\\/?:\\@&=+\\$,%#]+)$/', $val["value"])) {
                     $arrOther[$key]["value"] = "<a href='" . $val["value"] . "'>" . $val["value"] . "</a>";
                 }
             }
             $this->arrOther = $arrOther;
         }
         // アフィリエイト用コンバージョンタグの設定
         $this->tpl_conv_page = AFF_SHOPPING_COMPLETE;
         $this->tpl_aff_option = "order_id={$order_id}";
         //合計価格の取得
         $total = $objQuery->get("dtb_order", "total", "order_id = ? ", array($order_id));
         if ($total != "") {
             $this->tpl_aff_option .= "|total={$total}";
         }
         // TS連携モジュールの実行
         if (function_exists('sfTSRequest')) {
             sfTSRequest($order_id);
         }
     }
     $objView->assignobj($this);
     $objView->display(SITE_FRAME);
 }
 /**
  * 配送情報を登録する
  *
  * @return $deliv_id 
  */
 function lfRegistData()
 {
     $arrRet = $this->objFormParam->getHashArray();
     $objQuery = new SC_Query();
     $objQuery->begin();
     // 入力データを渡す。
     $sqlval['name'] = $arrRet['name'];
     $sqlval['service_name'] = $arrRet['service_name'];
     $sqlval['confirm_url'] = $arrRet['confirm_url'];
     $sqlval['creator_id'] = $_SESSION['member_id'];
     $sqlval['update_date'] = 'Now()';
     // deliv_id が決まっていた場合
     if ($_POST['deliv_id'] != "") {
         $deliv_id = $_POST['deliv_id'];
         $where = "deliv_id = ?";
         $objQuery->update("dtb_deliv", $sqlval, $where, array($deliv_id));
         // 配送時間の登録
         $table = "dtb_delivtime";
         $where = "deliv_id = ? AND time_id = ?";
         for ($cnt = 1; $cnt <= DELIVTIME_MAX; $cnt++) {
             $sqlval = array();
             $keyname = "deliv_time" . $cnt;
             $arrval = array($deliv_id, $cnt * $deliv_id);
             // 既存データの有無を確認
             $curData = $objQuery->select("*", $table, $where, $arrval);
             if (strcmp($arrRet[$keyname], "") != 0) {
                 $sqlval['deliv_time'] = $arrRet[$keyname];
                 // 入力が空ではなく、DBに情報があれば更新
                 if (count($curData)) {
                     $objQuery->update($table, $sqlval, $where, $arrval);
                 } else {
                     $sqlval['deliv_id'] = $deliv_id;
                     $sqlval['time_id'] = $cnt * $deliv_id;
                     $objQuery->insert($table, $sqlval);
                 }
             } else {
                 if (count($curData)) {
                     $objQuery->delete($table, $where, $arrval);
                 }
             }
         }
         // 配送料の登録
         if (INPUT_DELIV_FEE) {
             for ($cnt = 1; $cnt <= DELIVFEE_MAX; $cnt++) {
                 $keyname = "fee" . $cnt;
                 if (strcmp($arrRet[$keyname], "") != 0) {
                     $sqlval = array('fee' => $arrRet[$keyname]);
                     $objQuery->update("dtb_delivfee", $sqlval, "deliv_id = ? AND pref = ?", array($deliv_id, $cnt));
                 }
             }
         }
     } else {
         // 登録する配送業者IDの取得
         if (DB_TYPE == "pgsql") {
             $deliv_id = $objQuery->nextval('dtb_deliv', 'deliv_id');
             $sqlval['deliv_id'] = $deliv_id;
         }
         $sqlval['rank'] = $objQuery->max("dtb_deliv", "rank") + 1;
         $sqlval['create_date'] = 'Now()';
         // INSERTの実行
         $objQuery->insert("dtb_deliv", $sqlval);
         if (DB_TYPE == "mysql") {
             $deliv_id = $objQuery->nextval('dtb_deliv', 'deliv_id');
         }
         $sqlval = array();
         // 配送時間の設定
         for ($cnt = 1; $cnt <= DELIVTIME_MAX; $cnt++) {
             $keyname = "deliv_time{$cnt}";
             if ($arrRet[$keyname] != "") {
                 $sqlval['deliv_id'] = $deliv_id;
                 $sqlval['time_id'] = $cnt * $deliv_id;
                 $sqlval['deliv_time'] = $arrRet[$keyname];
                 // INSERTの実行
                 $objQuery->insert("dtb_delivtime", $sqlval);
             }
         }
         if (INPUT_DELIV_FEE) {
             $sqlval = array();
             // 配送料金の設定
             for ($cnt = 1; $cnt <= DELIVFEE_MAX; $cnt++) {
                 $keyname = "fee{$cnt}";
                 if ($arrRet[$keyname] != "") {
                     $sqlval['deliv_id'] = $deliv_id;
                     $sqlval['fee'] = $arrRet[$keyname];
                     $sqlval['pref'] = $cnt;
                     // INSERTの実行
                     $objQuery->insert("dtb_delivfee", $sqlval);
                 }
             }
         }
     }
     $objQuery->commit();
     return $deliv_id;
 }
 function lfInsertProductClass($arrList, $product_id)
 {
     $objQuery = new SC_Query();
     $objQuery->begin();
     // 既存規格の削除
     $where = "product_id = ?";
     $objQuery->delete("dtb_products_class", $where, array($product_id));
     $cnt = 1;
     // すべての規格を登録する。
     while ($arrList["classcategory_id1:" . $cnt] != "") {
         if ($arrList["check:" . $cnt] == 1) {
             $sqlval = array();
             $sqlval['product_id'] = $product_id;
             $sqlval['classcategory_id1'] = $arrList["classcategory_id1:" . $cnt];
             $sqlval['classcategory_id2'] = $arrList["classcategory_id2:" . $cnt];
             if (strlen($arrList["product_class_id:" . $cnt]) > 0) {
                 $sqlval['product_class_id'] = $arrList["product_class_id:" . $cnt];
             }
             $sqlval['product_code'] = $arrList["product_code:" . $cnt];
             $sqlval['stock'] = $arrList["stock:" . $cnt];
             $sqlval['stock_unlimited'] = $arrList["stock_unlimited:" . $cnt];
             $sqlval['price01'] = $arrList['price01:' . $cnt];
             $sqlval['price02'] = $arrList['price02:' . $cnt];
             $sqlval['creator_id'] = $_SESSION['member_id'];
             $sqlval['create_date'] = "now()";
             $sqlval['update_date'] = "now()";
             // INSERTの実行
             $objQuery->insert("dtb_products_class", $sqlval);
         }
         $cnt++;
     }
     $objQuery->commit();
 }
예제 #17
0
 function lfDeleteFavoriteProduct($customer_id, $product_id)
 {
     $objQuery = new SC_Query();
     $objConn = new SC_DbConn();
     $count = $objConn->getOne("SELECT COUNT(*) FROM dtb_customer_favorite_products WHERE customer_id = ? AND product_id = ?", array($customer_id, $product_id));
     if ($count > 0) {
         $where = "customer_id = ? AND product_id = ?";
         $sqlval['customer_id'] = $customer_id;
         $sqlval['product_id'] = $product_id;
         $objQuery->begin();
         $objQuery->delete('dtb_customer_favorite_products', $where, $sqlval);
         $objQuery->commit();
     }
 }