source: branches/version-2_4/data/class/pages/admin/order/LC_Page_Admin_Order.php @ 18157

Revision 18157, 20.9 KB checked in by kajiwara, 15 years ago (diff)

#502 管理画面「受注管理」において受注日検索の不具合 を修正

  • Property svn:eol-style set to LF
  • 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/* ペイジェント決済モジュール連携用 */
28if (file_exists(MODULE_PATH . 'mdl_paygent/include.php') === TRUE) {
29  require_once(MODULE_PATH . 'mdl_paygent/include.php');
30}
31
32/**
33 * 受注管理 のページクラス.
34 *
35 * @package Page
36 * @author LOCKON CO.,LTD.
37 * @version $Id$
38 */
39class LC_Page_Admin_Order extends LC_Page {
40
41    // }}}
42    // {{{ functions
43
44    /**
45     * Page を初期化する.
46     *
47     * @return void
48     */
49    function init() {
50        parent::init();
51        $this->tpl_mainpage = 'order/index.tpl';
52        $this->tpl_subnavi = 'order/subnavi.tpl';
53        $this->tpl_mainno = 'order';
54        $this->tpl_subno = 'index';
55        $this->tpl_pager = TEMPLATE_DIR . 'admin/pager.tpl';
56        $this->tpl_subtitle = '受注管理';
57
58        $masterData = new SC_DB_MasterData_Ex();
59        $this->arrORDERSTATUS = $masterData->getMasterData("mtb_order_status");
60        $this->arrORDERSTATUS_COLOR = $masterData->getMasterData("mtb_order_status_color");
61        $this->arrSex = $masterData->getMasterData("mtb_sex");
62        $this->arrPageMax = $masterData->getMasterData("mtb_page_max");
63
64        /* ペイジェント決済モジュール連携用 */
65        if(function_exists("sfPaygentOrderPage")) {
66            $this->arrDispKind = sfPaygentOrderPage();
67        }
68    }
69
70    /**
71     * Page のプロセス.
72     *
73     * @return void
74     */
75    function process() {
76        $conn = new SC_DBConn();
77        $objView = new SC_AdminView();
78        $objDb = new SC_Helper_DB_Ex();
79        $objSess = new SC_Session();
80        // パラメータ管理クラス
81        $this->objFormParam = new SC_FormParam();
82        // パラメータ情報の初期化
83        $this->lfInitParam();
84        $this->objFormParam->setParam($_POST);
85
86        $this->objFormParam->splitParamCheckBoxes('search_order_sex');
87        $this->objFormParam->splitParamCheckBoxes('search_payment_id');
88
89        // 検索ワードの引き継ぎ
90        foreach ($_POST as $key => $val) {
91            if (ereg("^search_", $key)) {
92                switch($key) {
93                case 'search_order_sex':
94                case 'search_payment_id':
95                    $this->arrHidden[$key] = SC_Utils_Ex::sfMergeParamCheckBoxes($val);
96                    break;
97                default:
98                    $this->arrHidden[$key] = $val;
99                    break;
100                }
101            }
102        }
103
104        // ページ送り用
105        $this->arrHidden['search_pageno'] =
106            isset($_POST['search_pageno']) ? $_POST['search_pageno'] : "";
107
108        // 認証可否の判定
109        SC_Utils_Ex::sfIsSuccess($objSess);
110
111        if (!isset($_POST['mode'])) $_POST['mode'] = "";
112        if (!isset($arrRet)) $arrRet = array();
113
114        if($_POST['mode'] == 'delete') {
115            if(SC_Utils_Ex::sfIsInt($_POST['order_id'])) {
116                $objQuery = new SC_Query();
117                $where = "order_id = ?";
118                $sqlval['del_flg'] = '1';
119                $objQuery->update("dtb_order", $sqlval, $where, array($_POST['order_id']));
120            }
121        }
122
123        switch($_POST['mode']) {
124        case 'delete':
125        case 'csv':
126        case 'pdf':
127        case 'delete_all':
128        case 'search':
129            // 入力値の変換
130            $this->objFormParam->convParam();
131            $this->arrErr = $this->lfCheckError($arrRet);
132            $arrRet = $this->objFormParam->getHashArray();
133            // 入力なし
134            if (count($this->arrErr) == 0) {
135                $where = "del_flg = 0";
136                foreach ($arrRet as $key => $val) {
137                    if($val == "") {
138                        continue;
139                    }
140                    $val = SC_Utils_Ex::sfManualEscape($val);
141
142                    switch ($key) {
143                    case 'search_order_name':
144                        if(DB_TYPE == "pgsql"){
145                            $where .= " AND order_name01||order_name02 ILIKE ?";
146                        }elseif(DB_TYPE == "mysql"){
147                            $where .= " AND concat(order_name01,order_name02) ILIKE ?";
148                        }
149                        $nonsp_val = mb_ereg_replace("[  ]+","",$val);
150                        $arrval[] = "%$nonsp_val%";
151                        break;
152                    case 'search_order_kana':
153                        if(DB_TYPE == "pgsql"){
154                            $where .= " AND order_kana01||order_kana02 ILIKE ?";
155                        }elseif(DB_TYPE == "mysql"){
156                            $where .= " AND concat(order_kana01,order_kana02) ILIKE ?";
157                        }
158                        $nonsp_val = mb_ereg_replace("[  ]+","",$val);
159                        $arrval[] = "%$nonsp_val%";
160                        break;
161                    case 'search_order_id1':
162                        $where .= " AND order_id >= ?";
163                        $arrval[] = $val;
164                        break;
165                    case 'search_order_id2':
166                        $where .= " AND order_id <= ?";
167                        $arrval[] = $val;
168                        break;
169                    case 'search_order_sex':
170                        $tmp_where = "";
171                        foreach($val as $element) {
172                            if($element != "") {
173                                if($tmp_where == "") {
174                                    $tmp_where .= " AND (order_sex = ?";
175                                } else {
176                                    $tmp_where .= " OR order_sex = ?";
177                                }
178                                $arrval[] = $element;
179                            }
180                        }
181
182                        if($tmp_where != "") {
183                            $tmp_where .= ")";
184                            $where .= " $tmp_where ";
185                        }
186                        break;
187                    case 'search_order_tel':
188                        if(DB_TYPE == "pgsql"){
189                            $where .= " AND (order_tel01 || order_tel02 || order_tel03) LIKE ?";
190                        }elseif(DB_TYPE == "mysql"){
191                            $where .= " AND concat(order_tel01,order_tel02,order_tel03) LIKE ?";
192                        }
193                        $nonmark_val = ereg_replace("[()-]+","",$val);
194                        $arrval[] = "%$nonmark_val%";
195                        break;
196                    case 'search_order_email':
197                        $where .= " AND order_email ILIKE ?";
198                        $arrval[] = "%$val%";
199                        break;
200                    case 'search_payment_id':
201                        $tmp_where = "";
202                        foreach($val as $element) {
203                            if($element != "") {
204                                if($tmp_where == "") {
205                                    $tmp_where .= " AND (payment_id = ?";
206                                } else {
207                                    $tmp_where .= " OR payment_id = ?";
208                                }
209                                $arrval[] = $element;
210                            }
211                        }
212
213                        if($tmp_where != "") {
214                            $tmp_where .= ")";
215                            $where .= " $tmp_where ";
216                        }
217                        break;
218                    case 'search_total1':
219                        $where .= " AND total >= ?";
220                        $arrval[] = $val;
221                        break;
222                    case 'search_total2':
223                        $where .= " AND total <= ?";
224                        $arrval[] = $val;
225                        break;
226                    case 'search_sorderyear':
227                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_sorderyear'], $_POST['search_sordermonth'], $_POST['search_sorderday']);
228                        $where.= " AND create_date >= ?";
229                        $arrval[] = $date;
230                        break;
231                    case 'search_eorderyear':
232                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_eorderyear'], $_POST['search_eordermonth'], $_POST['search_eorderday'], true);
233                        $where.= " AND create_date <= ?";
234                        $arrval[] = $date;
235                        break;
236                    case 'search_supdateyear':
237                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_supdateyear'], $_POST['search_supdatemonth'], $_POST['search_supdateday']);
238                        $where.= " AND update_date >= ?";
239                        $arrval[] = $date;
240                        break;
241                    case 'search_eupdateyear':
242                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_eupdateyear'], $_POST['search_eupdatemonth'], $_POST['search_eupdateday'], true);
243                        $where.= " AND update_date <= ?";
244                        $arrval[] = $date;
245                        break;
246                    case 'search_sbirthyear':
247                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_sbirthyear'], $_POST['search_sbirthmonth'], $_POST['search_sbirthday']);
248                        $where.= " AND order_birth >= ?";
249                        $arrval[] = $date;
250                        break;
251                    case 'search_ebirthyear':
252                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_ebirthyear'], $_POST['search_ebirthmonth'], $_POST['search_ebirthday'], true);
253                        $where.= " AND order_birth <= ?";
254                        $arrval[] = $date;
255                        break;
256                    case 'search_order_status':
257                        $where.= " AND status = ?";
258                        $arrval[] = $val;
259                        break;
260                    default:
261                        if (!isset($arrval)) $arrval = array();
262                        break;
263                    }
264                }
265
266                $order = "update_date DESC";
267
268                switch($_POST['mode']) {
269                case 'csv':
270
271                    require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php");
272                    $objCSV = new SC_Helper_CSV_Ex();
273                    // オプションの指定
274                    $option = "ORDER BY $order";
275
276                    // CSV出力タイトル行の作成
277                    $arrCsvOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput(3, " WHERE csv_id = 3 AND status = 1"));
278
279                    if (count($arrCsvOutput) <= 0) break;
280
281                    $arrCsvOutputCols = $arrCsvOutput['col'];
282                    $arrCsvOutputTitle = $arrCsvOutput['disp_name'];
283                    $head = SC_Utils_Ex::sfGetCSVList($arrCsvOutputTitle);
284                    $data = $objCSV->lfGetCSV("dtb_order", $where, $option, $arrval, $arrCsvOutputCols);
285
286                    // CSVを送信する。
287                    SC_Utils_Ex::sfCSVDownload($head.$data);
288                    exit;
289                    break;
290                case 'pdf':
291                    $objFpdf = new SC_Fpdf(1, '納品書');
292                    $objFpdf->setData($arrRet);
293                    $objFpdf->createPdf();
294                    break;
295                case 'delete_all':
296                    // 検索結果をすべて削除
297                    $sqlval['del_flg'] = 1;
298                    $objQuery = new SC_Query();
299                    $objQuery->update("dtb_order", $sqlval, $where, $arrval);
300                    break;
301                default:
302                    // 読み込む列とテーブルの指定
303                    $col = "*";
304                    $from = "dtb_order";
305
306                    $objQuery = new SC_Query();
307                    // 行数の取得
308                    $linemax = $objQuery->count($from, $where, $arrval);
309                    $this->tpl_linemax = $linemax;               // 何件が該当しました。表示用
310
311                    // ページ送りの処理
312                    if(is_numeric($_POST['search_page_max'])) {
313                        $page_max = $_POST['search_page_max'];
314                    } else {
315                        $page_max = SEARCH_PMAX;
316                    }
317
318                    // ページ送りの取得
319                    $objNavi = new SC_PageNavi($this->arrHidden['search_pageno'],
320                                               $linemax, $page_max,
321                                               "fnNaviSearchPage", NAVI_PMAX);
322                    $startno = $objNavi->start_row;
323                    $this->arrPagenavi = $objNavi->arrPagenavi;
324
325                    // 取得範囲の指定(開始行番号、行数のセット)
326                    $objQuery->setlimitoffset($page_max, $startno);
327                    // 表示順序
328                    $objQuery->setorder($order);
329                    // 検索結果の取得
330                    $this->arrResults = $objQuery->select($col, $from, $where, $arrval);
331                }
332            }
333            break;
334
335        default:
336            break;
337        }
338
339        $objDate = new SC_Date();
340        // 登録・更新日検索用
341        $objDate->setStartYear(RELEASE_YEAR);
342        $objDate->setEndYear(DATE("Y"));
343        $this->arrRegistYear = $objDate->getYear();
344        // 生年月日検索用
345        $objDate->setStartYear(BIRTH_YEAR);
346        $objDate->setEndYear(DATE("Y"));
347        $this->arrBirthYear = $objDate->getYear();
348        // 月日の設定
349        $this->arrMonth = $objDate->getMonth();
350        $this->arrDay = $objDate->getDay();
351
352        // 入力値の取得
353        $this->arrForm = $this->objFormParam->getFormParamList();
354        // 支払い方法の取得
355        $arrRet = $objDb->sfGetPayment();
356        $this->arrPayment = SC_Utils_Ex::sfArrKeyValue($arrRet, 'payment_id', 'payment_method');
357
358        $objView->assignobj($this);
359        $objView->display(MAIN_FRAME);
360    }
361
362    /**
363     * デストラクタ.
364     *
365     * @return void
366     */
367    function destroy() {
368        parent::destroy();
369    }
370
371    /* パラメータ情報の初期化 */
372    function lfInitParam() {
373        $this->objFormParam->addParam("注文番号1", "search_order_id1", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
374        $this->objFormParam->addParam("注文番号2", "search_order_id2", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
375        $this->objFormParam->addParam("対応状況", "search_order_status", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
376        $this->objFormParam->addParam("顧客名", "search_order_name", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
377        $this->objFormParam->addParam("顧客名(カナ)", "search_order_kana", STEXT_LEN, "KVCa", array("KANA_CHECK","MAX_LENGTH_CHECK"));
378        $this->objFormParam->addParam("性別", "search_order_sex", INT_LEN, "n", array("MAX_LENGTH_CHECK"));
379        $this->objFormParam->addParam("年齢1", "search_age1", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
380        $this->objFormParam->addParam("年齢2", "search_age2", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
381        $this->objFormParam->addParam("メールアドレス", "search_order_email", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
382        $this->objFormParam->addParam("TEL", "search_order_tel", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
383        $this->objFormParam->addParam("支払い方法", "search_payment_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
384        $this->objFormParam->addParam("購入金額1", "search_total1", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
385        $this->objFormParam->addParam("購入金額2", "search_total2", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
386        $this->objFormParam->addParam("表示件数", "search_page_max", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
387        $this->objFormParam->addParam("開始日", "search_sorderyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
388        $this->objFormParam->addParam("開始日", "search_sordermonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
389        $this->objFormParam->addParam("開始日", "search_sorderday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
390        $this->objFormParam->addParam("終了日", "search_eorderyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
391        $this->objFormParam->addParam("終了日", "search_eordermonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
392        $this->objFormParam->addParam("終了日", "search_eorderday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
393        $this->objFormParam->addParam("開始日", "search_supdateyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
394        $this->objFormParam->addParam("開始日", "search_supdatemonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
395        $this->objFormParam->addParam("開始日", "search_supdateday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
396        $this->objFormParam->addParam("終了日", "search_eupdateyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
397        $this->objFormParam->addParam("終了日", "search_eupdatemonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
398        $this->objFormParam->addParam("終了日", "search_eupdateday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
399        $this->objFormParam->addParam("開始日", "search_sbirthyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
400        $this->objFormParam->addParam("開始日", "search_sbirthmonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
401        $this->objFormParam->addParam("開始日", "search_sbirthday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
402        $this->objFormParam->addParam("終了日", "search_ebirthyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
403        $this->objFormParam->addParam("終了日", "search_ebirthmonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
404        $this->objFormParam->addParam("終了日", "search_ebirthday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
405    }
406
407    /* 入力内容のチェック */
408    function lfCheckError() {
409        // 入力データを渡す。
410        $arrRet = $this->objFormParam->getHashArray();
411        $objErr = new SC_CheckError($arrRet);
412        $objErr->arrErr = $this->objFormParam->checkError();
413
414        // 特殊項目チェック
415        $objErr->doFunc(array("注文番号1", "注文番号2", "search_order_id1", "search_order_id2"), array("GREATER_CHECK"));
416        $objErr->doFunc(array("年齢1", "年齢2", "search_age1", "search_age2"), array("GREATER_CHECK"));
417        $objErr->doFunc(array("購入金額1", "購入金額2", "search_total1", "search_total2"), array("GREATER_CHECK"));
418        $objErr->doFunc(array("開始日", "search_sorderyear", "search_sordermonth", "search_sorderday"), array("CHECK_DATE"));
419        $objErr->doFunc(array("終了日", "search_eorderyear", "search_eordermonth", "search_eorderday"), array("CHECK_DATE"));
420        $objErr->doFunc(array("開始日", "終了日", "search_sorderyear", "search_sordermonth", "search_sorderday", "search_eorderyear", "search_eordermonth", "search_eorderday"), array("CHECK_SET_TERM"));
421
422        $objErr->doFunc(array("開始日", "search_supdateyear", "search_supdatemonth", "search_supdateday"), array("CHECK_DATE"));
423        $objErr->doFunc(array("終了日", "search_eupdateyear", "search_eupdatemonth", "search_eupdateday"), array("CHECK_DATE"));
424        $objErr->doFunc(array("開始日", "終了日", "search_supdateyear", "search_supdatemonth", "search_supdateday", "search_eupdateyear", "search_eupdatemonth", "search_eupdateday"), array("CHECK_SET_TERM"));
425
426        $objErr->doFunc(array("開始日", "search_sbirthyear", "search_sbirthmonth", "search_sbirthday"), array("CHECK_DATE"));
427        $objErr->doFunc(array("終了日", "search_ebirthyear", "search_ebirthmonth", "search_ebirthday"), array("CHECK_DATE"));
428        $objErr->doFunc(array("開始日", "終了日", "search_sbirthyear", "search_sbirthmonth", "search_sbirthday", "search_ebirthyear", "search_ebirthmonth", "search_ebirthday"), array("CHECK_SET_TERM"));
429
430        return $objErr->arrErr;
431    }
432
433
434}
435?>
Note: See TracBrowser for help on using the repository browser.