source: branches/feature-module-update/data/class/pages/admin/order/LC_Page_Admin_Order.php @ 16582

Revision 16582, 18.3 KB checked in by nanasess, 16 years ago (diff)

ライセンス表記変更

  • Property svn:keywords set to "Id Revision Date"
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24// {{{ requires
25require_once(CLASS_PATH . "pages/LC_Page.php");
26
27/**
28 * 受注管理 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_Order extends LC_Page {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_mainpage = 'order/index.tpl';
47        $this->tpl_subnavi = 'order/subnavi.tpl';
48        $this->tpl_mainno = 'order';
49        $this->tpl_subno = 'index';
50        $this->tpl_pager = TEMPLATE_DIR . 'admin/pager.tpl';
51        $this->tpl_subtitle = '受注管理';
52
53        $masterData = new SC_DB_MasterData_Ex();
54        $this->arrORDERSTATUS = $masterData->getMasterData("mtb_order_status");
55        $this->arrORDERSTATUS_COLOR = $masterData->getMasterData("mtb_order_status_color");
56        $this->arrSex = $masterData->getMasterData("mtb_sex");
57        $this->arrPageMax = $masterData->getMasterData("mtb_page_max");
58    }
59
60    /**
61     * Page のプロセス.
62     *
63     * @return void
64     */
65    function process() {
66        $conn = new SC_DBConn();
67        $objView = new SC_AdminView();
68        $objDb = new SC_Helper_DB_Ex();
69        $objSess = new SC_Session();
70        // パラメータ管理クラス
71        $this->objFormParam = new SC_FormParam();
72        // パラメータ情報の初期化
73        $this->lfInitParam();
74        $this->objFormParam->setParam($_POST);
75
76        $this->objFormParam->splitParamCheckBoxes('search_order_sex');
77        $this->objFormParam->splitParamCheckBoxes('search_payment_id');
78
79        // 検索ワードの引き継ぎ
80        foreach ($_POST as $key => $val) {
81            if (ereg("^search_", $key)) {
82                switch($key) {
83                case 'search_order_sex':
84                case 'search_payment_id':
85                    $this->arrHidden[$key] = SC_Utils_Ex::sfMergeParamCheckBoxes($val);
86                    break;
87                default:
88                    $this->arrHidden[$key] = $val;
89                    break;
90                }
91            }
92        }
93
94        // ページ送り用
95        $this->arrHidden['search_pageno'] =
96            isset($_POST['search_pageno']) ? $_POST['search_pageno'] : "";
97
98        // 認証可否の判定
99        SC_Utils_Ex::sfIsSuccess($objSess);
100
101        if (!isset($_POST['mode'])) $_POST['mode'] = "";
102        if (!isset($arrRet)) $arrRet = array();
103
104        if($_POST['mode'] == 'delete') {
105            if(sfIsInt($_POST['order_id'])) {
106                $objQuery = new SC_Query();
107                $where = "order_id = ?";
108                $sqlval['del_flg'] = '1';
109                $objQuery->update("dtb_order", $sqlval, $where, array($_POST['order_id']));
110            }
111        }
112
113        switch($_POST['mode']) {
114        case 'delete':
115        case 'csv':
116        case 'delete_all':
117        case 'search':
118            // 入力値の変換
119            $this->objFormParam->convParam();
120            $this->arrErr = $this->lfCheckError($arrRet);
121            $arrRet = $this->objFormParam->getHashArray();
122            // 入力なし
123            if (count($this->arrErr) == 0) {
124                $where = "del_flg = 0";
125                foreach ($arrRet as $key => $val) {
126                    if($val == "") {
127                        continue;
128                    }
129                    $val = SC_Utils_Ex::sfManualEscape($val);
130
131                    switch ($key) {
132                    case 'search_order_name':
133                        if(DB_TYPE == "pgsql"){
134                            $where .= " AND order_name01||order_name02 ILIKE ?";
135                        }elseif(DB_TYPE == "mysql"){
136                            $where .= " AND concat(order_name01,order_name02) ILIKE ?";
137                        }
138                        $nonsp_val = ereg_replace("[  ]+","",$val);
139                        $arrval[] = "%$nonsp_val%";
140                        break;
141                    case 'search_order_kana':
142                        if(DB_TYPE == "pgsql"){
143                            $where .= " AND order_kana01||order_kana02 ILIKE ?";
144                        }elseif(DB_TYPE == "mysql"){
145                            $where .= " AND concat(order_kana01,order_kana02) ILIKE ?";
146                        }
147                        $nonsp_val = ereg_replace("[  ]+","",$val);
148                        $arrval[] = "%$nonsp_val%";
149                        break;
150                    case 'search_order_id1':
151                        $where .= " AND order_id >= ?";
152                        $arrval[] = $val;
153                        break;
154                    case 'search_order_id2':
155                        $where .= " AND order_id <= ?";
156                        $arrval[] = $val;
157                        break;
158                    case 'search_order_sex':
159                        $tmp_where = "";
160                        foreach($val as $element) {
161                            if($element != "") {
162                                if($tmp_where == "") {
163                                    $tmp_where .= " AND (order_sex = ?";
164                                } else {
165                                    $tmp_where .= " OR order_sex = ?";
166                                }
167                                $arrval[] = $element;
168                            }
169                        }
170
171                        if($tmp_where != "") {
172                            $tmp_where .= ")";
173                            $where .= " $tmp_where ";
174                        }
175                        break;
176                    case 'search_order_tel':
177                        if(DB_TYPE == "pgsql"){
178                            $where .= " AND (order_tel01||order_tel02||order_tel03) ILIKE ?";
179                        }elseif(DB_TYPE == "mysql"){
180                            $where .= " AND concat(order_tel01,order_tel02,order_tel03) ILIKE ?";
181                        }
182                        $nonmark_val = ereg_replace("[()-]+","",$val);
183                        $arrval[] = "$nonmark_val%";
184                        break;
185                    case 'search_order_email':
186                        $where .= " AND order_email ILIKE ?";
187                        $arrval[] = "%$val%";
188                        break;
189                    case 'search_payment_id':
190                        $tmp_where = "";
191                        foreach($val as $element) {
192                            if($element != "") {
193                                if($tmp_where == "") {
194                                    $tmp_where .= " AND (payment_id = ?";
195                                } else {
196                                    $tmp_where .= " OR payment_id = ?";
197                                }
198                                $arrval[] = $element;
199                            }
200                        }
201
202                        if($tmp_where != "") {
203                            $tmp_where .= ")";
204                            $where .= " $tmp_where ";
205                        }
206                        break;
207                    case 'search_total1':
208                        $where .= " AND total >= ?";
209                        $arrval[] = $val;
210                        break;
211                    case 'search_total2':
212                        $where .= " AND total <= ?";
213                        $arrval[] = $val;
214                        break;
215                    case 'search_startyear':
216                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_startyear'], $_POST['search_startmonth'], $_POST['search_startday']);
217                        $where.= " AND update_date >= ?";
218                        $arrval[] = $date;
219                        break;
220                    case 'search_endyear':
221                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_endyear'], $_POST['search_endmonth'], $_POST['search_endday'], true);
222                        $where.= " AND update_date <= ?";
223                        $arrval[] = $date;
224                        break;
225                    case 'search_sbirthyear':
226                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_sbirthyear'], $_POST['search_sbirthmonth'], $_POST['search_sbirthday']);
227                        $where.= " AND order_birth >= ?";
228                        $arrval[] = $date;
229                        break;
230                    case 'search_ebirthyear':
231                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_ebirthyear'], $_POST['search_ebirthmonth'], $_POST['search_ebirthday'], true);
232                        $where.= " AND order_birth <= ?";
233                        $arrval[] = $date;
234                        break;
235                    case 'search_order_status':
236                        $where.= " AND status = ?";
237                        $arrval[] = $val;
238                        break;
239                    default:
240                        if (!isset($arrval)) $arrval = array();
241                        break;
242                    }
243                }
244
245                $order = "update_date DESC";
246
247                switch($_POST['mode']) {
248                case 'csv':
249
250                    require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php");
251                    $objCSV = new SC_Helper_CSV_Ex();
252                    // オプションの指定
253                    $option = "ORDER BY $order";
254
255                    // CSV出力タイトル行の作成
256                    $arrCsvOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput(3, " WHERE csv_id = 3 AND status = 1"));
257
258                    if (count($arrCsvOutput) <= 0) break;
259
260                    $arrCsvOutputCols = $arrCsvOutput['col'];
261                    $arrCsvOutputTitle = $arrCsvOutput['disp_name'];
262                    $head = SC_Utils_Ex::sfGetCSVList($arrCsvOutputTitle);
263                    $data = $objCSV->lfGetCSV("dtb_order", $where, $option, $arrval, $arrCsvOutputCols);
264
265                    // CSVを送信する。
266                    SC_Utils_Ex::sfCSVDownload($head.$data);
267                    exit;
268                    break;
269                case 'delete_all':
270                    // 検索結果をすべて削除
271                    $sqlval['del_flg'] = 1;
272                    $objQuery = new SC_Query();
273                    $objQuery->update("dtb_order", $sqlval, $where, $arrval);
274                    break;
275                default:
276                    // 読み込む列とテーブルの指定
277                    $col = "*";
278                    $from = "dtb_order";
279
280                    $objQuery = new SC_Query();
281                    // 行数の取得
282                    $linemax = $objQuery->count($from, $where, $arrval);
283                    $this->tpl_linemax = $linemax;               // 何件が該当しました。表示用
284
285                    // ページ送りの処理
286                    if(is_numeric($_POST['search_page_max'])) {
287                        $page_max = $_POST['search_page_max'];
288                    } else {
289                        $page_max = SEARCH_PMAX;
290                    }
291
292                    // ページ送りの取得
293                    $objNavi = new SC_PageNavi($this->arrHidden['search_pageno'],
294                                               $linemax, $page_max,
295                                               "fnNaviSearchPage", NAVI_PMAX);
296                    $startno = $objNavi->start_row;
297                    $this->arrPagenavi = $objNavi->arrPagenavi;
298
299                    // 取得範囲の指定(開始行番号、行数のセット)
300                    $objQuery->setlimitoffset($page_max, $startno);
301                    // 表示順序
302                    $objQuery->setorder($order);
303                    // 検索結果の取得
304                    $this->arrResults = $objQuery->select($col, $from, $where, $arrval);
305                }
306            }
307            break;
308
309        default:
310            break;
311        }
312
313        $objDate = new SC_Date();
314        // 登録・更新日検索用
315        $objDate->setStartYear(RELEASE_YEAR);
316        $objDate->setEndYear(DATE("Y"));
317        $this->arrRegistYear = $objDate->getYear();
318        // 生年月日検索用
319        $objDate->setStartYear(BIRTH_YEAR);
320        $objDate->setEndYear(DATE("Y"));
321        $this->arrBirthYear = $objDate->getYear();
322        // 月日の設定
323        $this->arrMonth = $objDate->getMonth();
324        $this->arrDay = $objDate->getDay();
325
326        // 入力値の取得
327        $this->arrForm = $this->objFormParam->getFormParamList();
328        // 支払い方法の取得
329        $arrRet = $objDb->sfGetPayment();
330        $this->arrPayment = SC_Utils_Ex::sfArrKeyValue($arrRet, 'payment_id', 'payment_method');
331
332        $objView->assignobj($this);
333        $objView->display(MAIN_FRAME);
334    }
335
336    /**
337     * デストラクタ.
338     *
339     * @return void
340     */
341    function destroy() {
342        parent::destroy();
343    }
344
345    /* パラメータ情報の初期化 */
346    function lfInitParam() {
347        $this->objFormParam->addParam("受注番号1", "search_order_id1", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
348        $this->objFormParam->addParam("受注番号2", "search_order_id2", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
349        $this->objFormParam->addParam("対応状況", "search_order_status", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
350        $this->objFormParam->addParam("顧客名", "search_order_name", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
351        $this->objFormParam->addParam("顧客名(カナ)", "search_order_kana", STEXT_LEN, "KVCa", array("KANA_CHECK","MAX_LENGTH_CHECK"));
352        $this->objFormParam->addParam("性別", "search_order_sex", INT_LEN, "n", array("MAX_LENGTH_CHECK"));
353        $this->objFormParam->addParam("年齢1", "search_age1", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
354        $this->objFormParam->addParam("年齢2", "search_age2", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
355        $this->objFormParam->addParam("メールアドレス", "search_order_email", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
356        $this->objFormParam->addParam("TEL", "search_order_tel", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
357        $this->objFormParam->addParam("支払い方法", "search_payment_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
358        $this->objFormParam->addParam("購入金額1", "search_total1", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
359        $this->objFormParam->addParam("購入金額2", "search_total2", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
360        $this->objFormParam->addParam("表示件数", "search_page_max", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
361        $this->objFormParam->addParam("開始日", "search_startyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
362        $this->objFormParam->addParam("開始日", "search_startmonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
363        $this->objFormParam->addParam("開始日", "search_startday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
364        $this->objFormParam->addParam("終了日", "search_endyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
365        $this->objFormParam->addParam("終了日", "search_endmonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
366        $this->objFormParam->addParam("終了日", "search_endday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
367        $this->objFormParam->addParam("開始日", "search_sbirthyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
368        $this->objFormParam->addParam("開始日", "search_sbirthmonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
369        $this->objFormParam->addParam("開始日", "search_sbirthday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
370        $this->objFormParam->addParam("終了日", "search_ebirthyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
371        $this->objFormParam->addParam("終了日", "search_ebirthmonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
372        $this->objFormParam->addParam("終了日", "search_ebirthday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
373    }
374
375    /* 入力内容のチェック */
376    function lfCheckError() {
377        // 入力データを渡す。
378        $arrRet =  $this->objFormParam->getHashArray();
379        $objErr = new SC_CheckError($arrRet);
380        $objErr->arrErr = $this->objFormParam->checkError();
381
382        // 特殊項目チェック
383        $objErr->doFunc(array("受注番号1", "受注番号2", "search_order_id1", "search_order_id2"), array("GREATER_CHECK"));
384        $objErr->doFunc(array("年齢1", "年齢2", "search_age1", "search_age2"), array("GREATER_CHECK"));
385        $objErr->doFunc(array("購入金額1", "購入金額2", "search_total1", "search_total2"), array("GREATER_CHECK"));
386        $objErr->doFunc(array("開始日", "search_startyear", "search_startmonth", "search_startday"), array("CHECK_DATE"));
387        $objErr->doFunc(array("終了日", "search_endyear", "search_endmonth", "search_endday"), array("CHECK_DATE"));
388        $objErr->doFunc(array("開始日", "終了日", "search_startyear", "search_startmonth", "search_startday", "search_endyear", "search_endmonth", "search_endday"), array("CHECK_SET_TERM"));
389
390        $objErr->doFunc(array("開始日", "search_sbirthyear", "search_sbirthmonth", "search_sbirthday"), array("CHECK_DATE"));
391        $objErr->doFunc(array("終了日", "search_ebirthyear", "search_ebirthmonth", "search_ebirthday"), array("CHECK_DATE"));
392        $objErr->doFunc(array("開始日", "終了日", "search_sbirthyear", "search_sbirthmonth", "search_sbirthday", "search_ebirthyear", "search_ebirthmonth", "search_ebirthday"), array("CHECK_SET_TERM"));
393
394        return $objErr->arrErr;
395    }
396
397
398}
399?>
Note: See TracBrowser for help on using the repository browser.