Index: /branches/version-2_12-dev/data/class/pages/admin/total/LC_Page_Admin_Total.php
===================================================================
--- /branches/version-2_12-dev/data/class/pages/admin/total/LC_Page_Admin_Total.php	(revision 21527)
+++ /branches/version-2_12-dev/data/class/pages/admin/total/LC_Page_Admin_Total.php	(revision 21562)
@@ -76,10 +76,12 @@
 
         // 期間別集計のkey名
-        $this->arrSearchForm2       = array('search_startyear',
-                                            'search_startmonth',
-                                            'search_startday',
-                                            'search_endyear',
-                                            'search_endmonth',
-                                            'search_endday');
+        $this->arrSearchForm2 = array(
+            'search_startyear',
+            'search_startmonth',
+            'search_startday',
+            'search_endyear',
+            'search_endmonth',
+            'search_endday',
+        );
     }
 
@@ -275,17 +277,17 @@
             }
             switch ($key) {
-            case 'search_startyear':
-                $sdate = $objFormParam->getValue('search_startyear') . '/' . $objFormParam->getValue('search_startmonth') . '/' . $objFormParam->getValue('search_startday');
-                break;
-            case 'search_endyear':
-                $edate = $objFormParam->getValue('search_endyear') . '/' . $objFormParam->getValue('search_endmonth') . '/' . $objFormParam->getValue('search_endday');
-                break;
-            case 'search_startyear_m':
-                list($sdate, $edate) = SC_Utils_Ex::sfTermMonth($objFormParam->getValue('search_startyear_m'),
-                                                                $objFormParam->getValue('search_startmonth_m'),
-                                                                CLOSE_DAY);
-                break;
-            default:
-                break;
+                case 'search_startyear':
+                    $sdate = $objFormParam->getValue('search_startyear') . '/' . $objFormParam->getValue('search_startmonth') . '/' . $objFormParam->getValue('search_startday');
+                    break;
+                case 'search_endyear':
+                    $edate = $objFormParam->getValue('search_endyear') . '/' . $objFormParam->getValue('search_endmonth') . '/' . $objFormParam->getValue('search_endday');
+                    break;
+                case 'search_startyear_m':
+                    list($sdate, $edate) = SC_Utils_Ex::sfTermMonth($objFormParam->getValue('search_startyear_m'),
+                                                                    $objFormParam->getValue('search_startmonth_m'),
+                                                                    CLOSE_DAY);
+                    break;
+                default:
+                    break;
             }
         }
@@ -475,20 +477,20 @@
         switch ($type) {
             // 全体
-        case 'all':
-            break;
-        case 'member':
-            if ($where != '') {
-                $where.= ' AND ';
-            }
-            $where.= " $col_member <> 0";
-            break;
-        case 'nonmember':
-            if ($where != '') {
-                $where.= ' AND ';
-            }
-            $where.= " $col_member = 0";
-            break;
-        default:
-            break;
+            case 'all':
+                break;
+            case 'member':
+                if ($where != '') {
+                    $where.= ' AND ';
+                }
+                $where.= " $col_member <> 0";
+                break;
+            case 'nonmember':
+                if ($where != '') {
+                    $where.= ' AND ';
+                }
+                $where.= " $col_member = 0";
+                break;
+            default:
+                break;
         }
 
@@ -500,9 +502,10 @@
         $objQuery = SC_Query_Ex::getSingletonInstance();
 
-        list($where, $arrval) = $this->lfGetWhereMember('create_date', $sdate, $edate, $type);
-        $where .= ' AND del_flg = 0 AND status <> ' . ORDER_CANCEL;
+        list($where, $arrWhereVal) = $this->lfGetWhereMember('create_date', $sdate, $edate, $type);
+        $where .= ' AND del_flg = 0 AND status <> ?';
+        $arrWhereVal[] = ORDER_CANCEL;
 
         // 会員集計の取得
-        $col        = "
+        $col = <<< __EOS__
             COUNT(order_id) AS order_count,
             SUM(total) AS total,
@@ -513,10 +516,11 @@
             END AS member,
             order_sex
-                ";
+__EOS__;
+
         $from       = 'dtb_order';
 
         $objQuery->setGroupBy('member, order_sex');
 
-        $arrTotalResults = $objQuery->select($col, $from, $where, $arrval);
+        $arrTotalResults = $objQuery->select($col, $from, $where, $arrWhereVal);
 
         foreach (array_keys($arrTotalResults) as $key) {
@@ -539,9 +543,10 @@
         $objQuery = SC_Query_Ex::getSingletonInstance();
 
-        list($where, $arrval) = $this->lfGetWhereMember('create_date', $sdate, $edate, $type);
-
-        $where .= ' AND dtb_order.del_flg = 0 AND dtb_order.status <> ' . ORDER_CANCEL;
-
-        $col = "
+        list($where, $arrWhereVal) = $this->lfGetWhereMember('create_date', $sdate, $edate, $type);
+
+        $where .= ' AND dtb_order.del_flg = 0 AND dtb_order.status <> ?';
+        $arrWhereVal[] = ORDER_CANCEL;
+
+        $col = <<< __EOS__
                 product_id,
                 product_code,
@@ -550,5 +555,6 @@
                 COUNT(order_id) AS order_count,
                 price,
-                (price * SUM(quantity)) AS total";
+                (price * SUM(quantity)) AS total
+__EOS__;
 
         $from = 'dtb_order_detail JOIN dtb_order USING(order_id)';
@@ -563,5 +569,5 @@
         //$objQuery->setGroupBy('product_id');
         $objQuery->setOrder('total DESC');
-        $arrTotalResults = $objQuery->select($col, $from, $where, $arrval);
+        $arrTotalResults = $objQuery->select($col, $from, $where, $arrWhereVal);
 
         $tpl_image  = $this->lfGetGraphPie($arrTotalResults, 'product_name', 'products_' . $type, '(売上比率)', $sdate, $edate);
@@ -573,20 +579,21 @@
     function lfGetOrderJob($type, $sdate, $edate) {
         $objQuery = SC_Query_Ex::getSingletonInstance();
-        list($where, $arrval) = $this->lfGetWhereMember('dtb_order.create_date', $sdate, $edate, $type);
-
-        $col    = '
+        list($where, $arrWhereVal) = $this->lfGetWhereMember('dtb_order.create_date', $sdate, $edate, $type);
+
+        $col = <<< __EOS__
             job,
             COUNT(order_id) AS order_count,
             SUM(total) AS total,
             AVG(total) AS total_average
-            ';
+__EOS__;
 
         $from   = 'dtb_order JOIN dtb_customer USING ( customer_id)';
 
-        $where .= ' AND dtb_order.del_flg = 0 AND dtb_order.status <> ' . ORDER_CANCEL;
+        $where .= ' AND dtb_order.del_flg = 0 AND dtb_order.status <> ?';
+        $arrWhereVal[] = ORDER_CANCEL;
 
         $objQuery->setGroupBy('job');
         $objQuery->setOrder('total DESC');
-        $arrTotalResults = $objQuery->select($col, $from, $where, $arrval);
+        $arrTotalResults = $objQuery->select($col, $from, $where, $arrWhereVal);
 
         foreach (array_keys($arrTotalResults) as $key) {
@@ -610,20 +617,20 @@
         $objQuery = SC_Query_Ex::getSingletonInstance();
 
-        list($where, $arrval) = $this->lfGetWhereMember('create_date', $sdate, $edate, $type);
+        list($where, $arrWhereVal) = $this->lfGetWhereMember('create_date', $sdate, $edate, $type);
 
         $dbFactory = SC_DB_DBFactory_Ex::getInstance();
-        $col = $dbFactory->getOrderTotalAgeColSql() . ' AS age,
-            COUNT(order_id) AS order_count,
-            SUM(total) AS total,
-            AVG(total) AS total_average
-            ';
+        $col = $dbFactory->getOrderTotalAgeColSql() . ' AS age';
+        $col .= ',COUNT(order_id) AS order_count';
+        $col .= ',SUM(total) AS total';
+        $col .= ',AVG(total) AS total_average';
 
         $from   = 'dtb_order';
 
-        $where .= ' AND del_flg = 0 AND status <> ' . ORDER_CANCEL;
+        $where .= ' AND del_flg = 0 AND status <> ?';
+        $arrWhereVal[] = ORDER_CANCEL;
 
         $objQuery->setGroupBy('age');
         $objQuery->setOrder('age DESC');
-        $arrTotalResults = $objQuery->select($col, $from, $where, $arrval);
+        $arrTotalResults = $objQuery->select($col, $from, $where, $arrWhereVal);
 
         foreach (array_keys($arrTotalResults) as $key) {
@@ -647,34 +654,35 @@
         $objQuery   = SC_Query_Ex::getSingletonInstance();
 
-        list($where, $arrval) = $this->lfGetWhereMember('create_date', $sdate, $edate);
-        $where .= ' AND del_flg = 0 AND status <> ' . ORDER_CANCEL;
+        list($where, $arrWhereVal) = $this->lfGetWhereMember('create_date', $sdate, $edate);
+        $where .= ' AND del_flg = 0 AND status <> ?';
+        $arrWhereVal[] = ORDER_CANCEL;
 
         switch ($type) {
-        case 'month':
-            $xtitle = '(月別)';
-            $ytitle = '(売上合計)';
-            $format = '%m';
-            break;
-        case 'year':
-            $xtitle = '(年別)';
-            $ytitle = '(売上合計)';
-            $format = '%Y';
-            break;
-        case 'wday':
-            $xtitle = '(曜日別)';
-            $ytitle = '(売上合計)';
-            $format = '%a';
-            break;
-        case 'hour':
-            $xtitle = '(時間別)';
-            $ytitle = '(売上合計)';
-            $format = '%H';
-            break;
-        default:
-            $xtitle = '(日別)';
-            $ytitle = '(売上合計)';
-            $format = '%Y-%m-%d';
-            $xincline = true;
-            break;
+            case 'month':
+                $xtitle = '(月別)';
+                $ytitle = '(売上合計)';
+                $format = '%m';
+                break;
+            case 'year':
+                $xtitle = '(年別)';
+                $ytitle = '(売上合計)';
+                $format = '%Y';
+                break;
+            case 'wday':
+                $xtitle = '(曜日別)';
+                $ytitle = '(売上合計)';
+                $format = '%a';
+                break;
+            case 'hour':
+                $xtitle = '(時間別)';
+                $ytitle = '(売上合計)';
+                $format = '%H';
+                break;
+            default:
+                $xtitle = '(日別)';
+                $ytitle = '(売上合計)';
+                $format = '%Y-%m-%d';
+                $xincline = true;
+                break;
         }
 
@@ -686,5 +694,5 @@
         $objQuery->setOrder('str_date');
         // 検索結果の取得
-        $arrTotalResults = $objQuery->select($col, 'dtb_order', $where);
+        $arrTotalResults = $objQuery->select($col, 'dtb_order', $where, $arrWhereVal);
 
         $arrTotalResults = $this->lfAddBlankLine($arrTotalResults, $type, $sdate, $edate);
@@ -800,94 +808,94 @@
         switch ($page) {
             // 商品別集計
-        case 'products':
-            $arrTitleCol = array(
-                '商品コード',
-                '商品名',
-                '購入件数',
-                '数量',
-                '単価',
-                '金額',
-            );
-            $arrDataCol = array(
-                'product_code',
-                'product_name',
-                'order_count',
-                'products_count',
-                'price',
-                'total',
-            );
-            break;
+            case 'products':
+                $arrTitleCol = array(
+                    '商品コード',
+                    '商品名',
+                    '購入件数',
+                    '数量',
+                    '単価',
+                    '金額',
+                );
+                $arrDataCol = array(
+                    'product_code',
+                    'product_name',
+                    'order_count',
+                    'products_count',
+                    'price',
+                    'total',
+                );
+                break;
             // 職業別集計
-        case 'job':
-            $arrTitleCol = array(
-                '職業',
-                '購入件数',
-                '購入合計',
-                '購入平均',
-            );
-            $arrDataCol = array(
-                'job_name',
-                'order_count',
-                'total',
-                'total_average',
-            );
-            break;
+            case 'job':
+                $arrTitleCol = array(
+                    '職業',
+                    '購入件数',
+                    '購入合計',
+                    '購入平均',
+                );
+                $arrDataCol = array(
+                    'job_name',
+                    'order_count',
+                    'total',
+                    'total_average',
+                );
+                break;
             // 会員別集計
-        case 'member':
-            $arrTitleCol = array(
-                '会員',
-                '購入件数',
-                '購入合計',
-                '購入平均',
-            );
-            $arrDataCol = array(
-                'member_name',
-                'order_count',
-                'total',
-                'total_average',
-            );
-            break;
+            case 'member':
+                $arrTitleCol = array(
+                    '会員',
+                    '購入件数',
+                    '購入合計',
+                    '購入平均',
+                );
+                $arrDataCol = array(
+                    'member_name',
+                    'order_count',
+                    'total',
+                    'total_average',
+                );
+                break;
             // 年代別集計
-        case 'age':
-            $arrTitleCol = array(
-                '年齢',
-                '購入件数',
-                '購入合計',
-                '購入平均',
-            );
-            $arrDataCol = array(
-                'age_name',
-                'order_count',
-                'total',
-                'total_average',
-            );
-            break;
+            case 'age':
+                $arrTitleCol = array(
+                    '年齢',
+                    '購入件数',
+                    '購入合計',
+                    '購入平均',
+                );
+                $arrDataCol = array(
+                    'age_name',
+                    'order_count',
+                    'total',
+                    'total_average',
+                );
+                break;
             // 期間別集計
-        default:
-            $arrTitleCol = array(
-                '期間',
-                '購入件数',
-                '男性',
-                '女性',
-                '男性(会員)',
-                '男性(非会員)',
-                '女性(会員)',
-                '女性(非会員)',
-                '購入合計',
-                '購入平均',
-            );
-            $arrDataCol = array(
-                'str_date',
-                'total_order',
-                'men',
-                'women',
-                'men_member',
-                'men_nonmember',
-                'women_member',
-                'women_nonmember',
-                'total',
-                'total_average',
-            );
-            break;
+            default:
+                $arrTitleCol = array(
+                    '期間',
+                    '購入件数',
+                    '男性',
+                    '女性',
+                    '男性(会員)',
+                    '男性(非会員)',
+                    '女性(会員)',
+                    '女性(非会員)',
+                    '購入合計',
+                    '購入平均',
+                );
+                $arrDataCol = array(
+                    'str_date',
+                    'total_order',
+                    'men',
+                    'women',
+                    'men_member',
+                    'men_nonmember',
+                    'women_member',
+                    'women_nonmember',
+                    'total',
+                    'total_average',
+                );
+                break;
         }
 
