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