/** * 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); }
/** * * PDFの作成 * @param SC_FormParam $objFormParam */ function createPdf(&$objFormParam) { $arrErr = $this->lfCheckError($objFormParam); $arrRet = $objFormParam->getHashArray(); $this->arrForm = $arrRet; // エラー入力なし if (count($arrErr) == 0) { $objFpdf = new SC_Fpdf($arrRet['download'], $arrRet['title']); foreach ($arrRet['order_id'] as $key => $val) { $arrPdfData = $arrRet; $arrPdfData['order_id'] = $val; $objFpdf->setData($arrPdfData); } $objFpdf->createPdf(); return true; } else { return $arrErr; } }
/** * Page のプロセス. * * @return void */ function process() { $conn = new SC_DBConn(); $objView = new SC_AdminView(); $objDb = new SC_Helper_DB_Ex(); $objSess = new SC_Session(); $objDate = new SC_Date(1901); $objDate->setStartYear(RELEASE_YEAR); $this->arrYear = $objDate->getYear(); $this->arrMonth = $objDate->getMonth(); $this->arrDay = $objDate->getDay(); // 認証可否の判定 SC_Utils_Ex::sfIsSuccess($objSess); // 画面遷移の正当性チェック用にuniqidを埋め込む $objPage->tpl_uniqid = $objSess->getUniqId(); // パラメータ管理クラス $this->objFormParam = new SC_FormParam(); // パラメータ情報の初期化 $this->lfInitParam(); $this->objFormParam->setParam($_POST); if (!isset($_POST['mode'])) { $_POST['mode'] = ""; } if (!isset($arrRet)) { $arrRet = array(); } switch ($_POST['mode']) { case "confirm": // 入力値の変換 $this->objFormParam->convParam(); $this->arrErr = $this->lfCheckError($arrRet); $arrRet = $this->objFormParam->getHashArray(); $this->arrForm = $arrRet; // エラー入力なし if (count($this->arrErr) == 0) { $i = 0; $objFpdf = new SC_Fpdf($arrRet['download'], $arrRet['title']); foreach ($arrRet['order_id'] as $key => $val) { $arrPdfData = $arrRet; $arrPdfData['order_id'] = $val; $objFpdf->setData($arrPdfData); ++$i; } $objFpdf->createPdf(); } break; default: // タイトルをセット $arrForm['title'] = "お買上げ明細書(納品書)"; // 今日の日付をセット $arrForm['year'] = date("Y"); $arrForm['month'] = date("m"); $arrForm['day'] = date("d"); // メッセージ $arrForm['msg1'] = 'このたびはお買上げいただきありがとうございます。'; $arrForm['msg2'] = '下記の内容にて納品させていただきます。'; $arrForm['msg3'] = 'ご確認いただきますよう、お願いいたします。'; // 注文番号があったら、セットする if (SC_Utils_Ex::sfIsInt($_GET['order_id'])) { $arrForm['order_id'][0] = $_GET['order_id']; } elseif (is_array($_POST['pdf_order_id'])) { sort($_POST['pdf_order_id']); foreach ($_POST['pdf_order_id'] as $key => $val) { $arrForm['order_id'][] = $val; } } $this->arrForm = $arrForm; break; } $objView->assignobj($this); $objView->display($this->tpl_mainpage); }