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