/**
  * hidden情報の作成
  *
  * @param array $arrForm フォームデータ
  * @return array hidden情報
  */
 function lfSetHidden($arrForm)
 {
     $arrHidden = array();
     foreach ($arrForm as $key => $val) {
         if (preg_match("/^search_/", $key)) {
             switch ($key) {
                 case 'search_sex':
                     $arrHidden[$key] = SC_Utils_Ex::sfMergeParamCheckBoxes($val);
                     if (!is_array($val)) {
                         $arrForm[$key] = explode("-", $val);
                     }
                     break;
                 default:
                     $arrHidden[$key] = $val;
                     break;
             }
         }
     }
     return $arrHidden;
 }
예제 #2
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);
 }
예제 #3
0
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     //---- ページ初期設定
     $objQuery = new SC_Query();
     $objView = new SC_AdminView();
     $objDate = new SC_Date(1901);
     $objDb = new SC_Helper_DB_Ex();
     $this->arrYear = $objDate->getYear();
     // 日付プルダウン設定
     $this->arrMonth = $objDate->getMonth();
     $this->arrDay = $objDate->getDay();
     $this->objDate = $objDate;
     // 認証可否の判定
     $objSess = new SC_Session();
     SC_Utils_Ex::sfIsSuccess($objSess);
     // POST値の引き継ぎ
     $this->arrForm = $_POST;
     // ページ送り用
     $this->arrHidden['search_pageno'] = isset($_POST['search_pageno']) ? $_POST['search_pageno'] : "";
     // 検索ワードの引き継ぎ
     foreach ($_POST as $key => $val) {
         switch ($key) {
             case 'sex':
             case 'status':
                 $this->arrHidden[$key] = SC_Utils_Ex::sfMergeParamCheckBoxes($val);
                 if (!is_array($val)) {
                     $this->arrForm[$key] = split("-", $val);
                 }
                 break;
             default:
                 $this->arrHidden[$key] = $val;
                 break;
         }
     }
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     // 顧客削除
     if ($_POST['mode'] == "delete") {
         $sql = "SELECT status,email FROM dtb_customer WHERE customer_id = ? AND del_flg = 0";
         $result_customer = $objQuery->conn->getAll($sql, array($_POST["edit_customer_id"]));
         if ($result_customer[0]["status"] == 2) {
             //本会員削除
             $arrDel = array("del_flg" => 1, "update_date" => "NOW()");
             $objQuery->conn->autoExecute("dtb_customer", $arrDel, "customer_id = " . SC_Utils_Ex::sfQuoteSmart($_POST["edit_customer_id"]));
         } elseif ($result_customer[0]["status"] == 1) {
             //仮会員削除
             $sql = "DELETE FROM dtb_customer WHERE customer_id = ?";
             $objQuery->conn->query($sql, array($_POST["edit_customer_id"]));
         }
     }
     //if ($_POST['mode'] == "search" || $_POST['mode'] == "csv"  || $_POST['mode'] == "delete" || $_POST['mode'] == "delete_all") {
     // 登録メール再送
     if ($_POST['mode'] == "resend_mail") {
         $arrRet = $objQuery->select("name01, name02, secret_key, email", "dtb_customer", "customer_id = ? AND del_flg <> 1 AND status = 1", array($_POST["edit_customer_id"]));
         if (is_array($arrRet) === true && count($arrRet) > 0) {
             $CONF = $objDb->sf_getBasisData();
             $this->CONF = $CONF;
             $objMailText = new SC_SiteView();
             $objMailText->assignobj($this);
             $mailHelper = new SC_Helper_Mail_Ex();
             $this->name01 = $arrRet[0]['name01'];
             $this->name02 = $arrRet[0]['name02'];
             $this->uniqid = $arrRet[0]['secret_key'];
             $subject = $mailHelper->sfMakesubject($objQuery, $objMailText, $this, '会員登録のご確認');
             $toCustomerMail = $objMailText->fetch("mail_templates/customer_mail.tpl");
             $objMail = new SC_SendMail();
             $objMail->setItem('', $subject, $toCustomerMail, $CONF["email03"], $CONF["shop_name"], $CONF["email03"], $CONF["email04"], $CONF["email04"]);
             // 宛先の設定
             $name = $this->name01 . $this->name02 . " 様";
             $objMail->setTo($arrRet[0]["email"], $name);
             $objMail->sendMail();
         }
     }
     if ($_POST['mode'] == "search" || $_POST['mode'] == "csv" || $_POST['mode'] == "delete" || $_POST['mode'] == "delete_all" || $_POST['mode'] == "resend_mail") {
         // 入力文字の強制変換
         $this->lfConvertParam();
         // エラーチェック
         $this->arrErr = $this->lfCheckError($this->arrForm);
         $where = "del_flg = 0";
         /* 入力エラーなし */
         if (count($this->arrErr) == 0) {
             //-- 検索データ取得
             $objSelect = new SC_CustomerList($this->arrForm, "customer");
             // 表示件数設定
             $page_rows = $this->arrForm['page_rows'];
             if (is_numeric($page_rows)) {
                 $page_max = $page_rows;
             } else {
                 $page_max = SEARCH_PMAX;
             }
             if (!isset($this->arrForm['search_pageno'])) {
                 $this->arrForm['search_pageno'] = "";
             }
             if ($this->arrForm['search_pageno'] == 0) {
                 $this->arrForm['search_pageno'] = 1;
             }
             $offset = $page_max * ($this->arrForm['search_pageno'] - 1);
             $objSelect->setLimitOffset($page_max, $offset);
             if ($_POST["mode"] == 'csv') {
                 $searchSql = $objSelect->getListCSV($this->arrColumnCSV);
             } else {
                 $searchSql = $objSelect->getList();
             }
             $this->search_data = $objQuery->conn->getAll($searchSql, $objSelect->arrVal);
             switch ($_POST['mode']) {
                 case 'csv':
                     require_once CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php";
                     $objCSV = new SC_Helper_CSV_Ex();
                     $i = 0;
                     $header = "";
                     // CSVカラム取得
                     $arrCsvOutput = $objCSV->sfgetCsvOutput(2, " WHERE csv_id = 2 AND status = 1");
                     if (count($arrCsvOutput) <= 0) {
                         break;
                     }
                     foreach ($arrCsvOutput as $data) {
                         $arrColumn[] = $data["col"];
                         if ($i != 0) {
                             $header .= ", ";
                         }
                         $header .= $data["disp_name"];
                         $i++;
                     }
                     $header .= "\n";
                     //- 都道府県/職業の変換
                     for ($i = 0; $i < count($this->search_data); $i++) {
                         $this->search_data[$i]["pref"] = $this->arrPref[$this->search_data[$i]["pref"]];
                         $this->search_data[$i]["job"] = $this->arrJob[$this->search_data[$i]["job"]];
                     }
                     //- CSV出力
                     $data = SC_Utils_Ex::getCSVData($this->search_data, $arrColumn);
                     SC_Utils_Ex::sfCSVDownload($header . $data);
                     exit;
                     break;
                 case 'delete_all':
                     // 検索結果をすべて削除
                     $where = "product_id IN (SELECT product_id FROM vw_products_nonclass AS noncls WHERE {$where})";
                     $sqlval['del_flg'] = 1;
                     $objQuery->update("dtb_products", $sqlval, $where, $arrval);
                     $sql = "SELECT status,email FROM dtb_customer WHERE customer_id = ? AND del_flg = 0";
                     $result_customer = $objQuery->conn->getAll($sql, array($_POST["del_customer_id"]));
                     if ($result_customer[0]["status"] == 2) {
                         //本会員削除
                         $arrDel = array("del_flg" => 1, "update_date" => "NOW()");
                         $objQuery->conn->autoExecute("dtb_customer", $arrDel, "customer_id = " . SC_Utils_Ex::sfQuoteSmart($_POST["del_customer_id"]));
                     } elseif ($result_customer[0]["status"] == 1) {
                         //仮会員削除
                         $sql = "DELETE FROM dtb_customer WHERE customer_id = ?";
                         $objQuery->conn->query($sql, array($_POST["del_customer_id"]));
                     }
                     break;
                 default:
                     // 行数の取得
                     $linemax = $objQuery->conn->getOne($objSelect->getListCount(), $objSelect->arrVal);
                     $this->tpl_linemax = $linemax;
                     // 何件が該当しました。表示用
                     // ページ送りの取得
                     $objNavi = new SC_PageNavi($this->arrHidden['search_pageno'], $linemax, $page_max, "fnCustomerPage", NAVI_PMAX);
                     $startno = $objNavi->start_row;
                     $this->arrPagenavi = $objNavi->arrPagenavi;
             }
         }
     }
     $this->arrCatList = $objDb->sfGetCategoryList();
     //---- ページ表示
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $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);
 }
 function lfRegistData(&$objFormParam, $questionnaire_id)
 {
     $objCustomer = new SC_Customer_Ex();
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objQuery->begin();
     $result_id = $objQuery->nextVal('dtb_questionnaire_result_id_id');
     $sqlval['customer_id'] = $objCustomer->getValue('customer_id');
     $sqlval['questionnaire_id'] = $questionnaire_id;
     $sqlval['result_id'] = $result_id;
     $sqlval['del_flg'] = '0';
     $sqlval['create_date'] = 'now()';
     $objQuery->insert("dtb_questionnaire_result", $sqlval);
     $arrResults = $objFormParam->getDbArray();
     $i = 0;
     foreach ($arrResults as $key => $result) {
         $sqlval = array();
         $sqlval['answer_id'] = $i;
         $sqlval['result_id'] = $result_id;
         $sqlval['answer'] = SC_Utils_Ex::sfMergeParamCheckBoxes($result);
         $objQuery->insert("dtb_questionnaire_result_answer", $sqlval);
         $i++;
     }
     $objQuery->commit();
 }
예제 #6
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);
 }