/**
  * WHERE文の作成
  *
  * @param array $arrForm フォームデータ
  * @return array WHERE文、判定値
  */
 function lfGetWhere($arrForm)
 {
     //削除されていない商品を検索
     $where = "A.del_flg = 0 AND B.del_flg = 0";
     foreach ($arrForm as $key => $val) {
         if (empty($val)) {
             continue;
         }
         switch ($key) {
             case 'search_reviewer_name':
                 $val = preg_replace("/ /", "%", $val);
                 $where .= " AND reviewer_name LIKE ? ";
                 $arrval[] = "%{$val}%";
                 break;
             case 'search_reviewer_url':
                 $val = preg_replace("/ /", "%", $val);
                 $where .= " AND reviewer_url LIKE ? ";
                 $arrval[] = "%{$val}%";
                 break;
             case 'search_name':
                 $val = preg_replace("/ /", "%", $val);
                 $where .= " AND name LIKE ? ";
                 $arrval[] = "%{$val}%";
                 break;
             case 'search_product_code':
                 $val = preg_replace("/ /", "%", $val);
                 $where .= " AND A.product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code LIKE ? )";
                 $arrval[] = "%{$val}%";
                 break;
             case 'search_sex':
                 $tmp_where = "";
                 //$val=配列の中身,$element=各キーの値(1,2)
                 if (is_array($val)) {
                     foreach ($val as $element) {
                         if ($element != "") {
                             if ($tmp_where == "") {
                                 $tmp_where .= " AND (sex = ?";
                             } else {
                                 $tmp_where .= " OR sex = ?";
                             }
                             $arrval[] = $element;
                         }
                     }
                     if ($tmp_where != "") {
                         $tmp_where .= ")";
                         $where .= " {$tmp_where} ";
                     }
                 }
                 break;
             case 'search_recommend_level':
                 $where .= " AND recommend_level = ? ";
                 $arrval[] = $val;
                 break;
             case 'search_startyear':
                 if (isset($_POST['search_startyear']) && isset($_POST['search_startmonth']) && isset($_POST['search_startday'])) {
                     $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_startyear'], $_POST['search_startmonth'], $_POST['search_startday']);
                     $where .= " AND A.create_date >= ? ";
                     $arrval[] = $date;
                 }
                 break;
             case 'search_endyear':
                 if (isset($_POST['search_startyear']) && isset($_POST['search_startmonth']) && isset($_POST['search_startday'])) {
                     $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_endyear'], $_POST['search_endmonth'], $_POST['search_endday']);
                     $end_date = date("Y/m/d", strtotime("1 day", strtotime($date)));
                     $where .= " AND A.create_date <= cast('{$end_date}' as date) ";
                 }
                 break;
         }
     }
     return array($where, $arrval);
 }
 /**
  * クエリを構築する.
  *
  * 検索条件のキーに応じた WHERE 句と, クエリパラメーターを構築する.
  * クエリパラメーターは, SC_FormParam の入力値から取得する.
  *
  * 構築内容は, 引数の $where 及び $arrValues にそれぞれ追加される.
  *
  * @param  string       $key          検索条件のキー
  * @param  string       $where        構築する WHERE 句
  * @param  array        $arrValues    構築するクエリパラメーター
  * @param  SC_FormParam $objFormParam SC_FormParam インスタンス
  * @return void
  */
 public function buildQuery($key, &$where, &$arrValues, &$objFormParam)
 {
     switch ($key) {
         case "search_year":
         case "search_month":
         case "search_day":
             if ($key != "search_year") {
                 break;
             }
             $y = $objFormParam->getValue('search_year');
             $m = $objFormParam->getValue('search_month');
             $d = $objFormParam->getValue('search_day');
             $where .= ' AND create_date BETWEEN ? AND ? ';
             $arrValues[] = SC_Utils_Ex::sfGetTimestamp($y, $m, $d);
             $arrValues[] = SC_Utils_Ex::sfGetTimestamp($y, $m, $d, true);
             break;
         case 'search_order_id':
             $where .= ' AND order_id = ?';
             $arrValues[] = sprintf('%d', $objFormParam->getValue($key));
             break;
         case 'search_customer_id':
             $where .= ' AND customer_id = ?';
             $arrValues[] = sprintf('%d', $objFormParam->getValue($key));
             break;
         case 'search_product_id':
             $where .= ' AND EXISTS (SELECT 1 FROM dtb_order_detail od WHERE od.order_id = dtb_order.order_id AND od.product_id = ?)';
             $arrValues[] = sprintf('%d', $objFormParam->getValue($key));
             break;
         default:
             parent::buildQuery($key, $where, $arrValues, $objFormParam);
             break;
     }
 }
Ejemplo n.º 3
0
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $conn = new SC_DBConn();
     $objView = new SC_AdminView();
     $objDb = new SC_Helper_DB_Ex();
     $objSess = new SC_Session();
     // パラメータ管理クラス
     $this->objFormParam = new SC_FormParam();
     // パラメータ情報の初期化
     $this->lfInitParam();
     $this->objFormParam->setParam($_POST);
     $this->objFormParam->splitParamCheckBoxes('search_order_sex');
     $this->objFormParam->splitParamCheckBoxes('search_payment_id');
     // 検索ワードの引き継ぎ
     foreach ($_POST as $key => $val) {
         if (ereg("^search_", $key)) {
             switch ($key) {
                 case 'search_order_sex':
                 case 'search_payment_id':
                     $this->arrHidden[$key] = SC_Utils_Ex::sfMergeParamCheckBoxes($val);
                     break;
                 default:
                     $this->arrHidden[$key] = $val;
                     break;
             }
         }
     }
     // ページ送り用
     $this->arrHidden['search_pageno'] = isset($_POST['search_pageno']) ? $_POST['search_pageno'] : "";
     // 認証可否の判定
     SC_Utils_Ex::sfIsSuccess($objSess);
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     if (!isset($arrRet)) {
         $arrRet = array();
     }
     if ($_POST['mode'] == 'delete') {
         if (SC_Utils_Ex::sfIsInt($_POST['order_id'])) {
             $objQuery = new SC_Query();
             $where = "order_id = ?";
             $sqlval['del_flg'] = '1';
             $objQuery->update("dtb_order", $sqlval, $where, array($_POST['order_id']));
         }
     }
     switch ($_POST['mode']) {
         case 'delete':
         case 'csv':
         case 'pdf':
         case 'delete_all':
         case 'search':
             // 入力値の変換
             $this->objFormParam->convParam();
             $this->arrErr = $this->lfCheckError($arrRet);
             $arrRet = $this->objFormParam->getHashArray();
             // 入力なし
             if (count($this->arrErr) == 0) {
                 $where = "del_flg = 0";
                 foreach ($arrRet as $key => $val) {
                     if ($val == "") {
                         continue;
                     }
                     $val = SC_Utils_Ex::sfManualEscape($val);
                     switch ($key) {
                         case 'search_order_name':
                             if (DB_TYPE == "pgsql") {
                                 $where .= " AND order_name01||order_name02 ILIKE ?";
                             } elseif (DB_TYPE == "mysql") {
                                 $where .= " AND concat(order_name01,order_name02) ILIKE ?";
                             }
                             $nonsp_val = mb_ereg_replace("[  ]+", "", $val);
                             $arrval[] = "%{$nonsp_val}%";
                             break;
                         case 'search_order_kana':
                             if (DB_TYPE == "pgsql") {
                                 $where .= " AND order_kana01||order_kana02 ILIKE ?";
                             } elseif (DB_TYPE == "mysql") {
                                 $where .= " AND concat(order_kana01,order_kana02) ILIKE ?";
                             }
                             $nonsp_val = mb_ereg_replace("[  ]+", "", $val);
                             $arrval[] = "%{$nonsp_val}%";
                             break;
                         case 'search_order_id1':
                             $where .= " AND order_id >= ?";
                             $arrval[] = $val;
                             break;
                         case 'search_order_id2':
                             $where .= " AND order_id <= ?";
                             $arrval[] = $val;
                             break;
                         case 'search_order_sex':
                             $tmp_where = "";
                             foreach ($val as $element) {
                                 if ($element != "") {
                                     if ($tmp_where == "") {
                                         $tmp_where .= " AND (order_sex = ?";
                                     } else {
                                         $tmp_where .= " OR order_sex = ?";
                                     }
                                     $arrval[] = $element;
                                 }
                             }
                             if ($tmp_where != "") {
                                 $tmp_where .= ")";
                                 $where .= " {$tmp_where} ";
                             }
                             break;
                         case 'search_order_tel':
                             if (DB_TYPE == "pgsql") {
                                 $where .= " AND (order_tel01 || order_tel02 || order_tel03) LIKE ?";
                             } elseif (DB_TYPE == "mysql") {
                                 $where .= " AND concat(order_tel01,order_tel02,order_tel03) LIKE ?";
                             }
                             $nonmark_val = ereg_replace("[()-]+", "", $val);
                             $arrval[] = "%{$nonmark_val}%";
                             break;
                         case 'search_order_email':
                             $where .= " AND order_email ILIKE ?";
                             $arrval[] = "%{$val}%";
                             break;
                         case 'search_payment_id':
                             $tmp_where = "";
                             foreach ($val as $element) {
                                 if ($element != "") {
                                     if ($tmp_where == "") {
                                         $tmp_where .= " AND (payment_id = ?";
                                     } else {
                                         $tmp_where .= " OR payment_id = ?";
                                     }
                                     $arrval[] = $element;
                                 }
                             }
                             if ($tmp_where != "") {
                                 $tmp_where .= ")";
                                 $where .= " {$tmp_where} ";
                             }
                             break;
                         case 'search_total1':
                             $where .= " AND total >= ?";
                             $arrval[] = $val;
                             break;
                         case 'search_total2':
                             $where .= " AND total <= ?";
                             $arrval[] = $val;
                             break;
                         case 'search_sorderyear':
                             $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_sorderyear'], $_POST['search_sordermonth'], $_POST['search_sorderday']);
                             $where .= " AND create_date >= ?";
                             $arrval[] = $date;
                             break;
                         case 'search_eorderyear':
                             $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_eorderyear'], $_POST['search_eordermonth'], $_POST['search_eorderday'], true);
                             $where .= " AND create_date <= ?";
                             $arrval[] = $date;
                             break;
                         case 'search_supdateyear':
                             $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_supdateyear'], $_POST['search_supdatemonth'], $_POST['search_supdateday']);
                             $where .= " AND update_date >= ?";
                             $arrval[] = $date;
                             break;
                         case 'search_eupdateyear':
                             $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_eupdateyear'], $_POST['search_eupdatemonth'], $_POST['search_eupdateday'], true);
                             $where .= " AND update_date <= ?";
                             $arrval[] = $date;
                             break;
                         case 'search_sbirthyear':
                             $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_sbirthyear'], $_POST['search_sbirthmonth'], $_POST['search_sbirthday']);
                             $where .= " AND order_birth >= ?";
                             $arrval[] = $date;
                             break;
                         case 'search_ebirthyear':
                             $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_ebirthyear'], $_POST['search_ebirthmonth'], $_POST['search_ebirthday'], true);
                             $where .= " AND order_birth <= ?";
                             $arrval[] = $date;
                             break;
                         case 'search_order_status':
                             $where .= " AND status = ?";
                             $arrval[] = $val;
                             break;
                         default:
                             if (!isset($arrval)) {
                                 $arrval = array();
                             }
                             break;
                     }
                 }
                 $order = "update_date DESC";
                 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出力タイトル行の作成
                         $arrCsvOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput(3, " WHERE csv_id = 3 AND status = 1"));
                         if (count($arrCsvOutput) <= 0) {
                             break;
                         }
                         $arrCsvOutputCols = $arrCsvOutput['col'];
                         $arrCsvOutputTitle = $arrCsvOutput['disp_name'];
                         $head = SC_Utils_Ex::sfGetCSVList($arrCsvOutputTitle);
                         $data = $objCSV->lfGetCSV("dtb_order", $where, $option, $arrval, $arrCsvOutputCols);
                         // CSVを送信する。
                         SC_Utils_Ex::sfCSVDownload($head . $data);
                         exit;
                         break;
                     case 'pdf':
                         $objFpdf = new SC_Fpdf(1, '納品書');
                         $objFpdf->setData($arrRet);
                         $objFpdf->createPdf();
                         break;
                     case 'delete_all':
                         // 検索結果をすべて削除
                         $sqlval['del_flg'] = 1;
                         $objQuery = new SC_Query();
                         $objQuery->update("dtb_order", $sqlval, $where, $arrval);
                         break;
                     default:
                         // 読み込む列とテーブルの指定
                         $col = "*";
                         $from = "dtb_order";
                         $objQuery = new SC_Query();
                         // 行数の取得
                         $linemax = $objQuery->count($from, $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;
                         // 取得範囲の指定(開始行番号、行数のセット)
                         $objQuery->setlimitoffset($page_max, $startno);
                         // 表示順序
                         $objQuery->setorder($order);
                         // 検索結果の取得
                         $this->arrResults = $objQuery->select($col, $from, $where, $arrval);
                 }
             }
             break;
         default:
             break;
     }
     $objDate = new SC_Date();
     // 登録・更新日検索用
     $objDate->setStartYear(RELEASE_YEAR);
     $objDate->setEndYear(DATE("Y"));
     $this->arrRegistYear = $objDate->getYear();
     // 生年月日検索用
     $objDate->setStartYear(BIRTH_YEAR);
     $objDate->setEndYear(DATE("Y"));
     $this->arrBirthYear = $objDate->getYear();
     // 月日の設定
     $this->arrMonth = $objDate->getMonth();
     $this->arrDay = $objDate->getDay();
     // 入力値の取得
     $this->arrForm = $this->objFormParam->getFormParamList();
     // 支払い方法の取得
     $arrRet = $objDb->sfGetPayment();
     $this->arrPayment = SC_Utils_Ex::sfArrKeyValue($arrRet, 'payment_id', 'payment_method');
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
 /**
  * クエリを構築する.
  *
  * 検索条件のキーに応じた WHERE 句と, クエリパラメーターを構築する.
  * クエリパラメーターは, SC_FormParam の入力値から取得する.
  *
  * 構築内容は, 引数の $where 及び $arrValues にそれぞれ追加される.
  *
  * @param string $key 検索条件のキー
  * @param string $where 構築する WHERE 句
  * @param array $arrValues 構築するクエリパラメーター
  * @param SC_FormParam $objFormParam SC_FormParam インスタンス
  * @return void
  */
 function buildQuery($key, &$where, &$arrValues, &$objFormParam)
 {
     $dbFactory = SC_DB_DBFactory_Ex::getInstance();
     switch ($key) {
         case 'search_product_name':
             $where .= ' AND EXISTS (SELECT 1 FROM dtb_order_detail od WHERE od.order_id = dtb_order.order_id AND od.product_name LIKE ?)';
             $arrValues[] = sprintf('%%%s%%', $objFormParam->getValue($key));
             break;
         case 'search_order_name':
             $where .= ' AND ' . $dbFactory->concatColumn(array('order_name01', 'order_name02')) . ' LIKE ?';
             $arrValues[] = sprintf('%%%s%%', $objFormParam->getValue($key));
             break;
         case 'search_order_kana':
             $where .= ' AND ' . $dbFactory->concatColumn(array('order_kana01', 'order_kana02')) . ' LIKE ?';
             $arrValues[] = sprintf('%%%s%%', $objFormParam->getValue($key));
             break;
         case 'search_order_id1':
             $where .= ' AND order_id >= ?';
             $arrValues[] = sprintf('%d', $objFormParam->getValue($key));
             break;
         case 'search_order_id2':
             $where .= ' AND order_id <= ?';
             $arrValues[] = sprintf('%d', $objFormParam->getValue($key));
             break;
         case 'search_order_sex':
             $tmp_where = '';
             foreach ($objFormParam->getValue($key) as $element) {
                 if ($element != '') {
                     if (SC_Utils_Ex::isBlank($tmp_where)) {
                         $tmp_where .= ' AND (order_sex = ?';
                     } else {
                         $tmp_where .= ' OR order_sex = ?';
                     }
                     $arrValues[] = $element;
                 }
             }
             if (!SC_Utils_Ex::isBlank($tmp_where)) {
                 $tmp_where .= ')';
                 $where .= " {$tmp_where} ";
             }
             break;
         case 'search_order_tel':
             $where .= ' AND (' . $dbFactory->concatColumn(array('order_tel01', 'order_tel02', 'order_tel03')) . ' LIKE ?)';
             $arrValues[] = sprintf('%%%d%%', preg_replace('/[()-]+/', '', $objFormParam->getValue($key)));
             break;
         case 'search_order_email':
             $where .= ' AND order_email LIKE ?';
             $arrValues[] = sprintf('%%%s%%', $objFormParam->getValue($key));
             break;
         case 'search_payment_id':
             $tmp_where = '';
             foreach ($objFormParam->getValue($key) as $element) {
                 if ($element != '') {
                     if ($tmp_where == '') {
                         $tmp_where .= ' AND (payment_id = ?';
                     } else {
                         $tmp_where .= ' OR payment_id = ?';
                     }
                     $arrValues[] = $element;
                 }
             }
             if (!SC_Utils_Ex::isBlank($tmp_where)) {
                 $tmp_where .= ')';
                 $where .= " {$tmp_where} ";
             }
             break;
         case 'search_total1':
             $where .= ' AND total >= ?';
             $arrValues[] = sprintf('%d', $objFormParam->getValue($key));
             break;
         case 'search_total2':
             $where .= ' AND total <= ?';
             $arrValues[] = sprintf('%d', $objFormParam->getValue($key));
             break;
         case 'search_sorderyear':
             $date = SC_Utils_Ex::sfGetTimestamp($objFormParam->getValue('search_sorderyear'), $objFormParam->getValue('search_sordermonth'), $objFormParam->getValue('search_sorderday'));
             $where .= ' AND create_date >= ?';
             $arrValues[] = $date;
             break;
         case 'search_eorderyear':
             $date = SC_Utils_Ex::sfGetTimestamp($objFormParam->getValue('search_eorderyear'), $objFormParam->getValue('search_eordermonth'), $objFormParam->getValue('search_eorderday'), true);
             $where .= ' AND create_date <= ?';
             $arrValues[] = $date;
             break;
         case 'search_supdateyear':
             $date = SC_Utils_Ex::sfGetTimestamp($objFormParam->getValue('search_supdateyear'), $objFormParam->getValue('search_supdatemonth'), $objFormParam->getValue('search_supdateday'));
             $where .= ' AND update_date >= ?';
             $arrValues[] = $date;
             break;
         case 'search_eupdateyear':
             $date = SC_Utils_Ex::sfGetTimestamp($objFormParam->getValue('search_eupdateyear'), $objFormParam->getValue('search_eupdatemonth'), $objFormParam->getValue('search_eupdateday'), true);
             $where .= ' AND update_date <= ?';
             $arrValues[] = $date;
             break;
         case 'search_sbirthyear':
             $date = SC_Utils_Ex::sfGetTimestamp($objFormParam->getValue('search_sbirthyear'), $objFormParam->getValue('search_sbirthmonth'), $objFormParam->getValue('search_sbirthday'));
             $where .= ' AND order_birth >= ?';
             $arrValues[] = $date;
             break;
         case 'search_ebirthyear':
             $date = SC_Utils_Ex::sfGetTimestamp($objFormParam->getValue('search_ebirthyear'), $objFormParam->getValue('search_ebirthmonth'), $objFormParam->getValue('search_ebirthday'), true);
             $where .= ' AND order_birth <= ?';
             $arrValues[] = $date;
             break;
         case 'search_order_status':
             $where .= ' AND status = ?';
             $arrValues[] = $objFormParam->getValue($key);
             break;
         default:
             break;
     }
 }
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $objView = new SC_AdminView();
     $objSess = new SC_Session();
     $objDate = new SC_Date();
     $objQuery = new SC_Query();
     // 状態の設定
     // 登録・更新検索開始年
     $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();
     // 認証可否の判定
     SC_Utils_Ex::sfIsSuccess($objSess);
     // トラックバック情報のカラムの取得(viewとの結合のため、テーブルをAと定義しておく)
     $select = "A.trackback_id, A.product_id, A.blog_name, A.title, A.url, ";
     $select .= "A.excerpt, A.status, A.create_date, A.update_date, B.name";
     $from = "dtb_trackback AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ";
     // 検索ワードの引き継ぎ
     foreach ($_POST as $key => $val) {
         if (ereg("^search_", $key)) {
             $this->arrHidden[$key] = $val;
         }
     }
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     // トラックバックの削除
     if ($_POST['mode'] == "delete") {
         $objQuery->exec("UPDATE dtb_trackback SET del_flg = 1, update_date = now() WHERE trackback_id = ?", array($_POST['trackback_id']));
     }
     if ($_POST['mode'] == 'search' || $_POST['mode'] == 'csv' || $_POST['mode'] == 'delete') {
         //削除されていない商品を検索
         $where = "A.del_flg = 0 AND B.del_flg = 0";
         $this->arrForm = $_POST;
         //エラーチェック
         $this->arrErr = $this->lfCheckError();
         if (!$this->arrErr) {
             foreach ($_POST as $key => $val) {
                 $val = SC_Utils_Ex::sfManualEscape($val);
                 if ($val == "") {
                     continue;
                 }
                 switch ($key) {
                     case 'search_blog_name':
                         $val = ereg_replace(" ", "%", $val);
                         $val = ereg_replace(" ", "%", $val);
                         $where .= " AND A.blog_name ILIKE ? ";
                         $arrval[] = "%{$val}%";
                         break;
                     case 'search_blog_title':
                         $val = ereg_replace(" ", "%", $val);
                         $val = ereg_replace(" ", "%", $val);
                         $where .= " AND A.title ILIKE ? ";
                         $arrval[] = "%{$val}%";
                         break;
                     case 'search_blog_url':
                         $val = ereg_replace(" ", "%", $val);
                         $val = ereg_replace(" ", "%", $val);
                         $where .= " AND A.url ILIKE ? ";
                         $arrval[] = "%{$val}%";
                         break;
                     case 'search_status':
                         if (isset($_POST['search_status'])) {
                             $where .= " AND A.status = ? ";
                             $arrval[] = $val;
                         }
                         break;
                     case 'search_name':
                         $val = ereg_replace(" ", "%", $val);
                         $val = ereg_replace(" ", "%", $val);
                         $where .= " AND B.name ILIKE ? ";
                         $arrval[] = "%{$val}%";
                         break;
                     case 'search_product_code':
                         $val = ereg_replace(" ", "%", $val);
                         $val = ereg_replace(" ", "%", $val);
                         $where .= " AND B.product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code ILIKE ? )";
                         $arrval[] = "%{$val}%";
                         break;
                     case 'search_startyear':
                         if (isset($_POST['search_startyear']) && isset($_POST['search_startmonth']) && isset($_POST['search_startday'])) {
                             $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_startyear'], $_POST['search_startmonth'], $_POST['search_startday']);
                             $where .= " AND A.create_date >= ? ";
                             $arrval[] = $date;
                         }
                         break;
                     case 'search_endyear':
                         if (isset($_POST['search_startyear']) && isset($_POST['search_startmonth']) && isset($_POST['search_startday'])) {
                             $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_endyear'], $_POST['search_endmonth'], $_POST['search_endday']);
                             $end_date = date("Y/m/d", strtotime("1 day", strtotime($date)));
                             $where .= " AND A.create_date <= cast('{$end_date}' as date) ";
                         }
                         break;
                 }
             }
         }
         $order = "A.create_date DESC";
         // ページ送りの処理
         if (is_numeric($_POST['search_page_max'])) {
             $page_max = $_POST['search_page_max'];
         } else {
             $page_max = SEARCH_PMAX;
         }
         if (!isset($arrval)) {
             $arrval = array();
         }
         $linemax = $objQuery->count($from, $where, $arrval);
         $this->tpl_linemax = $linemax;
         $this->tpl_pageno = isset($_POST['search_pageno']) ? $_POST['search_pageno'] : "";
         // ページ送りの取得
         $objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $page_max, "fnNaviSearchPage", NAVI_PMAX);
         $this->arrPagenavi = $objNavi->arrPagenavi;
         $startno = $objNavi->start_row;
         // 取得範囲の指定(開始行番号、行数のセット)
         $objQuery->setlimitoffset($page_max, $startno);
         // 表示順序
         $objQuery->setorder($order);
         //検索結果の取得
         $this->arrTrackback = $objQuery->select($select, $from, $where, $arrval);
         //CSVダウンロード
         if ($_POST['mode'] == 'csv') {
             $objCSV = new SC_Helper_CSV_Ex();
             // オプションの指定
             $option = "ORDER BY A.trackback_id";
             // CSV出力タイトル行の作成
             $head = SC_Utils_Ex::sfGetCSVList($objCSV->arrTRACKBACK_CVSTITLE);
             $data = $objCSV->lfGetTrackbackCSV($where, '', $arrval);
             // CSVを送信する。
             SC_Utils_Ex::sfCSVDownload($head . $data);
             exit;
         }
     }
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
 /**
  * 会員登録に必要なSQLパラメーターの配列を生成する.
  *
  * フォームに入力された情報を元に, SQLパラメーターの配列を生成する.
  * モバイル端末の場合は, email を email_mobile にコピーし,
  * mobile_phone_id に携帯端末IDを格納する.
  *
  * @param mixed $objFormParam
  * @access private
  * @return $arrResults
  */
 public function lfMakeSqlVal(&$objFormParam)
 {
     $arrForm = $objFormParam->getHashArray();
     $arrResults = $objFormParam->getDbArray();
     // 生年月日の作成
     $arrResults['birth'] = SC_Utils_Ex::sfGetTimestamp($arrForm['year'], $arrForm['month'], $arrForm['day']);
     // 仮会員 1 本会員 2
     $arrResults['status'] = CUSTOMER_CONFIRM_MAIL == true ? '1' : '2';
     /*
      * secret_keyは、テーブルで重複許可されていない場合があるので、
      * 本会員登録では利用されないがセットしておく。
      */
     $arrResults['secret_key'] = SC_Helper_Customer_Ex::sfGetUniqSecretKey();
     // 入会時ポイント
     $CONF = SC_Helper_DB_Ex::sfGetBasisData();
     $arrResults['point'] = $CONF['welcome_point'];
     if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
         // 携帯メールアドレス
         $arrResults['email_mobile'] = $arrResults['email'];
         // PHONE_IDを取り出す
         $arrResults['mobile_phone_id'] = SC_MobileUserAgent_Ex::getId();
     }
     return $arrResults;
 }
Ejemplo n.º 7
0
 function lfRegistData($uniqid)
 {
     $arrRet = $this->objFormParam->getHashArray();
     $sqlval = $this->objFormParam->getDbArray();
     // 登録データの作成
     $sqlval['order_temp_id'] = $uniqid;
     $sqlval['order_birth'] = SC_Utils_Ex::sfGetTimestamp($arrRet['year'], $arrRet['month'], $arrRet['day']);
     $sqlval['update_date'] = 'Now()';
     $sqlval['customer_id'] = '0';
     // 既存データのチェック
     $objQuery = new SC_Query();
     $where = "order_temp_id = ?";
     $cnt = $objQuery->count("dtb_order_temp", $where, array($uniqid));
     // 既存データがない場合
     if ($cnt == 0) {
         $sqlval['create_date'] = 'Now()';
         $objQuery->insert("dtb_order_temp", $sqlval);
     } else {
         $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid));
     }
 }
 /**
  * テスト用 会員データ を生成する.
  *
  * @return void
  */
 function createCustomers()
 {
     lfPrintLog("createCustomers START.(" . CUSTOMERS_VOLUME . " data)");
     for ($i = 0; $i < CUSTOMERS_VOLUME; $i++) {
         lfPrintLog("----------");
         lfPrintLog("creating customer data count:[" . ($i + 1) . "] start.");
         $sqlval['name01'] = "検証";
         $sqlval['name02'] = sprintf("太郎%05d", $i + 1);
         $sqlval['kana01'] = "ケンショウ";
         $sqlval['kana02'] = "タロウ";
         $sqlval['zip01'] = '101';
         $sqlval['zip02'] = '0051';
         $sqlval['pref'] = '13';
         // 13:東京都
         $sqlval['addr01'] = "千代田区神田神保町";
         $sqlval['addr02'] = "1-3-5";
         $sqlval['tel01'] = '012';
         $sqlval['tel02'] = '3456';
         $sqlval['tel03'] = '7890';
         $sqlval['email'] = EMAIL_ADDRESS_ACCOUNT . "+" . sprintf("%05d", $i + 1) . EMAIL_ADDRESS_DOMAIN;
         $sqlval['sex'] = '1';
         // 1:男性 2:女性
         $sqlval['password'] = '******';
         $sqlval['reminder'] = '1';
         // 1:「母親の旧姓は?」
         $sqlval['reminder_answer'] = "てすと";
         $sqlval['mailmaga_flg'] = (string) '1';
         // 1:HTMLメール 2:テキストメール 3:希望しない
         // 生年月日の作成
         $sqlval['birth'] = SC_Utils_Ex::sfGetTimestamp(2006, 9, 1);
         // 仮会員 1 本会員 2
         $sqlval['status'] = '2';
         /*
          * secret_keyは、テーブルで重複許可されていない場合があるので、
          * 本会員登録では利用されないがセットしておく。
          */
         $sqlval['secret_key'] = SC_Helper_Customer_Ex::sfGetUniqSecretKey();
         // 入会時ポイント
         $CONF = SC_Helper_DB_Ex::sfGetBasisData();
         $sqlval['point'] = $CONF['welcome_point'];
         // 会員データの生成
         SC_Helper_Customer_Ex::sfEditCustomerData($sqlval);
         print "*";
         lfPrintLog("creating customer data count:[" . ($i + 1) . "] end.");
     }
     print "\n";
     lfPrintLog("createCustomers DONE.(" . CUSTOMERS_VOLUME . " data created)");
 }
Ejemplo n.º 9
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);
 }
Ejemplo n.º 10
0
 /**
  * データの一時登録を行う.
  *
  * @param integer $uniqid 受注一時テーブルのユニークID
  * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
  * @param SC_Customer $objCustomer SC_Customer インスタンス
  * @param SC_FormParam $objFormParam SC_FormParam インスタンス
  * @param boolean $isMultiple 複数配送の場合 true
  */
 function lfRegistData($uniqid, &$objPurchase, &$objCustomer, &$objFormParam, $isMultiple = false)
 {
     $arrParams = $objFormParam->getHashArray();
     $arrValues = $objFormParam->getDbArray();
     // 登録データの作成
     $arrValues['order_birth'] = SC_Utils_Ex::sfGetTimestamp($arrParams['year'], $arrParams['month'], $arrParams['day']);
     $arrValues['update_date'] = 'CURRENT_TIMESTAMP';
     $arrValues['customer_id'] = '0';
     // お届け先を指定しない場合、
     if ($arrParams['deliv_check'] != '1') {
         // order_* を shipping_* へコピー
         $objPurchase->copyFromOrder($arrValues, $arrParams);
     }
     /*
      * order_* と shipping_* をそれぞれ $_SESSION['shipping'][$shipping_id]
      * に, shipping_* というキーで保存
      */
     foreach ($arrValues as $key => $val) {
         if (preg_match('/^order_/', $key)) {
             $arrOrder['shipping_' . str_replace('order_', '', $key)] = $val;
         } elseif (preg_match('/^shipping_/', $key)) {
             $arrShipping[$key] = $val;
         }
     }
     if ($isMultiple) {
         $objPurchase->saveShippingTemp($arrOrder, 0);
         if ($arrParams['deliv_check'] == '1') {
             $objPurchase->saveShippingTemp($arrShipping, 1);
         }
     } else {
         if ($arrParams['deliv_check'] == '1') {
             $objPurchase->saveShippingTemp($arrShipping, 0);
         } else {
             $objPurchase->saveShippingTemp($arrOrder, 0);
         }
     }
     $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer);
 }
 protected function sfGetTimestamp($arrList, $prefix = "", $end = false)
 {
     $y = $arrList["{$prefix}_year"];
     $m = $arrList["{$prefix}_month"];
     $d = $arrList["{$prefix}_day"];
     return SC_Utils_Ex::sfGetTimestamp($y, $m, $d, $end);
 }
Ejemplo n.º 12
0
 function init()
 {
     parent::init();
     $objCustomer = new SC_Customer_Ex();
     if (isset($_GET["sid"]) && isset($_GET["admin"])) {
         $sid = $_REQUEST["sid"];
         $email = $objCustomer->getValue("email");
         $osid = session_id();
         if ($osid != $sid) {
             session_destroy();
             session_id($sid);
             session_start();
         }
         $objCustomer->setLogin($email);
         $get = $_GET;
         unset($get["sid"]);
         SC_Response_Ex::reload($get, true);
     }
     $objQuery = SC_Query_Ex::getSingletonInstance();
     $objProduct = new SC_Product_Ex();
     if (GC_Utils_Ex::isFrontFunction() && $this->skip_load_page_layout == false) {
         $objCustomer = new SC_Customer_Ex();
         // 画面更新毎に情報を更新する
         if ($objCustomer->isLoginSuccess()) {
             // 初回アクセス時に更新
             $objCustomer->updateSession();
             $this->tpl_login = true;
             $this->tpl_point = $objCustomer->getValue("point");
             $this->tpl_customer_id = $objCustomer->getValue("customer_id");
             $this->tpl_first_buy_date = $objCustomer->getValue("first_buy_date");
             $this->tpl_carrier = $objCustomer->getValue("carrier");
             $downloadable_days = $this->arrSiteInfo["downloadable_days"];
             $downloadable_days_unlimited = $this->arrSiteInfo["downloadable_days_unlimited"];
             $date = null;
             if ($downloadable_days_unlimited) {
                 $date = SC_Utils_Ex::sfGetTimestamp(RELEASE_YEAR, 1, 1, false);
                 $date2 = SC_Utils_Ex::sfGetTimestamp(9999, 12, 31, false);
             } else {
                 $xdate = strtotime("-{$downloadable_days} day");
                 $date = SC_Utils_Ex::sfGetTimestamp(date("Y", $xdate), date("m", $xdate), date("d", $xdate), false);
                 $xdate = strtotime("+{$downloadable_days} day");
                 $date2 = SC_Utils_Ex::sfGetTimestamp(date("Y", $xdate), date("m", $xdate), date("d", $xdate), false);
             }
             $this->downloadable_days = $date;
             $this->downloadable_days2 = $date2;
             $objPurchase = new SC_Helper_Purchase_Ex();
             $arrOrderId = $objQuery->getCol("order_id", "dtb_order", "payment_date > ? AND customer_id = ?", array($date, $this->tpl_customer_id));
             $this->arrRedownloadProduct = array();
             foreach ($arrOrderId as $order_id) {
                 $arrOrderDetail = $objPurchase->getOrderDetail($order_id, true);
                 $this->arrRedownloadProduct = array_merge($this->arrRedownloadProduct, $arrOrderDetail);
             }
             // 再ダウンロード可能な商品一覧
             $this->arrRedownloadProduct = SC_Utils_Ex::makeArrayIDToKey("product_id", $this->arrRedownloadProduct);
             foreach ($this->arrRedownloadProduct as $product_id => $row) {
                 $row["product"] = $objProduct->getDetail($product_id);
                 $this->arrRedownloadProduct[$product_id] = $row;
             }
         } else {
             $this->tpl_login = false;
             $this->tpl_point = 0;
             $this->tpl_customer_id = 0;
             $this->tpl_first_buy_date = null;
             $this->tpl_carrier = 9;
             $this->arrRedownloadProduct = array();
         }
         $objDb = new SC_Helper_DB_Ex();
         if ($objDb->sfColumnExists("cp_dtb_customer_transaction", "id")) {
             $where = " customer_id =  ? AND transaction_status =  ? AND continue_account_id IS NOT NULL AND del_flg = 0";
             $arrWhereVal = array($this->tpl_customer_id, 40);
             if ($objQuery->exists("cp_dtb_customer_transaction", $where, $arrWhereVal)) {
                 // OK
             } else {
                 switch (basename(dirname($_SERVER["SCRIPT_NAME"]))) {
                     case "au":
                         break;
                     default:
                         if ($objCustomer->isLoginSuccess()) {
                             $objCustomer->EndSession();
                             SC_Response_Ex::reload();
                         }
                         break;
                 }
             }
         }
         $objCategory = new SC_Helper_Category_Ex();
         $this->arrCommonCategory = $objCategory->getList(true);
         $this->arrCommonCategoryTree = $objCategory->getTree();
         $detect = new Mobile_Detect();
         $script_file = $_SERVER["SCRIPT_NAME"];
         $script_file = ltrim($script_file, "/");
         $script_file2 = str_replace("ios/", "", $script_file);
         if ($detect->is("iOS")) {
             if (file_exists(HTML_REALDIR . "ios/{$script_file}")) {
                 SC_Response_Ex::sendRedirect(HTTP_URL . "ios/{$script_file}", $_GET);
             }
         } elseif (strcmp($script_file, $script_file2) !== 0) {
             SC_Response_Ex::sendRedirect(HTTP_URL . "{$script_file2}", $_GET);
         }
         $_SESSION["is_android"] = $detect->is("AndroidOS");
         if ($detect->isMobile() == false) {
             // NG
             $this->device_support = false;
         } elseif ($detect->is("iOS")) {
             if ($detect->match("iPhone")) {
                 // OK
                 $this->device_support = true;
             } elseif ($detect->match("iPod")) {
                 // NG
                 $this->device_support = false;
             } elseif ($detect->match("iPad")) {
                 // NG
                 $this->device_support = false;
             } else {
                 // NG
                 $this->device_support = false;
             }
             $version = $detect->version("iOS", $detect::VERSION_TYPE_FLOAT);
             if ($version < 6) {
                 // NG
                 $this->device_support = false;
             }
         } elseif ($detect->match("Android") == false) {
             // NG
             $this->device_support = false;
         } elseif (class_exists("SC_DeviceAndroidSelect_Ex", true)) {
             $useragent = array();
             if (preg_match("|.*; ([^;]+) Build/.*|", $_SERVER["HTTP_USER_AGENT"], $useragent)) {
                 $device = new SC_DeviceAndroidSelect_Ex(array("search_device_user_agent_word" => $useragent[1], "search_status" => 1));
                 $this->device_support = $device->exists();
                 $this->tpl_device = $device->getOne();
             }
         } elseif ($detect->match("Android")) {
             // OK
             $this->device_support = true;
         } else {
             // NG
             $this->device_support = false;
         }
     }
     if ($this->device_support) {
         GC_Utils_Ex::gfPrintLog("対応端末:" . $_SERVER['HTTP_USER_AGENT']);
         return;
     } else {
         GC_Utils_Ex::gfPrintLog("非対応端末:" . $_SERVER['HTTP_USER_AGENT']);
         if (is_a($this, "LC_Page_Index")) {
             SC_Response_Ex::sendRedirect(HTTP_URL . "unsupported/index.php");
         } elseif (is_a($this, "LC_Page_Unsupported")) {
             // 非対応端末表示を行わない
             return;
         } elseif (is_a($this, "LC_Page_Entry_Kiyaku")) {
             // 非対応端末表示を行わない
             return;
         } elseif ($this->not_unsupported) {
             // 非対応端末表示を行わない
             return;
         } else {
             SC_Response_Ex::sendRedirect(HTTP_URL . "unsupported/index.php");
         }
     }
 }
Ejemplo n.º 13
0
 /**
  * クエリを構築する.
  *
  * 検索条件のキーに応じた WHERE 句と, クエリパラメーターを構築する.
  * クエリパラメーターは, SC_FormParam の入力値から取得する.
  *
  * 構築内容は, 引数の $where 及び $arrValues にそれぞれ追加される.
  *
  * @param string $key 検索条件のキー
  * @param string $where 構築する WHERE 句
  * @param array $arrValues 構築するクエリパラメーター
  * @param SC_FormParam $objFormParam SC_FormParam インスタンス
  * @param SC_FormParam $objDb SC_Helper_DB_Ex インスタンス
  * @return void
  */
 function buildQuery($key, &$where, &$arrValues, &$objFormParam, &$objDb)
 {
     $dbFactory = SC_DB_DBFactory_Ex::getInstance();
     switch ($key) {
         // 商品ID
         case 'search_product_id':
             $where .= " AND product_id = ?";
             $arrValues[] = sprintf('%d', $objFormParam->getValue($key));
             break;
             // 商品コード
         // 商品コード
         case 'search_product_code':
             $where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code LIKE ? GROUP BY product_id)";
             $arrValues[] = sprintf('%%%s%%', $objFormParam->getValue($key));
             break;
             // 商品名
         // 商品名
         case 'search_name':
             $where .= " AND name LIKE ?";
             $arrValues[] = sprintf('%%%s%%', $objFormParam->getValue($key));
             break;
             // カテゴリ
         // カテゴリ
         case 'search_category_id':
             list($tmp_where, $tmp_Values) = $objDb->sfGetCatWhere($objFormParam->getValue($key));
             if ($tmp_where != "") {
                 $where .= " AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")";
                 $arrValues = array_merge((array) $arrValues, (array) $tmp_Values);
             }
             break;
             // 種別
         // 種別
         case 'search_status':
             $tmp_where = "";
             foreach ($objFormParam->getValue($key) as $element) {
                 if ($element != "") {
                     if (SC_Utils_Ex::isBlank($tmp_where)) {
                         $tmp_where .= " AND (status = ?";
                     } else {
                         $tmp_where .= " OR status = ?";
                     }
                     $arrValues[] = $element;
                 }
             }
             if (!SC_Utils_Ex::isBlank($tmp_where)) {
                 $tmp_where .= ")";
                 $where .= " {$tmp_where} ";
             }
             break;
             // 登録・更新日(開始)
         // 登録・更新日(開始)
         case 'search_startyear':
             $date = SC_Utils_Ex::sfGetTimestamp($objFormParam->getValue('search_startyear'), $objFormParam->getValue('search_startmonth'), $objFormParam->getValue('search_startday'));
             $where .= " AND update_date >= ?";
             $arrValues[] = $date;
             break;
             // 登録・更新日(終了)
         // 登録・更新日(終了)
         case 'search_endyear':
             $date = SC_Utils_Ex::sfGetTimestamp($objFormParam->getValue('search_endyear'), $objFormParam->getValue('search_endmonth'), $objFormParam->getValue('search_endday'), true);
             $where .= " AND update_date <= ?";
             $arrValues[] = $date;
             break;
             // 商品ステータス
         // 商品ステータス
         case 'search_product_statuses':
             if (count($objFormParam->getValue($key)) > 0) {
                 $where .= " AND product_id IN (SELECT product_id FROM dtb_product_status WHERE product_status_id IN (";
                 foreach ($objFormParam->getValue($key) as $param) {
                     $where .= "?,";
                     $arrValues[] = $param;
                 }
                 $where = preg_replace("/,\$/", "))", $where);
             }
             break;
     }
 }
 /**
  * DB更新処理
  *
  * @param integer $order_id 受注ID
  * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
  * @param SC_FormParam $objFormParam SC_FormParam インスタンス
  * @param string $message 通知メッセージ
  * @param array $arrValuesBefore 更新前の受注情報
  * @return integer $order_id 受注ID
  *
  * エラー発生時は負数を返す。
  */
 function doRegister($order_id, &$objPurchase, &$objFormParam, &$message, &$arrValuesBefore)
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $arrValues = $objFormParam->getDbArray();
     $where = 'order_id = ?';
     $objQuery->begin();
     // 支払い方法が変更されたら、支払い方法名称も更新
     if ($arrValues['payment_id'] != $arrValuesBefore['payment_id']) {
         $arrValues['payment_method'] = $this->arrPayment[$arrValues['payment_id']];
         $arrValuesBefore['payment_id'] = NULL;
     }
     // 受注テーブルの更新
     $order_id = $objPurchase->registerOrder($order_id, $arrValues);
     $arrDetail = $objFormParam->getSwapArray(array('product_id', 'product_class_id', 'product_code', 'product_name', 'price', 'quantity', 'point_rate', 'classcategory_name1', 'classcategory_name2'));
     // 変更しようとしている商品情報とDBに登録してある商品情報を比較することで、更新すべき数量を計算
     $max = count($arrDetail);
     $k = 0;
     $arrStockData = array();
     for ($i = 0; $i < $max; $i++) {
         if (!empty($arrDetail[$i]['product_id'])) {
             $arrPreDetail = $objQuery->select('*', 'dtb_order_detail', 'order_id = ? AND product_class_id = ?', array($order_id, $arrDetail[$i]['product_class_id']));
             if (!empty($arrPreDetail) && $arrPreDetail[0]['quantity'] != $arrDetail[$i]['quantity']) {
                 // 数量が変更された商品
                 $arrStockData[$k]['product_class_id'] = $arrDetail[$i]['product_class_id'];
                 $arrStockData[$k]['quantity'] = $arrPreDetail[0]['quantity'] - $arrDetail[$i]['quantity'];
                 ++$k;
             } elseif (empty($arrPreDetail)) {
                 // 新しく追加された商品 もしくは 違う商品に変更された商品
                 $arrStockData[$k]['product_class_id'] = $arrDetail[$i]['product_class_id'];
                 $arrStockData[$k]['quantity'] = -$arrDetail[$i]['quantity'];
                 ++$k;
             }
             $objQuery->delete('dtb_order_detail', 'order_id = ? AND product_class_id = ?', array($order_id, $arrDetail[$i]['product_class_id']));
         }
     }
     // 上記の新しい商品のループでDELETEされなかった商品は、注文より削除された商品
     $arrPreDetail = $objQuery->select('*', 'dtb_order_detail', 'order_id = ?', array($order_id));
     foreach ($arrPreDetail as $key => $val) {
         $arrStockData[$k]['product_class_id'] = $val['product_class_id'];
         $arrStockData[$k]['quantity'] = $val['quantity'];
         ++$k;
     }
     // 受注詳細データの更新
     $objPurchase->registerOrderDetail($order_id, $arrDetail);
     // 在庫数調整
     if (ORDER_DELIV != $arrValues['status'] && ORDER_CANCEL != $arrValues['status']) {
         foreach ($arrStockData as $stock) {
             $objQuery->update('dtb_products_class', array(), 'product_class_id = ?', array($stock['product_class_id']), array('stock' => 'stock + ?'), array($stock['quantity']));
         }
     }
     $arrAllShipping = $objFormParam->getSwapArray($this->arrShippingKeys);
     $arrAllShipmentItem = $objFormParam->getSwapArray($this->arrShipmentItemKeys);
     $arrDelivTime = $objPurchase->getDelivTime($objFormParam->getValue('deliv_id'));
     $arrShippingValues = array();
     foreach ($arrAllShipping as $shipping_index => $arrShipping) {
         $shipping_id = $arrShipping['shipping_id'];
         $arrShippingValues[$shipping_index] = $arrShipping;
         $arrShippingValues[$shipping_index]['shipping_date'] = SC_Utils_Ex::sfGetTimestamp($arrShipping['shipping_date_year'], $arrShipping['shipping_date_month'], $arrShipping['shipping_date_day']);
         // 配送業者IDを取得
         $arrShippingValues[$shipping_index]['deliv_id'] = $objFormParam->getValue('deliv_id');
         // お届け時間名称を取得
         $arrShippingValues[$shipping_index]['shipping_time'] = $arrDelivTime[$arrShipping['time_id']];
         // 複数配送の場合は配送商品を登録
         if (!SC_Utils_Ex::isBlank($arrAllShipmentItem)) {
             $arrShipmentValues = array();
             foreach ($arrAllShipmentItem[$shipping_index] as $key => $arrItem) {
                 $i = 0;
                 foreach ($arrItem as $item) {
                     $arrShipmentValues[$shipping_index][$i][str_replace('shipment_', '', $key)] = $item;
                     $i++;
                 }
             }
             $objPurchase->registerShipmentItem($order_id, $shipping_id, $arrShipmentValues[$shipping_index]);
         }
     }
     $objPurchase->registerShipping($order_id, $arrShippingValues, false);
     $objQuery->commit();
     return $order_id;
 }
 /**
  * データの一時登録を行う.
  *
  * 非会員向けの処理
  * @param integer $uniqid 受注一時テーブルのユニークID
  * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
  * @param SC_Customer $objCustomer SC_Customer インスタンス
  * @param SC_FormParam $objFormParam SC_FormParam インスタンス
  * @param boolean $isMultiple 複数配送の場合 true
  */
 function lfRegistData($uniqid, &$objPurchase, &$objCustomer, &$objFormParam, $isMultiple = false)
 {
     $arrParams = $objFormParam->getHashArray();
     // 注文者をお届け先とする配列を取得
     $arrShippingOwn = array();
     $objPurchase->copyFromOrder($arrShippingOwn, $arrParams);
     // 都度入力されたお届け先
     $arrShipping = $objPurchase->extractShipping($arrParams);
     if ($isMultiple) {
         $objPurchase->unsetOneShippingTemp(0);
         $objPurchase->unsetOneShippingTemp(1);
         $objPurchase->saveShippingTemp($arrShippingOwn, 0);
         if ($arrParams['deliv_check'] == '1') {
             $objPurchase->saveShippingTemp($arrShipping, 1);
         }
     } else {
         $objPurchase->unsetAllShippingTemp(true);
         if ($arrParams['deliv_check'] == '1') {
             $objPurchase->saveShippingTemp($arrShipping, 1);
         } else {
             $objPurchase->saveShippingTemp($arrShippingOwn, 0);
         }
     }
     $arrValues = $objFormParam->getDbArray();
     // 登録データの作成
     $arrValues['order_birth'] = SC_Utils_Ex::sfGetTimestamp($arrParams['year'], $arrParams['month'], $arrParams['day']);
     $arrValues['update_date'] = 'CURRENT_TIMESTAMP';
     $arrValues['customer_id'] = '0';
     $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer);
 }
 /**
  *  会員情報を登録する
  *
  * @param mixed $objFormParam
  * @param mixed $customer_id
  * @access private
  * @return void
  */
 function lfRegistCustomerData(&$objFormParam, $customer_id)
 {
     $arrRet = $objFormParam->getHashArray();
     $sqlval = $objFormParam->getDbArray();
     $sqlval['birth'] = SC_Utils_Ex::sfGetTimestamp($arrRet['year'], $arrRet['month'], $arrRet['day']);
     SC_Helper_Customer_Ex::sfEditCustomerData($sqlval, $customer_id);
 }
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $objView = new SC_AdminView();
     $objSess = new SC_Session();
     $objDate = new SC_Date();
     $objQuery = new SC_Query();
     // 登録・更新検索開始年
     $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();
     // 認証可否の判定
     SC_Utils_Ex::sfIsSuccess($objSess);
     //レビュー情報のカラムの取得
     $select = "review_id, A.product_id, reviewer_name, sex, recommend_level, ";
     $select .= "reviewer_url, title, comment, A.status, A.create_date, A.update_date, name";
     $from = "dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ";
     // 検索ワードの引き継ぎ
     foreach ($_POST as $key => $val) {
         if (ereg("^search_", $key)) {
             switch ($key) {
                 case 'search_sex':
                     $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") {
         //レビューの削除
         $objQuery->exec("UPDATE dtb_review SET del_flg=1 WHERE review_id=?", array($_POST['review_id']));
     }
     if ($_POST['mode'] == 'search' || $_POST['mode'] == 'csv' || $_POST['mode'] == 'delete') {
         //削除されていない商品を検索
         $where = "A.del_flg = 0 AND B.del_flg = 0";
         $this->arrForm = $_POST;
         if (isset($_POST['search_sex']) && !is_array($_POST['search_sex'])) {
             $this->arrForm['search_sex'] = split("-", $_POST['search_sex']);
         }
         //エラーチェック
         $this->arrErr = $this->lfCheckError();
         if (!$this->arrErr) {
             foreach ($_POST as $key => $val) {
                 $val = SC_Utils_Ex::sfManualEscape($val);
                 if ($val == "") {
                     continue;
                 }
                 switch ($key) {
                     case 'search_reviewer_name':
                         $val = ereg_replace(" ", "%", $val);
                         $val = ereg_replace(" ", "%", $val);
                         $where .= " AND reviewer_name ILIKE ? ";
                         $arrval[] = "%{$val}%";
                         break;
                     case 'search_reviewer_url':
                         $val = ereg_replace(" ", "%", $val);
                         $val = ereg_replace(" ", "%", $val);
                         $where .= " AND reviewer_url ILIKE ? ";
                         $arrval[] = "%{$val}%";
                         break;
                     case 'search_name':
                         $val = ereg_replace(" ", "%", $val);
                         $val = ereg_replace(" ", "%", $val);
                         $where .= " AND name ILIKE ? ";
                         $arrval[] = "%{$val}%";
                         break;
                     case 'search_product_code':
                         $val = ereg_replace(" ", "%", $val);
                         $val = ereg_replace(" ", "%", $val);
                         $where .= " AND A.product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code ILIKE ? )";
                         $arrval[] = "%{$val}%";
                         break;
                     case 'search_sex':
                         $tmp_where = "";
                         //$val=配列の中身,$element=各キーの値(1,2)
                         if (is_array($val)) {
                             foreach ($val as $element) {
                                 if ($element != "") {
                                     if ($tmp_where == "") {
                                         $tmp_where .= " AND (sex = ?";
                                     } else {
                                         $tmp_where .= " OR sex = ?";
                                     }
                                     $arrval[] = $element;
                                 }
                             }
                             if ($tmp_where != "") {
                                 $tmp_where .= ")";
                                 $where .= " {$tmp_where} ";
                             }
                         }
                         break;
                     case 'search_recommend_level':
                         $where .= " AND recommend_level = ? ";
                         $arrval[] = $val;
                         break;
                     case 'search_startyear':
                         if (isset($_POST['search_startyear']) && isset($_POST['search_startmonth']) && isset($_POST['search_startday'])) {
                             $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_startyear'], $_POST['search_startmonth'], $_POST['search_startday']);
                             $where .= " AND A.create_date >= ? ";
                             $arrval[] = $date;
                         }
                         break;
                     case 'search_endyear':
                         if (isset($_POST['search_startyear']) && isset($_POST['search_startmonth']) && isset($_POST['search_startday'])) {
                             $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_endyear'], $_POST['search_endmonth'], $_POST['search_endday']);
                             $end_date = date("Y/m/d", strtotime("1 day", strtotime($date)));
                             $where .= " AND A.create_date <= cast('{$end_date}' as date) ";
                         }
                         break;
                 }
             }
         }
         $order = "A.create_date DESC";
         // ページ送りの処理
         if (is_numeric($_POST['search_page_max'])) {
             $page_max = $_POST['search_page_max'];
         } else {
             $page_max = SEARCH_PMAX;
         }
         if (!isset($arrval)) {
             $arrval = array();
         }
         $linemax = $objQuery->count($from, $where, $arrval);
         $this->tpl_linemax = $linemax;
         $this->tpl_pageno = isset($_POST['search_pageno']) ? $_POST['search_pageno'] : "";
         // ページ送りの取得
         $objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $page_max, "fnNaviSearchPage", NAVI_PMAX);
         $this->arrPagenavi = $objNavi->arrPagenavi;
         $startno = $objNavi->start_row;
         // 取得範囲の指定(開始行番号、行数のセット)
         $objQuery->setlimitoffset($page_max, $startno);
         // 表示順序
         $objQuery->setorder($order);
         //検索結果の取得
         $this->arrReview = $objQuery->select($select, $from, $where, $arrval);
         //CSVダウンロード
         if ($_POST['mode'] == 'csv') {
             $objCSV = new SC_Helper_CSV_Ex();
             // オプションの指定
             $option = "ORDER BY review_id";
             // CSV出力タイトル行の作成
             $head = SC_Utils_Ex::sfGetCSVList($objCSV->arrREVIEW_CVSTITLE);
             $data = $objCSV->lfGetReviewCSV($where, '', $arrval);
             // CSVを送信する。
             SC_Utils_Ex::sfCSVDownload($head . $data);
             exit;
         }
     }
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
 /**
  * クエリを構築する.
  *
  * 検索条件のキーに応じた WHERE 句と, クエリパラメーターを構築する.
  * クエリパラメーターは, SC_FormParam の入力値から取得する.
  *
  * 構築内容は, 引数の $where 及び $arrValues にそれぞれ追加される.
  *
  * @param string $key 検索条件のキー
  * @param string $where 構築する WHERE 句
  * @param array $arrValues 構築するクエリパラメーター
  * @param SC_FormParam $objFormParam SC_FormParam インスタンス
  * @param SC_FormParam $objDb SC_Helper_DB_Ex インスタンス
  * @return void
  */
 function buildQuery($key, &$where, &$arrValues, &$objFormParam, &$objDb)
 {
     $dbFactory = SC_DB_DBFactory_Ex::getInstance();
     switch ($key) {
         // 商品ID
         case 'search_product_id':
             $where .= ' AND product_id = ?';
             $arrValues[] = sprintf('%d', $objFormParam->getValue($key));
             break;
             // 商品コード
         // 商品コード
         case 'search_product_code':
             $where .= ' AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code ILIKE ?)';
             $arrValues[] = sprintf('%%%s%%', $objFormParam->getValue($key));
             break;
             // 商品名
         // 商品名
         case 'search_name':
             $where .= ' AND name LIKE ?';
             $arrValues[] = sprintf('%%%s%%', $objFormParam->getValue($key));
             break;
             // カテゴリ
         // カテゴリ
         case 'search_category_id':
             list($tmp_where, $tmp_Values) = $objDb->sfGetCatWhere($objFormParam->getValue($key));
             if ($tmp_where != '') {
                 $where .= ' AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE ' . $tmp_where . ')';
                 $arrValues = array_merge((array) $arrValues, (array) $tmp_Values);
             }
             break;
             // 種別
         // 種別
         case 'search_status':
             $tmp_where = '';
             foreach ($objFormParam->getValue($key) as $element) {
                 if ($element != '') {
                     if (SC_Utils_Ex::isBlank($tmp_where)) {
                         $tmp_where .= ' AND (status = ?';
                     } else {
                         $tmp_where .= ' OR status = ?';
                     }
                     $arrValues[] = $element;
                 }
             }
             if (!SC_Utils_Ex::isBlank($tmp_where)) {
                 $tmp_where .= ')';
                 $where .= " {$tmp_where} ";
             }
             break;
             // 登録・更新日(開始)
         // 登録・更新日(開始)
         case 'search_startyear':
             $date = SC_Utils_Ex::sfGetTimestamp($objFormParam->getValue('search_startyear'), $objFormParam->getValue('search_startmonth'), $objFormParam->getValue('search_startday'));
             $where .= ' AND update_date >= ?';
             $arrValues[] = $date;
             break;
             // 登録・更新日(終了)
         // 登録・更新日(終了)
         case 'search_endyear':
             $date = SC_Utils_Ex::sfGetTimestamp($objFormParam->getValue('search_endyear'), $objFormParam->getValue('search_endmonth'), $objFormParam->getValue('search_endday'), true);
             $where .= ' AND update_date <= ?';
             $arrValues[] = $date;
             break;
             // 商品ステータス
         // 商品ステータス
         case 'search_product_statuses':
             $arrPartVal = $objFormParam->getValue($key);
             $count = count($arrPartVal);
             if ($count >= 1) {
                 $where .= ' ' . 'AND product_id IN (' . '    SELECT product_id FROM dtb_product_status WHERE product_status_id IN (' . SC_Utils_Ex::repeatStrWithSeparator('?', $count) . ')' . ')';
                 $arrValues = array_merge($arrValues, $arrPartVal);
             }
             break;
         default:
             break;
     }
 }
 function doEdit(SC_Query $objQuery, SC_FormParam &$objFormParam)
 {
     if (is_array($this->arrErr)) {
         $this->arrErr = array_filter($this->arrErr);
         if (count($this->arrErr)) {
             GC_Utils_Ex::gfPrintLog(print_r($this->arrErr, TRUE), ERROR_LOG_REALFILE);
             return;
         }
     }
     $this->arrErr = $objFormParam->checkError();
     if (!SC_Utils_Ex::isBlank($this->arrErr)) {
         return;
     }
     $device_id = $objFormParam->getValue("device_id");
     $sqldata = $objFormParam->getDbArray();
     $arrDateColumn = $this->ARR_DATE_COLUMN;
     foreach ($arrDateColumn as $column) {
         $date_keys = $this->date_keys($column);
         $date = $objFormParam->getHashArray(array_values($date_keys));
         $date = array_map("intval", $date);
         if (checkdate($date[$date_keys["month"]], $date[$date_keys["day"]], $date[$date_keys["year"]])) {
             $sqldata[$column] = SC_Utils_Ex::sfGetTimestamp($date[$date_keys["year"]], $date[$date_keys["month"]], $date[$date_keys["day"]], FALSE);
         }
     }
     $has_insert = false;
     $sqldata["update_date"] = "CURRENT_TIMESTAMP";
     $device_id = intval($device_id);
     if ($device_id == 0) {
         $sqldata["device_id"] = $objQuery->nextVal("cp_dtb_device_device_id");
         $sqldata["create_date"] = "CURRENT_TIMESTAMP";
         $sqldata["del_flg"] = 0;
         $objQuery->insert("cp_dtb_device", $sqldata);
         $device_id = $sqldata["device_id"];
         // 端末情報初期設定
         $objFormParam->addParam("edit_device_id", "edit_device_id");
         $objFormParam->setValue("edit_device_id", $device_id);
         $has_insert = true;
     } else {
         $sqldata["update_date"] = "CURRENT_TIMESTAMP";
         $objQuery->update("cp_dtb_device", $sqldata, "device_id=?", (array) $device_id);
         $objQuery->delete("cp_dtb_device_categories", "device_id=?", (array) $device_id);
     }
     $form = $objFormParam->getHashArray(array("category_id"));
     if (is_array($form["category_id"]) && count($form["category_id"])) {
         foreach ($form["category_id"] as $category_id) {
             $sqldata = compact("category_id", "device_id");
             $objQuery->insert("cp_dtb_device_categories", $sqldata);
         }
         if ($has_insert) {
             // 初回登録時のみ
             $this->doProductSupportinitial($objQuery, $objFormParam);
         }
     }
     $this->tpl_onload = "eccube.setValueAndSubmit('search_form', 'mode', 'return');";
     return $device_id;
 }