[15304] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
| 4 | * |
---|
| 5 | * http://www.lockon.co.jp/ |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | // {{{ requires |
---|
| 9 | require_once(CLASS_PATH . "pages/LC_Page.php"); |
---|
| 10 | |
---|
| 11 | /** |
---|
| 12 | * 支払方法設定 のページクラス. |
---|
| 13 | * |
---|
| 14 | * @package Page |
---|
| 15 | * @author LOCKON CO.,LTD. |
---|
| 16 | * @version $Id$ |
---|
| 17 | */ |
---|
| 18 | class LC_Page_Admin_Basis_Payment_Input extends LC_Page { |
---|
| 19 | |
---|
| 20 | // {{{ properties |
---|
| 21 | |
---|
| 22 | /** フォームパラメータの配列 */ |
---|
| 23 | var $objFormParam; |
---|
| 24 | |
---|
| 25 | /** SC_UploadFile インスタンス */ |
---|
| 26 | var $objUpFile; |
---|
| 27 | |
---|
| 28 | // }}} |
---|
| 29 | // {{{ functions |
---|
| 30 | |
---|
| 31 | /** |
---|
| 32 | * Page を初期化する. |
---|
| 33 | * |
---|
| 34 | * @return void |
---|
| 35 | */ |
---|
| 36 | function init() { |
---|
| 37 | parent::init(); |
---|
| 38 | $this->tpl_mainpage = 'basis/payment_input.tpl'; |
---|
| 39 | $this->tpl_subtitle = '支払方法設定'; |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | /** |
---|
| 43 | * Page のプロセス. |
---|
| 44 | * |
---|
| 45 | * @return void |
---|
| 46 | */ |
---|
| 47 | function process() { |
---|
| 48 | $conn = new SC_DBConn(); |
---|
| 49 | $objView = new SC_AdminView(); |
---|
| 50 | $objSess = new SC_Session(); |
---|
| 51 | $objDb = new SC_Helper_DB_Ex(); |
---|
| 52 | |
---|
| 53 | // 認証可否の判定 |
---|
| 54 | SC_Utils_Ex::sfIsSuccess($objSess); |
---|
| 55 | |
---|
| 56 | // ファイル管理クラス |
---|
| 57 | $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR); |
---|
| 58 | // ファイル情報の初期化 |
---|
| 59 | $this->objUpFile = $this->lfInitFile(); |
---|
| 60 | // Hiddenからのデータを引き継ぐ |
---|
| 61 | $this->objUpFile->setHiddenFileList($_POST); |
---|
| 62 | |
---|
| 63 | // パラメータ管理クラス |
---|
| 64 | $this->objFormParam = new SC_FormParam(); |
---|
| 65 | // パラメータ情報の初期化 |
---|
| 66 | $this->lfInitParam(); |
---|
| 67 | // POST値の取得 |
---|
| 68 | $this->objFormParam->setParam($_POST); |
---|
| 69 | |
---|
| 70 | switch($_POST['mode']) { |
---|
| 71 | case 'edit': |
---|
| 72 | // 入力値の変換 |
---|
| 73 | $this->objFormParam->convParam(); |
---|
| 74 | |
---|
| 75 | // エラーチェック |
---|
| 76 | $this->arrErr = $this->lfCheckError(); |
---|
| 77 | $this->charge_flg = $_POST["charge_flg"]; |
---|
| 78 | if(count($this->arrErr) == 0) { |
---|
| 79 | $this->lfRegistData($_POST['payment_id']); |
---|
| 80 | // 一時ファイルを本番ディレクトリに移動する |
---|
| 81 | $this->objUpFile->moveTempFile(); |
---|
| 82 | // 親ウィンドウを更新するようにセットする。 |
---|
| 83 | $this->tpl_onload="fnUpdateParent('".URL_PAYMENT_TOP."'); window.close();"; |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | break; |
---|
| 87 | // 画像のアップロード |
---|
| 88 | case 'upload_image': |
---|
| 89 | // ファイル存在チェック |
---|
| 90 | $this->arrErr = array_merge($this->arrErr, $this->objUpFile->checkEXISTS($_POST['image_key'])); |
---|
| 91 | // 画像保存処理 |
---|
| 92 | $this->arrErr[$_POST['image_key']] = $this->objUpFile->makeTempFile($_POST['image_key']); |
---|
| 93 | break; |
---|
| 94 | // 画像の削除 |
---|
| 95 | case 'delete_image': |
---|
| 96 | $this->objUpFile->deleteFile($_POST['image_key']); |
---|
| 97 | break; |
---|
| 98 | default: |
---|
| 99 | break; |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | if($_POST['mode'] == "") { |
---|
| 103 | switch($_GET['mode']) { |
---|
| 104 | case 'pre_edit': |
---|
| 105 | if(SC_Utils_Ex::sfIsInt($_GET['payment_id'])) { |
---|
| 106 | $arrRet = $this->lfGetData($_GET['payment_id']); |
---|
| 107 | $this->objFormParam->setParam($arrRet); |
---|
| 108 | $this->charge_flg = $arrRet["charge_flg"]; |
---|
| 109 | // DBデータから画像ファイル名の読込 |
---|
| 110 | $this->objUpFile->setDBFileList($arrRet); |
---|
| 111 | $this->tpl_payment_id = $_GET['payment_id']; |
---|
| 112 | } |
---|
| 113 | break; |
---|
| 114 | default: |
---|
| 115 | break; |
---|
| 116 | } |
---|
| 117 | } else { |
---|
| 118 | $this->tpl_payment_id = $_POST['payment_id']; |
---|
| 119 | } |
---|
| 120 | |
---|
| 121 | $this->arrDelivList = $objDb->sfGetIDValueList("dtb_deliv", "deliv_id", "service_name"); |
---|
| 122 | $this->arrForm = $this->objFormParam->getFormParamList(); |
---|
| 123 | |
---|
| 124 | // FORM表示用配列を渡す。 |
---|
| 125 | $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL); |
---|
| 126 | // HIDDEN用に配列を渡す。 |
---|
| 127 | $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objUpFile->getHiddenFileList()); |
---|
| 128 | |
---|
| 129 | $objView->assignobj($this); |
---|
| 130 | $objView->display($this->tpl_mainpage); |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | /** |
---|
| 134 | * デストラクタ. |
---|
| 135 | * |
---|
| 136 | * @return void |
---|
| 137 | */ |
---|
| 138 | function destroy() { |
---|
| 139 | parent::destroy(); |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | /* ファイル情報の初期化 */ |
---|
| 143 | function lfInitFile() { |
---|
| 144 | $this->objUpFile->addFile("ロゴ画像", 'payment_image', array('gif'), IMAGE_SIZE, false, CLASS_IMAGE_WIDTH, CLASS_IMAGE_HEIGHT); |
---|
| 145 | return $this->objUpFile; |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | /* パラメータ情報の初期化 */ |
---|
| 149 | function lfInitParam() { |
---|
| 150 | $this->objFormParam->addParam("支払方法", "payment_method", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 151 | $this->objFormParam->addParam("手数料", "charge", PRICE_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 152 | $this->objFormParam->addParam("利用条件(〜円以上)", "rule", PRICE_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 153 | $this->objFormParam->addParam("利用条件(〜円以下)", "upper_rule", PRICE_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 154 | $this->objFormParam->addParam("配送サービス", "deliv_id", INT_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 155 | $this->objFormParam->addParam("固定", "fix"); |
---|
| 156 | } |
---|
| 157 | |
---|
| 158 | /* DBからデータを読み込む */ |
---|
| 159 | function lfGetData($payment_id) { |
---|
| 160 | $objQuery = new SC_Query(); |
---|
| 161 | $where = "payment_id = ?"; |
---|
| 162 | $arrRet = $objQuery->select("*", "dtb_payment", $where, array($payment_id)); |
---|
| 163 | return $arrRet[0]; |
---|
| 164 | } |
---|
| 165 | |
---|
| 166 | /* DBへデータを登録する */ |
---|
| 167 | function lfRegistData($payment_id = "") { |
---|
| 168 | |
---|
| 169 | $objQuery = new SC_Query(); |
---|
| 170 | $sqlval = $this->objFormParam->getHashArray(); |
---|
| 171 | $arrRet = $this->objUpFile->getDBFileList(); // ファイル名の取得 |
---|
| 172 | $sqlval = array_merge($sqlval, $arrRet); |
---|
| 173 | $sqlval['update_date'] = 'Now()'; |
---|
| 174 | |
---|
| 175 | if($sqlval['fix'] != '1') { |
---|
| 176 | $sqlval['fix'] = 2; // 自由設定 |
---|
| 177 | } |
---|
| 178 | |
---|
| 179 | // 新規登録 |
---|
| 180 | if($payment_id == "") { |
---|
| 181 | // INSERTの実行 |
---|
| 182 | $sqlval['creator_id'] = $_SESSION['member_id']; |
---|
| 183 | $sqlval['rank'] = $objQuery->max("dtb_payment", "rank") + 1; |
---|
| 184 | $sqlval['create_date'] = 'Now()'; |
---|
| 185 | $objQuery->insert("dtb_payment", $sqlval); |
---|
| 186 | // 既存編集 |
---|
| 187 | } else { |
---|
| 188 | $where = "payment_id = ?"; |
---|
| 189 | $objQuery->update("dtb_payment", $sqlval, $where, array($payment_id)); |
---|
| 190 | } |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | /* 利用条件の数値チェック */ |
---|
| 194 | |
---|
| 195 | /* 入力内容のチェック */ |
---|
| 196 | function lfCheckError() { |
---|
| 197 | |
---|
| 198 | // DBのデータを取得 |
---|
| 199 | $arrPaymentData = $this->lfGetData($_POST['payment_id']); |
---|
| 200 | |
---|
| 201 | // 手数料を設定できない場合には、手数料を0にする |
---|
| 202 | if($arrPaymentData["charge_flg"] == 2) $this->objFormParam->setValue("charge", "0"); |
---|
| 203 | |
---|
| 204 | // 入力データを渡す。 |
---|
| 205 | $arrRet = $this->objFormParam->getHashArray(); |
---|
| 206 | $objErr = new SC_CheckError($arrRet); |
---|
| 207 | $objErr->arrErr = $this->objFormParam->checkError(); |
---|
| 208 | |
---|
| 209 | // 利用条件(下限)チェック |
---|
| 210 | if($arrRet["rule"] < $arrPaymentData["rule_min"] and $arrPaymentData["rule_min"] != ""){ |
---|
| 211 | $objErr->arrErr["rule"] = "利用条件(下限)は" . $arrPaymentData["rule_min"] ."円以上にしてください。<br>"; |
---|
| 212 | } |
---|
| 213 | |
---|
| 214 | // 利用条件(上限)チェック |
---|
| 215 | if($arrRet["upper_rule"] > $arrPaymentData["upper_rule_max"] and $arrPaymentData["upper_rule_max"] != ""){ |
---|
| 216 | $objErr->arrErr["upper_rule"] = "利用条件(上限)は" . $arrPaymentData["upper_rule_max"] ."円以下にしてください。<br>"; |
---|
| 217 | } |
---|
| 218 | |
---|
| 219 | // 利用条件チェック |
---|
| 220 | $objErr->doFunc(array("利用条件(〜円以上)", "利用条件(〜円以下)", "rule", "upper_rule"), array("GREATER_CHECK")); |
---|
| 221 | |
---|
| 222 | return $objErr->arrErr; |
---|
| 223 | } |
---|
| 224 | } |
---|
| 225 | ?> |
---|