예제 #1
0
 function SC_CustomerList($array, $mode = '')
 {
     parent::SC_SelectSql($array);
     $masterData = new SC_DB_MasterData_Ex();
     $arrMobileDomain = $masterData->getMasterData("mtb_mobile_domain");
     $objDb = new SC_Helper_DB_Ex();
     if ($mode == "") {
         // 会員本登録会員で削除していない会員
         $this->setWhere("status = 2 AND del_flg = 0 ");
         // 登録日を示すカラム
         $regdate_col = 'dtb_customer.update_date';
     }
     if ($mode == "customer") {
         // 管理者ページ顧客検索の場合仮登録会員も検索
         //$this->setWhere( "(status = 1 OR status = 2) AND del_flg = 0 ");
         $this->setWhere(" del_flg = 0 ");
         // 登録日を示すカラム
         $regdate_col = 'dtb_customer.update_date';
     }
     // メールマガジンの場合
     if ($mode == "magazine") {
         $this->setWhere("(del_flg = 0 OR del_flg IS NULL)");
         $this->setWhere("status = 2");
         // 登録日を示すカラム
         $regdate_col = 'dtb_customer.create_date';
     }
     // 顧客ID
     if (!isset($this->arrSql['customer_id'])) {
         $this->arrSql['customer_id'] = "";
     }
     if (strlen($this->arrSql['customer_id']) > 0) {
         $this->setWhere("customer_id =  ?");
         $this->arrVal[] = $this->arrSql['customer_id'];
     }
     // 名前
     if (!isset($this->arrSql['name'])) {
         $this->arrSql['name'] = "";
     }
     if (strlen($this->arrSql['name']) > 0) {
         if (DB_TYPE == "pgsql") {
             $this->setWhere("(name01 || name02 LIKE ?)");
         } elseif (DB_TYPE == "mysql") {
             $this->setWhere("concat(name01,name02) LIKE ?");
         }
         $searchName = $this->addSearchStr($this->arrSql['name']);
         $this->arrVal[] = mb_ereg_replace("[  ]+", "", $searchName);
     }
     // 名前(カナ)
     if (!isset($this->arrSql['kana'])) {
         $this->arrSql['kana'] = "";
     }
     if (strlen($this->arrSql['kana']) > 0) {
         if (DB_TYPE == "pgsql") {
             $this->setWhere("(kana01 || kana02 LIKE ?)");
         } elseif (DB_TYPE == "mysql") {
             $this->setWhere("concat(kana01,kana02) LIKE ?");
         }
         $searchKana = $this->addSearchStr($this->arrSql['kana']);
         $this->arrVal[] = mb_ereg_replace("[  ]+", "", $searchKana);
     }
     // 都道府県
     if (!isset($this->arrSql['pref'])) {
         $this->arrSql['pref'] = "";
     }
     if (strlen($this->arrSql['pref']) > 0) {
         $this->setWhere("pref = ?");
         $this->arrVal[] = $this->arrSql['pref'];
     }
     // 電話番号
     if (!isset($this->arrSql['tel'])) {
         $this->arrSql['tel'] = "";
     }
     if (is_numeric($this->arrSql['tel'])) {
         if (DB_TYPE == "pgsql") {
             $this->setWhere("(tel01 || tel02 || tel03 LIKE ?)");
         } elseif (DB_TYPE == "mysql") {
             $this->setWhere("concat(tel01,tel02,tel03) LIKE ?");
         }
         $searchTel = $this->addSearchStr($this->arrSql['tel']);
         $this->arrVal[] = ereg_replace("-", "", $searchTel);
     }
     //性別
     if (!isset($this->arrSql['sex'])) {
         $this->arrSql['sex'] = "";
     }
     if (is_array($this->arrSql['sex'])) {
         $arrSexVal = $this->setItemTerm($this->arrSql['sex'], "sex");
         foreach ($arrSexVal as $data) {
             $this->arrVal[] = $data;
         }
     }
     //職業
     if (!isset($this->arrSql['job'])) {
         $this->arrSql['job'] = "";
     }
     if (is_array($this->arrSql['job'])) {
         if (in_array("不明", $this->arrSql['job'])) {
             $arrJobVal = $this->setItemTermWithNull($this->arrSql['job'], "job");
         } else {
             $arrJobVal = $this->setItemTerm($this->arrSql['job'], "job");
         }
         if (is_array($arrJobVal)) {
             foreach ($arrJobVal as $data) {
                 $this->arrVal[] = $data;
             }
         }
     }
     // E-MAIL
     if (!isset($this->arrSql['email'])) {
         $this->arrSql['email'] = "";
     }
     if (strlen($this->arrSql['email']) > 0) {
         //カンマ区切りで複数の条件指定可能に
         $this->arrSql['email'] = explode(",", $this->arrSql['email']);
         $sql_where = "";
         foreach ($this->arrSql['email'] as $val) {
             $val = trim($val);
             //検索条件を含まない
             if ($this->arrSql['not_emailinc'] == '1') {
                 if ($sql_where == "") {
                     $sql_where .= "dtb_customer.email NOT ILIKE ? ";
                 } else {
                     $sql_where .= "AND dtb_customer.email NOT ILIKE ? ";
                 }
             } else {
                 if ($sql_where == "") {
                     $sql_where .= "dtb_customer.email ILIKE ? ";
                 } else {
                     $sql_where .= "OR dtb_customer.email ILIKE ? ";
                 }
             }
             $searchEmail = $this->addSearchStr($val);
             $this->arrVal[] = $searchEmail;
         }
         $this->setWhere($sql_where);
     }
     // E-MAIL(mobile)
     if (!isset($this->arrSql['email_mobile'])) {
         $this->arrSql['email_mobile'] = "";
     }
     if (strlen($this->arrSql['email_mobile']) > 0) {
         //カンマ区切りで複数の条件指定可能に
         $this->arrSql['email_mobile'] = explode(",", $this->arrSql['email_mobile']);
         $sql_where = "";
         foreach ($this->arrSql['email_mobile'] as $val) {
             $val = trim($val);
             //検索条件を含まない
             if ($this->arrSql['not_email_mobileinc'] == '1') {
                 if ($sql_where == "") {
                     $sql_where .= "dtb_customer.email_mobile NOT ILIKE ? ";
                 } else {
                     $sql_where .= "AND dtb_customer.email_mobile NOT ILIKE ? ";
                 }
             } else {
                 if ($sql_where == "") {
                     $sql_where .= "dtb_customer.email_mobile ILIKE ? ";
                 } else {
                     $sql_where .= "OR dtb_customer.email_mobile ILIKE ? ";
                 }
             }
             $searchemail_mobile = $this->addSearchStr($val);
             $this->arrVal[] = $searchemail_mobile;
         }
         $this->setWhere($sql_where);
     }
     // 配信メールアドレス種別
     if ($mode == 'magazine') {
         if (!isset($this->arrSql['mail_type'])) {
             $this->arrSql['mail_type'] = "";
         }
         // PCサイトメールが指定されている場合
         if (strlen($this->arrSql['mail_type']) > 0 && $this->arrSql['mail_type'] == 1) {
             // 携帯ドメインを外す。
             foreach ($arrMobileDomain as $mobile_domain) {
                 $this->setWhere(" dtb_customer.email NOT ILIKE '%{$mobile_domain}' ");
             }
             // 携帯サイトメールが指定されている場合
         } else {
             if (strlen($this->arrSql['mail_type']) > 0 && $this->arrSql['mail_type'] == 2) {
                 $this->setWhere(" dtb_customer.email_mobile <> ''  ");
             }
         }
     }
     // HTML-mail
     if ($mode == 'magazine') {
         if (!isset($this->arrSql['htmlmail'])) {
             $this->arrSql['htmlmail'] = "";
         }
         if (strlen($this->arrSql['htmlmail']) > 0) {
             $this->setWhere(" mailmaga_flg = ? ");
             $this->arrVal[] = $this->arrSql['htmlmail'];
         } else {
             $this->setWhere(" (mailmaga_flg = 1 or mailmaga_flg = 2) ");
         }
     }
     // 購入金額指定
     if (!isset($this->arrSql['buy_total_from'])) {
         $this->arrSql['buy_total_from'] = "";
     }
     if (!isset($this->arrSql['buy_total_to'])) {
         $this->arrSql['buy_total_to'] = "";
     }
     if (is_numeric($this->arrSql["buy_total_from"]) || is_numeric($this->arrSql["buy_total_to"])) {
         $arrBuyTotal = $this->selectRange($this->arrSql["buy_total_from"], $this->arrSql["buy_total_to"], "buy_total");
         foreach ($arrBuyTotal as $data1) {
             $this->arrVal[] = $data1;
         }
     }
     // 購入回数指定
     if (!isset($this->arrSql['buy_times_from'])) {
         $this->arrSql['buy_times_from'] = "";
     }
     if (!isset($this->arrSql['buy_times_to'])) {
         $this->arrSql['buy_times_to'] = "";
     }
     if (is_numeric($this->arrSql["buy_times_from"]) || is_numeric($this->arrSql["buy_times_to"])) {
         $arrBuyTimes = $this->selectRange($this->arrSql["buy_times_from"], $this->arrSql["buy_times_to"], "buy_times");
         foreach ($arrBuyTimes as $data2) {
             $this->arrVal[] = $data2;
         }
     }
     // 誕生日期間指定
     if (!isset($this->arrSql['b_start_year'])) {
         $this->arrSql['b_start_year'] = "";
     }
     if (!isset($this->arrSql['b_start_month'])) {
         $this->arrSql['b_start_month'] = "";
     }
     if (!isset($this->arrSql['b_start_day'])) {
         $this->arrSql['b_start_day'] = "";
     }
     if (!isset($this->arrSql['b_end_year'])) {
         $this->arrSql['b_end_year'] = "";
     }
     if (!isset($this->arrSql['b_end_month'])) {
         $this->arrSql['b_end_month'] = "";
     }
     if (!isset($this->arrSql['b_end_day'])) {
         $this->arrSql['b_end_day'] = "";
     }
     if (strlen($this->arrSql['b_start_year']) > 0 && strlen($this->arrSql['b_start_month']) > 0 && strlen($this->arrSql['b_start_day']) > 0 || strlen($this->arrSql['b_end_year']) > 0 && strlen($this->arrSql['b_end_month']) > 0 && strlen($this->arrSql['b_end_day']) > 0) {
         $arrBirth = $this->selectTermRange($this->arrSql['b_start_year'], $this->arrSql['b_start_month'], $this->arrSql['b_start_day'], $this->arrSql['b_end_year'], $this->arrSql['b_end_month'], $this->arrSql['b_end_day'], "birth");
         if (is_array($arrBirth)) {
             foreach ($arrBirth as $data3) {
                 $this->arrVal[] = $data3;
             }
         }
     }
     // 誕生月の検索
     if (!isset($this->arrSql['birth_month'])) {
         $this->arrSql['birth_month'] = "";
     }
     if (is_numeric($this->arrSql["birth_month"])) {
         $this->setWhere(" EXTRACT(month from birth) = ?");
         $this->arrVal[] = $this->arrSql["birth_month"];
     }
     // 登録期間指定
     if (!isset($this->arrSql['start_year'])) {
         $this->arrSql['start_year'] = "";
     }
     if (!isset($this->arrSql['start_month'])) {
         $this->arrSql['start_month'] = "";
     }
     if (!isset($this->arrSql['start_day'])) {
         $this->arrSql['start_day'] = "";
     }
     if (!isset($this->arrSql['end_year'])) {
         $this->arrSql['end_year'] = "";
     }
     if (!isset($this->arrSql['end_month'])) {
         $this->arrSql['end_month'] = "";
     }
     if (!isset($this->arrSql['end_day'])) {
         $this->arrSql['end_day'] = "";
     }
     if (strlen($this->arrSql['start_year']) > 0 && strlen($this->arrSql['start_month']) > 0 && strlen($this->arrSql['start_day']) > 0 || strlen($this->arrSql['end_year']) > 0 && strlen($this->arrSql['end_month']) > 0 && strlen($this->arrSql['end_day']) > 0) {
         $arrRegistTime = $this->selectTermRange($this->arrSql['start_year'], $this->arrSql['start_month'], $this->arrSql['start_day'], $this->arrSql['end_year'], $this->arrSql['end_month'], $this->arrSql['end_day'], $regdate_col);
         if (is_array($arrRegistTime)) {
             foreach ($arrRegistTime as $data4) {
                 $this->arrVal[] = $data4;
             }
         }
     }
     // 最終購入日指定
     if (!isset($this->arrSql['buy_start_year'])) {
         $this->arrSql['buy_start_year'] = "";
     }
     if (!isset($this->arrSql['buy_start_month'])) {
         $this->arrSql['buy_start_month'] = "";
     }
     if (!isset($this->arrSql['buy_start_day'])) {
         $this->arrSql['buy_start_day'] = "";
     }
     if (!isset($this->arrSql['buy_end_year'])) {
         $this->arrSql['buy_end_year'] = "";
     }
     if (!isset($this->arrSql['buy_end_month'])) {
         $this->arrSql['buy_end_month'] = "";
     }
     if (!isset($this->arrSql['buy_end_day'])) {
         $this->arrSql['buy_end_day'] = "";
     }
     if (strlen($this->arrSql['buy_start_year']) > 0 && strlen($this->arrSql['buy_start_month']) > 0 && strlen($this->arrSql['buy_start_day']) > 0 || strlen($this->arrSql['buy_end_year']) > 0 && strlen($this->arrSql['buy_end_month']) > 0 && strlen($this->arrSql['buy_end_day']) > 0) {
         $arrRegistTime = $this->selectTermRange($this->arrSql['buy_start_year'], $this->arrSql['buy_start_month'], $this->arrSql['buy_start_day'], $this->arrSql['buy_end_year'], $this->arrSql['buy_end_month'], $this->arrSql['buy_end_day'], "last_buy_date");
         if (is_array($arrRegistTime)) {
             foreach ($arrRegistTime as $data4) {
                 $this->arrVal[] = $data4;
             }
         }
     }
     //購入商品コード
     if (!isset($this->arrSql['buy_product_code'])) {
         $this->arrSql['buy_product_code'] = "";
     }
     if (strlen($this->arrSql['buy_product_code']) > 0) {
         $this->setWhere("customer_id IN (SELECT customer_id FROM dtb_order WHERE order_id IN (SELECT order_id FROM dtb_order_detail WHERE product_code LIKE ? ))");
         $search_buyproduct_code = $this->addSearchStr($this->arrSql['buy_product_code']);
         $this->arrVal[] = $search_buyproduct_code;
     }
     //購入商品名称
     if (!isset($this->arrSql['buy_product_name'])) {
         $this->arrSql['buy_product_name'] = "";
     }
     if (strlen($this->arrSql['buy_product_name']) > 0) {
         $this->setWhere("customer_id IN (SELECT customer_id FROM dtb_order WHERE order_id IN (SELECT order_id FROM dtb_order_detail WHERE product_name LIKE ? ))");
         $search_buyproduct_name = $this->addSearchStr($this->arrSql['buy_product_name']);
         $this->arrVal[] = $search_buyproduct_name;
     }
     //カテゴリーを選択している場合のみ絞込検索を行う
     if (!isset($this->arrSql['category_id'])) {
         $this->arrSql['category_id'] = "";
     }
     if (strlen($this->arrSql['category_id']) != "") {
         //カテゴリーで絞込検索を行うSQL文生成
         list($tmp_where, $tmp_arrval) = $objDb->sfGetCatWhere(SC_Utils_Ex::sfManualEscape($this->arrSql['category_id']));
         //カテゴリーで絞込みが可能の場合
         if ($tmp_where != "") {
             $this->setWhere(" customer_id IN (SELECT distinct customer_id FROM dtb_order WHERE order_id IN (SELECT distinct order_id FROM dtb_order_detail WHERE product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . " ))) ");
             $this->arrVal = array_merge((array) $this->arrVal, (array) $tmp_arrval);
         }
     }
     //携帯電話番号
     if (!isset($this->arrSql['cell'])) {
         $this->arrSql['cell'] = "";
     }
     if (is_numeric($this->arrSql['cell'])) {
         $this->setWhere("(cell01 || cell02 || cell03 LIKE ?)");
         $searchTel = $this->addSearchStr($this->arrSql['cell']);
         $this->arrVal[] = ereg_replace("-", "", $searchTel);
     }
     //キャンペーン
     if (!isset($this->arrSql['campaign_id'])) {
         $this->arrSql['campaign_id'] = "";
     }
     if (is_numeric($this->arrSql['campaign_id'])) {
         $this->setWhere(" customer_id IN (SELECT distinct customer_id FROM dtb_campaign_order WHERE campaign_id = ?)");
         $this->arrVal[] = $this->arrSql['campaign_id'];
     }
     //会員状態
     if (!isset($this->arrSql['status'])) {
         $this->arrSql['status'] = "";
     }
     if (is_array($this->arrSql['status'])) {
         $arrStatusVal = $this->setItemTerm($this->arrSql['status'], "status");
         foreach ($arrStatusVal as $data) {
             $this->arrVal[] = $data;
         }
     }
     $this->setOrder("customer_id DESC");
 }
 public function __construct($array, $mode = '')
 {
     $pmode = $mode;
     if ($mode == "delete_in_customer") {
         $pmode = "customer";
     }
     parent::__construct($array, $pmode);
     if ($mode == "delete_in_customer") {
         strpos($this->where, ' del_flg = 0 ');
         // 先頭の del_flg = 0 を全ての条件に変える
         $this->where = preg_replace('/^ del_flg = 0 /', ' del_flg IS NOT NULL ', $this->where);
     }
     $objDb = new SC_Helper_DB_Ex();
     // query 構築用
     $objQuery = SC_Query_Ex::getSingletonInstance();
     GC_Utils_Ex::gfPrintLog(print_r($this->arrSql, true), DB_LOG_REALFILE);
     $having = "";
     if (count($this->arrSql["search_status"]) == 1) {
         switch ($this->arrSql["search_status"][0]) {
             case 1:
                 $having = "MIN(del_flg) = 1";
                 break;
             case 2:
                 $having = "MIN(del_flg) = 0";
                 break;
         }
     }
     $dt = "cp_dtb_customer_docomo_mymenu";
     $at = "cp_dtb_customer_transaction";
     $d = $objDb->sfColumnExists($dt, "customer_id");
     $a = $objDb->sfColumnExists($at, "customer_id");
     $objQuery->setGroupBy("customer_id");
     if ($having) {
         $objQuery->setOption("HAVING {$having}");
     }
     $where = PHP_EOL;
     $where .= "CASE " . PHP_EOL;
     $where .= "   WHEN 1 = 0 THEN FALSE " . PHP_EOL;
     // 自動構築時に特定条件で使えなくなることを防ぐ
     if ($d) {
         $sub_where = " payment_type IN ( 'USER1','USER10','USER12','USER3')";
         // 都度課金を除く
         if ($this->strlen('search_docomo_site_id') > 0) {
             $sub_where .= " AND site_id = ?";
             $this->arrVal[] = $this->arrSql['search_docomo_site_id'];
         }
         if ($this->strlen('search_course') > 0) {
             $sub_where .= " AND price = ?";
             $this->arrVal[] = intval($this->arrSql['search_course']);
         }
         $where .= "WHEN carrier = 1 THEN " . PHP_EOL;
         // docomo
         $where .= sprintf("     customer_id IN (%s) " . PHP_EOL, $objQuery->getSql("customer_id", $dt, $sub_where));
     }
     if ($a) {
         $sub_where = "continue_account_id IS NOT NULL";
         if ($this->strlen('search_docomo_site_id') > 0) {
             // サイト ID を指定した場合は 検索対象から除外
             $sub_where .= " AND FALSE ";
         }
         if ($this->strlen('search_course') > 0) {
             $sub_where .= " AND amount = ?";
             $this->arrVal[] = intval($this->arrSql['search_course']);
         }
         $where .= "WHEN carrier = 2 THEN " . PHP_EOL;
         // au-kddi
         $where .= sprintf("     customer_id IN (%s) " . PHP_EOL, $objQuery->getSql("customer_id", $at, $sub_where));
     }
     $where .= "ELSE FALSE END" . PHP_EOL;
     $this->setWhere($where);
     unset($where);
     $objQuery->setGroupBy("");
     $objQuery->setOption("");
     // 有効なメルマガ会員か本登録ユーザー
     $where = "CASE WHEN email LIKE ? THEN TRUE ELSE mailmaga_flg <> 3 END " . PHP_EOL;
     $this->arrVal[] = $this->addSearchStr("@" . $_SERVER['SERVER_NAME']);
     $this->setWhere($where);
     if ($this->is_array("search_customer_type")) {
         switch ($this->sum("search_customer_type")) {
             case "1":
                 $this->setWhere('mailmaga_flg = 3');
                 break;
             case "2":
                 $this->setWhere('mailmaga_flg <> 3');
                 break;
         }
     }
     if ($this->strlen("search_point")) {
         $this->setWhere('point >= ? ' . PHP_EOL);
         $this->arrVal[] = intval($this->arrSql['search_point']);
     }
     // carrier
     if ($this->strlen("search_carrier")) {
         $this->setWhere(' carrier = ? ' . PHP_EOL);
         $this->arrVal[] = intval($this->arrSql['search_carrier']);
     } else {
     }
     if ($mode == 'customer') {
         // 登録日を示すカラム
         $regdate_col = 'dtb_customer.update_date DESC';
         $this->setOrder($regdate_col);
     } elseif ($mode == 'DuplicateSiteId') {
         if (SC_Helper_DB::sfColumnExists("cp_dtb_customer_docomo_mymenu", "customer_id")) {
             $arrPaymentType = array("USER1", "USER10", "USER12");
             $this->arrVal = array_merge($this->arrVal, $arrPaymentType);
             $objSql = new SC_SelectSql();
             $objSql->setWhere("del_flg = 0");
             $objSql->setItemTerm($arrPaymentType, "payment_type");
             $objSql->setSelect("SELECT customer_id FROM cp_dtb_customer_docomo_mymenu ");
             $objSql->setGroup("customer_id HAVING count(site_id) > 1");
             $inquery = $objSql->getSql(2);
             $this->setWhere("customer_id IN ({$inquery})");
         }
         $regdate_col = 'dtb_customer.customer_id DESC';
         $this->setOrder($regdate_col);
     }
 }
예제 #3
0
 /**
  * 開始行番号, 行数を指定して管理者データを取得する.
  *
  * @access private
  * @param integer $startno 開始行番号
  * @return array 管理者データの連想配列
  */
 function getMemberData($startno)
 {
     $objSql = new SC_SelectSql();
     $objSql->setSelect("SELECT member_id,name,department,login_id,authority,rank,work FROM dtb_member");
     $objSql->setOrder("rank DESC");
     $objSql->setWhere("del_flg <> 1 AND member_id <> " . ADMIN_ID);
     $objSql->setLimitOffset(MEMBER_PMAX, $startno);
     $objQuery = new SC_Query();
     $arrMemberData = $objQuery->getAll($objSql->getSql());
     return $arrMemberData;
 }
 /**
  * ポイント履歴集計
  */
 public function lfGetCustmoerPointHistory($type, $sdate, $edate)
 {
     $objQuery = SC_Query_Ex::getSingletonInstance();
     list($where, $arrWhereVal) = $this->lfGetWhereMember('create_date', $sdate, $edate, $type);
     $objSql = new SC_SelectSql();
     $objSql->setWhere($where);
     if (is_numeric($_REQUEST["search_customer_id"])) {
         $arrWhereVal[] = intval($_REQUEST["search_customer_id"]);
         $objSql->setWhere("customer_id = ? ");
     }
     // いずれかのポイントが 0 出ない場合出力する
     $objSql->setWhereByOR(array(array("column" => "NOT add_point", "value" => 0), array("column" => "NOT use_point", "value" => 0), array("column" => "NOT lost_point", "value" => 0)));
     $where = $objSql->getWhere(false);
     switch ($type) {
         case 'month':
             $xtitle = '(月別)';
             $ytitle = '(ポイント)';
             $db_format = 'YYYY-MM';
             $db_format2 = 'YYYY-MM';
             break;
         case 'year':
             $xtitle = '(年別)';
             $ytitle = '(ポイント)';
             $db_format = 'YYYY';
             $db_format2 = 'YYYY';
             break;
         case 'wday':
             $xtitle = '(曜日別)';
             $ytitle = '(ポイント)';
             $db_format = 'Dy';
             $db_format2 = 'ID';
             break;
         case 'hour':
             $xtitle = '(時間別)';
             $ytitle = '(ポイント)';
             $db_format = 'HH24';
             $db_format2 = 'HH24';
             break;
         default:
             $xtitle = '(日別)';
             $ytitle = '(ポイント)';
             $db_format = 'YYYY-MM-DD';
             $db_format2 = 'YYYY-MM-DD';
             $xincline = true;
             break;
     }
     $col = "\n    TO_CHAR(create_date, '{$db_format}')        AS str_date,\n    TO_CHAR(create_date, '{$db_format2}')       AS str_date2,\n    COUNT(*)                                  AS total_history,\n    SUM(add_point)                            AS add_point,\n    SUM(use_point)                            AS use_point,\n    SUM(lost_point)                           AS lost_point,\n    SUM(use_point + lost_point)               AS minus_point,\n    SUM(add_point - (use_point + lost_point)) AS total\n";
     $objQuery->setGroupBy('str_date,str_date2');
     $objQuery->setOrder('str_date2');
     // 検索結果の取得
     $arrTotalResults = $objQuery->select($col, 'cp_dtb_point_history', $where, $arrWhereVal);
     $arrTotalResults = is_array($arrTotalResults) ? $arrTotalResults : array();
     $arrTotalResults = $this->lfAddBlankLine($arrTotalResults, $type, $sdate, $edate);
     // todo GDない場合の処理
     $tpl_image = $this->lfGetGraphLine($arrTotalResults, 'str_date', 'term_' . $type, $xtitle, $ytitle, $sdate, $edate, $xincline);
     GC_Utils_Ex::gfDebugLog($tpl_image);
     $this->xtitle = $xtitle;
     $arrCsvResults = $arrTotalResults;
     if ($this->getMode() != "csv") {
         $arrTotalResults[] = array("str_date" => "合計", "total_history" => array_sum(SC_Utils_Ex::sfArrKeyValue($arrTotalResults, "str_date", 'total_history')), "add_point" => array_sum(SC_Utils_Ex::sfArrKeyValue($arrTotalResults, "str_date", 'add_point')), "use_point" => array_sum(SC_Utils_Ex::sfArrKeyValue($arrTotalResults, "str_date", 'use_point')), "lost_point" => array_sum(SC_Utils_Ex::sfArrKeyValue($arrTotalResults, "str_date", 'lost_point')), "minus_point" => array_sum(SC_Utils_Ex::sfArrKeyValue($arrTotalResults, "str_date", 'minus_point')), "total" => array_sum(SC_Utils_Ex::sfArrKeyValue($arrTotalResults, "str_date", 'total')), "total_history_sum" => array_sum(SC_Utils_Ex::sfArrKeyValue($arrTotalResults, "str_date", 'total_history')), "total_sum" => array_sum(SC_Utils_Ex::sfArrKeyValue($arrTotalResults, "str_date", 'total')));
     }
     return array($arrTotalResults, $tpl_image, $arrCsvResults);
 }