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

Revision 17738, 20.6 KB checked in by kishida, 15 years ago (diff)

#409 改修

  • 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 'delete_all':
127        case 'search':
128            // 入力値の変換
129            $this->objFormParam->convParam();
130            $this->arrErr = $this->lfCheckError($arrRet);
131            $arrRet = $this->objFormParam->getHashArray();
132            // 入力なし
133            if (count($this->arrErr) == 0) {
134                $where = "del_flg = 0";
135                foreach ($arrRet as $key => $val) {
136                    if($val == "") {
137                        continue;
138                    }
139                    $val = SC_Utils_Ex::sfManualEscape($val);
140
141                    switch ($key) {
142                    case 'search_order_name':
143                        if(DB_TYPE == "pgsql"){
144                            $where .= " AND order_name01||order_name02 ILIKE ?";
145                        }elseif(DB_TYPE == "mysql"){
146                            $where .= " AND concat(order_name01,order_name02) ILIKE ?";
147                        }
148                        $nonsp_val = mb_ereg_replace("[  ]+","",$val);
149                        $arrval[] = "%$nonsp_val%";
150                        break;
151                    case 'search_order_kana':
152                        if(DB_TYPE == "pgsql"){
153                            $where .= " AND order_kana01||order_kana02 ILIKE ?";
154                        }elseif(DB_TYPE == "mysql"){
155                            $where .= " AND concat(order_kana01,order_kana02) ILIKE ?";
156                        }
157                        $nonsp_val = mb_ereg_replace("[  ]+","",$val);
158                        $arrval[] = "%$nonsp_val%";
159                        break;
160                    case 'search_order_id1':
161                        $where .= " AND order_id >= ?";
162                        $arrval[] = $val;
163                        break;
164                    case 'search_order_id2':
165                        $where .= " AND order_id <= ?";
166                        $arrval[] = $val;
167                        break;
168                    case 'search_order_sex':
169                        $tmp_where = "";
170                        foreach($val as $element) {
171                            if($element != "") {
172                                if($tmp_where == "") {
173                                    $tmp_where .= " AND (order_sex = ?";
174                                } else {
175                                    $tmp_where .= " OR order_sex = ?";
176                                }
177                                $arrval[] = $element;
178                            }
179                        }
180
181                        if($tmp_where != "") {
182                            $tmp_where .= ")";
183                            $where .= " $tmp_where ";
184                        }
185                        break;
186                    case 'search_order_tel':
187                        if(DB_TYPE == "pgsql"){
188                            $where .= " AND (order_tel01 || order_tel02 || order_tel03) LIKE ?";
189                        }elseif(DB_TYPE == "mysql"){
190                            $where .= " AND concat(order_tel01,order_tel02,order_tel03) LIKE ?";
191                        }
192                        $nonmark_val = ereg_replace("[()-]+","",$val);
193                        $arrval[] = "%$nonmark_val%";
194                        break;
195                    case 'search_order_email':
196                        $where .= " AND order_email ILIKE ?";
197                        $arrval[] = "%$val%";
198                        break;
199                    case 'search_payment_id':
200                        $tmp_where = "";
201                        foreach($val as $element) {
202                            if($element != "") {
203                                if($tmp_where == "") {
204                                    $tmp_where .= " AND (payment_id = ?";
205                                } else {
206                                    $tmp_where .= " OR payment_id = ?";
207                                }
208                                $arrval[] = $element;
209                            }
210                        }
211
212                        if($tmp_where != "") {
213                            $tmp_where .= ")";
214                            $where .= " $tmp_where ";
215                        }
216                        break;
217                    case 'search_total1':
218                        $where .= " AND total >= ?";
219                        $arrval[] = $val;
220                        break;
221                    case 'search_total2':
222                        $where .= " AND total <= ?";
223                        $arrval[] = $val;
224                        break;
225                    case 'search_sorderyear':
226                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_sorderyear'], $_POST['search_sordermonth'], $_POST['search_sorderday']);
227                        $where.= " AND create_date >= ?";
228                        $arrval[] = $date;
229                        break;
230                    case 'search_eorderyear':
231                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_eorderyear'], $_POST['search_eordermonth'], $_POST['search_eorderday']);
232                        $where.= " AND create_date <= ?";
233                        $arrval[] = $date;
234                        break;
235                    case 'search_supdateyear':
236                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_supdateyear'], $_POST['search_supdatemonth'], $_POST['search_supdateday']);
237                        $where.= " AND update_date >= ?";
238                        $arrval[] = $date;
239                        break;
240                    case 'search_eupdateyear':
241                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_eupdateyear'], $_POST['search_eupdatemonth'], $_POST['search_eupdateday'], true);
242                        $where.= " AND update_date <= ?";
243                        $arrval[] = $date;
244                        break;
245                    case 'search_sbirthyear':
246                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_sbirthyear'], $_POST['search_sbirthmonth'], $_POST['search_sbirthday']);
247                        $where.= " AND order_birth >= ?";
248                        $arrval[] = $date;
249                        break;
250                    case 'search_ebirthyear':
251                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_ebirthyear'], $_POST['search_ebirthmonth'], $_POST['search_ebirthday'], true);
252                        $where.= " AND order_birth <= ?";
253                        $arrval[] = $date;
254                        break;
255                    case 'search_order_status':
256                        $where.= " AND status = ?";
257                        $arrval[] = $val;
258                        break;
259                    default:
260                        if (!isset($arrval)) $arrval = array();
261                        break;
262                    }
263                }
264
265                $order = "update_date DESC";
266
267                switch($_POST['mode']) {
268                case 'csv':
269
270                    require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php");
271                    $objCSV = new SC_Helper_CSV_Ex();
272                    // オプションの指定
273                    $option = "ORDER BY $order";
274
275                    // CSV出力タイトル行の作成
276                    $arrCsvOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput(3, " WHERE csv_id = 3 AND status = 1"));
277
278                    if (count($arrCsvOutput) <= 0) break;
279
280                    $arrCsvOutputCols = $arrCsvOutput['col'];
281                    $arrCsvOutputTitle = $arrCsvOutput['disp_name'];
282                    $head = SC_Utils_Ex::sfGetCSVList($arrCsvOutputTitle);
283                    $data = $objCSV->lfGetCSV("dtb_order", $where, $option, $arrval, $arrCsvOutputCols);
284
285                    // CSVを送信する。
286                    SC_Utils_Ex::sfCSVDownload($head.$data);
287                    exit;
288                    break;
289                case 'delete_all':
290                    // 検索結果をすべて削除
291                    $sqlval['del_flg'] = 1;
292                    $objQuery = new SC_Query();
293                    $objQuery->update("dtb_order", $sqlval, $where, $arrval);
294                    break;
295                default:
296                    // 読み込む列とテーブルの指定
297                    $col = "*";
298                    $from = "dtb_order";
299
300                    $objQuery = new SC_Query();
301                    // 行数の取得
302                    $linemax = $objQuery->count($from, $where, $arrval);
303                    $this->tpl_linemax = $linemax;               // 何件が該当しました。表示用
304
305                    // ページ送りの処理
306                    if(is_numeric($_POST['search_page_max'])) {
307                        $page_max = $_POST['search_page_max'];
308                    } else {
309                        $page_max = SEARCH_PMAX;
310                    }
311
312                    // ページ送りの取得
313                    $objNavi = new SC_PageNavi($this->arrHidden['search_pageno'],
314                                               $linemax, $page_max,
315                                               "fnNaviSearchPage", NAVI_PMAX);
316                    $startno = $objNavi->start_row;
317                    $this->arrPagenavi = $objNavi->arrPagenavi;
318
319                    // 取得範囲の指定(開始行番号、行数のセット)
320                    $objQuery->setlimitoffset($page_max, $startno);
321                    // 表示順序
322                    $objQuery->setorder($order);
323                    // 検索結果の取得
324                    $this->arrResults = $objQuery->select($col, $from, $where, $arrval);
325                }
326            }
327            break;
328
329        default:
330            break;
331        }
332
333        $objDate = new SC_Date();
334        // 登録・更新日検索用
335        $objDate->setStartYear(RELEASE_YEAR);
336        $objDate->setEndYear(DATE("Y"));
337        $this->arrRegistYear = $objDate->getYear();
338        // 生年月日検索用
339        $objDate->setStartYear(BIRTH_YEAR);
340        $objDate->setEndYear(DATE("Y"));
341        $this->arrBirthYear = $objDate->getYear();
342        // 月日の設定
343        $this->arrMonth = $objDate->getMonth();
344        $this->arrDay = $objDate->getDay();
345
346        // 入力値の取得
347        $this->arrForm = $this->objFormParam->getFormParamList();
348        // 支払い方法の取得
349        $arrRet = $objDb->sfGetPayment();
350        $this->arrPayment = SC_Utils_Ex::sfArrKeyValue($arrRet, 'payment_id', 'payment_method');
351
352        $objView->assignobj($this);
353        $objView->display(MAIN_FRAME);
354    }
355
356    /**
357     * デストラクタ.
358     *
359     * @return void
360     */
361    function destroy() {
362        parent::destroy();
363    }
364
365    /* パラメータ情報の初期化 */
366    function lfInitParam() {
367        $this->objFormParam->addParam("受注番号1", "search_order_id1", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
368        $this->objFormParam->addParam("受注番号2", "search_order_id2", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
369        $this->objFormParam->addParam("対応状況", "search_order_status", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
370        $this->objFormParam->addParam("顧客名", "search_order_name", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
371        $this->objFormParam->addParam("顧客名(カナ)", "search_order_kana", STEXT_LEN, "KVCa", array("KANA_CHECK","MAX_LENGTH_CHECK"));
372        $this->objFormParam->addParam("性別", "search_order_sex", INT_LEN, "n", array("MAX_LENGTH_CHECK"));
373        $this->objFormParam->addParam("年齢1", "search_age1", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
374        $this->objFormParam->addParam("年齢2", "search_age2", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
375        $this->objFormParam->addParam("メールアドレス", "search_order_email", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
376        $this->objFormParam->addParam("TEL", "search_order_tel", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
377        $this->objFormParam->addParam("支払い方法", "search_payment_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
378        $this->objFormParam->addParam("購入金額1", "search_total1", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
379        $this->objFormParam->addParam("購入金額2", "search_total2", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
380        $this->objFormParam->addParam("表示件数", "search_page_max", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
381        $this->objFormParam->addParam("開始日", "search_sorderyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
382        $this->objFormParam->addParam("開始日", "search_sordermonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
383        $this->objFormParam->addParam("開始日", "search_sorderday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
384        $this->objFormParam->addParam("終了日", "search_eorderyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
385        $this->objFormParam->addParam("終了日", "search_eordermonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
386        $this->objFormParam->addParam("終了日", "search_eorderday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
387        $this->objFormParam->addParam("開始日", "search_supdateyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
388        $this->objFormParam->addParam("開始日", "search_supdatemonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
389        $this->objFormParam->addParam("開始日", "search_supdateday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
390        $this->objFormParam->addParam("終了日", "search_eupdateyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
391        $this->objFormParam->addParam("終了日", "search_eupdatemonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
392        $this->objFormParam->addParam("終了日", "search_eupdateday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
393        $this->objFormParam->addParam("開始日", "search_sbirthyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
394        $this->objFormParam->addParam("開始日", "search_sbirthmonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
395        $this->objFormParam->addParam("開始日", "search_sbirthday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
396        $this->objFormParam->addParam("終了日", "search_ebirthyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
397        $this->objFormParam->addParam("終了日", "search_ebirthmonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
398        $this->objFormParam->addParam("終了日", "search_ebirthday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
399    }
400
401    /* 入力内容のチェック */
402    function lfCheckError() {
403        // 入力データを渡す。
404        $arrRet = $this->objFormParam->getHashArray();
405        $objErr = new SC_CheckError($arrRet);
406        $objErr->arrErr = $this->objFormParam->checkError();
407
408        // 特殊項目チェック
409        $objErr->doFunc(array("受注番号1", "受注番号2", "search_order_id1", "search_order_id2"), array("GREATER_CHECK"));
410        $objErr->doFunc(array("年齢1", "年齢2", "search_age1", "search_age2"), array("GREATER_CHECK"));
411        $objErr->doFunc(array("購入金額1", "購入金額2", "search_total1", "search_total2"), array("GREATER_CHECK"));
412        $objErr->doFunc(array("開始日", "search_sorderyear", "search_sordermonth", "search_sorderday"), array("CHECK_DATE"));
413        $objErr->doFunc(array("終了日", "search_eorderyear", "search_eordermonth", "search_eorderday"), array("CHECK_DATE"));
414        $objErr->doFunc(array("開始日", "終了日", "search_sorderyear", "search_sordermonth", "search_sorderday", "search_eorderyear", "search_eordermonth", "search_eorderday"), array("CHECK_SET_TERM"));
415
416        $objErr->doFunc(array("開始日", "search_supdateyear", "search_supdatemonth", "search_supdateday"), array("CHECK_DATE"));
417        $objErr->doFunc(array("終了日", "search_eupdateyear", "search_eupdatemonth", "search_eupdateday"), array("CHECK_DATE"));
418        $objErr->doFunc(array("開始日", "終了日", "search_supdateyear", "search_supdatemonth", "search_supdateday", "search_eupdateyear", "search_eupdatemonth", "search_eupdateday"), array("CHECK_SET_TERM"));
419
420        $objErr->doFunc(array("開始日", "search_sbirthyear", "search_sbirthmonth", "search_sbirthday"), array("CHECK_DATE"));
421        $objErr->doFunc(array("終了日", "search_ebirthyear", "search_ebirthmonth", "search_ebirthday"), array("CHECK_DATE"));
422        $objErr->doFunc(array("開始日", "終了日", "search_sbirthyear", "search_sbirthmonth", "search_sbirthday", "search_ebirthyear", "search_ebirthmonth", "search_ebirthday"), array("CHECK_SET_TERM"));
423
424        return $objErr->arrErr;
425    }
426
427
428}
429?>
Note: See TracBrowser for help on using the repository browser.