[15557] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[22206] | 5 | * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved. |
---|
[15557] | 6 | * |
---|
| 7 | * http://www.lockon.co.jp/ |
---|
[16582] | 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. |
---|
[15557] | 22 | */ |
---|
| 23 | |
---|
[20534] | 24 | require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php'; |
---|
[15557] | 25 | |
---|
| 26 | /** |
---|
| 27 | * 商品選択 のページクラス. |
---|
| 28 | * |
---|
| 29 | * @package Page |
---|
| 30 | * @author LOCKON CO.,LTD. |
---|
| 31 | * @version $Id$ |
---|
| 32 | */ |
---|
[22856] | 33 | class LC_Page_Admin_Products_ProductSelect extends LC_Page_Admin_Ex |
---|
[22567] | 34 | { |
---|
[15557] | 35 | /** |
---|
| 36 | * Page を初期化する. |
---|
| 37 | * |
---|
| 38 | * @return void |
---|
| 39 | */ |
---|
[22567] | 40 | function init() |
---|
| 41 | { |
---|
[15557] | 42 | parent::init(); |
---|
| 43 | $this->tpl_mainpage = 'products/product_select.tpl'; |
---|
[15872] | 44 | $this->tpl_mainno = 'products'; |
---|
[21514] | 45 | $this->tpl_subno = ''; |
---|
[20911] | 46 | $this->tpl_maintitle = '商品管理'; |
---|
[15872] | 47 | $this->tpl_subtitle = '商品選択'; |
---|
[15557] | 48 | |
---|
[19687] | 49 | $masterData = new SC_DB_MasterData_Ex(); |
---|
[21481] | 50 | $this->arrPRODUCTSTATUS_COLOR = $masterData->getMasterData('mtb_product_status_color'); |
---|
[15557] | 51 | } |
---|
| 52 | |
---|
| 53 | /** |
---|
| 54 | * Page のプロセス. |
---|
| 55 | * |
---|
| 56 | * @return void |
---|
| 57 | */ |
---|
[22567] | 58 | function process() |
---|
| 59 | { |
---|
[19661] | 60 | $this->action(); |
---|
| 61 | $this->sendResponse(); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | /** |
---|
| 65 | * Page のアクション. |
---|
| 66 | * |
---|
| 67 | * @return void |
---|
| 68 | */ |
---|
[22567] | 69 | function action() |
---|
| 70 | { |
---|
[15557] | 71 | $objDb = new SC_Helper_DB_Ex(); |
---|
| 72 | |
---|
[20501] | 73 | $objFormParam = new SC_FormParam_Ex(); |
---|
[20419] | 74 | $this->lfInitParam($objFormParam); |
---|
| 75 | $objFormParam->setParam($_POST); |
---|
| 76 | $objFormParam->convParam(); |
---|
| 77 | $this->arrForm = $objFormParam->getHashArray(); |
---|
| 78 | |
---|
[20044] | 79 | switch ($this->getMode()) { |
---|
[21526] | 80 | case 'search': |
---|
| 81 | $this->arrProducts = $this->lfGetProducts($objDb); |
---|
| 82 | break; |
---|
| 83 | default: |
---|
| 84 | break; |
---|
[15557] | 85 | } |
---|
| 86 | |
---|
| 87 | // カテゴリ取得 |
---|
| 88 | $this->arrCatList = $objDb->sfGetCategoryList(); |
---|
[19909] | 89 | $this->setTemplate($this->tpl_mainpage); |
---|
[15557] | 90 | } |
---|
| 91 | |
---|
| 92 | /** |
---|
[20970] | 93 | * パラメーター情報の初期化を行う. |
---|
[20419] | 94 | * |
---|
| 95 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 96 | * @return void |
---|
| 97 | */ |
---|
[22567] | 98 | function lfInitParam(&$objFormParam) |
---|
| 99 | { |
---|
[21514] | 100 | $objFormParam->addParam('カテゴリ', 'search_category_id', STEXT_LEN, 'n'); |
---|
| 101 | $objFormParam->addParam('商品名', 'search_name', STEXT_LEN, 'KVa'); |
---|
| 102 | $objFormParam->addParam('商品コード', 'search_product_code', STEXT_LEN, 'KVa'); |
---|
[15557] | 103 | } |
---|
[20191] | 104 | |
---|
| 105 | /* 商品検索結果取得 */ |
---|
[22567] | 106 | function lfGetProducts(&$objDb) |
---|
| 107 | { |
---|
[21514] | 108 | $where = 'del_flg = 0'; |
---|
[21563] | 109 | $arrWhereVal = array(); |
---|
[20191] | 110 | |
---|
| 111 | /* 入力エラーなし */ |
---|
| 112 | foreach ($this->arrForm AS $key=>$val) { |
---|
[21684] | 113 | if ($val == '') continue; |
---|
[20191] | 114 | |
---|
| 115 | switch ($key) { |
---|
[21526] | 116 | case 'search_name': |
---|
| 117 | $where .= ' AND name ILIKE ?'; |
---|
[21563] | 118 | $arrWhereVal[] = "%$val%"; |
---|
[21526] | 119 | break; |
---|
| 120 | case 'search_category_id': |
---|
[21563] | 121 | list($tmp_where, $arrTmp) = $objDb->sfGetCatWhere($val); |
---|
[21526] | 122 | if ($tmp_where != '') { |
---|
| 123 | $where.= ' AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE ' . $tmp_where . ')'; |
---|
[21563] | 124 | $arrWhereVal = array_merge((array)$arrWhereVal, (array)$arrTmp); |
---|
[21526] | 125 | } |
---|
| 126 | break; |
---|
| 127 | case 'search_product_code': |
---|
[23084] | 128 | $where .= ' AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code LIKE ?)'; |
---|
[21563] | 129 | $arrWhereVal[] = "$val%"; |
---|
[21526] | 130 | break; |
---|
| 131 | default: |
---|
| 132 | break; |
---|
[20191] | 133 | } |
---|
| 134 | } |
---|
| 135 | |
---|
[21514] | 136 | $order = 'update_date DESC, product_id DESC '; |
---|
[20191] | 137 | |
---|
[20507] | 138 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[20191] | 139 | // 行数の取得 |
---|
[21563] | 140 | $linemax = $objQuery->count('dtb_products', $where, $arrWhereVal); |
---|
[20191] | 141 | $this->tpl_linemax = $linemax; // 何件が該当しました。表示用 |
---|
| 142 | |
---|
| 143 | // ページ送りの処理 |
---|
[20380] | 144 | $page_max = SC_Utils_Ex::sfGetSearchPageMax($_POST['search_page_max']); |
---|
[20191] | 145 | |
---|
| 146 | // ページ送りの取得 |
---|
[20538] | 147 | $objNavi = new SC_PageNavi_Ex($_POST['search_pageno'], $linemax, $page_max, 'fnNaviSearchOnlyPage', NAVI_PMAX); |
---|
[20191] | 148 | $this->tpl_strnavi = $objNavi->strnavi; // 表示文字列 |
---|
| 149 | $startno = $objNavi->start_row; |
---|
| 150 | |
---|
| 151 | // 取得範囲の指定(開始行番号、行数のセット) |
---|
| 152 | $objQuery->setLimitOffset($page_max, $startno); |
---|
| 153 | // 表示順序 |
---|
| 154 | $objQuery->setOrder($order); |
---|
| 155 | |
---|
| 156 | // 検索結果の取得 |
---|
| 157 | // FIXME 商品コードの表示 |
---|
[21563] | 158 | $arrProducts = $objQuery->select('*', SC_Product_Ex::alldtlSQL(), $where, $arrWhereVal); |
---|
[22856] | 159 | |
---|
[20191] | 160 | return $arrProducts; |
---|
| 161 | } |
---|
[15557] | 162 | } |
---|