[15600] | 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. |
---|
[15600] | 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. |
---|
[15600] | 22 | */ |
---|
| 23 | // {{{ requires |
---|
[20534] | 24 | require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php'; |
---|
[15600] | 25 | |
---|
| 26 | /** |
---|
| 27 | * 売上集計 のページクラス. |
---|
| 28 | * |
---|
| 29 | * @package Page |
---|
| 30 | * @author LOCKON CO.,LTD. |
---|
| 31 | * @version $Id$ |
---|
| 32 | */ |
---|
[20345] | 33 | class LC_Page_Admin_Total extends LC_Page_Admin_Ex { |
---|
[15600] | 34 | |
---|
| 35 | // }}} |
---|
| 36 | // {{{ functions |
---|
| 37 | |
---|
| 38 | /** |
---|
| 39 | * Page を初期化する. |
---|
| 40 | * |
---|
| 41 | * @return void |
---|
| 42 | */ |
---|
| 43 | function init() { |
---|
| 44 | parent::init(); |
---|
| 45 | // GDライブラリのインストール判定 |
---|
[21481] | 46 | $this->install_GD = function_exists('gd_info') ? true : false; |
---|
[20129] | 47 | $this->tpl_mainpage = 'total/index.tpl'; |
---|
| 48 | $this->tpl_graphsubtitle = 'total/subtitle.tpl'; |
---|
| 49 | $this->tpl_titleimage = ROOT_URLPATH.'img/title/title_sale.jpg'; |
---|
[20911] | 50 | $this->tpl_maintitle = '売上集計'; |
---|
[20129] | 51 | $this->tpl_mainno = 'total'; |
---|
[15600] | 52 | |
---|
[20129] | 53 | $masterData = new SC_DB_MasterData_Ex(); |
---|
[21481] | 54 | $this->arrWDAY = $masterData->getMasterData('mtb_wday'); |
---|
| 55 | $this->arrSex = $masterData->getMasterData('mtb_sex'); |
---|
| 56 | $this->arrJob = $masterData->getMasterData('mtb_job'); |
---|
[20129] | 57 | |
---|
| 58 | // 登録・更新日検索用 |
---|
[20499] | 59 | $objDate = new SC_Date_Ex(); |
---|
[20129] | 60 | $objDate->setStartYear(RELEASE_YEAR); |
---|
[20538] | 61 | $objDate->setEndYear(DATE('Y')); |
---|
[20129] | 62 | $this->arrYear = $objDate->getYear(); |
---|
| 63 | $this->arrMonth = $objDate->getMonth(); |
---|
| 64 | $this->arrDay = $objDate->getDay(); |
---|
| 65 | |
---|
| 66 | // ページタイトル todo あとでなおす |
---|
[21514] | 67 | $this->arrTitle[''] = '期間別集計'; |
---|
| 68 | $this->arrTitle['term'] = '期間別集計'; |
---|
| 69 | $this->arrTitle['products'] = '商品別集計'; |
---|
| 70 | $this->arrTitle['age'] = '年代別集計'; |
---|
| 71 | $this->arrTitle['job'] = '職業別集計'; |
---|
| 72 | $this->arrTitle['member'] = '会員別集計'; |
---|
[15600] | 73 | |
---|
[20129] | 74 | // 月度集計のkey名 |
---|
| 75 | $this->arrSearchForm1 = array('search_startyear_m', 'search_startmonth_m'); |
---|
[15636] | 76 | |
---|
[20129] | 77 | // 期間別集計のkey名 |
---|
[21562] | 78 | $this->arrSearchForm2 = array( |
---|
| 79 | 'search_startyear', |
---|
| 80 | 'search_startmonth', |
---|
| 81 | 'search_startday', |
---|
| 82 | 'search_endyear', |
---|
| 83 | 'search_endmonth', |
---|
| 84 | 'search_endday', |
---|
| 85 | ); |
---|
[15600] | 86 | } |
---|
| 87 | |
---|
| 88 | /** |
---|
| 89 | * Page のプロセス. |
---|
| 90 | * |
---|
| 91 | * @return void |
---|
| 92 | */ |
---|
| 93 | function process() { |
---|
[19661] | 94 | $this->action(); |
---|
| 95 | $this->sendResponse(); |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | /** |
---|
| 99 | * Page のアクション. |
---|
| 100 | * |
---|
| 101 | * @return void |
---|
| 102 | */ |
---|
| 103 | function action() { |
---|
[21591] | 104 | |
---|
[21515] | 105 | if (isset($_GET['draw_image']) && $_GET['draw_image'] != '') { |
---|
[15624] | 106 | define('DRAW_IMAGE' , true); |
---|
[21441] | 107 | } else { |
---|
[15624] | 108 | define('DRAW_IMAGE' , false); |
---|
[15600] | 109 | } |
---|
| 110 | |
---|
[20970] | 111 | // パラメーター管理クラス |
---|
[20501] | 112 | $objFormParam = new SC_FormParam_Ex(); |
---|
[20970] | 113 | // パラメーター情報の初期化 |
---|
[20129] | 114 | $this->lfInitParam($objFormParam); |
---|
[22138] | 115 | $objFormParam->setParam($_REQUEST); |
---|
[15600] | 116 | |
---|
| 117 | // 検索ワードの引き継ぎ |
---|
[20721] | 118 | $this->arrHidden = $objFormParam->getSearchArray(); |
---|
[15600] | 119 | |
---|
[21441] | 120 | switch ($this->getMode()) { |
---|
[21526] | 121 | case 'csv': |
---|
| 122 | case 'search': |
---|
[20129] | 123 | |
---|
[21526] | 124 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 125 | if (empty($this->arrErr)) { |
---|
[15600] | 126 | |
---|
[21526] | 127 | // 日付 |
---|
| 128 | list($sdate, $edate) = $this->lfSetStartEndDate($objFormParam); |
---|
[15600] | 129 | |
---|
[21526] | 130 | // ページ |
---|
| 131 | $page = ($objFormParam->getValue('page')) ? $objFormParam->getValue('page') : 'term'; |
---|
[15600] | 132 | |
---|
[21526] | 133 | // 集計種類 |
---|
| 134 | $type = ($objFormParam->getValue('type')) ? $objFormParam->getValue('type'): 'all'; |
---|
[15600] | 135 | |
---|
[21526] | 136 | $this->tpl_page_type = 'total/page_'. $page .'.tpl'; |
---|
[22138] | 137 | // FIXME 可読性が低いので call_user_func_array を使わない (またはメソッド名を1つの定数値とする) 実装に。 |
---|
[21526] | 138 | list($this->arrResults, $this->tpl_image) = call_user_func_array(array($this, 'lfGetOrder'.$page), |
---|
| 139 | array($type, $sdate, $edate)); |
---|
| 140 | if ($this->getMode() == 'csv') { |
---|
| 141 | // CSV出力タイトル行の取得 |
---|
| 142 | list($arrTitleCol, $arrDataCol) = $this->lfGetCSVColum($page); |
---|
| 143 | $head = SC_Utils_Ex::sfGetCSVList($arrTitleCol); |
---|
| 144 | $data = $this->lfGetDataColCSV($this->arrResults, $arrDataCol); |
---|
[20129] | 145 | |
---|
[21526] | 146 | // CSVを送信する。 |
---|
| 147 | list($fime_name, $data) = SC_Utils_Ex::sfGetCSVData($head.$data); |
---|
[21591] | 148 | |
---|
[21526] | 149 | $this->sendResponseCSV($fime_name, $data); |
---|
[21743] | 150 | SC_Response_Ex::actionExit(); |
---|
[21526] | 151 | } |
---|
[15600] | 152 | } |
---|
[21526] | 153 | break; |
---|
| 154 | default: |
---|
[21527] | 155 | break; |
---|
| 156 | } |
---|
[15600] | 157 | |
---|
[20129] | 158 | // 画面宣しても日付が保存される |
---|
| 159 | $_SESSION = $this->lfSaveDateSession($_SESSION, $this->arrHidden); |
---|
| 160 | $objFormParam->setParam($_SESSION['total']); |
---|
[15600] | 161 | // 入力値の取得 |
---|
[20129] | 162 | $this->arrForm = $objFormParam->getFormParamList(); |
---|
| 163 | $this->tpl_subtitle = $this->arrTitle[$objFormParam->getValue('page')]; |
---|
[21591] | 164 | |
---|
[15600] | 165 | } |
---|
| 166 | |
---|
| 167 | /** |
---|
| 168 | * デストラクタ. |
---|
| 169 | * |
---|
| 170 | * @return void |
---|
| 171 | */ |
---|
| 172 | function destroy() { |
---|
| 173 | parent::destroy(); |
---|
| 174 | } |
---|
| 175 | |
---|
[20741] | 176 | /* デフォルト値の取得 */ |
---|
| 177 | function lfGetDateDefault() { |
---|
[21480] | 178 | $year = date('Y'); |
---|
[21481] | 179 | $month = date('m'); |
---|
| 180 | $day = date('d'); |
---|
[20741] | 181 | |
---|
[21515] | 182 | $list = isset($_SESSION['total']) ? $_SESSION['total'] : ''; |
---|
[20741] | 183 | |
---|
| 184 | // セッション情報に開始月度が保存されていない。 |
---|
[21441] | 185 | if (empty($_SESSION['total']['startyear_m'])) { |
---|
[20741] | 186 | $list['startyear_m'] = $year; |
---|
| 187 | $list['startmonth_m'] = $month; |
---|
| 188 | } |
---|
| 189 | |
---|
| 190 | // セッション情報に開始日付、終了日付が保存されていない。 |
---|
[21441] | 191 | if (empty($_SESSION['total']['startyear']) && empty($_SESSION['total']['endyear'])) { |
---|
[20741] | 192 | $list['startyear'] = $year; |
---|
| 193 | $list['startmonth'] = $month; |
---|
| 194 | $list['startday'] = $day; |
---|
| 195 | $list['endyear'] = $year; |
---|
| 196 | $list['endmonth'] = $month; |
---|
| 197 | $list['endday'] = $day; |
---|
| 198 | } |
---|
| 199 | |
---|
| 200 | return $list; |
---|
| 201 | } |
---|
| 202 | |
---|
[20970] | 203 | /* パラメーター情報の初期化 */ |
---|
[20129] | 204 | function lfInitParam(&$objFormParam) { |
---|
[20741] | 205 | // デフォルト値の取得 |
---|
| 206 | $arrList = $this->lfGetDateDefault(); |
---|
| 207 | |
---|
[20129] | 208 | // 月度集計 |
---|
[22138] | 209 | $objFormParam->addParam('月度(年)', 'search_startyear_m', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), $arrList['startyear_m']); |
---|
| 210 | $objFormParam->addParam('月度(月)', 'search_startmonth_m', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), $arrList['startmonth_m']); |
---|
[20129] | 211 | // 期間集計 |
---|
[22138] | 212 | $objFormParam->addParam('期間(開始日)', 'search_startyear', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), $arrList['startyear']); |
---|
| 213 | $objFormParam->addParam('期間(開始日)', 'search_startmonth', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), $arrList['startmonth']); |
---|
| 214 | $objFormParam->addParam('期間(開始日)', 'search_startday', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), $arrList['startday']); |
---|
| 215 | $objFormParam->addParam('期間(終了日)', 'search_endyear', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), $arrList['endyear']); |
---|
| 216 | $objFormParam->addParam('期間(終了日)', 'search_endmonth', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), $arrList['endmonth']); |
---|
| 217 | $objFormParam->addParam('期間(終了日)', 'search_endday', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), $arrList['endday']); |
---|
[15626] | 218 | |
---|
[20129] | 219 | // hiddenデータの取得用 |
---|
[21514] | 220 | $objFormParam->addParam('', 'page'); |
---|
| 221 | $objFormParam->addParam('', 'type'); |
---|
| 222 | $objFormParam->addParam('', 'mode'); |
---|
[22138] | 223 | $objFormParam->addParam('', 'search_form'); |
---|
[20129] | 224 | } |
---|
| 225 | |
---|
| 226 | /* 入力内容のチェック */ |
---|
| 227 | function lfCheckError(&$objFormParam) { |
---|
| 228 | |
---|
| 229 | $objFormParam->convParam(); |
---|
[22138] | 230 | $objErr = new SC_CheckError_Ex($objFormParam->getHashArray()); |
---|
[20129] | 231 | $objErr->arrErr = $objFormParam->checkError(); |
---|
| 232 | |
---|
| 233 | // 特殊項目チェック |
---|
[22138] | 234 | |
---|
| 235 | // 月度集計 |
---|
| 236 | if ($objFormParam->getValue('search_form') == 1) { |
---|
| 237 | $objErr->doFunc(array('月度', 'search_startyear_m', 'search_startmonth_m'), array('FULL_EXIST_CHECK')); |
---|
[15600] | 238 | } |
---|
| 239 | |
---|
[22138] | 240 | // 期間集計 |
---|
| 241 | if ($objFormParam->getValue('search_form') == 2) { |
---|
| 242 | $objErr->doFunc(array('期間(開始日)', 'search_startyear', 'search_startmonth', 'search_startday'), array('FULL_EXIST_CHECK')); |
---|
| 243 | $objErr->doFunc(array('期間(終了日)', 'search_endyear', 'search_endmonth', 'search_endday'), array('FULL_EXIST_CHECK')); |
---|
| 244 | $objErr->doFunc(array('期間(開始日)', 'search_startyear', 'search_startmonth', 'search_startday'), array('CHECK_DATE')); |
---|
| 245 | $objErr->doFunc(array('期間(終了日)', 'search_endyear', 'search_endmonth', 'search_endday'), array('CHECK_DATE')); |
---|
| 246 | $objErr->doFunc(array('期間(開始日)', '期間(終了日)', 'search_startyear', 'search_startmonth', 'search_startday', 'search_endyear', 'search_endmonth', 'search_endday'), array('CHECK_SET_TERM')); |
---|
[15600] | 247 | } |
---|
[22138] | 248 | |
---|
[20129] | 249 | return $objErr->arrErr; |
---|
[15600] | 250 | } |
---|
| 251 | |
---|
[20129] | 252 | /* サブナビを移動しても日付が残るようにセッションに入力期間を記録する */ |
---|
| 253 | function lfSaveDateSession($session, $arrForm) { |
---|
[15600] | 254 | |
---|
[20129] | 255 | // session の初期化をする |
---|
| 256 | if (!isset($session['total'])) { |
---|
| 257 | $session['total'] = $this->lfGetDateInit(); |
---|
[15600] | 258 | } |
---|
| 259 | |
---|
[20129] | 260 | if (!empty($arrForm)) { |
---|
| 261 | $session['total'] = array_merge($session['total'], $arrForm); |
---|
[15600] | 262 | } |
---|
| 263 | |
---|
[20129] | 264 | return $session; |
---|
[15600] | 265 | } |
---|
| 266 | |
---|
[20129] | 267 | /* 日付の初期値 */ |
---|
| 268 | function lfGetDateInit() { |
---|
[20538] | 269 | $search_startyear_m = $search_startyear = $search_endyear = date('Y'); |
---|
| 270 | $search_startmonth_m = $search_startmonth = $search_endmonth = date('m'); |
---|
| 271 | $search_startday = $search_endday = date('d'); |
---|
[15600] | 272 | |
---|
[20129] | 273 | return compact($this->arrSearchForm1, $this->arrSearchForm2); |
---|
[15600] | 274 | } |
---|
| 275 | |
---|
[20129] | 276 | /* フォームで入力された日付を適切な形にする */ |
---|
| 277 | function lfSetStartEndDate(&$objFormParam) { |
---|
| 278 | $arrRet = $objFormParam->getHashArray(); |
---|
[15600] | 279 | |
---|
[22138] | 280 | // 月度集計 |
---|
| 281 | if ($arrRet['search_form'] == 1) { |
---|
| 282 | list($sdate, $edate) = SC_Utils_Ex::sfTermMonth($arrRet['search_startyear_m'], |
---|
| 283 | $arrRet['search_startmonth_m'], |
---|
| 284 | CLOSE_DAY); |
---|
[15600] | 285 | } |
---|
[22138] | 286 | // 期間集計 |
---|
| 287 | elseif ($arrRet['search_form'] == 2) { |
---|
| 288 | $sdate = $arrRet['search_startyear'] . '/' . $arrRet['search_startmonth'] . '/' . $arrRet['search_startday']; |
---|
| 289 | $edate = $arrRet['search_endyear'] . '/' . $arrRet['search_endmonth'] . '/' . $arrRet['search_endday']; |
---|
| 290 | } |
---|
[15600] | 291 | |
---|
[20129] | 292 | return array($sdate, $edate); |
---|
[15600] | 293 | } |
---|
| 294 | |
---|
| 295 | /* 折れ線グラフの作成 */ |
---|
[21443] | 296 | function lfGetGraphLine($arrResults, $keyname, $type, $xtitle, $ytitle, $sdate, $edate, $xincline) { |
---|
[15600] | 297 | |
---|
[21514] | 298 | $ret_path = ''; |
---|
[15600] | 299 | |
---|
| 300 | // 結果が0行以上ある場合のみグラフを生成する。 |
---|
[21441] | 301 | if (count($arrResults) > 0 && $this->install_GD) { |
---|
[15600] | 302 | |
---|
| 303 | // グラフの生成 |
---|
[20538] | 304 | $arrList = SC_Utils_Ex::sfArrKeyValue($arrResults, $keyname, 'total'); |
---|
[15600] | 305 | |
---|
| 306 | // 一時ファイル名の取得 |
---|
| 307 | $pngname = $this->lfGetGraphPng($type); |
---|
| 308 | |
---|
[19805] | 309 | $path = GRAPH_REALDIR . $pngname; |
---|
[15600] | 310 | |
---|
| 311 | // ラベル表示インターバルを求める |
---|
| 312 | $interval = intval(count($arrList) / 20); |
---|
[21441] | 313 | if ($interval < 1) { |
---|
[15600] | 314 | $interval = 1; |
---|
| 315 | } |
---|
[21490] | 316 | $objGraphLine = new SC_Graph_Line(); |
---|
[15600] | 317 | |
---|
| 318 | // 値のセット |
---|
| 319 | $objGraphLine->setData($arrList); |
---|
| 320 | $objGraphLine->setXLabel(array_keys($arrList)); |
---|
| 321 | |
---|
| 322 | // ラベル回転(日本語不可) |
---|
[21443] | 323 | if ($xincline == true) { |
---|
[15600] | 324 | $objGraphLine->setXLabelAngle(45); |
---|
| 325 | } |
---|
| 326 | |
---|
| 327 | // タイトルセット |
---|
| 328 | $objGraphLine->setXTitle($xtitle); |
---|
| 329 | $objGraphLine->setYTitle($ytitle); |
---|
| 330 | |
---|
| 331 | // メインタイトル作成 |
---|
[21514] | 332 | list($sy, $sm, $sd) = preg_split('|[/ ]|' , $sdate); |
---|
| 333 | list($ey, $em, $ed) = preg_split('|[/ ]|' , $edate); |
---|
[21515] | 334 | $start_date = $sy . '年' . $sm . '月' . $sd . '日'; |
---|
| 335 | $end_date = $ey . '年' . $em . '月' . $ed . '日'; |
---|
[21514] | 336 | $objGraphLine->drawTitle('集計期間:' . $start_date . ' - ' . $end_date); |
---|
[15600] | 337 | |
---|
| 338 | // グラフ描画 |
---|
| 339 | $objGraphLine->drawGraph(); |
---|
| 340 | |
---|
| 341 | // グラフの出力 |
---|
[21441] | 342 | if (DRAW_IMAGE) { |
---|
[15600] | 343 | $objGraphLine->outputGraph(); |
---|
[21743] | 344 | SC_Response_Ex::actionExit(); |
---|
[15600] | 345 | } |
---|
| 346 | |
---|
| 347 | // ファイルパスを返す |
---|
[19943] | 348 | $ret_path = GRAPH_URLPATH . $pngname; |
---|
[15600] | 349 | } |
---|
| 350 | return $ret_path; |
---|
| 351 | } |
---|
| 352 | |
---|
| 353 | // 円グラフの作成 |
---|
[21515] | 354 | function lfGetGraphPie($arrResults, $keyname, $type, $title = '', $sdate = '', $edate = '') { |
---|
[15600] | 355 | |
---|
[21514] | 356 | $ret_path = ''; |
---|
[15600] | 357 | // 結果が0行以上ある場合のみグラフを生成する。 |
---|
[21441] | 358 | if (count($arrResults) > 0 && $this->install_GD) { |
---|
[15600] | 359 | // グラフの生成 |
---|
[15636] | 360 | $arrList = SC_Utils_Ex::sfArrKeyValue($arrResults, $keyname, |
---|
[20538] | 361 | 'total', GRAPH_PIE_MAX, |
---|
[15636] | 362 | GRAPH_LABEL_MAX); |
---|
[15600] | 363 | |
---|
| 364 | // 一時ファイル名の取得 |
---|
| 365 | $pngname = $this->lfGetGraphPng($type); |
---|
[19805] | 366 | $path = GRAPH_REALDIR . $pngname; |
---|
[15600] | 367 | |
---|
[21490] | 368 | $objGraphPie = new SC_Graph_Pie(); |
---|
[15600] | 369 | |
---|
| 370 | // データをセットする |
---|
| 371 | $objGraphPie->setData($arrList); |
---|
| 372 | // 凡例をセットする |
---|
| 373 | $objGraphPie->setLegend(array_keys($arrList)); |
---|
| 374 | |
---|
| 375 | // メインタイトル作成 |
---|
[21514] | 376 | list($sy, $sm, $sd) = preg_split('|[/ ]|' , $sdate); |
---|
| 377 | list($ey, $em, $ed) = preg_split('|[/ ]|' , $edate); |
---|
[21515] | 378 | $start_date = $sy . '年' . $sm . '月' . $sd . '日'; |
---|
| 379 | $end_date = $ey . '年' . $em . '月' . $ed . '日'; |
---|
[21514] | 380 | $objGraphPie->drawTitle('集計期間:' . $start_date . ' - ' . $end_date); |
---|
[15600] | 381 | |
---|
| 382 | // 円グラフ描画 |
---|
| 383 | $objGraphPie->drawGraph(); |
---|
| 384 | |
---|
| 385 | // グラフの出力 |
---|
[21441] | 386 | if (DRAW_IMAGE) { |
---|
[15600] | 387 | $objGraphPie->outputGraph(); |
---|
[21743] | 388 | SC_Response_Ex::actionExit(); |
---|
[15600] | 389 | } |
---|
| 390 | |
---|
| 391 | // ファイルパスを返す |
---|
[19943] | 392 | $ret_path = GRAPH_URLPATH . $pngname; |
---|
[15600] | 393 | } |
---|
| 394 | return $ret_path; |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | // 棒グラフの作成 |
---|
| 398 | function lfGetGraphBar($arrResults, $keyname, $type, $xtitle, $ytitle, $sdate, $edate) { |
---|
[21514] | 399 | $ret_path = ''; |
---|
[15600] | 400 | |
---|
| 401 | // 結果が0行以上ある場合のみグラフを生成する。 |
---|
[21441] | 402 | if (count($arrResults) > 0 && $this->install_GD) { |
---|
[15600] | 403 | // グラフの生成 |
---|
[20538] | 404 | $arrList = SC_Utils_Ex::sfArrKeyValue($arrResults, $keyname, 'total', GRAPH_PIE_MAX, GRAPH_LABEL_MAX); |
---|
[15600] | 405 | |
---|
| 406 | // 一時ファイル名の取得 |
---|
| 407 | $pngname = $this->lfGetGraphPng($type); |
---|
[19805] | 408 | $path = GRAPH_REALDIR . $pngname; |
---|
[15600] | 409 | |
---|
[21490] | 410 | $objGraphBar = new SC_Graph_Bar(); |
---|
[15600] | 411 | |
---|
[21935] | 412 | foreach ($arrList as $key => $value) { |
---|
| 413 | $arrKey[] = mb_ereg_replace('~', '-', $key); |
---|
[15600] | 414 | } |
---|
| 415 | |
---|
| 416 | // グラフ描画 |
---|
| 417 | $objGraphBar->setXLabel($arrKey); |
---|
| 418 | $objGraphBar->setXTitle($xtitle); |
---|
| 419 | $objGraphBar->setYTitle($ytitle); |
---|
| 420 | $objGraphBar->setData($arrList); |
---|
| 421 | |
---|
| 422 | // メインタイトル作成 |
---|
| 423 | $arrKey = array_keys($arrList); |
---|
[21514] | 424 | list($sy, $sm, $sd) = preg_split('|[/ ]|' , $sdate); |
---|
| 425 | list($ey, $em, $ed) = preg_split('|[/ ]|' , $edate); |
---|
[21515] | 426 | $start_date = $sy . '年' . $sm . '月' . $sd . '日'; |
---|
| 427 | $end_date = $ey . '年' . $em . '月' . $ed . '日'; |
---|
[21514] | 428 | $objGraphBar->drawTitle('集計期間:' . $start_date . ' - ' . $end_date); |
---|
[15600] | 429 | |
---|
| 430 | $objGraphBar->drawGraph(); |
---|
| 431 | |
---|
[21441] | 432 | if (DRAW_IMAGE) { |
---|
[15600] | 433 | $objGraphBar->outputGraph(); |
---|
[21743] | 434 | SC_Response_Ex::actionExit(); |
---|
[15600] | 435 | } |
---|
| 436 | |
---|
| 437 | // ファイルパスを返す |
---|
[19943] | 438 | $ret_path = GRAPH_URLPATH . $pngname; |
---|
[15600] | 439 | } |
---|
| 440 | return $ret_path; |
---|
| 441 | } |
---|
| 442 | |
---|
| 443 | // グラフ用のPNGファイル名 |
---|
| 444 | function lfGetGraphPng($keyname) { |
---|
[15636] | 445 | |
---|
[21514] | 446 | if ($_POST['search_startyear_m'] != '') { |
---|
| 447 | $pngname = sprintf('%s_%02d%02d.png', $keyname, substr($_POST['search_startyear_m'],2), $_POST['search_startmonth_m']); |
---|
[15600] | 448 | } else { |
---|
[21514] | 449 | $pngname = sprintf('%s_%02d%02d%02d_%02d%02d%02d.png', $keyname, substr($_POST['search_startyear'], 2), $_POST['search_startmonth'], $_POST['search_startday'], substr($_POST['search_endyear'],2), $_POST['search_endmonth'], $_POST['search_endday']); |
---|
[15600] | 450 | } |
---|
| 451 | return $pngname; |
---|
| 452 | } |
---|
| 453 | |
---|
| 454 | // 会員、非会員集計のWHERE分の作成 |
---|
[21481] | 455 | function lfGetWhereMember($col_date, $sdate, $edate, $type, $col_member = 'customer_id') { |
---|
[21514] | 456 | $where = ''; |
---|
[15600] | 457 | // 取得日付の指定 |
---|
[21514] | 458 | if ($sdate != '') { |
---|
| 459 | if ($where != '') { |
---|
| 460 | $where.= ' AND '; |
---|
[15600] | 461 | } |
---|
| 462 | $where.= " $col_date >= '". $sdate ."'"; |
---|
| 463 | } |
---|
| 464 | |
---|
[21514] | 465 | if ($edate != '') { |
---|
| 466 | if ($where != '') { |
---|
| 467 | $where.= ' AND '; |
---|
[15600] | 468 | } |
---|
[21514] | 469 | $edate = date('Y/m/d',strtotime('1 day' ,strtotime($edate))); |
---|
[15600] | 470 | $where.= " $col_date < date('" . $edate ."')"; |
---|
| 471 | } |
---|
| 472 | |
---|
| 473 | // 会員、非会員の判定 |
---|
[21441] | 474 | switch ($type) { |
---|
[15600] | 475 | // 全体 |
---|
[21562] | 476 | case 'all': |
---|
| 477 | break; |
---|
| 478 | case 'member': |
---|
| 479 | if ($where != '') { |
---|
| 480 | $where.= ' AND '; |
---|
| 481 | } |
---|
| 482 | $where.= " $col_member <> 0"; |
---|
| 483 | break; |
---|
| 484 | case 'nonmember': |
---|
| 485 | if ($where != '') { |
---|
| 486 | $where.= ' AND '; |
---|
| 487 | } |
---|
| 488 | $where.= " $col_member = 0"; |
---|
| 489 | break; |
---|
| 490 | default: |
---|
| 491 | break; |
---|
[15600] | 492 | } |
---|
| 493 | |
---|
[15636] | 494 | return array($where, array()); |
---|
[15600] | 495 | } |
---|
| 496 | |
---|
| 497 | /** 会員別集計 **/ |
---|
[20129] | 498 | function lfGetOrderMember($type, $sdate, $edate) { |
---|
[20507] | 499 | $objQuery = SC_Query_Ex::getSingletonInstance(); |
---|
[20129] | 500 | |
---|
[21562] | 501 | list($where, $arrWhereVal) = $this->lfGetWhereMember('create_date', $sdate, $edate, $type); |
---|
| 502 | $where .= ' AND del_flg = 0 AND status <> ?'; |
---|
| 503 | $arrWhereVal[] = ORDER_CANCEL; |
---|
[15600] | 504 | |
---|
| 505 | // 会員集計の取得 |
---|
[21562] | 506 | $col = <<< __EOS__ |
---|
[20129] | 507 | COUNT(order_id) AS order_count, |
---|
| 508 | SUM(total) AS total, |
---|
| 509 | AVG(total) AS total_average, |
---|
| 510 | CASE |
---|
[20241] | 511 | WHEN customer_id <> 0 THEN 1 |
---|
[20129] | 512 | ELSE 0 |
---|
| 513 | END AS member, |
---|
[20241] | 514 | order_sex |
---|
[21562] | 515 | __EOS__; |
---|
| 516 | |
---|
[21481] | 517 | $from = 'dtb_order'; |
---|
[15600] | 518 | |
---|
[21514] | 519 | $objQuery->setGroupBy('member, order_sex'); |
---|
[15600] | 520 | |
---|
[21562] | 521 | $arrTotalResults = $objQuery->select($col, $from, $where, $arrWhereVal); |
---|
[15600] | 522 | |
---|
[21935] | 523 | foreach ($arrTotalResults as $key => $value) { |
---|
[20677] | 524 | $arrResult =& $arrTotalResults[$key]; |
---|
[20129] | 525 | $member_key = $arrResult['order_sex']; |
---|
[21514] | 526 | if ($member_key != '') { |
---|
[20241] | 527 | $arrResult['member_name'] = (($arrResult['member']) ? '会員' : '非会員') . $this->arrSex[$member_key]; |
---|
[20129] | 528 | } else { |
---|
[21514] | 529 | $arrResult['member_name'] = '未回答'; |
---|
[20129] | 530 | } |
---|
[15600] | 531 | } |
---|
| 532 | |
---|
[21515] | 533 | $tpl_image = $this->lfGetGraphPie($arrTotalResults, 'member_name', 'member', '(売上比率)', $sdate, $edate); |
---|
[15600] | 534 | |
---|
[20129] | 535 | return array($arrTotalResults, $tpl_image); |
---|
[15600] | 536 | } |
---|
| 537 | |
---|
| 538 | /** 商品別集計 **/ |
---|
[20129] | 539 | function lfGetOrderProducts($type, $sdate, $edate) { |
---|
[20507] | 540 | $objQuery = SC_Query_Ex::getSingletonInstance(); |
---|
[20129] | 541 | |
---|
[21562] | 542 | list($where, $arrWhereVal) = $this->lfGetWhereMember('create_date', $sdate, $edate, $type); |
---|
[15600] | 543 | |
---|
[21562] | 544 | $where .= ' AND dtb_order.del_flg = 0 AND dtb_order.status <> ?'; |
---|
| 545 | $arrWhereVal[] = ORDER_CANCEL; |
---|
[15600] | 546 | |
---|
[21562] | 547 | $col = <<< __EOS__ |
---|
[20129] | 548 | product_id, |
---|
| 549 | product_code, |
---|
| 550 | product_name, |
---|
| 551 | SUM(quantity) AS products_count, |
---|
[21809] | 552 | COUNT(dtb_order_detail.order_id) AS order_count, |
---|
[20129] | 553 | price, |
---|
[21562] | 554 | (price * SUM(quantity)) AS total |
---|
| 555 | __EOS__; |
---|
[15600] | 556 | |
---|
[21809] | 557 | $from = 'dtb_order_detail JOIN dtb_order ON dtb_order_detail.order_id = dtb_order.order_id'; |
---|
[20129] | 558 | |
---|
| 559 | /* |
---|
[21441] | 560 | if ($mode != 'csv') { |
---|
[21514] | 561 | $sql.= 'LIMIT ' . PRODUCTS_TOTAL_MAX; |
---|
[20129] | 562 | }*/ |
---|
[15600] | 563 | |
---|
[20129] | 564 | // 要index |
---|
[20239] | 565 | $objQuery->setGroupBy('product_id, product_name, product_code, price'); |
---|
| 566 | //$objQuery->setGroupBy('product_id'); |
---|
[20129] | 567 | $objQuery->setOrder('total DESC'); |
---|
[21562] | 568 | $arrTotalResults = $objQuery->select($col, $from, $where, $arrWhereVal); |
---|
[15600] | 569 | |
---|
[21515] | 570 | $tpl_image = $this->lfGetGraphPie($arrTotalResults, 'product_name', 'products_' . $type, '(売上比率)', $sdate, $edate); |
---|
[20129] | 571 | |
---|
| 572 | return array($arrTotalResults, $tpl_image); |
---|
[15600] | 573 | } |
---|
| 574 | |
---|
| 575 | /** 職業別集計 **/ |
---|
[20129] | 576 | function lfGetOrderJob($type, $sdate, $edate) { |
---|
[20507] | 577 | $objQuery = SC_Query_Ex::getSingletonInstance(); |
---|
[21562] | 578 | list($where, $arrWhereVal) = $this->lfGetWhereMember('dtb_order.create_date', $sdate, $edate, $type); |
---|
[15600] | 579 | |
---|
[21562] | 580 | $col = <<< __EOS__ |
---|
[20129] | 581 | job, |
---|
| 582 | COUNT(order_id) AS order_count, |
---|
| 583 | SUM(total) AS total, |
---|
| 584 | AVG(total) AS total_average |
---|
[21562] | 585 | __EOS__; |
---|
[15600] | 586 | |
---|
[21809] | 587 | $from = 'dtb_order JOIN dtb_customer ON dtb_order.customer_id = dtb_customer.customer_id'; |
---|
[15600] | 588 | |
---|
[21562] | 589 | $where .= ' AND dtb_order.del_flg = 0 AND dtb_order.status <> ?'; |
---|
| 590 | $arrWhereVal[] = ORDER_CANCEL; |
---|
[20129] | 591 | |
---|
| 592 | $objQuery->setGroupBy('job'); |
---|
| 593 | $objQuery->setOrder('total DESC'); |
---|
[21562] | 594 | $arrTotalResults = $objQuery->select($col, $from, $where, $arrWhereVal); |
---|
[20129] | 595 | |
---|
[21935] | 596 | foreach ($arrTotalResults as $key => $value) { |
---|
[20677] | 597 | $arrResult =& $arrTotalResults[$key]; |
---|
[20129] | 598 | $job_key = $arrResult['job']; |
---|
[21514] | 599 | if ($job_key != '') { |
---|
[20129] | 600 | $arrResult['job_name'] = $this->arrJob[$job_key]; |
---|
[15600] | 601 | } else { |
---|
[21514] | 602 | $arrResult['job_name'] = '未回答'; |
---|
[15600] | 603 | } |
---|
[20129] | 604 | |
---|
[15600] | 605 | } |
---|
[21515] | 606 | $tpl_image = $this->lfGetGraphPie($arrTotalResults, 'job_name', 'job_' . $type, '(売上比率)', $sdate, $edate); |
---|
[15600] | 607 | |
---|
[20238] | 608 | return array($arrTotalResults, $tpl_image); |
---|
[15600] | 609 | } |
---|
| 610 | |
---|
| 611 | /** 年代別集計 **/ |
---|
[20129] | 612 | function lfGetOrderAge($type, $sdate, $edate) { |
---|
[15600] | 613 | |
---|
[20507] | 614 | $objQuery = SC_Query_Ex::getSingletonInstance(); |
---|
[15600] | 615 | |
---|
[21562] | 616 | list($where, $arrWhereVal) = $this->lfGetWhereMember('create_date', $sdate, $edate, $type); |
---|
[15600] | 617 | |
---|
[20792] | 618 | $dbFactory = SC_DB_DBFactory_Ex::getInstance(); |
---|
[21562] | 619 | $col = $dbFactory->getOrderTotalAgeColSql() . ' AS age'; |
---|
| 620 | $col .= ',COUNT(order_id) AS order_count'; |
---|
| 621 | $col .= ',SUM(total) AS total'; |
---|
| 622 | $col .= ',AVG(total) AS total_average'; |
---|
[15600] | 623 | |
---|
[20129] | 624 | $from = 'dtb_order'; |
---|
| 625 | |
---|
[21562] | 626 | $where .= ' AND del_flg = 0 AND status <> ?'; |
---|
| 627 | $arrWhereVal[] = ORDER_CANCEL; |
---|
[20129] | 628 | |
---|
| 629 | $objQuery->setGroupBy('age'); |
---|
| 630 | $objQuery->setOrder('age DESC'); |
---|
[21562] | 631 | $arrTotalResults = $objQuery->select($col, $from, $where, $arrWhereVal); |
---|
[20129] | 632 | |
---|
[21935] | 633 | foreach ($arrTotalResults as $key => $value) { |
---|
[20677] | 634 | $arrResult =& $arrTotalResults[$key]; |
---|
[20129] | 635 | $age_key = $arrResult['age']; |
---|
[21514] | 636 | if ($age_key != '') { |
---|
[20129] | 637 | $arrResult['age_name'] = $arrResult['age'] . '代'; |
---|
[15600] | 638 | } else { |
---|
[21514] | 639 | $arrResult['age_name'] = '未回答'; |
---|
[15600] | 640 | } |
---|
[20129] | 641 | |
---|
[15600] | 642 | } |
---|
[21515] | 643 | $tpl_image = $this->lfGetGraphBar($arrTotalResults, 'age_name', 'age_' . $type, '(年齢)', '(売上合計)', $sdate, $edate); |
---|
[15600] | 644 | |
---|
[20129] | 645 | return array($arrTotalResults, $tpl_image); |
---|
[15600] | 646 | } |
---|
| 647 | |
---|
| 648 | /** 期間別集計 **/ |
---|
[20129] | 649 | // todo あいだの日付埋める |
---|
| 650 | function lfGetOrderTerm($type, $sdate, $edate) { |
---|
[20507] | 651 | $objQuery = SC_Query_Ex::getSingletonInstance(); |
---|
[15600] | 652 | |
---|
[21562] | 653 | list($where, $arrWhereVal) = $this->lfGetWhereMember('create_date', $sdate, $edate); |
---|
| 654 | $where .= ' AND del_flg = 0 AND status <> ?'; |
---|
| 655 | $arrWhereVal[] = ORDER_CANCEL; |
---|
[15600] | 656 | |
---|
[21441] | 657 | switch ($type) { |
---|
[21562] | 658 | case 'month': |
---|
| 659 | $xtitle = '(月別)'; |
---|
| 660 | $ytitle = '(売上合計)'; |
---|
| 661 | $format = '%m'; |
---|
| 662 | break; |
---|
| 663 | case 'year': |
---|
| 664 | $xtitle = '(年別)'; |
---|
| 665 | $ytitle = '(売上合計)'; |
---|
| 666 | $format = '%Y'; |
---|
| 667 | break; |
---|
| 668 | case 'wday': |
---|
| 669 | $xtitle = '(曜日別)'; |
---|
| 670 | $ytitle = '(売上合計)'; |
---|
| 671 | $format = '%a'; |
---|
| 672 | break; |
---|
| 673 | case 'hour': |
---|
| 674 | $xtitle = '(時間別)'; |
---|
| 675 | $ytitle = '(売上合計)'; |
---|
| 676 | $format = '%H'; |
---|
| 677 | break; |
---|
| 678 | default: |
---|
| 679 | $xtitle = '(日別)'; |
---|
| 680 | $ytitle = '(売上合計)'; |
---|
| 681 | $format = '%Y-%m-%d'; |
---|
| 682 | $xincline = true; |
---|
| 683 | break; |
---|
[15600] | 684 | } |
---|
| 685 | |
---|
[20484] | 686 | $dbFactory = SC_DB_DBFactory_Ex::getInstance(); |
---|
[20129] | 687 | // todo postgres |
---|
| 688 | $col = $dbFactory->getOrderTotalDaysWhereSql($type); |
---|
[15600] | 689 | |
---|
[20129] | 690 | $objQuery->setGroupBy('str_date'); |
---|
| 691 | $objQuery->setOrder('str_date'); |
---|
| 692 | // 検索結果の取得 |
---|
[21562] | 693 | $arrTotalResults = $objQuery->select($col, 'dtb_order', $where, $arrWhereVal); |
---|
[20129] | 694 | |
---|
| 695 | $arrTotalResults = $this->lfAddBlankLine($arrTotalResults, $type, $sdate, $edate); |
---|
| 696 | // todo GDない場合の処理 |
---|
[21481] | 697 | $tpl_image = $this->lfGetGraphLine($arrTotalResults, 'str_date', 'term_' . $type, $xtitle, $ytitle, $sdate, $edate, $xincline); |
---|
[20129] | 698 | $arrTotalResults = $this->lfAddTotalLine($arrTotalResults); |
---|
| 699 | |
---|
| 700 | return array($arrTotalResults, $tpl_image); |
---|
| 701 | } |
---|
| 702 | |
---|
| 703 | /* |
---|
| 704 | * 期間中の日付を埋める |
---|
| 705 | */ |
---|
| 706 | function lfAddBlankLine($arrResults, $type, $st, $ed) { |
---|
| 707 | |
---|
| 708 | $arrDateList = $this->lfDateTimeArray($type, $st, $ed); |
---|
| 709 | |
---|
[21441] | 710 | foreach ($arrResults as $arrResult) { |
---|
[20129] | 711 | $strdate = $arrResult['str_date']; |
---|
| 712 | $arrDateResults[$strdate] = $arrResult; |
---|
[15600] | 713 | } |
---|
| 714 | |
---|
[20129] | 715 | foreach ($arrDateList as $date) { |
---|
| 716 | |
---|
[21441] | 717 | if (array_key_exists($date, $arrDateResults)) { |
---|
[20129] | 718 | |
---|
| 719 | $arrRet[] = $arrDateResults[$date]; |
---|
| 720 | |
---|
| 721 | } else { |
---|
| 722 | $arrRet[]['str_date'] = $date; |
---|
[15600] | 723 | } |
---|
| 724 | } |
---|
[20129] | 725 | return $arrRet; |
---|
| 726 | } |
---|
[15600] | 727 | |
---|
[20129] | 728 | /* |
---|
| 729 | * 日付の配列を作成する |
---|
| 730 | * |
---|
| 731 | */ |
---|
| 732 | function lfDateTimeArray($type, $st, $ed) { |
---|
[21441] | 733 | switch ($type) { |
---|
[20129] | 734 | case 'month': |
---|
| 735 | $format = 'm'; |
---|
| 736 | break; |
---|
| 737 | case 'year': |
---|
| 738 | $format = 'Y'; |
---|
| 739 | break; |
---|
| 740 | case 'wday': |
---|
| 741 | $format = 'D'; |
---|
| 742 | break; |
---|
| 743 | case 'hour': |
---|
| 744 | $format = 'H'; |
---|
| 745 | break; |
---|
| 746 | default: |
---|
| 747 | $format = 'Y-m-d'; |
---|
| 748 | break; |
---|
| 749 | } |
---|
[15600] | 750 | |
---|
[20129] | 751 | if ($type == 'hour') { |
---|
| 752 | $arrDateList = array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23'); |
---|
| 753 | |
---|
| 754 | } else { |
---|
| 755 | $arrDateList = array(); |
---|
| 756 | $tmp = strtotime($st); |
---|
| 757 | $nAday = 60*60*24; |
---|
| 758 | $edx = strtotime($ed); |
---|
[21442] | 759 | while ($tmp <= $edx) { |
---|
[20129] | 760 | $sDate = date($format, $tmp); |
---|
[21442] | 761 | if (!in_array($sDate, $arrDateList)) { |
---|
[20129] | 762 | $arrDateList[] = $sDate; |
---|
| 763 | } |
---|
| 764 | $tmp += $nAday; |
---|
| 765 | } |
---|
[15600] | 766 | } |
---|
[20129] | 767 | return $arrDateList; |
---|
| 768 | } |
---|
[15600] | 769 | |
---|
[20129] | 770 | /* |
---|
| 771 | * 合計を付与する |
---|
| 772 | */ |
---|
| 773 | function lfAddTotalLine($arrResults) { |
---|
[15600] | 774 | // 検索結果が0でない場合 |
---|
[21441] | 775 | if (count($arrResults) > 0) { |
---|
[15600] | 776 | |
---|
[20129] | 777 | // 合計の計算 |
---|
| 778 | foreach ($arrResults as $arrResult) { |
---|
[21935] | 779 | foreach ($arrResult as $key => $value) { |
---|
| 780 | $arrTotal[$key] += $arrResult[$key]; |
---|
[20129] | 781 | } |
---|
[15600] | 782 | } |
---|
[20129] | 783 | // 平均値の計算 |
---|
| 784 | $arrTotal['total_average'] = $arrTotal['total'] / $arrTotal['total_order']; |
---|
| 785 | $arrResults[] = $arrTotal; |
---|
[15600] | 786 | } |
---|
[20129] | 787 | |
---|
| 788 | return $arrResults; |
---|
[15600] | 789 | } |
---|
[15638] | 790 | |
---|
| 791 | // 必要なカラムのみ抽出する(CSVデータで取得する) |
---|
| 792 | function lfGetDataColCSV($arrData, $arrDataCol) { |
---|
| 793 | $max = count($arrData); |
---|
[21514] | 794 | $csv_data = ''; |
---|
[21441] | 795 | for ($i = 0; $i < $max; $i++) { |
---|
| 796 | foreach ($arrDataCol as $val) { |
---|
[22239] | 797 | $arrRet[$i][$val] = ($arrData[$i][$val]) ? $arrData[$i][$val] : "0"; |
---|
[15638] | 798 | } |
---|
[22003] | 799 | // 期間別集計の合計行の「期間」項目に不要な値が表示されてしまわない様、'合計'と表示する |
---|
[22010] | 800 | if (($i === $max -1) && isset($arrRet[$i]['str_date'])) { |
---|
[22003] | 801 | $arrRet[$i]['str_date'] = '合計'; |
---|
| 802 | } |
---|
[15638] | 803 | $csv_data.= SC_Utils_Ex::sfGetCSVList($arrRet[$i]); |
---|
| 804 | } |
---|
| 805 | return $csv_data; |
---|
| 806 | } |
---|
| 807 | |
---|
[20129] | 808 | function lfGetCSVColum($page) { |
---|
[21441] | 809 | switch ($page) { |
---|
[15638] | 810 | // 商品別集計 |
---|
[21562] | 811 | case 'products': |
---|
| 812 | $arrTitleCol = array( |
---|
| 813 | '商品コード', |
---|
| 814 | '商品名', |
---|
| 815 | '購入件数', |
---|
| 816 | '数量', |
---|
| 817 | '単価', |
---|
| 818 | '金額', |
---|
| 819 | ); |
---|
| 820 | $arrDataCol = array( |
---|
| 821 | 'product_code', |
---|
| 822 | 'product_name', |
---|
| 823 | 'order_count', |
---|
| 824 | 'products_count', |
---|
| 825 | 'price', |
---|
| 826 | 'total', |
---|
| 827 | ); |
---|
| 828 | break; |
---|
[15638] | 829 | // 職業別集計 |
---|
[21562] | 830 | case 'job': |
---|
| 831 | $arrTitleCol = array( |
---|
| 832 | '職業', |
---|
| 833 | '購入件数', |
---|
| 834 | '購入合計', |
---|
| 835 | '購入平均', |
---|
| 836 | ); |
---|
| 837 | $arrDataCol = array( |
---|
| 838 | 'job_name', |
---|
| 839 | 'order_count', |
---|
| 840 | 'total', |
---|
| 841 | 'total_average', |
---|
| 842 | ); |
---|
| 843 | break; |
---|
[15638] | 844 | // 会員別集計 |
---|
[21562] | 845 | case 'member': |
---|
| 846 | $arrTitleCol = array( |
---|
| 847 | '会員', |
---|
| 848 | '購入件数', |
---|
| 849 | '購入合計', |
---|
| 850 | '購入平均', |
---|
| 851 | ); |
---|
| 852 | $arrDataCol = array( |
---|
| 853 | 'member_name', |
---|
| 854 | 'order_count', |
---|
| 855 | 'total', |
---|
| 856 | 'total_average', |
---|
| 857 | ); |
---|
| 858 | break; |
---|
[15638] | 859 | // 年代別集計 |
---|
[21562] | 860 | case 'age': |
---|
| 861 | $arrTitleCol = array( |
---|
| 862 | '年齢', |
---|
| 863 | '購入件数', |
---|
| 864 | '購入合計', |
---|
| 865 | '購入平均', |
---|
| 866 | ); |
---|
| 867 | $arrDataCol = array( |
---|
| 868 | 'age_name', |
---|
| 869 | 'order_count', |
---|
| 870 | 'total', |
---|
| 871 | 'total_average', |
---|
| 872 | ); |
---|
| 873 | break; |
---|
[15638] | 874 | // 期間別集計 |
---|
[21562] | 875 | default: |
---|
| 876 | $arrTitleCol = array( |
---|
| 877 | '期間', |
---|
| 878 | '購入件数', |
---|
| 879 | '男性', |
---|
| 880 | '女性', |
---|
| 881 | '男性(会員)', |
---|
| 882 | '男性(非会員)', |
---|
| 883 | '女性(会員)', |
---|
| 884 | '女性(非会員)', |
---|
| 885 | '購入合計', |
---|
| 886 | '購入平均', |
---|
| 887 | ); |
---|
| 888 | $arrDataCol = array( |
---|
| 889 | 'str_date', |
---|
| 890 | 'total_order', |
---|
| 891 | 'men', |
---|
| 892 | 'women', |
---|
| 893 | 'men_member', |
---|
| 894 | 'men_nonmember', |
---|
| 895 | 'women_member', |
---|
| 896 | 'women_nonmember', |
---|
| 897 | 'total', |
---|
| 898 | 'total_average', |
---|
| 899 | ); |
---|
| 900 | break; |
---|
[15638] | 901 | } |
---|
| 902 | |
---|
| 903 | return array($arrTitleCol, $arrDataCol); |
---|
| 904 | } |
---|
[15600] | 905 | } |
---|