source: branches/comu/html/admin/basis/delivery_input.php @ 2

Revision 2, 5.2 KB checked in by root, 17 years ago (diff)

new import

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