1 | <?php |
---|
2 | /* |
---|
3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
4 | * |
---|
5 | * http://www.lockon.co.jp/ |
---|
6 | */ |
---|
7 | require_once("../require.php"); |
---|
8 | require_once("./index_sub.php"); |
---|
9 | require_once("../batch/daily.php"); |
---|
10 | |
---|
11 | require_once("./class/SC_GraphPie.php"); |
---|
12 | require_once("./class/SC_GraphLine.php"); |
---|
13 | require_once("./class/SC_GraphBar.php"); |
---|
14 | |
---|
15 | // GD¥é¥¤¥Ö¥é¥ê¤Î¥¤¥ó¥¹¥È¡¼¥ëȽÄê |
---|
16 | $install_GD = (function_exists("gd_info"))?true:false; |
---|
17 | |
---|
18 | class LC_Page { |
---|
19 | var $arrResults; |
---|
20 | var $keyname; |
---|
21 | var $tpl_image; |
---|
22 | var $arrTitle; |
---|
23 | function LC_Page() { |
---|
24 | $this->tpl_mainpage = 'total/index.tpl'; |
---|
25 | $this->tpl_subnavi = 'total/subnavi.tpl'; |
---|
26 | $this->tpl_graphsubtitle = 'total/subtitle.tpl'; |
---|
27 | $this->tpl_titleimage = URL_DIR.'img/title/title_sale.jpg'; |
---|
28 | $this->tpl_mainno = 'total'; |
---|
29 | global $arrWDAY; |
---|
30 | $this->arrWDAY = $arrWDAY; |
---|
31 | // ¥Ú¡¼¥¸¥¿¥¤¥È¥ë |
---|
32 | $this->arrTitle[''] = "´ü´ÖÊ̽¸·×"; |
---|
33 | $this->arrTitle['term'] = "´ü´ÖÊ̽¸·×"; |
---|
34 | $this->arrTitle['products'] = "¾¦ÉÊÊ̽¸·×"; |
---|
35 | $this->arrTitle['age'] = "ǯÂåÊ̽¸·×"; |
---|
36 | $this->arrTitle['job'] = "¿¦¶ÈÊ̽¸·×"; |
---|
37 | $this->arrTitle['member'] = "²ñ°÷Ê̽¸·×"; |
---|
38 | |
---|
39 | // ¥¥ã¥Ã¥·¥å²óÈò¤Î¤¿¤á¤ËÆüÉÕ¤òÅϤ¹ |
---|
40 | $this->cashtime = time(); |
---|
41 | } |
---|
42 | } |
---|
43 | |
---|
44 | $objPage = new LC_Page(); |
---|
45 | $objView = new SC_AdminView(); |
---|
46 | $objSess = new SC_Session(); |
---|
47 | // ǧ¾Ú²ÄÈݤÎȽÄê |
---|
48 | sfIsSuccess($objSess); |
---|
49 | |
---|
50 | // ÆþÎÏ´ü´Ö¤ò¥»¥Ã¥·¥ç¥ó¤ËµÏ¿¤¹¤ë |
---|
51 | lfSaveDateSession(); |
---|
52 | |
---|
53 | if($_GET['draw_image'] != ""){ |
---|
54 | define(DRAW_IMAGE , true); |
---|
55 | }else{ |
---|
56 | define(DRAW_IMAGE , false); |
---|
57 | } |
---|
58 | |
---|
59 | // ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹ |
---|
60 | $objFormParam = new SC_FormParam(); |
---|
61 | // ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ |
---|
62 | lfInitParam(); |
---|
63 | $objFormParam->setParam($_POST); |
---|
64 | $objFormParam->setParam($_GET); |
---|
65 | |
---|
66 | // ¸¡º÷¥ï¡¼¥É¤Î°ú¤·Ñ¤® |
---|
67 | foreach ($_POST as $key => $val) { |
---|
68 | if (ereg("^search_", $key)) { |
---|
69 | $objPage->arrHidden[$key] = $val; |
---|
70 | } |
---|
71 | } |
---|
72 | |
---|
73 | $mode = $objFormParam->getValue('mode'); |
---|
74 | switch($mode) { |
---|
75 | case 'pdf': |
---|
76 | case 'csv': |
---|
77 | case 'search': |
---|
78 | // ÆþÎÏÃͤÎÊÑ´¹ |
---|
79 | $objFormParam->convParam(); |
---|
80 | $objPage->arrErr = lfCheckError($arrRet); |
---|
81 | $arrRet = $objFormParam->getHashArray(); |
---|
82 | |
---|
83 | // ÆþÎÏ¥¨¥é¡¼¤Ê¤· |
---|
84 | if (count($objPage->arrErr) == 0) { |
---|
85 | foreach ($arrRet as $key => $val) { |
---|
86 | if($val == "") { |
---|
87 | continue; |
---|
88 | } |
---|
89 | switch ($key) { |
---|
90 | case 'search_startyear': |
---|
91 | $sdate = $objFormParam->getValue('search_startyear') . "/" . $objFormParam->getValue('search_startmonth') . "/" . $objFormParam->getValue('search_startday'); |
---|
92 | break; |
---|
93 | case 'search_endyear': |
---|
94 | $edate = $objFormParam->getValue('search_endyear') . "/" . $objFormParam->getValue('search_endmonth') . "/" . $objFormParam->getValue('search_endday'); |
---|
95 | break; |
---|
96 | case 'search_startyear_m': |
---|
97 | list($sdate, $edate) = sfTermMonth($objFormParam->getValue('search_startyear_m'), $objFormParam->getValue('search_startmonth_m'), CLOSE_DAY); |
---|
98 | break; |
---|
99 | default: |
---|
100 | break; |
---|
101 | } |
---|
102 | } |
---|
103 | |
---|
104 | if($objFormParam->getValue('type') != "") { |
---|
105 | $type = $objFormParam->getValue('type'); |
---|
106 | } |
---|
107 | |
---|
108 | $page = $objFormParam->getValue('page'); |
---|
109 | |
---|
110 | switch($page) { |
---|
111 | // ¾¦ÉÊÊ̽¸·× |
---|
112 | case 'products': |
---|
113 | if($type == "") { |
---|
114 | $type = 'all'; |
---|
115 | } |
---|
116 | $objPage->tpl_page_type = "total/page_products.tpl"; |
---|
117 | // ̤½¸·×¥Ç¡¼¥¿¤Î½¸·×¤ò¹Ô¤¦ |
---|
118 | if(!DAILY_BATCH_MODE) { |
---|
119 | lfRealTimeDailyTotal($sdate, $edate); |
---|
120 | } |
---|
121 | // ¸¡º÷·ë²Ì¤Î¼èÆÀ |
---|
122 | $objPage = lfGetOrderProducts($type, $sdate, $edate, $objPage, $install_GD, $mode); |
---|
123 | break; |
---|
124 | // ¿¦¶ÈÊ̽¸·× |
---|
125 | case 'job': |
---|
126 | if($type == "") { |
---|
127 | $type = 'all'; |
---|
128 | } |
---|
129 | $objPage->tpl_page_type = "total/page_job.tpl"; |
---|
130 | // ̤½¸·×¥Ç¡¼¥¿¤Î½¸·×¤ò¹Ô¤¦ |
---|
131 | if(!DAILY_BATCH_MODE) { |
---|
132 | lfRealTimeDailyTotal($sdate, $edate); |
---|
133 | } |
---|
134 | // ¸¡º÷·ë²Ì¤Î¼èÆÀ |
---|
135 | $objPage = lfGetOrderJob($type, $sdate, $edate, $objPage, $install_GD); |
---|
136 | break; |
---|
137 | // ²ñ°÷Ê̽¸·× |
---|
138 | case 'member': |
---|
139 | if($type == "") { |
---|
140 | $type = 'all'; |
---|
141 | } |
---|
142 | $objPage->tpl_page_type = "total/page_member.tpl"; |
---|
143 | // ̤½¸·×¥Ç¡¼¥¿¤Î½¸·×¤ò¹Ô¤¦ |
---|
144 | if(!DAILY_BATCH_MODE) { |
---|
145 | lfRealTimeDailyTotal($sdate, $edate); |
---|
146 | } |
---|
147 | // ¸¡º÷·ë²Ì¤Î¼èÆÀ |
---|
148 | $objPage = lfGetOrderMember($type, $sdate, $edate, $objPage, $install_GD); |
---|
149 | break; |
---|
150 | // ǯÂåÊ̽¸·× |
---|
151 | case 'age': |
---|
152 | if($type == "") { |
---|
153 | $type = 'all'; |
---|
154 | } |
---|
155 | |
---|
156 | $objPage->tpl_page_type = "total/page_age.tpl"; |
---|
157 | // ̤½¸·×¥Ç¡¼¥¿¤Î½¸·×¤ò¹Ô¤¦ |
---|
158 | if(!DAILY_BATCH_MODE) { |
---|
159 | lfRealTimeDailyTotal($sdate, $edate); |
---|
160 | } |
---|
161 | // ¸¡º÷·ë²Ì¤Î¼èÆÀ |
---|
162 | $objPage = lfGetOrderAge($type, $sdate, $edate, $objPage, $install_GD); |
---|
163 | break; |
---|
164 | // ´ü´ÖÊ̽¸·× |
---|
165 | default: |
---|
166 | if($type == "") { |
---|
167 | $type = 'day'; |
---|
168 | } |
---|
169 | $objPage->tpl_page_type = "total/page_term.tpl"; |
---|
170 | // ̤½¸·×¥Ç¡¼¥¿¤Î½¸·×¤ò¹Ô¤¦ |
---|
171 | if(!DAILY_BATCH_MODE) { |
---|
172 | lfRealTimeDailyTotal($sdate, $edate); |
---|
173 | } |
---|
174 | // ¸¡º÷·ë²Ì¤Î¼èÆÀ |
---|
175 | $objPage = lfGetOrderTerm($type, $sdate, $edate, $objPage, $install_GD); |
---|
176 | |
---|
177 | break; |
---|
178 | } |
---|
179 | |
---|
180 | if($mode == 'csv') { |
---|
181 | // CSV½ÐÎÏ¥¿¥¤¥È¥ë¹Ô¤Î¼èÆÀ |
---|
182 | list($arrTitleCol, $arrDataCol) = lfGetCSVColum($page, $objPage->keyname); |
---|
183 | $head = sfGetCSVList($arrTitleCol); |
---|
184 | $data = lfGetDataColCSV($objPage->arrResults, $arrDataCol); |
---|
185 | // CSV¤òÁ÷¿®¤¹¤ë¡£ |
---|
186 | sfCSVDownload($head.$data, $page."_".$type); |
---|
187 | exit; |
---|
188 | } |
---|
189 | |
---|
190 | if($mode == 'pdf') { |
---|
191 | // CSV½ÐÎÏ¥¿¥¤¥È¥ë¹Ô¤Î¼èÆÀ |
---|
192 | list($arrTitleCol, $arrDataCol, $arrColSize, $arrAlign, $title) = lfGetPDFColum($page, $type, $objPage->keyname); |
---|
193 | $head = sfGetPDFList($arrTitleCol); |
---|
194 | $data = lfGetDataColPDF($objPage->arrResults, $arrDataCol, 40); |
---|
195 | // PDF½ÐÎÏÍÑ |
---|
196 | $graph_name = basename($objPage->tpl_image); |
---|
197 | lfPDFDownload($graph_name, $head . $data, $arrColSize, $arrAlign, $sdate, $edate, $title, $page); |
---|
198 | exit; |
---|
199 | } |
---|
200 | } |
---|
201 | break; |
---|
202 | default: |
---|
203 | if(count($_GET) == 0) { |
---|
204 | // ¥Ð¥Ã¥Á¥â¡¼¥É¤Î¾ì¹ç¤Î¤ß¼Â¹Ô¤¹¤ë¡ÊÅöÆü¤Î½¸·×¤ò¹Ô¤¦¤¿¤á¡Ë |
---|
205 | if(DAILY_BATCH_MODE) { |
---|
206 | // 3ÆüÁ°¤Þ¤Ç¤Î½¸·× |
---|
207 | lfStartDailyTotal(3,0); |
---|
208 | } |
---|
209 | } |
---|
210 | break; |
---|
211 | } |
---|
212 | |
---|
213 | $objPage->install_GD = $install_GD; |
---|
214 | |
---|
215 | // ÅÐÏ¿¡¦¹¹¿·Æü¸¡º÷ÍÑ |
---|
216 | $objDate = new SC_Date(); |
---|
217 | $objDate->setStartYear(RELEASE_YEAR); |
---|
218 | $objDate->setEndYear(DATE("Y")); |
---|
219 | $objPage->arrYear = $objDate->getYear(); |
---|
220 | $objPage->arrMonth = $objDate->getMonth(); |
---|
221 | $objPage->arrDay = $objDate->getDay(); |
---|
222 | // ÆþÎÏÃͤμèÆÀ |
---|
223 | $objPage->arrForm = $objFormParam->getFormParamList(); |
---|
224 | |
---|
225 | $objPage->tpl_subtitle = $objPage->arrTitle[$objFormParam->getValue('page')]; |
---|
226 | |
---|
227 | $objView->assignobj($objPage); |
---|
228 | $objView->display(MAIN_FRAME); |
---|
229 | |
---|
230 | //--------------------------------------------------------------------------------------------------------------------------- |
---|
231 | /* PDF½ÐÎÏ */ |
---|
232 | function lfPDFDownload($image, $table, $arrColSize, $arrAlign, $sdate, $edate, $title, $page = "") { |
---|
233 | |
---|
234 | $objPdf = new SC_Pdf(); |
---|
235 | $objPdf->setTableColor("CCCCCC", "F0F0F0", "D1DEFE"); |
---|
236 | |
---|
237 | // ÅÚÂæ¤È¤Ê¤ëPDF¥Õ¥¡¥¤¥ë¤Î»ØÄê |
---|
238 | $objPdf->setTemplate(PDF_DIR . "total.pdf"); |
---|
239 | |
---|
240 | $disp_sdate = sfDispDBDate($sdate, false); |
---|
241 | $disp_edate = sfDispDBDate($edate, false); |
---|
242 | |
---|
243 | $arrText['title_block'] = $title; |
---|
244 | $arrText['date_block'] = "$disp_sdate-$disp_edate"; |
---|
245 | $arrImage['graph_block'] = GRAPH_DIR . $image; |
---|
246 | |
---|
247 | // ʸËö¤Î\n¤òºï½ü¤¹¤ë |
---|
248 | $table = ereg_replace("\n$", "", $table); |
---|
249 | $arrRet = split("\n", $table); |
---|
250 | $page_max = intval((count($arrRet) / 35) + 1); |
---|
251 | |
---|
252 | for($page = 1; $page <= $page_max; $page++) { |
---|
253 | if($page > 1) { |
---|
254 | // 2¥Ú¡¼¥¸°Ê¹ß |
---|
255 | $start_no = 35 * ($page - 1) + 1; |
---|
256 | } else { |
---|
257 | // ³«»Ï¥Ú¡¼¥¸ |
---|
258 | $start_no = 1; |
---|
259 | } |
---|
260 | |
---|
261 | $arrText['page_block'] = $page . " / " . $page_max; |
---|
262 | $objPdf->setTextBlock($arrText); |
---|
263 | $objPdf->setImageBlock($arrImage); |
---|
264 | // ¥Ö¥í¥Ã¥¯ÃͤÎÆþÎÏ |
---|
265 | $objPdf->writeBlock(); |
---|
266 | // ºÇ½ª¥Ú¡¼¥¸¤Î¤ß¡¢¾¦ÉÊÊ̽¸·×¤Ï¹ç·×¤¬¤Ê¤¤¤Î¤ÇºÇ½ª¹Ô¤Î¿§¤òÊѹ¹¤·¤Ê¤¤¡£ |
---|
267 | if($page == $page_max && $page != 'products') { |
---|
268 | $last_color_flg = true; |
---|
269 | } else { |
---|
270 | $last_color_flg = false; |
---|
271 | } |
---|
272 | $objPdf->writeTableCenter($table, 500, $arrColSize, $arrAlign, 35, $start_no, $last_color_flg); |
---|
273 | $objPdf->closePage(); |
---|
274 | } |
---|
275 | |
---|
276 | // PDF¤Î½ÐÎÏ |
---|
277 | $objPdf->output(); |
---|
278 | } |
---|
279 | |
---|
280 | /* ¥»¥Ã¥·¥ç¥ó¤ËÆþÎÏ´ü´Ö¤òµÏ¿¤¹¤ë */ |
---|
281 | function lfSaveDateSession() { |
---|
282 | if($_POST['form'] == 1) { |
---|
283 | $_SESSION['total']['startyear_m'] = $_POST['search_startyear_m']; |
---|
284 | $_SESSION['total']['startmonth_m'] = $_POST['search_startmonth_m']; |
---|
285 | } |
---|
286 | |
---|
287 | if($_POST['form'] == 2) { |
---|
288 | $_SESSION['total']['startyear'] = $_POST['search_startyear']; |
---|
289 | $_SESSION['total']['startmonth'] = $_POST['search_startmonth']; |
---|
290 | $_SESSION['total']['startday'] = $_POST['search_startday']; |
---|
291 | $_SESSION['total']['endyear'] = $_POST['search_endyear']; |
---|
292 | $_SESSION['total']['endmonth'] = $_POST['search_endmonth']; |
---|
293 | $_SESSION['total']['endday'] = $_POST['search_endday']; |
---|
294 | } |
---|
295 | } |
---|
296 | |
---|
297 | /* ¥Ç¥Õ¥©¥ë¥ÈÃͤμèÆÀ */ |
---|
298 | function lfGetDateDefault() { |
---|
299 | $year = date("Y"); |
---|
300 | $month = date("m"); |
---|
301 | $day = date("d"); |
---|
302 | |
---|
303 | $list = $_SESSION['total']; |
---|
304 | |
---|
305 | // ¥»¥Ã¥·¥ç¥ó¾ðÊó¤Ë³«»Ï·îÅÙ¤¬Êݸ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£ |
---|
306 | if($_SESSION['total']['startyear_m'] == "") { |
---|
307 | $list['startyear_m'] = $year; |
---|
308 | $list['startmonth_m'] = $month; |
---|
309 | } |
---|
310 | |
---|
311 | // ¥»¥Ã¥·¥ç¥ó¾ðÊó¤Ë³«»ÏÆüÉÕ¡¢½ªÎ»ÆüÉÕ¤¬Êݸ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£ |
---|
312 | if($_SESSION['total']['startyear'] == "" && $_SESSION['total']['endyear'] == "") { |
---|
313 | $list['startyear'] = $year; |
---|
314 | $list['startmonth'] = $month; |
---|
315 | $list['startday'] = $day; |
---|
316 | $list['endyear'] = $year; |
---|
317 | $list['endmonth'] = $month; |
---|
318 | $list['endday'] = $day; |
---|
319 | } |
---|
320 | |
---|
321 | return $list; |
---|
322 | } |
---|
323 | |
---|
324 | /* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */ |
---|
325 | function lfInitParam() { |
---|
326 | global $objFormParam; |
---|
327 | |
---|
328 | // ¥Ç¥Õ¥©¥ë¥ÈÃͤμèÆÀ |
---|
329 | $arrList = lfGetDateDefault(); |
---|
330 | |
---|
331 | // ·îÅÙ½¸·× |
---|
332 | $objFormParam->addParam("·îÅÙ", "search_startyear_m", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), $arrList['startyear_m']); |
---|
333 | $objFormParam->addParam("·îÅÙ", "search_startmonth_m", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), $arrList['startmonth_m']); |
---|
334 | // ´ü´Ö½¸·× |
---|
335 | $objFormParam->addParam("³«»ÏÆü", "search_startyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), $arrList['startyear']); |
---|
336 | $objFormParam->addParam("³«»ÏÆü", "search_startmonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), $arrList['startmonth']); |
---|
337 | $objFormParam->addParam("³«»ÏÆü", "search_startday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), $arrList['startday']); |
---|
338 | $objFormParam->addParam("½ªÎ»Æü", "search_endyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), $arrList['endyear']); |
---|
339 | $objFormParam->addParam("½ªÎ»Æü", "search_endmonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), $arrList['endmonth']); |
---|
340 | $objFormParam->addParam("½ªÎ»Æü", "search_endday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), $arrList['endday']); |
---|
341 | |
---|
342 | // hidden¥Ç¡¼¥¿¤Î¼èÆÀÍÑ |
---|
343 | $objFormParam->addParam("", "page"); |
---|
344 | $objFormParam->addParam("", "type"); |
---|
345 | $objFormParam->addParam("", "mode"); |
---|
346 | |
---|
347 | } |
---|
348 | |
---|
349 | /* ÆþÎÏÆâÍƤΥÁ¥§¥Ã¥¯ */ |
---|
350 | function lfCheckError() { |
---|
351 | global $objFormParam; |
---|
352 | // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£ |
---|
353 | $arrRet = $objFormParam->getHashArray(); |
---|
354 | $objErr = new SC_CheckError($arrRet); |
---|
355 | $objErr->arrErr = $objFormParam->checkError(); |
---|
356 | |
---|
357 | // Æüì¹àÌÜ¥Á¥§¥Ã¥¯ |
---|
358 | if($_POST['form'] == 1) { |
---|
359 | $objErr->doFunc(array("·îÅÙ", "search_startyear_m"), array("ONE_EXIST_CHECK")); |
---|
360 | } |
---|
361 | |
---|
362 | if($_POST['form'] == 2) { |
---|
363 | $objErr->doFunc(array("´ü´Ö", "search_startyear", "search_endyear"), array("ONE_EXIST_CHECK")); |
---|
364 | } |
---|
365 | |
---|
366 | $objErr->doFunc(array("·îÅÙ", "search_startyear_m", "search_startmonth_m"), array("ALL_EXIST_CHECK")); |
---|
367 | $objErr->doFunc(array("³«»ÏÆü", "search_startyear", "search_startmonth", "search_startday"), array("CHECK_DATE")); |
---|
368 | $objErr->doFunc(array("½ªÎ»Æü", "search_endyear", "search_endmonth", "search_endday"), array("CHECK_DATE")); |
---|
369 | $objErr->doFunc(array("³«»ÏÆü", "½ªÎ»Æü", "search_startyear", "search_startmonth", "search_startday", "search_endyear", "search_endmonth", "search_endday"), array("CHECK_SET_TERM")); |
---|
370 | return $objErr->arrErr; |
---|
371 | } |
---|
372 | |
---|
373 | /* ÀÞ¤ìÀþ¥°¥é¥Õ¤ÎºîÀ® */ |
---|
374 | function lfGetGraphLine($arrResults, $keyname, $type, $xtitle, $ytitle, $sdate, $edate) { |
---|
375 | |
---|
376 | $ret_path = ""; |
---|
377 | |
---|
378 | // ·ë²Ì¤¬0¹Ô°Ê¾å¤¢¤ë¾ì¹ç¤Î¤ß¥°¥é¥Õ¤òÀ¸À®¤¹¤ë¡£ |
---|
379 | if(count($arrResults) > 0) { |
---|
380 | |
---|
381 | // ¥°¥é¥Õ¤ÎÀ¸À® |
---|
382 | $arrList = sfArrKeyValue($arrResults, $keyname, "total"); |
---|
383 | |
---|
384 | // °ì»þ¥Õ¥¡¥¤¥ë̾¤Î¼èÆÀ |
---|
385 | $pngname = lfGetGraphPng($type); |
---|
386 | |
---|
387 | $path = GRAPH_DIR . $pngname; |
---|
388 | |
---|
389 | // ¥é¥Ù¥ëɽ¼¨¥¤¥ó¥¿¡¼¥Ð¥ë¤òµá¤á¤ë |
---|
390 | $interval = intval(count($arrList) / 20); |
---|
391 | if($interval < 1) { |
---|
392 | $interval = 1; |
---|
393 | } |
---|
394 | $objGraphPie = new SC_GraphPie(); |
---|
395 | $objGraphLine = new SC_GraphLine(); |
---|
396 | |
---|
397 | // ÃͤΥ»¥Ã¥È |
---|
398 | $objGraphLine->setData($arrList); |
---|
399 | $objGraphLine->setXLabel(array_keys($arrList)); |
---|
400 | |
---|
401 | // ¥é¥Ù¥ë²óž(ÆüËܸìÉÔ²Ä) |
---|
402 | if($keyname == "key_day"){ |
---|
403 | $objGraphLine->setXLabelAngle(45); |
---|
404 | } |
---|
405 | |
---|
406 | // ¥¿¥¤¥È¥ë¥»¥Ã¥È |
---|
407 | $objGraphLine->setXTitle($xtitle); |
---|
408 | $objGraphLine->setYTitle($ytitle); |
---|
409 | |
---|
410 | // ¥á¥¤¥ó¥¿¥¤¥È¥ëºîÀ® |
---|
411 | list($sy, $sm, $sd) = split("[/ ]" , $sdate); |
---|
412 | list($ey, $em, $ed) = split("[/ ]" , $edate); |
---|
413 | $start_date = $sy . "ǯ" . $sm . "·î" . $sd . "Æü"; |
---|
414 | $end_date = $ey . "ǯ" . $em . "·î" . $ed . "Æü"; |
---|
415 | $objGraphLine->drawTitle("½¸·×´ü´Ö¡§" . $start_date . " - " . $end_date); |
---|
416 | |
---|
417 | // ¥°¥é¥ÕÉÁ²è |
---|
418 | $objGraphLine->drawGraph(); |
---|
419 | |
---|
420 | // ¥°¥é¥Õ¤Î½ÐÎÏ |
---|
421 | if(DRAW_IMAGE){ |
---|
422 | $objGraphLine->outputGraph(); |
---|
423 | exit(); |
---|
424 | } |
---|
425 | |
---|
426 | // ¥Õ¥¡¥¤¥ë¥Ñ¥¹¤òÊÖ¤¹ |
---|
427 | $ret_path = GRAPH_URL . $pngname; |
---|
428 | } |
---|
429 | return $ret_path; |
---|
430 | } |
---|
431 | |
---|
432 | // ±ß¥°¥é¥Õ¤ÎºîÀ® |
---|
433 | function lfGetGraphPie($arrResults, $keyname, $type, $title = "", $sdate = "", $edate = "") { |
---|
434 | |
---|
435 | $ret_path = ""; |
---|
436 | |
---|
437 | // ·ë²Ì¤¬0¹Ô°Ê¾å¤¢¤ë¾ì¹ç¤Î¤ß¥°¥é¥Õ¤òÀ¸À®¤¹¤ë¡£ |
---|
438 | if(count($arrResults) > 0) { |
---|
439 | // ¥°¥é¥Õ¤ÎÀ¸À® |
---|
440 | $arrList = sfArrKeyValue($arrResults, $keyname, "total", GRAPH_PIE_MAX, GRAPH_LABEL_MAX); |
---|
441 | |
---|
442 | // °ì»þ¥Õ¥¡¥¤¥ë̾¤Î¼èÆÀ |
---|
443 | $pngname = lfGetGraphPng($type); |
---|
444 | $path = GRAPH_DIR . $pngname; |
---|
445 | |
---|
446 | $objGraphPie = new SC_GraphPie(); |
---|
447 | |
---|
448 | /* ¥Ç¥Ð¥Ã¥°É½¼¨ÍÑ by naka |
---|
449 | foreach($arrList as $key => $val) { |
---|
450 | $objGraphPie->debugPrint("key:$key val:$val"); |
---|
451 | } |
---|
452 | */ |
---|
453 | |
---|
454 | // ¥Ç¡¼¥¿¤ò¥»¥Ã¥È¤¹¤ë |
---|
455 | $objGraphPie->setData($arrList); |
---|
456 | // ËÞÎã¤ò¥»¥Ã¥È¤¹¤ë |
---|
457 | $objGraphPie->setLegend(array_keys($arrList)); |
---|
458 | |
---|
459 | // ¥á¥¤¥ó¥¿¥¤¥È¥ëºîÀ® |
---|
460 | list($sy, $sm, $sd) = split("[/ ]" , $sdate); |
---|
461 | list($ey, $em, $ed) = split("[/ ]" , $edate); |
---|
462 | $start_date = $sy . "ǯ" . $sm . "·î" . $sd . "Æü"; |
---|
463 | $end_date = $ey . "ǯ" . $em . "·î" . $ed . "Æü"; |
---|
464 | $objGraphPie->drawTitle("½¸·×´ü´Ö¡§" . $start_date . " - " . $end_date); |
---|
465 | |
---|
466 | // ±ß¥°¥é¥ÕÉÁ²è |
---|
467 | $objGraphPie->drawGraph(); |
---|
468 | |
---|
469 | // ¥°¥é¥Õ¤Î½ÐÎÏ |
---|
470 | if(DRAW_IMAGE){ |
---|
471 | $objGraphPie->outputGraph(); |
---|
472 | exit(); |
---|
473 | } |
---|
474 | |
---|
475 | // ¥Õ¥¡¥¤¥ë¥Ñ¥¹¤òÊÖ¤¹ |
---|
476 | $ret_path = GRAPH_URL . $pngname; |
---|
477 | } |
---|
478 | return $ret_path; |
---|
479 | } |
---|
480 | |
---|
481 | // ËÀ¥°¥é¥Õ¤ÎºîÀ® |
---|
482 | function lfGetGraphBar($arrResults, $keyname, $type, $xtitle, $ytitle, $sdate, $edate) { |
---|
483 | $ret_path = ""; |
---|
484 | |
---|
485 | // ·ë²Ì¤¬0¹Ô°Ê¾å¤¢¤ë¾ì¹ç¤Î¤ß¥°¥é¥Õ¤òÀ¸À®¤¹¤ë¡£ |
---|
486 | if(count($arrResults) > 0) { |
---|
487 | // ¥°¥é¥Õ¤ÎÀ¸À® |
---|
488 | $arrList = sfArrKeyValue($arrResults, $keyname, "total", GRAPH_PIE_MAX, GRAPH_LABEL_MAX); |
---|
489 | |
---|
490 | // °ì»þ¥Õ¥¡¥¤¥ë̾¤Î¼èÆÀ |
---|
491 | $pngname = lfGetGraphPng($type); |
---|
492 | $path = GRAPH_DIR . $pngname; |
---|
493 | |
---|
494 | $objGraphBar = new SC_GraphBar(); |
---|
495 | |
---|
496 | foreach(array_keys($arrList) as $val) { |
---|
497 | $arrKey[] = ereg_replace("¡Á", "-", $val); |
---|
498 | } |
---|
499 | |
---|
500 | // ¥°¥é¥ÕÉÁ²è |
---|
501 | $objGraphBar->setXLabel($arrKey); |
---|
502 | $objGraphBar->setXTitle($xtitle); |
---|
503 | $objGraphBar->setYTitle($ytitle); |
---|
504 | $objGraphBar->setData($arrList); |
---|
505 | |
---|
506 | // ¥á¥¤¥ó¥¿¥¤¥È¥ëºîÀ® |
---|
507 | $arrKey = array_keys($arrList); |
---|
508 | list($sy, $sm, $sd) = split("[/ ]" , $sdate); |
---|
509 | list($ey, $em, $ed) = split("[/ ]" , $edate); |
---|
510 | $start_date = $sy . "ǯ" . $sm . "·î" . $sd . "Æü"; |
---|
511 | $end_date = $ey . "ǯ" . $em . "·î" . $ed . "Æü"; |
---|
512 | $objGraphBar->drawTitle("½¸·×´ü´Ö¡§" . $start_date . " - " . $end_date); |
---|
513 | |
---|
514 | $objGraphBar->drawGraph(); |
---|
515 | |
---|
516 | if(DRAW_IMAGE){ |
---|
517 | $objGraphBar->outputGraph(); |
---|
518 | exit(); |
---|
519 | } |
---|
520 | |
---|
521 | // ¥Õ¥¡¥¤¥ë¥Ñ¥¹¤òÊÖ¤¹ |
---|
522 | $ret_path = GRAPH_URL . $pngname; |
---|
523 | } |
---|
524 | return $ret_path; |
---|
525 | } |
---|
526 | |
---|
527 | // ¥°¥é¥ÕÍѤÎPNG¥Õ¥¡¥¤¥ë̾ |
---|
528 | function lfGetGraphPng($keyname) { |
---|
529 | if($_POST['search_startyear_m'] != "") { |
---|
530 | $pngname = sprintf("%s_%02d%02d.png", $keyname, substr($_POST['search_startyear_m'],2), $_POST['search_startmonth_m']); |
---|
531 | } else { |
---|
532 | $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']); |
---|
533 | } |
---|
534 | return $pngname; |
---|
535 | } |
---|
536 | |
---|
537 | // ²ñ°÷¡¢Èó²ñ°÷½¸·×¤ÎWHEREʬ¤ÎºîÀ® |
---|
538 | function lfGetWhereMember($col_date, $sdate, $edate, $type, $col_member = "customer_id") { |
---|
539 | // ¼èÆÀÆüÉդλØÄê |
---|
540 | if($sdate != "") { |
---|
541 | if ($where != "") { |
---|
542 | $where.= " AND "; |
---|
543 | } |
---|
544 | $where.= " $col_date >= '". $sdate ."'"; |
---|
545 | } |
---|
546 | |
---|
547 | if($edate != "") { |
---|
548 | if ($where != "") { |
---|
549 | $where.= " AND "; |
---|
550 | } |
---|
551 | $edate = date("Y/m/d",strtotime("1 day" ,strtotime($edate))); |
---|
552 | $where.= " $col_date < date('" . $edate ."')"; |
---|
553 | } |
---|
554 | |
---|
555 | // ²ñ°÷¡¢Èó²ñ°÷¤ÎȽÄê |
---|
556 | switch($type) { |
---|
557 | // Á´ÂÎ |
---|
558 | case 'all': |
---|
559 | break; |
---|
560 | case 'member': |
---|
561 | if ($where != "") { |
---|
562 | $where.= " AND "; |
---|
563 | } |
---|
564 | $where.= " $col_member <> 0"; |
---|
565 | break; |
---|
566 | case 'nonmember': |
---|
567 | if ($where != "") { |
---|
568 | $where.= " AND "; |
---|
569 | } |
---|
570 | $where.= " $col_member = 0"; |
---|
571 | break; |
---|
572 | default: |
---|
573 | break; |
---|
574 | } |
---|
575 | |
---|
576 | return array($where, $arrval); |
---|
577 | } |
---|
578 | |
---|
579 | /** ²ñ°÷Ê̽¸·× **/ |
---|
580 | function lfGetOrderMember($type, $sdate, $edate, $objPage, $graph = true) { |
---|
581 | global $arrSex; |
---|
582 | |
---|
583 | list($where, $arrval) = lfGetWhereMember('create_date', $sdate, $edate, $type); |
---|
584 | |
---|
585 | // ²ñ°÷½¸·×¤Î¼èÆÀ |
---|
586 | $col = "COUNT(*) AS order_count, SUM(total) AS total, (AVG(total)) AS total_average, order_sex"; |
---|
587 | $from = "dtb_order"; |
---|
588 | $objQuery = new SC_Query(); |
---|
589 | $objQuery->setGroupBy("order_sex"); |
---|
590 | |
---|
591 | $tmp_where = $where . " AND customer_id <> 0 AND del_flg = 0 "; |
---|
592 | $arrRet = $objQuery->select($col, $from, $tmp_where, $arrval); |
---|
593 | |
---|
594 | // ²ñ°÷¹ØÆþ¤Ç¤¢¤ë¤³¤È¤òµÏ¿¤¹¤ë¡£ |
---|
595 | $max = count($arrRet); |
---|
596 | for($i = 0; $i < $max; $i++) { |
---|
597 | $arrRet[$i]['member_name'] = '²ñ°÷'.$arrSex[$arrRet[$i]['order_sex']]; |
---|
598 | } |
---|
599 | $objPage->arrResults = $arrRet; |
---|
600 | |
---|
601 | // Èó²ñ°÷½¸·×¤Î¼èÆÀ |
---|
602 | $tmp_where = $where . " AND customer_id = 0 AND del_flg = 0 "; |
---|
603 | $arrRet = $objQuery->select($col, $from, $tmp_where, $arrval); |
---|
604 | // Èó²ñ°÷¹ØÆþ¤Ç¤¢¤ë¤³¤È¤òµÏ¿¤¹¤ë¡£ |
---|
605 | $max = count($arrRet); |
---|
606 | for($i = 0; $i < $max; $i++) { |
---|
607 | $arrRet[$i]['member_name'] = 'Èó²ñ°÷'.$arrSex[$arrRet[$i]['order_sex']]; |
---|
608 | } |
---|
609 | |
---|
610 | $objPage->arrResults = array_merge($objPage->arrResults, $arrRet); |
---|
611 | |
---|
612 | // ±ß¥°¥é¥Õ¤ÎÀ¸À® |
---|
613 | if($graph) { |
---|
614 | $image_key = "member"; |
---|
615 | $objPage->tpl_image = lfGetGraphPie($objPage->arrResults, "member_name", $image_key, "(Çä¾åÈæΨ)", $sdate, $edate); |
---|
616 | } |
---|
617 | |
---|
618 | return $objPage; |
---|
619 | } |
---|
620 | |
---|
621 | /** ¾¦ÉÊÊ̽¸·× **/ |
---|
622 | function lfGetOrderProducts($type, $sdate, $edate, $objPage, $graph = true, $mode = "") { |
---|
623 | list($where, $arrval) = lfGetWhereMember('create_date', $sdate, $edate, $type); |
---|
624 | |
---|
625 | $where .= " and del_flg=0 and status <> " . ORDER_CANCEL; |
---|
626 | |
---|
627 | $sql = "SELECT T1.product_id, T1.product_code, T1.product_name as name, T1.products_count, T1.order_count, T1.price, T1.total "; |
---|
628 | $sql.= "FROM ( "; |
---|
629 | $sql.= "SELECT product_id, product_name, product_code, price, "; |
---|
630 | $sql.= "COUNT(*) AS order_count, "; |
---|
631 | $sql.= "SUM(quantity) AS products_count, "; |
---|
632 | $sql.= "(price * sum(quantity)) AS total "; |
---|
633 | $sql.= "FROM dtb_order_detail WHERE order_id IN (SELECT order_id FROM dtb_order WHERE $where ) "; |
---|
634 | $sql.= "GROUP BY product_id, product_name, product_code, price "; |
---|
635 | $sql.= ") AS T1 "; |
---|
636 | $sql.= "ORDER BY T1.total DESC "; |
---|
637 | |
---|
638 | if($mode != "csv") { |
---|
639 | $sql.= "LIMIT " . PRODUCTS_TOTAL_MAX; |
---|
640 | } |
---|
641 | |
---|
642 | $objQuery = new SC_Query(); |
---|
643 | $objPage->arrResults = $objQuery->getall($sql, $arrval); |
---|
644 | |
---|
645 | // ±ß¥°¥é¥Õ¤ÎÀ¸À® |
---|
646 | if($graph) { |
---|
647 | $image_key = "products_" . $type; |
---|
648 | $objPage->tpl_image = lfGetGraphPie($objPage->arrResults, "name", $image_key, "(Çä¾åÈæΨ)", $sdate, $edate); |
---|
649 | } |
---|
650 | |
---|
651 | return $objPage; |
---|
652 | } |
---|
653 | |
---|
654 | /** ¿¦¶ÈÊ̽¸·× **/ |
---|
655 | function lfGetOrderJob($type, $sdate, $edate, $objPage, $graph = true) { |
---|
656 | global $arrJob; |
---|
657 | |
---|
658 | list($where, $arrval) = lfGetWhereMember('T2.create_date', $sdate, $edate, $type); |
---|
659 | |
---|
660 | $sql = "SELECT job, count(*) AS order_count, SUM(total) AS total, (AVG(total)) AS total_average "; |
---|
661 | $sql.= "FROM dtb_customer AS T1 LEFT JOIN dtb_order AS T2 USING ( customer_id ) WHERE $where AND T2.del_flg = 0 and T2.status <> " . ORDER_CANCEL; |
---|
662 | $sql.= " GROUP BY job ORDER BY total DESC"; |
---|
663 | |
---|
664 | $objQuery = new SC_Query(); |
---|
665 | $objPage->arrResults = $objQuery->getall($sql, $arrval); |
---|
666 | |
---|
667 | $max = count($objPage->arrResults); |
---|
668 | for($i = 0; $i < $max; $i++) { |
---|
669 | $job_key = $objPage->arrResults[$i]['job']; |
---|
670 | if($job_key != "") { |
---|
671 | $objPage->arrResults[$i]['job_name'] = $arrJob[$job_key]; |
---|
672 | } else { |
---|
673 | $objPage->arrResults[$i]['job_name'] = "̤²óÅú"; |
---|
674 | } |
---|
675 | } |
---|
676 | |
---|
677 | // ±ß¥°¥é¥Õ¤ÎÀ¸À® |
---|
678 | if($graph) { |
---|
679 | $image_key = "job_" . $type; |
---|
680 | $objPage->tpl_image = lfGetGraphPie($objPage->arrResults, "job_name", $image_key, "(Çä¾åÈæΨ)", $sdate, $edate); |
---|
681 | } |
---|
682 | |
---|
683 | return $objPage; |
---|
684 | } |
---|
685 | |
---|
686 | /** ǯÂåÊ̽¸·× **/ |
---|
687 | function lfGetOrderAge($type, $sdate, $edate, $objPage, $graph = true) { |
---|
688 | |
---|
689 | list($where, $arrval) = lfGetWhereMember('order_date', $sdate, $edate, $type, "member"); |
---|
690 | |
---|
691 | $sql = "SELECT SUM(order_count) AS order_count, SUM(total) AS total, start_age, end_age "; |
---|
692 | $sql.= "FROM dtb_bat_order_daily_age WHERE $where "; |
---|
693 | $sql.= "GROUP BY start_age, end_age ORDER BY start_age, end_age"; |
---|
694 | |
---|
695 | $objQuery = new SC_Query(); |
---|
696 | $objPage->arrResults = $objQuery->getall($sql, $arrval); |
---|
697 | |
---|
698 | $max = count($objPage->arrResults); |
---|
699 | for($i = 0; $i < $max; $i++) { |
---|
700 | if($objPage->arrResults[$i]['order_count'] > 0) { |
---|
701 | $objPage->arrResults[$i]['total_average'] = intval($objPage->arrResults[$i]['total'] / $objPage->arrResults[$i]['order_count']); |
---|
702 | } |
---|
703 | $start_age = $objPage->arrResults[$i]['start_age']; |
---|
704 | $end_age = $objPage->arrResults[$i]['end_age']; |
---|
705 | if($start_age != "" || $end_age != "") { |
---|
706 | if($end_age != 999) { |
---|
707 | $objPage->arrResults[$i]['age_name'] = $start_age . "¡Á" . $end_age . "ºÐ"; |
---|
708 | } else { |
---|
709 | $objPage->arrResults[$i]['age_name'] = $start_age . "ºÐ¡Á"; |
---|
710 | } |
---|
711 | } else { |
---|
712 | $objPage->arrResults[$i]['age_name'] = "̤²óÅú"; |
---|
713 | } |
---|
714 | } |
---|
715 | |
---|
716 | // ËÀ¥°¥é¥Õ¤ÎÀ¸À® |
---|
717 | if($graph) { |
---|
718 | $image_key = "age_" . $type; |
---|
719 | $xtitle = "(ǯÎð)"; |
---|
720 | $ytitle = "(Çä¾å¹ç·×)"; |
---|
721 | $objPage->tpl_image = lfGetGraphBar($objPage->arrResults, "age_name", $image_key, $xtitle, $ytitle, $sdate, $edate); |
---|
722 | } |
---|
723 | |
---|
724 | return $objPage; |
---|
725 | } |
---|
726 | |
---|
727 | /** ´ü´ÖÊ̽¸·× **/ |
---|
728 | function lfGetOrderTerm($type, $sdate, $edate, $objPage, $graph = true) { |
---|
729 | |
---|
730 | $tmp_col = "sum(total_order) as total_order, sum(men) as men, sum(women) as women,"; |
---|
731 | $tmp_col.= "sum(men_member) as men_member, sum(men_nonmember) as men_nonmember,"; |
---|
732 | $tmp_col.= "sum(women_member) as women_member, sum(women_nonmember) as women_nonmember,"; |
---|
733 | $tmp_col.= "sum(total) as total, (avg(total_average)) as total_average"; |
---|
734 | $objQuery = new SC_Query(); |
---|
735 | |
---|
736 | switch($type) { |
---|
737 | // ·îÊÌ |
---|
738 | case 'month': |
---|
739 | $col = $tmp_col . ",key_month"; |
---|
740 | $objQuery->setgroupby("key_month"); |
---|
741 | $objQuery->setOrder("key_month"); |
---|
742 | $objPage->keyname = "key_month"; |
---|
743 | $objPage->tpl_tail = "·î"; |
---|
744 | $from = "dtb_bat_order_daily"; |
---|
745 | $xtitle = "(·îÊÌ)"; |
---|
746 | $ytitle = "(Çä¾å¹ç·×)"; |
---|
747 | break; |
---|
748 | // ǯÊÌ |
---|
749 | case 'year': |
---|
750 | $col = $tmp_col . ",key_year"; |
---|
751 | $objQuery->setgroupby("key_year"); |
---|
752 | $objQuery->setOrder("key_year"); |
---|
753 | $objPage->keyname = "key_year"; |
---|
754 | $objPage->tpl_tail = "ǯ"; |
---|
755 | $from = "dtb_bat_order_daily"; |
---|
756 | $xtitle = "(ǯÊÌ)"; |
---|
757 | $ytitle = "(Çä¾å¹ç·×)"; |
---|
758 | break; |
---|
759 | // ÍËÆüÊÌ |
---|
760 | case 'wday': |
---|
761 | $col = $tmp_col . ",key_wday, wday"; |
---|
762 | $objQuery->setgroupby("key_wday, wday"); |
---|
763 | $objQuery->setOrder("wday"); |
---|
764 | $objPage->keyname = "key_wday"; |
---|
765 | $objPage->tpl_tail = "ÍËÆü"; |
---|
766 | $from = "dtb_bat_order_daily"; |
---|
767 | $xtitle = "(ÍËÆüÊÌ)"; |
---|
768 | $ytitle = "(Çä¾å¹ç·×)"; |
---|
769 | break; |
---|
770 | // »þ´ÖÊÌ |
---|
771 | case 'hour': |
---|
772 | $col = $tmp_col . ",hour"; |
---|
773 | $objQuery->setgroupby("hour"); |
---|
774 | $objQuery->setOrder("hour"); |
---|
775 | $objPage->keyname = "hour"; |
---|
776 | $objPage->tpl_tail = "»þ"; |
---|
777 | $from = "dtb_bat_order_daily_hour"; |
---|
778 | $xtitle = "(»þ´ÖÊÌ)"; |
---|
779 | $ytitle = "(Çä¾å¹ç·×)"; |
---|
780 | break; |
---|
781 | default: |
---|
782 | $col = "*"; |
---|
783 | $objQuery->setOrder("key_day"); |
---|
784 | $objPage->keyname = "key_day"; |
---|
785 | $from = "dtb_bat_order_daily"; |
---|
786 | $xtitle = "(ÆüÊÌ)"; |
---|
787 | $ytitle = "(Çä¾å¹ç·×)"; |
---|
788 | break; |
---|
789 | } |
---|
790 | |
---|
791 | |
---|
792 | // ¼èÆÀÆüÉդλØÄê |
---|
793 | if($sdate != "") { |
---|
794 | if ($where != "") { |
---|
795 | $where.= " AND "; |
---|
796 | } |
---|
797 | $where.= " order_date >= '". $sdate ."'"; |
---|
798 | } |
---|
799 | |
---|
800 | if($edate != "") { |
---|
801 | if ($where != "") { |
---|
802 | $where.= " AND "; |
---|
803 | } |
---|
804 | $edate_next = date("Y/m/d",strtotime("1 day" ,strtotime($edate))); |
---|
805 | $where.= " order_date < date('" . $edate_next ."')"; |
---|
806 | } |
---|
807 | |
---|
808 | // ¸¡º÷·ë²Ì¤Î¼èÆÀ |
---|
809 | $objPage->arrResults = $objQuery->select($col, $from, $where, $arrval); |
---|
810 | |
---|
811 | // ÀÞ¤ìÀþ¥°¥é¥Õ¤ÎÀ¸À® |
---|
812 | if($graph) { |
---|
813 | $image_key = "term_" . $type; |
---|
814 | $objPage->tpl_image = lfGetGraphLine($objPage->arrResults, $objPage->keyname, $image_key, $xtitle, $ytitle, $sdate, $edate); |
---|
815 | } |
---|
816 | |
---|
817 | // ¸¡º÷·ë²Ì¤¬0¤Ç¤Ê¤¤¾ì¹ç |
---|
818 | if(count($objPage->arrResults) > 0) { |
---|
819 | // ºÇ½ª½¸·×¹Ô¼èÆÀ¤¹¤ë |
---|
820 | $col = $tmp_col; |
---|
821 | $objQuery = new SC_Query(); |
---|
822 | $arrRet = $objQuery->select($col, $from, $where, $arrval); |
---|
823 | $arrRet[0][$objPage->keyname] = "¹ç·×"; |
---|
824 | $objPage->arrResults[] = $arrRet[0]; |
---|
825 | } |
---|
826 | |
---|
827 | // Ê¿¶ÑÃͤη׻» |
---|
828 | $max = count($objPage->arrResults); |
---|
829 | for($i = 0; $i < $max; $i++) { |
---|
830 | if($objPage->arrResults[$i]['total_order'] > 0) { |
---|
831 | $objPage->arrResults[$i]['total_average'] = intval($objPage->arrResults[$i]['total'] / $objPage->arrResults[$i]['total_order']); |
---|
832 | } |
---|
833 | } |
---|
834 | |
---|
835 | return $objPage; |
---|
836 | } |
---|
837 | |
---|
838 | ?> |
---|