source: branches/feature-module-update/data/class/pages/LC_Page_InputZip.php @ 16363

Revision 16363, 3.3 KB checked in by nanasess, 17 years ago (diff)
  • デグレ修正
  • Property svn:eol-style set to LF
  • Property svn:keywords set to HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
  • Property svn:mime-type set to text/x-httpd-php
Line 
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
9require_once(CLASS_PATH . "pages/LC_Page.php");
10
11/**
12 * 郵便番号入力 のページクラス.
13 *
14 * @package Page
15 * @author LOCKON CO.,LTD.
16 * @version $Id$
17 */
18class LC_Page_InputZip extends LC_Page {
19
20    // }}}
21    // {{{ functions
22
23    /**
24     * Page を初期化する.
25     *
26     * @return void
27     */
28    function init() {
29        parent::init();
30        $this->tpl_message = "住所を検索しています。";
31    }
32
33    /**
34     * Page のプロセス.
35     *
36     * @return void
37     */
38    function process() {
39        $conn = new SC_DBconn(ZIP_DSN);
40        $objView = new SC_SiteView(false);
41
42        // 入力エラーチェック
43        $arrErr = $this->fnErrorCheck();
44
45        // 入力エラーの場合は終了
46        if(count($arrErr) > 0) {
47            $this->tpl_start = "window.close();";
48        }
49
50        // 郵便番号検索文作成
51        $zipcode = $_GET['zip1'].$_GET['zip2'];
52        $zipcode = mb_convert_kana($zipcode ,"n");
53        $sqlse = "SELECT state, city, town FROM mtb_zip WHERE zipcode = ?";
54
55        $data_list = $conn->getAll($sqlse, array($zipcode));
56        if (empty($data_list)) $data_list = array();
57
58        $masterData = new SC_DB_MasterData_Ex();
59        $arrPref = $masterData->getMasterData("mtb_pref", array("pref_id", "pref_name", "rank"));
60        // インデックスと値を反転させる。
61        $arrREV_PREF = array_flip($arrPref);
62
63        if (!empty($data_list)) {
64            $this->tpl_state = isset($arrREV_PREF[$data_list[0]['state']])
65                ? $arrREV_PREF[$data_list[0]['state']] : "";
66            $this->tpl_city = isset($data_list[0]['city']) ? $data_list[0]['city'] : "";
67            $town =  isset($data_list[0]['town']) ? $data_list[0]['town'] : "";
68        } else {
69            $town = "";
70        }
71
72        /*
73         総務省からダウンロードしたデータをそのままインポートすると
74         以下のような文字列が入っているので  対策する。
75         ・(1~19丁目)
76         ・以下に掲載がない場合
77        */
78        $town = ereg_replace("(.*)$","",$town);
79        $town = ereg_replace("以下に掲載がない場合","",$town);
80        $this->tpl_town = $town;
81
82        // 郵便番号が発見された場合
83        if(!empty($data_list)) {
84            $func = "fnPutAddress('" . $_GET['input1'] . "','" . $_GET['input2']. "');";
85            $this->tpl_onload = "$func";
86            $this->tpl_start = "window.close();";
87        } else {
88            $this->tpl_message = "該当する住所が見つかりませんでした。";
89        }
90
91        /* ページの表示 */
92        $objView->assignobj($this);
93        $objView->display("input_zip.tpl");
94    }
95
96    /**
97     * デストラクタ.
98     *
99     * @return void
100     */
101    function destroy() {
102        parent::destroy();
103    }
104
105
106    /* 入力エラーのチェック */
107    function fnErrorCheck() {
108        // エラーメッセージ配列の初期化
109        $objErr = new SC_CheckError();
110
111        // 郵便番号
112        $objErr->doFunc( array("郵便番号1",'zip1',ZIP01_LEN ) ,array( "NUM_COUNT_CHECK" ) );
113        $objErr->doFunc( array("郵便番号2",'zip2',ZIP02_LEN ) ,array( "NUM_COUNT_CHECK" ) );
114
115        return $objErr->arrErr;
116    }
117
118
119}
120?>
Note: See TracBrowser for help on using the repository browser.