Changeset 21562


Ignore:
Timestamp:
2012/02/28 22:03:29 (12 years ago)
Author:
Seasoft
Message:

#1668 (SQL 文に定数を直接記述しない)
#1613 (typo修正・ソース整形・ソースコメントの改善)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-dev/data/class/pages/admin/total/LC_Page_Admin_Total.php

    r21527 r21562  
    7676 
    7777        // 期間別集計のkey名 
    78         $this->arrSearchForm2       = array('search_startyear', 
    79                                             'search_startmonth', 
    80                                             'search_startday', 
    81                                             'search_endyear', 
    82                                             'search_endmonth', 
    83                                             'search_endday'); 
     78        $this->arrSearchForm2 = array( 
     79            'search_startyear', 
     80            'search_startmonth', 
     81            'search_startday', 
     82            'search_endyear', 
     83            'search_endmonth', 
     84            'search_endday', 
     85        ); 
    8486    } 
    8587 
     
    275277            } 
    276278            switch ($key) { 
    277             case 'search_startyear': 
    278                 $sdate = $objFormParam->getValue('search_startyear') . '/' . $objFormParam->getValue('search_startmonth') . '/' . $objFormParam->getValue('search_startday'); 
    279                 break; 
    280             case 'search_endyear': 
    281                 $edate = $objFormParam->getValue('search_endyear') . '/' . $objFormParam->getValue('search_endmonth') . '/' . $objFormParam->getValue('search_endday'); 
    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; 
     279                case 'search_startyear': 
     280                    $sdate = $objFormParam->getValue('search_startyear') . '/' . $objFormParam->getValue('search_startmonth') . '/' . $objFormParam->getValue('search_startday'); 
     281                    break; 
     282                case 'search_endyear': 
     283                    $edate = $objFormParam->getValue('search_endyear') . '/' . $objFormParam->getValue('search_endmonth') . '/' . $objFormParam->getValue('search_endday'); 
     284                    break; 
     285                case 'search_startyear_m': 
     286                    list($sdate, $edate) = SC_Utils_Ex::sfTermMonth($objFormParam->getValue('search_startyear_m'), 
     287                                                                    $objFormParam->getValue('search_startmonth_m'), 
     288                                                                    CLOSE_DAY); 
     289                    break; 
     290                default: 
     291                    break; 
    290292            } 
    291293        } 
     
    475477        switch ($type) { 
    476478            // 全体 
    477         case 'all': 
    478             break; 
    479         case 'member': 
    480             if ($where != '') { 
    481                 $where.= ' AND '; 
    482             } 
    483             $where.= " $col_member <> 0"; 
    484             break; 
    485         case 'nonmember': 
    486             if ($where != '') { 
    487                 $where.= ' AND '; 
    488             } 
    489             $where.= " $col_member = 0"; 
    490             break; 
    491         default: 
    492             break; 
     479            case 'all': 
     480                break; 
     481            case 'member': 
     482                if ($where != '') { 
     483                    $where.= ' AND '; 
     484                } 
     485                $where.= " $col_member <> 0"; 
     486                break; 
     487            case 'nonmember': 
     488                if ($where != '') { 
     489                    $where.= ' AND '; 
     490                } 
     491                $where.= " $col_member = 0"; 
     492                break; 
     493            default: 
     494                break; 
    493495        } 
    494496 
     
    500502        $objQuery = SC_Query_Ex::getSingletonInstance(); 
    501503 
    502         list($where, $arrval) = $this->lfGetWhereMember('create_date', $sdate, $edate, $type); 
    503         $where .= ' AND del_flg = 0 AND status <> ' . ORDER_CANCEL; 
     504        list($where, $arrWhereVal) = $this->lfGetWhereMember('create_date', $sdate, $edate, $type); 
     505        $where .= ' AND del_flg = 0 AND status <> ?'; 
     506        $arrWhereVal[] = ORDER_CANCEL; 
    504507 
    505508        // 会員集計の取得 
    506         $col        = " 
     509        $col = <<< __EOS__ 
    507510            COUNT(order_id) AS order_count, 
    508511            SUM(total) AS total, 
     
    513516            END AS member, 
    514517            order_sex 
    515                 "; 
     518__EOS__; 
     519 
    516520        $from       = 'dtb_order'; 
    517521 
    518522        $objQuery->setGroupBy('member, order_sex'); 
    519523 
    520         $arrTotalResults = $objQuery->select($col, $from, $where, $arrval); 
     524        $arrTotalResults = $objQuery->select($col, $from, $where, $arrWhereVal); 
    521525 
    522526        foreach (array_keys($arrTotalResults) as $key) { 
     
    539543        $objQuery = SC_Query_Ex::getSingletonInstance(); 
    540544 
    541         list($where, $arrval) = $this->lfGetWhereMember('create_date', $sdate, $edate, $type); 
    542  
    543         $where .= ' AND dtb_order.del_flg = 0 AND dtb_order.status <> ' . ORDER_CANCEL; 
    544  
    545         $col = " 
     545        list($where, $arrWhereVal) = $this->lfGetWhereMember('create_date', $sdate, $edate, $type); 
     546 
     547        $where .= ' AND dtb_order.del_flg = 0 AND dtb_order.status <> ?'; 
     548        $arrWhereVal[] = ORDER_CANCEL; 
     549 
     550        $col = <<< __EOS__ 
    546551                product_id, 
    547552                product_code, 
     
    550555                COUNT(order_id) AS order_count, 
    551556                price, 
    552                 (price * SUM(quantity)) AS total"; 
     557                (price * SUM(quantity)) AS total 
     558__EOS__; 
    553559 
    554560        $from = 'dtb_order_detail JOIN dtb_order USING(order_id)'; 
     
    563569        //$objQuery->setGroupBy('product_id'); 
    564570        $objQuery->setOrder('total DESC'); 
    565         $arrTotalResults = $objQuery->select($col, $from, $where, $arrval); 
     571        $arrTotalResults = $objQuery->select($col, $from, $where, $arrWhereVal); 
    566572 
    567573        $tpl_image  = $this->lfGetGraphPie($arrTotalResults, 'product_name', 'products_' . $type, '(売上比率)', $sdate, $edate); 
     
    573579    function lfGetOrderJob($type, $sdate, $edate) { 
    574580        $objQuery = SC_Query_Ex::getSingletonInstance(); 
    575         list($where, $arrval) = $this->lfGetWhereMember('dtb_order.create_date', $sdate, $edate, $type); 
    576  
    577         $col    = ' 
     581        list($where, $arrWhereVal) = $this->lfGetWhereMember('dtb_order.create_date', $sdate, $edate, $type); 
     582 
     583        $col = <<< __EOS__ 
    578584            job, 
    579585            COUNT(order_id) AS order_count, 
    580586            SUM(total) AS total, 
    581587            AVG(total) AS total_average 
    582             '; 
     588__EOS__; 
    583589 
    584590        $from   = 'dtb_order JOIN dtb_customer USING ( customer_id)'; 
    585591 
    586         $where .= ' AND dtb_order.del_flg = 0 AND dtb_order.status <> ' . ORDER_CANCEL; 
     592        $where .= ' AND dtb_order.del_flg = 0 AND dtb_order.status <> ?'; 
     593        $arrWhereVal[] = ORDER_CANCEL; 
    587594 
    588595        $objQuery->setGroupBy('job'); 
    589596        $objQuery->setOrder('total DESC'); 
    590         $arrTotalResults = $objQuery->select($col, $from, $where, $arrval); 
     597        $arrTotalResults = $objQuery->select($col, $from, $where, $arrWhereVal); 
    591598 
    592599        foreach (array_keys($arrTotalResults) as $key) { 
     
    610617        $objQuery = SC_Query_Ex::getSingletonInstance(); 
    611618 
    612         list($where, $arrval) = $this->lfGetWhereMember('create_date', $sdate, $edate, $type); 
     619        list($where, $arrWhereVal) = $this->lfGetWhereMember('create_date', $sdate, $edate, $type); 
    613620 
    614621        $dbFactory = SC_DB_DBFactory_Ex::getInstance(); 
    615         $col = $dbFactory->getOrderTotalAgeColSql() . ' AS age, 
    616             COUNT(order_id) AS order_count, 
    617             SUM(total) AS total, 
    618             AVG(total) AS total_average 
    619             '; 
     622        $col = $dbFactory->getOrderTotalAgeColSql() . ' AS age'; 
     623        $col .= ',COUNT(order_id) AS order_count'; 
     624        $col .= ',SUM(total) AS total'; 
     625        $col .= ',AVG(total) AS total_average'; 
    620626 
    621627        $from   = 'dtb_order'; 
    622628 
    623         $where .= ' AND del_flg = 0 AND status <> ' . ORDER_CANCEL; 
     629        $where .= ' AND del_flg = 0 AND status <> ?'; 
     630        $arrWhereVal[] = ORDER_CANCEL; 
    624631 
    625632        $objQuery->setGroupBy('age'); 
    626633        $objQuery->setOrder('age DESC'); 
    627         $arrTotalResults = $objQuery->select($col, $from, $where, $arrval); 
     634        $arrTotalResults = $objQuery->select($col, $from, $where, $arrWhereVal); 
    628635 
    629636        foreach (array_keys($arrTotalResults) as $key) { 
     
    647654        $objQuery   = SC_Query_Ex::getSingletonInstance(); 
    648655 
    649         list($where, $arrval) = $this->lfGetWhereMember('create_date', $sdate, $edate); 
    650         $where .= ' AND del_flg = 0 AND status <> ' . ORDER_CANCEL; 
     656        list($where, $arrWhereVal) = $this->lfGetWhereMember('create_date', $sdate, $edate); 
     657        $where .= ' AND del_flg = 0 AND status <> ?'; 
     658        $arrWhereVal[] = ORDER_CANCEL; 
    651659 
    652660        switch ($type) { 
    653         case 'month': 
    654             $xtitle = '(月別)'; 
    655             $ytitle = '(売上合計)'; 
    656             $format = '%m'; 
    657             break; 
    658         case 'year': 
    659             $xtitle = '(年別)'; 
    660             $ytitle = '(売上合計)'; 
    661             $format = '%Y'; 
    662             break; 
    663         case 'wday': 
    664             $xtitle = '(曜日別)'; 
    665             $ytitle = '(売上合計)'; 
    666             $format = '%a'; 
    667             break; 
    668         case 'hour': 
    669             $xtitle = '(時間別)'; 
    670             $ytitle = '(売上合計)'; 
    671             $format = '%H'; 
    672             break; 
    673         default: 
    674             $xtitle = '(日別)'; 
    675             $ytitle = '(売上合計)'; 
    676             $format = '%Y-%m-%d'; 
    677             $xincline = true; 
    678             break; 
     661            case 'month': 
     662                $xtitle = '(月別)'; 
     663                $ytitle = '(売上合計)'; 
     664                $format = '%m'; 
     665                break; 
     666            case 'year': 
     667                $xtitle = '(年別)'; 
     668                $ytitle = '(売上合計)'; 
     669                $format = '%Y'; 
     670                break; 
     671            case 'wday': 
     672                $xtitle = '(曜日別)'; 
     673                $ytitle = '(売上合計)'; 
     674                $format = '%a'; 
     675                break; 
     676            case 'hour': 
     677                $xtitle = '(時間別)'; 
     678                $ytitle = '(売上合計)'; 
     679                $format = '%H'; 
     680                break; 
     681            default: 
     682                $xtitle = '(日別)'; 
     683                $ytitle = '(売上合計)'; 
     684                $format = '%Y-%m-%d'; 
     685                $xincline = true; 
     686                break; 
    679687        } 
    680688 
     
    686694        $objQuery->setOrder('str_date'); 
    687695        // 検索結果の取得 
    688         $arrTotalResults = $objQuery->select($col, 'dtb_order', $where); 
     696        $arrTotalResults = $objQuery->select($col, 'dtb_order', $where, $arrWhereVal); 
    689697 
    690698        $arrTotalResults = $this->lfAddBlankLine($arrTotalResults, $type, $sdate, $edate); 
     
    800808        switch ($page) { 
    801809            // 商品別集計 
    802         case 'products': 
    803             $arrTitleCol = array( 
    804                 '商品コード', 
    805                 '商品名', 
    806                 '購入件数', 
    807                 '数量', 
    808                 '単価', 
    809                 '金額', 
    810             ); 
    811             $arrDataCol = array( 
    812                 'product_code', 
    813                 'product_name', 
    814                 'order_count', 
    815                 'products_count', 
    816                 'price', 
    817                 'total', 
    818             ); 
    819             break; 
     810            case 'products': 
     811                $arrTitleCol = array( 
     812                    '商品コード', 
     813                    '商品名', 
     814                    '購入件数', 
     815                    '数量', 
     816                    '単価', 
     817                    '金額', 
     818                ); 
     819                $arrDataCol = array( 
     820                    'product_code', 
     821                    'product_name', 
     822                    'order_count', 
     823                    'products_count', 
     824                    'price', 
     825                    'total', 
     826                ); 
     827                break; 
    820828            // 職業別集計 
    821         case 'job': 
    822             $arrTitleCol = array( 
    823                 '職業', 
    824                 '購入件数', 
    825                 '購入合計', 
    826                 '購入平均', 
    827             ); 
    828             $arrDataCol = array( 
    829                 'job_name', 
    830                 'order_count', 
    831                 'total', 
    832                 'total_average', 
    833             ); 
    834             break; 
     829            case 'job': 
     830                $arrTitleCol = array( 
     831                    '職業', 
     832                    '購入件数', 
     833                    '購入合計', 
     834                    '購入平均', 
     835                ); 
     836                $arrDataCol = array( 
     837                    'job_name', 
     838                    'order_count', 
     839                    'total', 
     840                    'total_average', 
     841                ); 
     842                break; 
    835843            // 会員別集計 
    836         case 'member': 
    837             $arrTitleCol = array( 
    838                 '会員', 
    839                 '購入件数', 
    840                 '購入合計', 
    841                 '購入平均', 
    842             ); 
    843             $arrDataCol = array( 
    844                 'member_name', 
    845                 'order_count', 
    846                 'total', 
    847                 'total_average', 
    848             ); 
    849             break; 
     844            case 'member': 
     845                $arrTitleCol = array( 
     846                    '会員', 
     847                    '購入件数', 
     848                    '購入合計', 
     849                    '購入平均', 
     850                ); 
     851                $arrDataCol = array( 
     852                    'member_name', 
     853                    'order_count', 
     854                    'total', 
     855                    'total_average', 
     856                ); 
     857                break; 
    850858            // 年代別集計 
    851         case 'age': 
    852             $arrTitleCol = array( 
    853                 '年齢', 
    854                 '購入件数', 
    855                 '購入合計', 
    856                 '購入平均', 
    857             ); 
    858             $arrDataCol = array( 
    859                 'age_name', 
    860                 'order_count', 
    861                 'total', 
    862                 'total_average', 
    863             ); 
    864             break; 
     859            case 'age': 
     860                $arrTitleCol = array( 
     861                    '年齢', 
     862                    '購入件数', 
     863                    '購入合計', 
     864                    '購入平均', 
     865                ); 
     866                $arrDataCol = array( 
     867                    'age_name', 
     868                    'order_count', 
     869                    'total', 
     870                    'total_average', 
     871                ); 
     872                break; 
    865873            // 期間別集計 
    866         default: 
    867             $arrTitleCol = array( 
    868                 '期間', 
    869                 '購入件数', 
    870                 '男性', 
    871                 '女性', 
    872                 '男性(会員)', 
    873                 '男性(非会員)', 
    874                 '女性(会員)', 
    875                 '女性(非会員)', 
    876                 '購入合計', 
    877                 '購入平均', 
    878             ); 
    879             $arrDataCol = array( 
    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             ); 
    891             break; 
     874            default: 
     875                $arrTitleCol = array( 
     876                    '期間', 
     877                    '購入件数', 
     878                    '男性', 
     879                    '女性', 
     880                    '男性(会員)', 
     881                    '男性(非会員)', 
     882                    '女性(会員)', 
     883                    '女性(非会員)', 
     884                    '購入合計', 
     885                    '購入平均', 
     886                ); 
     887                $arrDataCol = array( 
     888                    'str_date', 
     889                    'total_order', 
     890                    'men', 
     891                    'women', 
     892                    'men_member', 
     893                    'men_nonmember', 
     894                    'women_member', 
     895                    'women_nonmember', 
     896                    'total', 
     897                    'total_average', 
     898                ); 
     899                break; 
    892900        } 
    893901 
Note: See TracChangeset for help on using the changeset viewer.