Ejemplo n.º 1
0
 function lfMakeCsvData(&$conn, $send_id)
 {
     $arrTitle = array('name01', 'email');
     $sql = "SELECT name01,email FROM dtb_send_customer WHERE send_id = ? ORDER BY email";
     $result = $conn->getAll($sql, array($send_id));
     if ($result) {
         $return = SC_Utils_Ex::getCSVData($result, $arrTitle);
     }
     return $return;
 }
Ejemplo n.º 2
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();
     $objDbFactory = SC_DB_DBFactory_Ex::getInstance();
     $objCSV = new SC_Helper_CSV_Ex();
     $this->arrSubnavi = $objCSV->arrSubnavi;
     // 認証可否の判定
     $objSess = new SC_Session();
     SC_Utils_Ex::sfIsSuccess($objSess);
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     if (!isset($_POST['sql_id'])) {
         $_POST['sql_id'] = "";
     }
     if (!isset($_GET['sql_id'])) {
         $_GET['sql_id'] = "";
     }
     if (!isset($_POST['selectTable'])) {
         $_POST['selectTable'] = "";
     }
     // SQL_IDの取得
     if ($_POST['sql_id'] != "") {
         $sql_id = $_POST['sql_id'];
     } elseif ($_GET['sql_id'] != "") {
         $sql_id = $_GET['sql_id'];
     } else {
         $sql_id = "";
     }
     $mode = $_POST['mode'];
     switch ($_POST['mode']) {
         // データの登録
         case "confirm":
             // エラーチェック
             $this->arrErr = $this->lfCheckError($_POST);
             if (count($this->arrErr) <= 0) {
                 // データの更新
                 $sql_id = $this->lfUpdData($sql_id, $_POST);
                 // 完了メッセージ表示
                 $this->tpl_onload = "alert('登録が完了しました。');";
             }
             break;
             // 確認画面
         // 確認画面
         case "preview":
             // SQL文表示
             $sql = "SELECT \n" . $_POST['csv_sql'];
             // FIXME
             $this->sql = $sql;
             // エラー表示
             $objErrMsg = $this->lfCheckSQL($_POST);
             if ($objErrMsg != "") {
                 $errMsg = $objErrMsg->message . "\n" . $objErrMsg->userinfo;
             }
             $this->sqlerr = isset($errMsg) ? $errMsg : "";
             $this->objView = $objView;
             // 画面の表示
             $objView->assignobj($this);
             $objView->display('contents/csv_sql_view.tpl');
             exit;
             break;
             // 新規作成
         // 新規作成
         case "new_page":
             $this->sendRedirect($this->getLocation("./csv_sql.php"));
             exit;
             break;
             // データ削除
         // データ削除
         case "delete":
             $this->lfDelData($sql_id);
             $this->sendRedirect($this->getLocation("./csv_sql.php"));
             exit;
             break;
         case "csv_output":
             // CSV出力データ取得
             $arrCsvData = $this->lfGetSqlList(" WHERE sql_id = ?", array($_POST['csv_output_id']));
             $objQuery = new SC_Query();
             $arrCsvOutputData = $objQuery->getall("SELECT " . $arrCsvData[0]['csv_sql']);
             if (count($arrCsvOutputData) > 0) {
                 $arrKey = array_keys(SC_Utils_Ex::sfSwapArray($arrCsvOutputData));
                 $i = 0;
                 $header = "";
                 foreach ($arrKey as $data) {
                     if ($i != 0) {
                         $header .= ", ";
                     }
                     $header .= $data;
                     $i++;
                 }
                 $header .= "\r\n";
                 $data = SC_Utils_Ex::getCSVData($arrCsvOutputData, $arrKey);
                 // CSV出力
                 SC_Utils_Ex::sfCSVDownload($header . $data);
                 exit;
                 break;
             } else {
                 $this->tpl_onload = "alert('出力データがありません。');";
                 $sql_id = "";
                 $_POST = "";
             }
             break;
     }
     // mode が confirm 以外のときは完了メッセージは出力しない
     if ($mode != "confirm" and $mode != "csv_output") {
         $this->tpl_onload = "";
     }
     // 登録済みSQL一覧取得
     $arrSqlList = $this->lfGetSqlList();
     // 編集用SQLデータの取得
     if ($sql_id != "") {
         $arrSqlData = $this->lfGetSqlList(" WHERE sql_id = ?", array($sql_id));
     }
     // テーブル一覧を取得する
     $arrTableList = $this->lfGetTableList();
     $arrTableList = SC_Utils_Ex::sfSwapArray($arrTableList);
     // 現在選択されているテーブルを取得する
     if ($_POST['selectTable'] == "") {
         $selectTable = $arrTableList['table_name'][0];
     } else {
         $selectTable = $_POST['selectTable'];
     }
     // カラム一覧を取得する
     $arrColList = $this->lfGetColumnList($selectTable);
     $arrColList = SC_Utils_Ex::sfSwapArray($arrColList);
     // 表示させる内容を編集
     foreach ($arrTableList['description'] as $key => $val) {
         $arrTableList['description'][$key] = $arrTableList['table_name'][$key] . ":" . $arrTableList['description'][$key];
     }
     foreach ($arrColList['description'] as $key => $val) {
         $arrColList['description'][$key] = $arrColList['column_name'][$key] . ":" . $arrColList['description'][$key];
     }
     $arrDiff = array_diff($objDbFactory->sfGetColumnList($selectTable), $arrColList["column_name"]);
     $arrColList["column_name"] = array_merge($arrColList["column_name"], $arrDiff);
     $arrColList["description"] = array_merge($arrColList["description"], $arrDiff);
     // テンプレートに出力するデータをセット
     $this->arrSqlList = $arrSqlList;
     // SQL一覧
     $this->arrTableList = SC_Utils_Ex::sfarrCombine($arrTableList['table_name'], $arrTableList['description']);
     // テーブル一覧
     $this->arrColList = SC_Utils_Ex::sfarrCombine($arrColList['column_name'], $arrColList['description']);
     // カラム一覧
     $this->selectTable = $selectTable;
     // 選択されているテーブル
     $this->sql_id = $sql_id;
     // 選択されているSQL
     // POSTされたデータをセットする
     if (isset($_POST['sql_name']) && isset($_POST['csv_sql'])) {
         $arrSqlData[0]['sql_name'] = isset($_POST['sql_name']) ? $_POST['sql_name'] : "";
         $arrSqlData[0]['csv_sql'] = isset($_POST['csv_sql']) ? $_POST['csv_sql'] : "";
     }
     $this->arrSqlData = $arrSqlData[0];
     // 選択されているSQLデータ
     // 画面の表示
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }