source: temp/trunk/html/admin/basis/delivery_input.php @ 1328

Revision 1328, 5.0 KB checked in by naka, 20 years ago (diff)

* empty log message *

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2
3require_once("../require.php");
4
5class LC_Page {
6    var $arrSession;
7    var $tpl_mode;
8    function LC_Page() {
9        $this->tpl_mainpage = 'basis/delivery_input.tpl';
10        $this->tpl_subnavi = 'basis/subnavi.tpl';
11        $this->tpl_subno = 'delivery';
12        $this->tpl_mainno = 'basis';
13        global $arrPref;
14        $this->arrPref = $arrPref;
15        $this->tpl_subtitle = 'ÇÛÁ÷¶È¼ÔÀßÄê';
16    }
17}
18
19$conn = new SC_DBConn();
20$objPage = new LC_Page();
21$objView = new SC_AdminView();
22$objSess = new SC_Session();
23$objQuery = new SC_Query();
24
25// ǧ¾Ú²ÄÈݤÎȽÄê
26sfIsSuccess($objSess);
27
28// ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹
29$objFormParam = new SC_FormParam();
30// ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
31lfInitParam();
32// POSTÃͤμèÆÀ
33$objFormParam->setParam($_POST);
34
35switch($_POST['mode']) {
36case 'edit':
37    // ÆþÎÏÃͤÎÊÑ´¹
38    $objFormParam->convParam();
39    $objPage->arrErr = lfCheckError();
40    if(count($objPage->arrErr) == 0) {
41        $objPage->tpl_deliv_id = lfRegistData();
42        $objPage->tpl_onload = "window.alert('ÇÛÁ÷¶È¼ÔÀßÄ꤬´°Î»¤·¤Þ¤·¤¿¡£');";
43    }
44    break;
45case 'pre_edit':
46    if($_POST['deliv_id'] != "") {
47        lfGetDelivData($_POST['deliv_id']);
48        $objPage->tpl_deliv_id = $_POST['deliv_id'];
49    }
50    break;
51default:
52    break;
53}
54
55$objPage->arrForm = $objFormParam->getFormParamList();
56$objView->assignobj($objPage);
57$objView->display(MAIN_FRAME);
58//--------------------------------------------------------------------------------------------------------------------------------------
59/* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */
60function lfInitParam() {
61    global $objFormParam;
62    $objFormParam->addParam("ÇÛÁ÷¶È¼Ô̾", "name", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
63    $objFormParam->addParam("̾¾Î", "service_name", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
64    $objFormParam->addParam("ÅÁɼNo.³ÎǧURL", "confirm_url", STEXT_LEN, "n", array("URL_CHECK", "MAX_LENGTH_CHECK"), "http://");
65   
66    for($cnt = 1; $cnt <= DELIVTIME_MAX; $cnt++) {
67        $objFormParam->addParam("ÇÛÁ÷»þ´Ö$cnt", "time$cnt", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
68    }
69   
70    if(INPUT_DELIV_FEE) {
71        for($cnt = 1; $cnt <= DELIVFEE_MAX; $cnt++) {
72            $objFormParam->addParam("ÇÛÁ÷ÎÁ¶â$cnt", "fee$cnt", PRICE_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
73        }
74    }
75}
76
77/* DB¤ËÅÐÏ¿¤¹¤ë */
78function lfRegistData() {
79    global $objFormParam;
80    $arrRet = $objFormParam->getHashArray();
81    $objQuery = new SC_Query();
82    $objQuery->begin();
83
84    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
85    $sqlval['name'] = $arrRet['name'];
86    $sqlval['service_name'] = $arrRet['service_name'];
87    $sqlval['confirm_url'] = $arrRet['confirm_url'];
88    $sqlval['creator_id'] = $_SESSION['member_id'];
89    $sqlval['update_date'] = 'Now()';
90   
91    if($_POST['deliv_id'] != "") {
92        $deliv_id = $_POST['deliv_id'];
93        $where = "deliv_id = ?";
94        $objQuery->update("dtb_deliv", $sqlval, $where, array($deliv_id));
95        $objQuery->delete("dtb_delivfee", $where, array($deliv_id));
96        $objQuery->delete("dtb_delivtime", $where, array($deliv_id));
97    } else {
98        // ÅÐÏ¿¤¹¤ëÇÛÁ÷¶È¼ÔID¤Î¼èÆÀ
99        $deliv_id = $objQuery->nextval('dtb_deliv', 'deliv_id');
100        $sqlval['deliv_id'] = $deliv_id;
101        $sqlval['rank'] = $objQuery->max("dtb_deliv", "rank") + 1;
102        // INSERT¤Î¼Â¹Ô
103        $objQuery->insert("dtb_deliv", $sqlval);
104    }
105   
106    $sqlval = array();
107    // ÇÛÁ÷»þ´Ö¤ÎÀßÄê
108    for($cnt = 1; $cnt <= DELIVTIME_MAX; $cnt++) {
109        $keyname = "time$cnt";
110        if($arrRet[$keyname] != "") {
111            $sqlval['deliv_id'] = $deliv_id;
112            $sqlval['time'] = $arrRet[$keyname];
113            // INSERT¤Î¼Â¹Ô
114            $objQuery->insert("dtb_delivtime", $sqlval);
115        }
116    }
117   
118    if(INPUT_DELIV_FEE) {
119        $sqlval = array();
120        // ÇÛÁ÷ÎÁ¶â¤ÎÀßÄê
121        for($cnt = 1; $cnt <= DELIVFEE_MAX; $cnt++) {
122            $keyname = "fee$cnt";
123            if($arrRet[$keyname] != "") {
124                $sqlval['deliv_id'] = $deliv_id;
125                $sqlval['fee'] = $arrRet[$keyname];
126                $sqlval['pref'] = $cnt;
127                // INSERT¤Î¼Â¹Ô
128                $objQuery->insert("dtb_delivfee", $sqlval);
129            }
130        }
131    }
132    $objQuery->commit();
133    return $deliv_id;
134}
135
136/* ÇÛÁ÷¶È¼Ô¾ðÊó¤Î¼èÆÀ */
137function lfGetDelivData($deliv_id) {
138    global $objFormParam;
139    $objQuery = new SC_Query();
140    // ÇÛÁ÷¶È¼Ô°ìÍ÷¤Î¼èÆÀ
141    $col = "deliv_id, name, service_name, confirm_url";
142    $where = "deliv_id = ?";
143    $table = "dtb_deliv";
144    $arrRet = $objQuery->select($col, $table, $where, array($deliv_id));
145    $objFormParam->setParam($arrRet[0]);
146    // ÇÛÁ÷»þ´Ö¤Î¼èÆÀ
147    $col = "time";
148    $where = "deliv_id = ?";
149    $table = "dtb_delivtime";
150    $arrRet = $objQuery->select($col, $table, $where, array($deliv_id));
151    $objFormParam->setParamList($arrRet, 'time');
152    // ÇÛÁ÷ÎÁ¶â¤Î¼èÆÀ
153    $col = "fee";
154    $where = "deliv_id = ?";
155    $table = "dtb_delivfee";
156    $arrRet = $objQuery->select($col, $table, $where, array($deliv_id));
157    $objFormParam->setParamList($arrRet, 'fee');
158}
159
160/* ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯ */
161function lfCheckError() {
162    global $objFormParam;
163    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
164    $arrRet =  $objFormParam->getHashArray();
165    $objErr = new SC_CheckError($arrRet);
166    $objErr->arrErr = $objFormParam->checkError();
167   
168    if(!isset($objErr->arrErr['name']) && $_POST['deliv_id'] == "") {
169        // ´û¸¥Á¥§¥Ã¥¯
170        $ret = sfIsRecord("dtb_deliv", "service_name", array($arrRet['service_name']));
171        if ($ret) {
172            $objErr->arrErr['name'] = "¢¨ Ʊ¤¸Ì¾¾Î¤ÎÁȤ߹ç¤ï¤»¤ÏÅÐÏ¿¤Ç¤­¤Þ¤»¤ó¡£<br>";
173        }
174    }
175   
176    return $objErr->arrErr;
177}
Note: See TracBrowser for help on using the repository browser.