/**
  * 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->tpl_pageno = isset($_POST['pageno']) ? $_POST['pageno'] : "";
     // 通常時は親カテゴリを0に設定する。
     $this->arrForm['parent_category_id'] = isset($_POST['parent_category_id']) ? $_POST['parent_category_id'] : 0;
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     switch ($_POST['mode']) {
         case 'up':
             $where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['parent_category_id']);
             $objDb->sfRankUp("dtb_product_categories", "product_id", $_POST['product_id'], $where);
             break;
         case 'down':
             $where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['parent_category_id']);
             $objDb->sfRankDown("dtb_product_categories", "product_id", $_POST['product_id'], $where);
             break;
         case 'move':
             $key = "pos-" . $_POST['product_id'];
             $input_pos = mb_convert_kana($_POST[$key], "n");
             if (SC_Utils_Ex::sfIsInt($input_pos)) {
                 $where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['parent_category_id']);
                 $objDb->sfMoveRank("dtb_product_categories", "product_id", $_POST['product_id'], $input_pos, $where);
             }
             break;
         case 'tree':
             // カテゴリの切替は、ページ番号をクリアする。
             $this->tpl_pageno = "";
             break;
         default:
             break;
     }
     $this->arrTree = $objDb->sfGetCatTree($this->arrForm['parent_category_id']);
     $this->arrProductsList = $this->lfGetProduct($this->arrForm['parent_category_id']);
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
 /**
  * 並び順を下げる
  *
  * @param integer $class_id 規格ID
  * @param integer $classcategory_id 規格分類ID
  * @return void
  */
 function lfDownRank($class_id, $classcategory_id)
 {
     $objDb = new SC_Helper_DB_Ex();
     $where = 'class_id = ' . SC_Utils_Ex::sfQuoteSmart($class_id);
     $objDb->sfRankDown('dtb_classcategory', 'classcategory_id', $classcategory_id, $where);
 }
 function lfRegistData($array, $arrRegistColumn, &$objCustomer)
 {
     $objConn = new SC_DBConn();
     foreach ($arrRegistColumn as $data) {
         if (strlen($array[$data["column"]]) > 0) {
             $arrRegist[$data["column"]] = $array[$data["column"]];
         }
     }
     $arrRegist['customer_id'] = $objCustomer->getvalue('customer_id');
     //-- 編集登録実行
     $objConn->query("BEGIN");
     if ($array['other_deliv_id'] != "") {
         $objConn->autoExecute("dtb_other_deliv", $arrRegist, "other_deliv_id = " . SC_Utils_Ex::sfQuoteSmart($array["other_deliv_id"]));
     } else {
         $objConn->autoExecute("dtb_other_deliv", $arrRegist);
     }
     $objConn->query("COMMIT");
 }
예제 #4
0
 /**
  * マスターデータを更新する.
  *
  * 引数 $masterData の値でマスターデータを更新する.
  * $masterData は key => value 形式の配列である必要がある.
  *
  * @param string $name マスターデータ名
  * @param array $columns [0] => キー, [1] => 表示文字列, [2] => 表示順
  *                        を表すカラム名を格納した配列
  * @param array $masterData マスターデータ
  * @param bool $autoCommit トランザクションを自動的に commit する場合 true
  * @return integer マスターデータの更新数
  */
 function updateMasterData($name, $columns, $masterData, $autoCommit = true)
 {
     $columns = $this->getDefaultColumnName($columns);
     $this->objQuery =& SC_Query_Ex::getSingletonInstance();
     if ($autoCommit) {
         $this->objQuery->begin();
     }
     // 指定のデータを更新
     $i = 0;
     foreach ($masterData as $key => $val) {
         $sqlVal = array($columns[1] => $val);
         $this->objQuery->update($name, $sqlVal, $columns[0] . ' = ' . SC_Utils_Ex::sfQuoteSmart($key));
         $i++;
     }
     if ($autoCommit) {
         $this->objQuery->commit();
     }
     return $i;
 }
 function lfGetSecretKey($email, &$objConn)
 {
     $sql = "SELECT secret_key FROM dtb_customer_mail WHERE email = ?";
     $uniqid = $objConn->getOne($sql, array($email));
     if ($uniqid == '') {
         $count = 1;
         while ($count != 0) {
             $uniqid = SC_Utils_Ex::sfGetUniqRandomId("t");
             $count = $objConn->getOne("SELECT COUNT(*) FROM dtb_customer_mail WHERE secret_key = ?", array($uniqid));
         }
         $objQuery = new SC_Query();
         $objQuery->update("dtb_customer_mail", array('secret_key' => $uniqid), "email = " . SC_Utils_Ex::sfQuoteSmart($email));
     }
     return $uniqid;
 }
예제 #6
0
 /**
  * View の WHERE 句を置換する.
  *
  * @param string $target 置換対象の文字列
  * @param string $where 置換する文字列
  * @param array $arrval WHERE 句の要素の配列
  * @param string $option SQL 文の追加文字列
  * @return string 置換後の SQL 文
  */
 function sfViewWhere($target, $where = "", $arrval = array(), $option = "")
 {
     $arrWhere = split("[?]", $where);
     $where_tmp = " WHERE " . $arrWhere[0];
     for ($i = 1; $i < count($arrWhere); $i++) {
         $where_tmp .= SC_Utils_Ex::sfQuoteSmart($arrval[$i - 1]) . $arrWhere[$i];
     }
     $arrWhere = $this->getWhereConverter();
     $arrWhere[$target] = $where_tmp . " " . $option;
     return $arrWhere[$target];
 }
예제 #7
0
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     //---- ページ初期設定
     $objQuery = new SC_Query();
     $objView = new SC_AdminView();
     $objDate = new SC_Date(1901);
     $objDb = new SC_Helper_DB_Ex();
     $this->arrYear = $objDate->getYear();
     // 日付プルダウン設定
     $this->arrMonth = $objDate->getMonth();
     $this->arrDay = $objDate->getDay();
     $this->objDate = $objDate;
     // 認証可否の判定
     $objSess = new SC_Session();
     SC_Utils_Ex::sfIsSuccess($objSess);
     // POST値の引き継ぎ
     $this->arrForm = $_POST;
     // ページ送り用
     $this->arrHidden['search_pageno'] = isset($_POST['search_pageno']) ? $_POST['search_pageno'] : "";
     // 検索ワードの引き継ぎ
     foreach ($_POST as $key => $val) {
         switch ($key) {
             case 'sex':
             case 'status':
                 $this->arrHidden[$key] = SC_Utils_Ex::sfMergeParamCheckBoxes($val);
                 if (!is_array($val)) {
                     $this->arrForm[$key] = split("-", $val);
                 }
                 break;
             default:
                 $this->arrHidden[$key] = $val;
                 break;
         }
     }
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     // 顧客削除
     if ($_POST['mode'] == "delete") {
         $sql = "SELECT status,email FROM dtb_customer WHERE customer_id = ? AND del_flg = 0";
         $result_customer = $objQuery->conn->getAll($sql, array($_POST["edit_customer_id"]));
         if ($result_customer[0]["status"] == 2) {
             //本会員削除
             $arrDel = array("del_flg" => 1, "update_date" => "NOW()");
             $objQuery->conn->autoExecute("dtb_customer", $arrDel, "customer_id = " . SC_Utils_Ex::sfQuoteSmart($_POST["edit_customer_id"]));
         } elseif ($result_customer[0]["status"] == 1) {
             //仮会員削除
             $sql = "DELETE FROM dtb_customer WHERE customer_id = ?";
             $objQuery->conn->query($sql, array($_POST["edit_customer_id"]));
         }
     }
     //if ($_POST['mode'] == "search" || $_POST['mode'] == "csv"  || $_POST['mode'] == "delete" || $_POST['mode'] == "delete_all") {
     // 登録メール再送
     if ($_POST['mode'] == "resend_mail") {
         $arrRet = $objQuery->select("name01, name02, secret_key, email", "dtb_customer", "customer_id = ? AND del_flg <> 1 AND status = 1", array($_POST["edit_customer_id"]));
         if (is_array($arrRet) === true && count($arrRet) > 0) {
             $CONF = $objDb->sf_getBasisData();
             $this->CONF = $CONF;
             $objMailText = new SC_SiteView();
             $objMailText->assignobj($this);
             $mailHelper = new SC_Helper_Mail_Ex();
             $this->name01 = $arrRet[0]['name01'];
             $this->name02 = $arrRet[0]['name02'];
             $this->uniqid = $arrRet[0]['secret_key'];
             $subject = $mailHelper->sfMakesubject($objQuery, $objMailText, $this, '会員登録のご確認');
             $toCustomerMail = $objMailText->fetch("mail_templates/customer_mail.tpl");
             $objMail = new SC_SendMail();
             $objMail->setItem('', $subject, $toCustomerMail, $CONF["email03"], $CONF["shop_name"], $CONF["email03"], $CONF["email04"], $CONF["email04"]);
             // 宛先の設定
             $name = $this->name01 . $this->name02 . " 様";
             $objMail->setTo($arrRet[0]["email"], $name);
             $objMail->sendMail();
         }
     }
     if ($_POST['mode'] == "search" || $_POST['mode'] == "csv" || $_POST['mode'] == "delete" || $_POST['mode'] == "delete_all" || $_POST['mode'] == "resend_mail") {
         // 入力文字の強制変換
         $this->lfConvertParam();
         // エラーチェック
         $this->arrErr = $this->lfCheckError($this->arrForm);
         $where = "del_flg = 0";
         /* 入力エラーなし */
         if (count($this->arrErr) == 0) {
             //-- 検索データ取得
             $objSelect = new SC_CustomerList($this->arrForm, "customer");
             // 表示件数設定
             $page_rows = $this->arrForm['page_rows'];
             if (is_numeric($page_rows)) {
                 $page_max = $page_rows;
             } else {
                 $page_max = SEARCH_PMAX;
             }
             if (!isset($this->arrForm['search_pageno'])) {
                 $this->arrForm['search_pageno'] = "";
             }
             if ($this->arrForm['search_pageno'] == 0) {
                 $this->arrForm['search_pageno'] = 1;
             }
             $offset = $page_max * ($this->arrForm['search_pageno'] - 1);
             $objSelect->setLimitOffset($page_max, $offset);
             if ($_POST["mode"] == 'csv') {
                 $searchSql = $objSelect->getListCSV($this->arrColumnCSV);
             } else {
                 $searchSql = $objSelect->getList();
             }
             $this->search_data = $objQuery->conn->getAll($searchSql, $objSelect->arrVal);
             switch ($_POST['mode']) {
                 case 'csv':
                     require_once CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php";
                     $objCSV = new SC_Helper_CSV_Ex();
                     $i = 0;
                     $header = "";
                     // CSVカラム取得
                     $arrCsvOutput = $objCSV->sfgetCsvOutput(2, " WHERE csv_id = 2 AND status = 1");
                     if (count($arrCsvOutput) <= 0) {
                         break;
                     }
                     foreach ($arrCsvOutput as $data) {
                         $arrColumn[] = $data["col"];
                         if ($i != 0) {
                             $header .= ", ";
                         }
                         $header .= $data["disp_name"];
                         $i++;
                     }
                     $header .= "\n";
                     //- 都道府県/職業の変換
                     for ($i = 0; $i < count($this->search_data); $i++) {
                         $this->search_data[$i]["pref"] = $this->arrPref[$this->search_data[$i]["pref"]];
                         $this->search_data[$i]["job"] = $this->arrJob[$this->search_data[$i]["job"]];
                     }
                     //- CSV出力
                     $data = SC_Utils_Ex::getCSVData($this->search_data, $arrColumn);
                     SC_Utils_Ex::sfCSVDownload($header . $data);
                     exit;
                     break;
                 case 'delete_all':
                     // 検索結果をすべて削除
                     $where = "product_id IN (SELECT product_id FROM vw_products_nonclass AS noncls WHERE {$where})";
                     $sqlval['del_flg'] = 1;
                     $objQuery->update("dtb_products", $sqlval, $where, $arrval);
                     $sql = "SELECT status,email FROM dtb_customer WHERE customer_id = ? AND del_flg = 0";
                     $result_customer = $objQuery->conn->getAll($sql, array($_POST["del_customer_id"]));
                     if ($result_customer[0]["status"] == 2) {
                         //本会員削除
                         $arrDel = array("del_flg" => 1, "update_date" => "NOW()");
                         $objQuery->conn->autoExecute("dtb_customer", $arrDel, "customer_id = " . SC_Utils_Ex::sfQuoteSmart($_POST["del_customer_id"]));
                     } elseif ($result_customer[0]["status"] == 1) {
                         //仮会員削除
                         $sql = "DELETE FROM dtb_customer WHERE customer_id = ?";
                         $objQuery->conn->query($sql, array($_POST["del_customer_id"]));
                     }
                     break;
                 default:
                     // 行数の取得
                     $linemax = $objQuery->conn->getOne($objSelect->getListCount(), $objSelect->arrVal);
                     $this->tpl_linemax = $linemax;
                     // 何件が該当しました。表示用
                     // ページ送りの取得
                     $objNavi = new SC_PageNavi($this->arrHidden['search_pageno'], $linemax, $page_max, "fnCustomerPage", NAVI_PMAX);
                     $startno = $objNavi->start_row;
                     $this->arrPagenavi = $objNavi->arrPagenavi;
             }
         }
     }
     $this->arrCatList = $objDb->sfGetCategoryList();
     //---- ページ表示
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $conn = new SC_DBConn();
     $objView = new SC_AdminView();
     $objQuery = new SC_Query();
     $objDb = new SC_Helper_DB_Ex();
     // 認証可否の判定
     $objSess = new SC_Session();
     SC_Utils_Ex::sfIsSuccess($objSess);
     $get_check = false;
     // 規格IDのチェック
     if (SC_Utils_Ex::sfIsInt($_GET['class_id'])) {
         // 規格名の取得
         $this->tpl_class_name = $objQuery->get("dtb_class", "name", "class_id = ?", array($_GET['class_id']));
         if ($this->tpl_class_name != "") {
             // 規格IDの引き継ぎ
             $this->arrHidden['class_id'] = $_GET['class_id'];
             $get_check = true;
         }
     }
     if (!$get_check) {
         // 規格登録ページに飛ばす。
         $this->sendRedirect($this->getLocation(URL_CLASS_REGIST));
         exit;
     }
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     if (isset($_POST['class_id'])) {
         if (!SC_Utils_Ex::sfIsInt($_POST['class_id'])) {
             SC_Utils_Ex::sfDispError("");
         }
     }
     // 新規作成 or 編集
     switch ($_POST['mode']) {
         // 登録ボタン押下
         case 'edit':
             // POST値の引き継ぎ
             $this->arrForm = $_POST;
             // 入力文字の変換
             $_POST = $this->lfConvertParam($_POST);
             // エラーチェック
             $this->arrErr = $this->lfErrorCheck();
             if (count($this->arrErr) <= 0) {
                 if ($_POST['classcategory_id'] == "") {
                     $this->lfInsertClass();
                     // DBへの書き込み
                 } else {
                     $this->lfUpdateClass();
                     // DBへの書き込み
                 }
                 // 再表示
                 $this->reload($_GET['class_id']);
                 //sfReload("class_id=" . $_GET['class_id']);
             } else {
                 // POSTデータを引き継ぐ
                 $this->tpl_classcategory_id = $_POST['classcategory_id'];
             }
             break;
             // 削除
         // 削除
         case 'delete':
             // ランク付きレコードの削除
             $where = "class_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['class_id']);
             $objDb->sfDeleteRankRecord("dtb_classcategory", "classcategory_id", $_POST['classcategory_id'], $where, true);
             break;
             // 編集前処理
         // 編集前処理
         case 'pre_edit':
             // 編集項目をDBより取得する。
             $where = "classcategory_id = ?";
             $name = $objQuery->get("dtb_classcategory", "name", $where, array($_POST['classcategory_id']));
             // 入力項目にカテゴリ名を入力する。
             $this->arrForm['name'] = $name;
             // POSTデータを引き継ぐ
             $this->tpl_classcategory_id = $_POST['classcategory_id'];
             break;
         case 'down':
             $where = "class_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['class_id']);
             $objDb->sfRankDown("dtb_classcategory", "classcategory_id", $_POST['classcategory_id'], $where);
             break;
         case 'up':
             $where = "class_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['class_id']);
             $objDb->sfRankUp("dtb_classcategory", "classcategory_id", $_POST['classcategory_id'], $where);
             break;
         default:
             break;
     }
     // 規格分類の読込
     $where = "del_flg <> 1 AND class_id = ?";
     $objQuery->setorder("rank DESC");
     $this->arrClassCat = $objQuery->select("name, classcategory_id", "dtb_classcategory", $where, array($_GET['class_id']));
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
 public function setWhereByOR($arrWhere)
 {
     $count = count($arrWhere);
     for ($i = 0; $i < $count; $i++) {
         if (isset($arrWhere[$i]['value'])) {
             $statement .= $arrWhere[$i]['column'] . ' = ' . SC_Utils_Ex::sfQuoteSmart($arrWhere[$i]['value']) . ' OR ';
         }
     }
     $statement = '(' . rtrim($statement, ' OR ') . ')';
     if ($this->where) {
         $this->where .= ' AND ' . $statement;
     } else {
         $this->where = 'WHERE ' . $statement;
     }
 }
 function lfRankMove(&$objDb, $parent_category_id, $product_id)
 {
     $key = "pos-" . $product_id;
     $input_pos = mb_convert_kana($_POST[$key], 'n');
     if (SC_Utils_Ex::sfIsInt($input_pos)) {
         $where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($parent_category_id);
         $objDb->sfMoveRank("dtb_product_categories", "product_id", $product_id, $input_pos, $where);
     }
 }
 public function lfRankMove(&$objDb, $parent_category_id, $product_id)
 {
     $key = 'pos-' . $product_id;
     $input_pos = mb_convert_kana($_POST[$key], 'n');
     if (SC_Utils_Ex::sfIsInt($input_pos)) {
         $where = 'category_id = ' . SC_Utils_Ex::sfQuoteSmart($parent_category_id);
         $objDb->sfMoveRank('dtb_product_categories', 'product_id', $product_id, $input_pos, $where);
     }
 }
예제 #12
0
 function lfChangeData($key, &$objQuery)
 {
     $arrUpdate['mail_flag'] = 3;
     $arrUpdate['secret_key'] = NULL;
     $result = $objQuery->update("dtb_customer_mail", $arrUpdate, "secret_key = " . SC_Utils_Ex::sfQuoteSmart($key));
 }
예제 #13
0
 function setWhereByOR($arrWhere)
 {
     $count = count($arrWhere);
     for ($i = 0; $i < $count; $i++) {
         if (isset($arrWhere[$i]["value"])) {
             $statement .= $arrWhere[$i]["column"] . " = " . SC_Utils_Ex::sfQuoteSmart($arrWhere[$i]["value"]) . " OR ";
         }
     }
     $statement = "( " . rtrim($statement, " OR ") . " )";
     if ($this->where) {
         $this->where .= " AND " . $statement;
     } else {
         $this->where = "WHERE " . $statement;
     }
 }
예제 #14
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を返す
 }
예제 #15
0
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $objView = new SC_AdminView();
     $objDb = new SC_Helper_DB_Ex();
     $objDate = new SC_Date();
     // 登録・更新検索開始年
     $objDate->setStartYear(RELEASE_YEAR);
     $objDate->setEndYear(DATE("Y"));
     $this->arrStartYear = $objDate->getYear();
     $this->arrStartMonth = $objDate->getMonth();
     $this->arrStartDay = $objDate->getDay();
     // 登録・更新検索終了年
     $objDate->setStartYear(RELEASE_YEAR);
     $objDate->setEndYear(DATE("Y"));
     $this->arrEndYear = $objDate->getYear();
     $this->arrEndMonth = $objDate->getMonth();
     $this->arrEndDay = $objDate->getDay();
     // 認証可否の判定
     $objSess = new SC_Session();
     SC_Utils_Ex::sfIsSuccess($objSess);
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     //キャンペーンの編集時
     if (isset($_POST['campaign_id']) && SC_Utils_Ex::sfIsInt($_POST['campaign_id']) && $_POST['mode'] == "camp_search") {
         $objQuery = new SC_Query();
         $search_data = $objQuery->get("dtb_campaign", "search_condition", "campaign_id = ? ", array($_POST['campaign_id']));
         $arrSearch = unserialize($search_data);
         foreach ($arrSearch as $key => $val) {
             $_POST[$key] = $val;
         }
     }
     // POST値の引き継ぎ
     $this->arrForm = $_POST;
     // 検索ワードの引き継ぎ
     foreach ($_POST as $key => $val) {
         if (ereg("^search_", $key) || ereg("^campaign_", $key)) {
             switch ($key) {
                 case 'search_product_flag':
                 case 'search_status':
                     $this->arrHidden[$key] = SC_Utils_Ex::sfMergeParamCheckBoxes($val);
                     if (!is_array($val)) {
                         $this->arrForm[$key] = split("-", $val);
                     }
                     break;
                 default:
                     $this->arrHidden[$key] = $val;
                     break;
             }
         }
     }
     // ページ送り用
     $this->arrHidden['search_pageno'] = isset($_POST['search_pageno']) ? $_POST['search_pageno'] : "";
     // 商品削除
     if ($_POST['mode'] == "delete") {
         if ($_POST['category_id'] != "") {
             // ランク付きレコードの削除
             $where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['category_id']);
             $objDb->sfDeleteRankRecord("dtb_products", "product_id", $_POST['product_id'], $where);
         } else {
             $objDb->sfDeleteRankRecord("dtb_products", "product_id", $_POST['product_id']);
         }
         // 子テーブル(商品規格)の削除
         $objQuery = new SC_Query();
         $objQuery->delete("dtb_products_class", "product_id = ?", array($_POST['product_id']));
         // 件数カウントバッチ実行
         $objDb->sfCategory_Count($objQuery);
     }
     if ($_POST['mode'] == "search" || $_POST['mode'] == "csv" || $_POST['mode'] == "delete" || $_POST['mode'] == "delete_all" || $_POST['mode'] == "camp_search") {
         // 入力文字の強制変換
         $this->lfConvertParam();
         // エラーチェック
         $this->arrErr = $this->lfCheckError();
         $where = "del_flg = 0";
         $view_where = "del_flg = 0";
         // 入力エラーなし
         if (count($this->arrErr) == 0) {
             $arrval = array();
             foreach ($this->arrForm as $key => $val) {
                 $val = SC_Utils_Ex::sfManualEscape($val);
                 if ($val == "") {
                     continue;
                 }
                 switch ($key) {
                     case 'search_product_id':
                         // 商品ID
                         $where .= " AND product_id = ?";
                         $view_where .= " AND product_id = ?";
                         $arrval[] = $val;
                         break;
                     case 'search_product_class_name':
                         //規格名称
                         $where_in = " (SELECT classcategory_id FROM dtb_classcategory WHERE class_id IN (SELECT class_id FROM dtb_class WHERE name LIKE ?)) ";
                         $where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE classcategory_id1 IN " . $where_in;
                         $where .= " OR classcategory_id2 IN" . $where_in . ")";
                         $view_where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE classcategory_id1 IN " . $where_in;
                         $view_where .= " OR classcategory_id2 IN" . $where_in . ")";
                         $arrval[] = "%{$val}%";
                         $arrval[] = "%{$val}%";
                         $view_where = $where;
                         break;
                     case 'search_name':
                         // 商品名
                         $where .= " AND name ILIKE ?";
                         $view_where .= " AND name ILIKE ?";
                         $arrval[] = "%{$val}%";
                         break;
                     case 'search_category_id':
                         // カテゴリー
                         list($tmp_where, $tmp_arrval) = $objDb->sfGetCatWhere($val);
                         if ($tmp_where != "") {
                             $where .= " AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")";
                             $view_where .= " AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")";
                             $arrval = array_merge((array) $arrval, (array) $tmp_arrval);
                         }
                         break;
                     case 'search_product_code':
                         // 商品コード
                         $where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code ILIKE ? GROUP BY product_id)";
                         $view_where .= " AND EXISTS (SELECT product_id FROM dtb_products_class as cls WHERE cls.product_code ILIKE ? AND dtb_products.product_id = cls.product_id GROUP BY cls.product_id )";
                         $arrval[] = "%{$val}%";
                         break;
                     case 'search_startyear':
                         // 登録更新日(FROM)
                         $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_startyear'], $_POST['search_startmonth'], $_POST['search_startday']);
                         $where .= " AND update_date >= '" . $_POST['search_startyear'] . "/" . $_POST['search_startmonth'] . "/" . $_POST['search_startday'] . "'";
                         $view_where .= " AND update_date >= '" . $_POST['search_startyear'] . "/" . $_POST['search_startmonth'] . "/" . $_POST['search_startday'] . "'";
                         break;
                     case 'search_endyear':
                         // 登録更新日(TO)
                         $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_endyear'], $_POST['search_endmonth'], $_POST['search_endday']);
                         $date = date('Y/m/d', strtotime($date) + 86400);
                         $where .= " AND update_date < date('" . $date . "')";
                         $view_where .= " AND update_date < date('" . $date . "')";
                         break;
                     case 'search_product_flag':
                         //種別
                         global $arrSTATUS;
                         $search_product_flag = SC_Utils_Ex::sfSearchCheckBoxes($val);
                         if ($search_product_flag != "") {
                             $where .= " AND product_flag LIKE ?";
                             $view_where .= " AND product_flag LIKE ?";
                             $arrval[] = $search_product_flag;
                         }
                         break;
                     case 'search_status':
                         // ステータス
                         $tmp_where = "";
                         foreach ($val as $element) {
                             if ($element != "") {
                                 if ($tmp_where == "") {
                                     $tmp_where .= "AND (status = ? ";
                                 } else {
                                     $tmp_where .= "OR status = ? ";
                                 }
                                 $arrval[] = $element;
                             }
                         }
                         if ($tmp_where != "") {
                             $tmp_where .= ")";
                             $where .= " {$tmp_where}";
                             $view_where .= " {$tmp_where}";
                         }
                         break;
                     default:
                         break;
                 }
             }
             $order = "update_date DESC, product_id DESC";
             $objQuery = new SC_Query();
             switch ($_POST['mode']) {
                 case 'csv':
                     require_once CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php";
                     $objCSV = new SC_Helper_CSV_Ex();
                     // オプションの指定
                     $option = "ORDER BY {$order}";
                     // CSV出力タイトル行の作成
                     $arrOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput(1, " WHERE csv_id = 1 AND status = 1"));
                     if (count($arrOutput) <= 0) {
                         break;
                     }
                     $arrOutputCols = $arrOutput['col'];
                     $arrOutputTitle = $arrOutput['disp_name'];
                     $head = SC_Utils_Ex::sfGetCSVList($arrOutputTitle);
                     $data = $objCSV->lfGetProductsCSV($where, $option, $arrval, $arrOutputCols);
                     // CSVを送信する。
                     SC_Utils_Ex::sfCSVDownload($head . $data);
                     exit;
                     break;
                 case 'delete_all':
                     // 検索結果の取得
                     $col = "product_id";
                     $from = "vw_products_nonclass AS noncls ";
                     $arrProducts = $objQuery->select($col, $from, $where, $arrval);
                     // 検索結果をすべて削除
                     $sqlval['del_flg'] = 1;
                     $where = "product_id = ?";
                     if (count($arrProducts) > 0) {
                         foreach ($arrProducts as $key => $val) {
                             $objQuery->update("dtb_products", $sqlval, $where, array($arrProducts[$key]["product_id"]));
                         }
                     }
                     break;
                 default:
                     // 読み込む列とテーブルの指定
                     $col = "product_id, name, category_id, main_list_image, status, product_code, price01, price02, stock, stock_unlimited";
                     $from = "vw_products_nonclass AS noncls ";
                     // 行数の取得
                     $linemax = $objQuery->count("dtb_products", $view_where, $arrval);
                     $this->tpl_linemax = $linemax;
                     // 何件が該当しました。表示用
                     // ページ送りの処理
                     if (is_numeric($_POST['search_page_max'])) {
                         $page_max = $_POST['search_page_max'];
                     } else {
                         $page_max = SEARCH_PMAX;
                     }
                     // ページ送りの取得
                     $objNavi = new SC_PageNavi($this->arrHidden['search_pageno'], $linemax, $page_max, "fnNaviSearchPage", NAVI_PMAX);
                     $startno = $objNavi->start_row;
                     $this->arrPagenavi = $objNavi->arrPagenavi;
                     //キャンペーン商品検索時は、全結果の商品IDを変数に格納する
                     if (isset($_POST['search_mode']) && $_POST['search_mode'] == 'campaign') {
                         $arrRet = $objQuery->select($col, $from, $where, $arrval);
                         if (count($arrRet) > 0) {
                             $arrRet = sfSwapArray($arrRet);
                             $pid = implode("-", $arrRet['product_id']);
                             $this->arrHidden['campaign_product_id'] = $pid;
                         }
                     }
                     // 取得範囲の指定(開始行番号、行数のセット)
                     //                    if(DB_TYPE != "mysql") $objQuery->setlimitoffset($page_max, $startno);
                     $objQuery->setlimitoffset($page_max, $startno);
                     // 表示順序
                     $objQuery->setorder($order);
                     // 検索結果の取得
                     $this->arrProducts = $objQuery->select($col, $from, $where, $arrval);
                     // 各商品ごとのカテゴリIDを取得
                     if (count($this->arrProducts) > 0) {
                         foreach ($this->arrProducts as $key => $val) {
                             $this->arrProducts[$key]["categories"] = $objDb->sfGetCategoryId($val["product_id"]);
                             $objDb->g_category_on = false;
                         }
                     }
             }
         }
     }
     // カテゴリの読込
     list($this->arrCatKey, $this->arrCatVal) = $objDb->sfGetLevelCatList(false);
     $this->arrCatList = $this->lfGetIDName($this->arrCatKey, $this->arrCatVal);
     // 画面の表示
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
 /**
  * 並び順を下げる
  *
  * @param integer $class_id 規格ID
  * @param integer $classcategory_id 規格分類ID
  * @return void
  */
 function lfDownRank($class_id, $classcategory_id)
 {
     $objDb = new SC_Helper_DB_Ex();
     $where = "class_id = " . SC_Utils_Ex::sfQuoteSmart($class_id);
     $objDb->sfRankDown("dtb_classcategory", "classcategory_id", $classcategory_id, $where);
 }