/**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     //---- 認証可否の判定
     $objSess = new SC_Session();
     SC_Utils_Ex::sfIsSuccess($objSess);
     $objView = new SC_AdminView();
     $objQuery = new SC_Query();
     $objFormParam = new SC_FormParam();
     $objCSV = new SC_Helper_CSV_Ex();
     // パラメータ情報の初期化
     $this->lfInitParam($objFormParam);
     // フォームの値をセット
     $objFormParam->setParam($_POST);
     // 編集処理の場合は状態を保持
     $this->is_update = isset($_POST['is_update']) ? $_POST['is_update'] : "";
     // フォームの値をテンプレートへ渡す
     $this->arrForm = $objFormParam->getHashArray();
     $campaign_id = isset($_POST['campaign_id']) ? $_POST['campaign_id'] : "";
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     switch ($_POST['mode']) {
         // 新規登録/編集登録
         case 'regist':
             // エラーチェック
             $this->arrErr = $this->lfErrorCheck($campaign_id, $objQuery, $objFormParam);
             if (count($this->arrErr) <= 0) {
                 // 登録
                 $this->lfRegistCampaign($campaign_id, $objQuery, $objFormParam);
                 // キャンペーンTOPへリダイレクト
                 $this->sendRedirect($this->getLocation(URL_CAMPAIGN_TOP));
                 exit;
             }
             break;
             // 編集押下時
         // 編集押下時
         case 'update':
             // キャンペーン情報を取得
             $this->arrForm = $this->lfGetCampaign($campaign_id, $objQuery);
             $this->is_update = true;
             break;
             // 削除押下時
         // 削除押下時
         case 'delete':
             // 削除
             $this->lfDeleteCampaign($campaign_id, $objQuery);
             // キャンペーンTOPへリダイレクト
             $this->sendRedirect($this->getLocation(URL_CAMPAIGN_TOP));
             exit;
             break;
             // CSV出力
         // CSV出力
         case 'csv':
             // オプションの指定
             $option = "ORDER BY create_date DESC";
             // CSV出力タイトル行の作成
             $arrCsvOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput(4, " WHERE csv_id = 4 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_campaign_order", "campaign_id = ?", $option, array($campaign_id), $arrCsvOutputCols);
             // CSVを送信する。
             SC_Utils_Ex::sfCSVDownload($head . $data);
             exit;
             break;
         default:
             break;
     }
     // キャンペーン一覧取得
     $this->arrCampaign = $this->lfGetCampaignList($objQuery);
     $this->campaign_id = $campaign_id;
     // キャンペーン期間用
     $objDate = new SC_Date();
     $this->arrYear = $objDate->getYear(min(date('Y'), $this->arrForm['start_year']));
     $this->arrMonth = $objDate->getMonth();
     $this->arrDay = $objDate->getDay();
     $this->arrHour = $objDate->getHour();
     $this->arrMinutes = $objDate->getMinutes();
     //---- ページ表示
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
 /**
  * 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->objFormParam = new SC_FormParam();
     // パラメータ情報の初期化
     $this->lfInitParam();
     // POST値の取得
     $this->objFormParam->setParam($_POST);
     // 通常時は親カテゴリを0に設定する。
     $this->arrForm['parent_category_id'] = isset($_POST['parent_category_id']) ? $_POST['parent_category_id'] : "";
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     switch ($_POST['mode']) {
         case 'edit':
             $this->objFormParam->convParam();
             $arrRet = $this->objFormParam->getHashArray();
             $this->arrErr = $this->lfCheckError($arrRet);
             if (count($this->arrErr) == 0) {
                 if ($_POST['category_id'] == "") {
                     $objQuery = new SC_Query();
                     $count = $objQuery->count("dtb_category");
                     if ($count < CATEGORY_MAX) {
                         $this->lfInsertCat($_POST['parent_category_id']);
                     } else {
                         print "カテゴリの登録最大数を超えました。";
                     }
                 } else {
                     $this->lfUpdateCat($_POST['category_id']);
                 }
             } else {
                 $this->arrForm = array_merge($this->arrForm, $this->objFormParam->getHashArray());
                 $this->arrForm['category_id'] = $_POST['category_id'];
             }
             break;
         case 'pre_edit':
             // 編集項目のカテゴリ名をDBより取得する。
             $oquery = new SC_Query();
             $where = "category_id = ?";
             $cat_name = $oquery->get("dtb_category", "category_name", $where, array($_POST['category_id']));
             $description = $oquery->get("dtb_category", "description", $where, array($_POST['category_id']));
             // 入力項目にカテゴリ名を入力する。
             $this->arrForm['category_name'] = $cat_name;
             $this->arrForm['description'] = $description;
             // POSTデータを引き継ぐ
             $this->arrForm['category_id'] = $_POST['category_id'];
             break;
         case 'delete':
             $objQuery = new SC_Query();
             // 子カテゴリのチェック
             $where = "parent_category_id = ? AND del_flg = 0";
             $count = $objQuery->count("dtb_category", $where, array($_POST['category_id']));
             if ($count != 0) {
                 $this->arrErr['category_name'] = "※ 子カテゴリが存在するため削除できません。<br>";
             }
             // 登録商品のチェック
             $table = "dtb_product_categories AS T1 LEFT JOIN dtb_products AS T2 ON T1.product_id = T2.product_id";
             $where = "T1.category_id = ? AND T2.del_flg = 0";
             $count = $objQuery->count($table, $where, array($_POST['category_id']));
             if ($count != 0) {
                 $this->arrErr['category_name'] = "※ カテゴリ内に商品が存在するため削除できません。<br>";
             }
             if (!isset($this->arrErr['category_name'])) {
                 // ランク付きレコードの削除(※処理負荷を考慮してレコードごと削除する。)
                 $objDb->sfDeleteRankRecord("dtb_category", "category_id", $_POST['category_id'], "", true);
             }
             break;
         case 'up':
             $objQuery = new SC_Query();
             $objQuery->begin();
             $up_id = $this->lfGetUpRankID($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']);
             if ($up_id != "") {
                 // 上のグループのrankから減算する数
                 $my_count = $this->lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']);
                 // 自分のグループのrankに加算する数
                 $up_count = $this->lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $up_id);
                 if ($my_count > 0 && $up_count > 0) {
                     // 自分のグループに加算
                     $this->lfUpRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id'], $up_count);
                     // 上のグループから減算
                     $this->lfDownRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $up_id, $my_count);
                 }
             }
             $objQuery->commit();
             break;
         case 'down':
             $objQuery = new SC_Query();
             $objQuery->begin();
             $down_id = $this->lfGetDownRankID($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']);
             if ($down_id != "") {
                 // 下のグループのrankに加算する数
                 $my_count = $this->lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']);
                 // 自分のグループのrankから減算する数
                 $down_count = $this->lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $down_id);
                 if ($my_count > 0 && $down_count > 0) {
                     // 自分のグループから減算
                     $this->lfUpRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $down_id, $my_count);
                     // 下のグループに加算
                     $this->lfDownRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id'], $down_count);
                 }
             }
             $objQuery->commit();
             break;
         case 'tree':
             break;
         case 'csv':
             require_once CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php";
             $objCSV = new SC_Helper_CSV_Ex();
             // オプションの指定
             $option = "ORDER BY rank DESC";
             // CSV出力タイトル行の作成
             $arrOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput(5, " WHERE csv_id = 5 AND status = 1"));
             if (count($arrOutput) <= 0) {
                 break;
             }
             $arrOutputCols = $arrOutput['col'];
             $arrOutputTitle = $arrOutput['disp_name'];
             $head = SC_Utils_Ex::sfGetCSVList($arrOutputTitle);
             $where = "del_flg = 0";
             $data = $objCSV->lfGetCategoryCSV($where, $option, $arrval, $arrOutputCols);
             // CSVを送信する。
             SC_Utils_Ex::sfCSVDownload($head . $data, 'category');
             exit;
             break;
         default:
             $this->arrForm['parent_category_id'] = 0;
             break;
     }
     $this->arrList = $this->lfGetCat($this->arrForm['parent_category_id']);
     $this->arrTree = $objDb->sfGetCatTree($this->arrForm['parent_category_id']);
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
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);
 }
Ejemplo n.º 4
0
 function lfGetDataColCSV($arrData, $arrDataCol)
 {
     $max = count($arrData);
     $csv_data = "";
     for ($i = 0; $i < $max; $i++) {
         foreach ($arrDataCol as $val) {
             $arrRet[$i][$val] = $arrData[$i][$val];
         }
         $csv_data .= SC_Utils_Ex::sfGetCSVList($arrRet[$i]);
     }
     return $csv_data;
 }
 function lfGetDataColCSV($arrData, $arrDataCol)
 {
     $max = count($arrData);
     $csv_data = '';
     for ($i = 0; $i < $max; $i++) {
         foreach ($arrDataCol as $val) {
             $arrRet[$i][$val] = $arrData[$i][$val];
         }
         // 期間別集計の合計行の「期間」項目に不要な値が表示されてしまわない様、'合計'と表示する
         if ($i === $max - 1 && isset($arrRet[$i]['str_date'])) {
             $arrRet[$i]['str_date'] = t('c_Total_01');
         }
         $csv_data .= SC_Utils_Ex::sfGetCSVList($arrRet[$i]);
     }
     return $csv_data;
 }
 /**
  * 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);
 }
    /**
     * Page のプロセス.
     *
     * @return void
     */
    function process()
    {
        $objQuery = new SC_Query();
        $objView = new SC_AdminView();
        $objSess = new SC_Session();
        // 認証可否の判定
        SC_Utils_Ex::sfIsSuccess($objSess);
        $arrActive = array("0" => "稼働", "1" => "非稼働");
        $arrQuestion = array("0" => "使用しない", "1" => "テキストエリア", "2" => "テキストボックス", "3" => "チェックボックス", "4" => "ラジオボタン");
        $result = $objQuery->select('*, cast(create_date as date) as disp_date', 'dtb_question', 'del_flg = 0 ORDER BY question_id');
        $this->list_data = $result;
        if (!isset($_GET['mode'])) {
            $_GET['mode'] = "";
        }
        // アンケートを作成ボタン押下時
        if ($_GET['mode'] == 'regist') {
            for ($i = 0; $i < count($_POST["question"]); $i++) {
                $_POST['question'][$i]['name'] = mb_convert_kana(trim($_POST['question'][$i]['name']), "K");
                for ($j = 0; $j < count($_POST['question'][$i]['option']); $j++) {
                    $_POST['question'][$i]['option'][$j] = mb_convert_kana(trim($_POST['question'][$i]['option'][$j]));
                }
            }
            $error = $this->lfErrCheck();
            if (!$error) {
                // 新規登録
                if (!is_numeric($_POST['question_id'])) {
                    //登録
                    $value = serialize($_POST);
                    if (DB_TYPE == "pgsql") {
                        $question_id = $objQuery->nextval('dtb_question', 'question_id');
                    }
                    $sql_val = array('question' => $value, 'question_name' => $_POST['title'], 'question_id' => $question_id, 'create_date' => 'now()');
                    $objQuery->insert('dtb_question', $sql_val);
                    $this->MESSAGE = "登録が完了しました";
                    if (DB_TYPE == "mysql") {
                        $question_id = $objQuery->nextval('dtb_question', 'question_id');
                    }
                    $this->QUESTION_ID = $question_id;
                    $this->reload(null, true);
                    // 編集
                } else {
                    //編集
                    $value = serialize($_POST);
                    $sql_val = array('question' => $value, 'question_name' => $_POST['title']);
                    $objQuery->update('dtb_question', $sql_val, 'question_id = ?', array($_POST['question_id']));
                    $this->MESSAGE = "編集が完了しました";
                    $this->QUESTION_ID = $_POST['question_id'];
                    $this->reload(null, true);
                }
            } else {
                //エラー表示
                $this->ERROR = $error;
                $this->QUESTION_ID = $_REQUEST['question_id'];
                $this->ERROR_COLOR = $this->lfGetErrColor($error, ERR_COLOR);
            }
            // 削除ボタン押下時
        } elseif ($_GET['mode'] == 'delete' && SC_Utils_Ex::sfCheckNumLength($_GET['question_id'])) {
            $sqlval = array('del_flg' => 1);
            $objQuery->update('dtb_question', $sqlval, 'question_id = ?', array($_GET['question_id']));
            $this->reload(null, true);
            // CSVダウンロードボタン押下時
        } elseif ($_GET['mode'] == 'csv' && SC_Utils_Ex::sfCheckNumLength($_GET['question_id'])) {
            require_once CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php";
            $objCSV = new SC_Helper_CSV_Ex();
            $head = SC_Utils_Ex::sfGetCSVList($this->arrCVSTITLE);
            $sql = <<<__EOS__
                    SELECT
                         dtb_question_result.result_id
                        ,dtb_question_result.question_id
                        ,dtb_question_result.create_date
                        ,dtb_question.question_name
                        ,dtb_question_result.name01
                        ,dtb_question_result.name02
                        ,dtb_question_result.kana01
                        ,dtb_question_result.kana02
                        ,dtb_question_result.zip01
                        ,dtb_question_result.zip02
                        ,dtb_question_result.pref
                        ,dtb_question_result.addr01
                        ,dtb_question_result.addr02
                        ,dtb_question_result.tel01
                        ,dtb_question_result.tel02
                        ,dtb_question_result.tel03
                        ,dtb_question_result.mail01
                        ,dtb_question_result.question01
                        ,dtb_question_result.question02
                        ,dtb_question_result.question03
                        ,dtb_question_result.question04
                        ,dtb_question_result.question05
                        ,dtb_question_result.question06
                    FROM dtb_question_result
                        LEFT JOIN dtb_question
                            ON dtb_question_result.question_id = dtb_question.question_id
                    WHERE 0=0
                        AND dtb_question_result.del_flg = 0
                        AND dtb_question_result.question_id = ?
                    ORDER BY dtb_question_result.result_id ASC
__EOS__;
            $list_data = $objQuery->getAll($sql, array($_GET['question_id']));
            $data = "";
            for ($i = 0; $i < count($list_data); $i++) {
                // 各項目をCSV出力用に変換する。
                $data .= $objCSV->lfMakeCSV($list_data[$i]);
            }
            // CSVを送信する
            SC_Utils_Ex::sfCSVDownload($head . $data);
            exit;
            // 初回表示 or 編集ボタン押下時
        } else {
            if (!isset($_GET['question_id'])) {
                $_GET['question_id'] = "";
            }
            if (is_numeric($_GET['question_id'])) {
                $sql = "SELECT question FROM dtb_question WHERE question_id = ?";
                $result = $objQuery->getOne($sql, array($_GET['question_id']));
                if ($result) {
                    $_POST = unserialize($result);
                    $this->QUESTION_ID = $_GET['question_id'];
                }
            }
        }
        //各ページ共通
        $this->cnt_question = 6;
        $this->arrActive = $arrActive;
        $this->arrQuestion = $arrQuestion;
        //---- ページ表示
        $objView->assignobj($this);
        $objView->display(MAIN_FRAME);
    }
Ejemplo n.º 8
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);
 }
 /**
  * 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);
 }
 /**
  * Page のアクション.
  *
  * @return void
  */
 public function action()
 {
     if (isset($_GET['draw_image']) && $_GET['draw_image'] != '') {
         define('DRAW_IMAGE', true);
     } else {
         define('DRAW_IMAGE', false);
     }
     // パラメーター管理クラス
     $objFormParam = new SC_FormParam_Ex();
     // パラメーター情報の初期化
     $this->lfInitParam($objFormParam);
     $objFormParam->setParam($_REQUEST);
     $objFormParam->setValue("page", "PointHistory");
     // 検索ワードの引き継ぎ
     $this->arrHidden = $objFormParam->getSearchArray();
     switch ($this->getMode()) {
         case 'csv':
         case 'search':
             $this->arrErr = $this->lfCheckError($objFormParam);
             if (empty($this->arrErr)) {
                 // 日付
                 list($sdate, $edate) = $this->lfSetStartEndDate($objFormParam);
                 // ページ
                 $page = "PointHistory";
                 if ($objFormParam->getValue("search_startyear") != $objFormParam->getValue("search_endyear")) {
                     // 集計種類 (年跨ぎの場合は月)
                     $type = $objFormParam->getValue("type", 'month');
                 } else {
                     if ($sdate == $edate) {
                         // 集計種類 (同一日の場合は時間)
                         $type = $objFormParam->getValue("type", 'hour');
                     } else {
                         $datetime1 = new DateTime($sdate);
                         $datetime2 = new DateTime($edate);
                         $interval = $datetime1->diff($datetime2);
                         $interval_m = intval($interval->format('%m'));
                         $interval_y = intval($interval->format('%y'));
                         $interval = intval($interval->format('%a'));
                         // 集計種類
                         if ($interval_y > 2) {
                             // 集計種類 (年跨ぎの場合は年)
                             $type = $objFormParam->getValue("type", 'year');
                         } elseif ($interval_m > 1) {
                             // 集計種類 (年跨ぎの場合は月)
                             $type = $objFormParam->getValue("type", 'month');
                         } else {
                             // 集計種類
                             $type = $objFormParam->getValue("type", 'day');
                         }
                     }
                 }
                 $objFormParam->setValue("type", $type);
                 $this->type = $type;
                 list($this->arrResults, $this->tpl_image, $this->arrCsvResults) = $this->lfGetCustmoerPointHistory($type, $sdate, $edate);
                 if ($this->getMode() == 'csv') {
                     // CSV出力タイトル行の取得
                     list($arrTitleCol, $arrDataCol) = $this->lfGetCSVColum($page);
                     $head = SC_Utils_Ex::sfGetCSVList($arrTitleCol);
                     $data = $this->lfGetDataColCSV($this->arrCsvResults, $arrDataCol);
                     // CSVを送信する。
                     list($fime_name, $data) = SC_Utils_Ex::sfGetCSVData($head . $data);
                     $this->sendResponseCSV($fime_name, $data);
                     SC_Response_Ex::actionExit();
                 }
             }
             break;
         default:
             break;
     }
     // 画面宣しても日付が保存される
     $_SESSION = $this->lfSaveDateSession($_SESSION, $this->arrHidden);
     $objFormParam->setParam($_SESSION['total']);
     // 入力値の取得
     $this->arrForm = $objFormParam->getFormParamList();
     GC_Utils_Ex::gfDebugLog($this);
 }