Source for file LC_Page_Admin_Customer.php

Documentation is available at LC_Page_Admin_Customer.php

  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.lockon.co.jp/
  8.  *
  9.  * This program is free software; you can redistribute it and/or
  10.  * modify it under the terms of the GNU General Public License
  11.  * as published by the Free Software Foundation; either version 2
  12.  * of the License, or (at your option) any later version.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to the Free Software
  21.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  22.  */
  23.  
  24. // {{{ requires
  25. require_once(CLASS_PATH . "pages/LC_Page.php");
  26.  
  27. /**
  28.  * 顧客管理 のページクラス.
  29.  *
  30.  * @package Page
  31.  * @author LOCKON CO.,LTD.
  32.  * @version $Id$
  33.  */
  34. class LC_Page_Admin_Customer extends LC_Page {
  35.  
  36.     // }}}
  37.     // {{{ functions
  38.  
  39.     /**
  40.      * Page を初期化する.
  41.      *
  42.      * @return void 
  43.      */
  44.     function init() {
  45.         parent::init();
  46.         $this->tpl_mainpage = 'customer/index.tpl';
  47.         $this->tpl_mainno = 'customer';
  48.         $this->tpl_subnavi = 'customer/subnavi.tpl';
  49.         $this->tpl_subno = 'index';
  50.         $this->tpl_pager = TEMPLATE_DIR . 'admin/pager.tpl';
  51.         $this->tpl_subtitle = '顧客マスタ';
  52.  
  53.         $masterData = new SC_DB_MasterData_Ex();
  54.         $this->arrPref = $masterData->getMasterData("mtb_pref",
  55.                              array("pref_id", "pref_name", "rank"));
  56.  
  57.         $this->arrJob = $masterData->getMasterData("mtb_job");
  58.         $this->arrJob["不明"] = "不明";
  59.         $this->arrSex = $masterData->getMasterData("mtb_sex");
  60.         $this->arrPageRows = $masterData->getMasterData("mtb_page_rows");
  61.         $this->arrMAILMAGATYPE = $masterData->getMasterData("mtb_mail_magazine_type");
  62.         $this->arrHtmlmail[''] = "すべて";
  63.         $this->arrHtmlmail[1] = $this->arrMAILMAGATYPE[1];
  64.         $this->arrHtmlmail[2] = $this->arrMAILMAGATYPE[2];
  65.  
  66.         $this->arrStatus[1] = "仮会員";
  67.         $this->arrStatus[2] = "本会員";
  68.  
  69.         //---- CSVダウンロード用
  70.         $this->arrColumnCSV = array(0  => array("sql" => "customer_id",
  71.                                                 "csv" => "customer_id",
  72.                                                 "header" => "顧客ID"),
  73.                                     1  => array("sql" => "name01",
  74.                                                 "csv" => "name01",
  75.                                                 "header" => "名前1"),
  76.                                     2  => array("sql" => "name02",
  77.                                                 "csv" => "name02",
  78.                                                 "header" => "名前2"),
  79.                                     3  => array("sql" => "kana01",
  80.                                                 "csv" => "kana01",
  81.                                                 "header" => "フリガナ1"),
  82.                                     4  => array("sql" => "kana02",
  83.                                                 "csv" => "kana02",
  84.                                                 "header" => "フリガナ2"),
  85.                                     5  => array("sql" => "zip01",
  86.                                                 "csv" => "zip01",
  87.                                                 "header" => "郵便番号1"),
  88.                                     6  => array("sql" => "zip02",
  89.                                                 "csv" => "zip02",
  90.                                                 "header" => "郵便番号2"),
  91.                                     7  => array("sql" => "pref",
  92.                                                 "csv" => "pref",
  93.                                                 "header" => "都道府県"),
  94.                                     8  => array("sql" => "addr01",
  95.                                                 "csv" => "addr01",
  96.                                                 "header" => "住所1"),
  97.                                     9  => array("sql" => "addr02",
  98.                                                 "csv" => "addr02",
  99.                                                 "header" => "住所2"),
  100.                                     10 => array("sql" => "email",
  101.                                                 "csv" => "email",
  102.                                                 "header" => "E-MAIL"),
  103.                                     11 => array("sql" => "tel01",
  104.                                                 "csv" => "tel01",
  105.                                                 "header" => "TEL1"),
  106.                                     12 => array("sql" => "tel02",
  107.                                                 "csv" => "tel02",
  108.                                                 "header" => "TEL2"),
  109.                                     13 => array("sql" => "tel03",
  110.                                                 "csv" => "tel03",
  111.                                                 "header" => "TEL3"),
  112.                                     14 => array("sql" => "fax01",
  113.                                                 "csv" => "fax01",
  114.                                                 "header" => "FAX1"),
  115.                                     15 => array("sql" => "fax02",
  116.                                                 "csv" => "fax02",
  117.                                                 "header" => "FAX2"),
  118.                                     16 => array("sql" => "fax03",
  119.                                                 "csv" => "fax03",
  120.                                                 "header" => "FAX3"),
  121.                                     17 => array("sql" => "CASE WHEN sex = 1 "
  122.                                                 . " THEN '男性' "
  123.                                                 . " ELSE '女性' END AS sex",
  124.                                                 "csv" => "sex",
  125.                                                 "header" => "性別"),
  126.                                     18 => array("sql" => "job",
  127.                                                 "csv" => "job",
  128.                                                 "header" => "職業"),
  129.                                     19 => array("sql" => "cast(birth as date) AS birth",
  130.                                                 "csv" => "birth",
  131.                                                 "header" => "誕生日"),
  132.                                     20 => array("sql" => "cast(first_buy_date as date) AS first_buy_date",
  133.                                                 "csv" => "first_buy_date",
  134.                                                 "header" => "初回購入日"),
  135.                                     21 => array("sql" => "cast(last_buy_date as date) AS last_buy_date",
  136.                                                 "csv" => "last_buy_date",
  137.                                                 "header" => "最終購入日"),
  138.                                     22 => array("sql" => "buy_times",
  139.                                                 "csv" => "buy_times",
  140.                                                 "header" => "購入回数"),
  141.                                     23 => array("sql" => "point",
  142.                                                 "csv" => "point",
  143.                                                 "header" => "ポイント残高"),
  144.                                     24 => array("sql" => "note",
  145.                                                 "csv" => "note",
  146.                                                 "header" => "備考"),
  147.                                     25 => array("sql" => "cast(create_date as date) AS create_date",
  148.                                                 "csv" => "create_date",
  149.                                                 "header" => "登録日"),
  150.                                     26 => array("sql" => "cast(update_date as date) AS update_date",
  151.                                                 "csv" => "update_date",
  152.                                                 "header" => "更新日")
  153.                                     );
  154.     }
  155.  
  156.     /**
  157.      * Page のプロセス.
  158.      *
  159.      * @return void 
  160.      */
  161.     function process() {
  162.         //---- ページ初期設定
  163.         $objQuery = new SC_Query();
  164.         $objView = new SC_AdminView();
  165.         $objDate = new SC_Date(1901);
  166.         $objDb = new SC_Helper_DB_Ex();
  167.         $this->arrYear = $objDate->getYear();   // 日付プルダウン設定
  168.         $this->arrMonth = $objDate->getMonth();
  169.         $this->arrDay = $objDate->getDay();
  170.         $this->objDate = $objDate;
  171.  
  172.         // 認証可否の判定
  173.         $objSess = new SC_Session();
  174.         SC_Utils_Ex::sfIsSuccess($objSess);
  175.  
  176.         // POST値の引き継ぎ
  177.         $this->arrForm = $_POST;
  178.  
  179.         // ページ送り用
  180.         $this->arrHidden['search_pageno'] =
  181.                 isset($_POST['search_pageno']) ? $_POST['search_pageno'] : "";
  182.  
  183.         // 検索ワードの引き継ぎ
  184.         foreach ($_POST as $key => $val) {
  185.             switch($key) {
  186.             case 'sex':
  187.             case 'status':
  188.                 $this->arrHidden[$key] = SC_Utils_Ex::sfMergeParamCheckBoxes($val);
  189.                 if(!is_array($val)) {
  190.                     $this->arrForm[$key] = split("-", $val);
  191.                 }
  192.                 break;
  193.             default:
  194.                 $this->arrHidden[$key] = $val;
  195.                 break;
  196.             }
  197.         }
  198.  
  199.         if (!isset($_POST['mode'])) $_POST['mode'] = "";
  200.  
  201.         // 顧客削除
  202.         if ($_POST['mode'] == "delete") {
  203.             $sql = "SELECT status,email FROM dtb_customer WHERE customer_id = ? AND del_flg = 0";
  204.             $result_customer = $objQuery->conn->getAll($sql, array($_POST["edit_customer_id"]));
  205.  
  206.             if ($result_customer[0]["status"] == 2) {           //本会員削除
  207.                 $arrDel = array("del_flg" => 1, "update_date" => "NOW()");
  208.                 $objQuery->conn->autoExecute("dtb_customer", $arrDel, "customer_id = " . SC_Utils_Ex::sfQuoteSmart($_POST["edit_customer_id"]) );
  209.             } elseif ($result_customer[0]["status"] == 1) {     //仮会員削除
  210.                 $sql = "DELETE FROM dtb_customer WHERE customer_id = ?";
  211.                 $objQuery->conn->query($sql, array($_POST["edit_customer_id"]));
  212.             }
  213.         }
  214.         // 登録メール再送
  215.         if ($_POST['mode'] == "resend_mail") {
  216.             $CONF = $objDb->sf_getBasisData();
  217.             $this->CONF = $CONF;
  218.             $objMailText = new SC_SiteView();
  219.             $objMailText->assignobj($this);
  220.             $mailHelper = new SC_Helper_Mail_Ex();
  221.  
  222.             $arrRet = $objQuery->select("name01, name02, secret_key, email", "dtb_customer","customer_id = ? AND del_flg <> 1 AND status = 1", array($_POST["edit_customer_id"]));
  223.  
  224.             $this->name01 = $arrRet[0]['name01'];
  225.             $this->name02 = $arrRet[0]['name02'];
  226.             $this->uniqid = $arrRet[0]['secret_key'];
  227.  
  228.  
  229.             $subject = $mailHelper->sfMakesubject('会員登録のご確認');
  230.             $toCustomerMail = $objMailText->fetch("mail_templates/customer_mail.tpl");
  231.  
  232.             $objMail = new SC_SendMail();
  233.             $objMail->setItem(
  234.                                 ''                  // 宛先
  235.                                 , $subject              // サブジェクト
  236.                                 , $toCustomerMail         // 本文
  237.                                 , $CONF["email03"]          // 配送元アドレス
  238.                                 , $CONF["shop_name"]        // 配送元 名前
  239.                                 , $CONF["email03"]          // reply_to
  240.                                 , $CONF["email04"]          // return_path
  241.                                 , $CONF["email04"]          //  Errors_to
  242.                             );
  243.             // 宛先の設定
  244.             $name = $this->name01 . $this->name02 ." 様";
  245.             $objMail->setTo($arrRet[0]["email"], $name);
  246.             $objMail->sendMail();
  247.  
  248.         }
  249.  
  250.         if ($_POST['mode'] == "search" || $_POST['mode'] == "csv"  || $_POST['mode'] == "delete" || $_POST['mode'] == "delete_all" || $_POST['mode'] == "resend_mail") {
  251.             // 入力文字の強制変換
  252.             $this->lfConvertParam();
  253.             // エラーチェック
  254.             $this->arrErr = $this->lfCheckError($this->arrForm);
  255.  
  256.             $where = "del_flg = 0";
  257.  
  258.             /* 入力エラーなし */
  259.             if (count($this->arrErr) == 0) {
  260.  
  261.                 //-- 検索データ取得
  262.                 $objSelect = new SC_CustomerList($this->arrForm, "customer");
  263.  
  264.                 // 表示件数設定
  265.                 $page_rows = $this->arrForm['page_rows'];
  266.                 if(is_numeric($page_rows)) {
  267.                     $page_max = $page_rows;
  268.                 } else {
  269.                     $page_max = SEARCH_PMAX;
  270.                 }
  271.  
  272.                 if (!isset($this->arrForm['search_pageno'])) $this->arrForm['search_pageno'] = "";
  273.  
  274.                 if ($this->arrForm['search_pageno'] == 0){
  275.                     $this->arrForm['search_pageno'] = 1;
  276.                 }
  277.  
  278.                 $offset = $page_max * ($this->arrForm['search_pageno'] - 1);
  279.                 $objSelect->setLimitOffset($page_max, $offset);
  280.  
  281.                 if ($_POST["mode"] == 'csv') {
  282.                     $searchSql = $objSelect->getListCSV($this->arrColumnCSV);
  283.                 }else{
  284.                     $searchSql = $objSelect->getList();
  285.                 }
  286.  
  287.                 $this->search_data = $objQuery->conn->getAll($searchSql, $objSelect->arrVal);
  288.  
  289.                 switch($_POST['mode']) {
  290.                 case 'csv':
  291.                     require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php");
  292.  
  293.                     $objCSV = new SC_Helper_CSV_Ex();
  294.                     $i = 0;
  295.                     $header = "";
  296.  
  297.                     // CSVカラム取得
  298.                     $arrCsvOutput = ($objCSV->sfgetCsvOutput(2, " WHERE csv_id = 2 AND status = 1"));
  299.  
  300.                     if (count($arrCsvOutput) <= 0) break;
  301.  
  302.                     foreach($arrCsvOutput as $data) {
  303.                         $arrColumn[] = $data["col"];
  304.                         if ($i != 0) $header .= ", ";
  305.                         $header .= $data["disp_name"];
  306.                         $i ++;
  307.                     }
  308.                     $header .= "\n";
  309.  
  310.                     //- 都道府県/職業の変換
  311.                     for($i = 0; $i < count($this->search_data); $i ++) {
  312.                         $this->search_data[$i]["pref"] = $this->arrPref[ $this->search_data[$i]["pref"] ];
  313.                         $this->search_data[$i]["job"]  = $this->arrJob[ $this->search_data[$i]["job"] ];
  314.                     }
  315.  
  316.                     //- CSV出力
  317.                     $data = SC_Utils_Ex::getCSVData($this->search_data, $arrColumn);
  318.  
  319.                     SC_Utils_Ex::sfCSVDownload($header.$data);
  320.                     exit;
  321.                     break;
  322.                 case 'delete_all':
  323.                     // 検索結果をすべて削除
  324.                     $where = "product_id IN (SELECT product_id FROM vw_products_nonclass AS noncls WHERE $where)";
  325.                     $sqlval['del_flg'] = 1;
  326.                     $objQuery->update("dtb_products", $sqlval, $where, $arrval);
  327.  
  328.                     $sql = "SELECT status,email FROM dtb_customer WHERE customer_id = ? AND del_flg = 0";
  329.                     $result_customer = $objQuery->conn->getAll($sql, array($_POST["del_customer_id"]));
  330.  
  331.                     if ($result_customer[0]["status"] == 2) {           //本会員削除
  332.                         $arrDel = array("del_flg" => 1, "update_date" => "NOW()");
  333.                         $objQuery->conn->autoExecute("dtb_customer", $arrDel, "customer_id = " . SC_Utils_Ex::sfQuoteSmart($_POST["del_customer_id"]) );
  334.                     } elseif ($result_customer[0]["status"] == 1) {     //仮会員削除
  335.                         $sql = "DELETE FROM dtb_customer WHERE customer_id = ?";
  336.                         $objQuery->conn->query($sql, array($_POST["del_customer_id"]));
  337.                     }
  338.  
  339.                     break;
  340.                 default:
  341.  
  342.                     // 行数の取得
  343.                     $linemax = $objQuery->conn->getOne( $objSelect->getListCount(), $objSelect->arrVal);
  344.                     $this->tpl_linemax = $linemax;              // 何件が該当しました。表示用
  345.  
  346.                     // ページ送りの取得
  347.                     $objNavi = new SC_PageNavi($this->arrHidden['search_pageno'],
  348.                                                $linemax, $page_max,
  349.                                                "fnCustomerPage", NAVI_PMAX);
  350.                     $startno = $objNavi->start_row;
  351.                     $this->arrPagenavi = $objNavi->arrPagenavi;
  352.                 }
  353.             }
  354.         }
  355.  
  356.         $this->arrCatList = $objDb->sfGetCategoryList();
  357.  
  358.         //---- ページ表示
  359.         $objView->assignobj($this);
  360.         $objView->display(MAIN_FRAME);
  361.     }
  362.  
  363.     /**
  364.      * デストラクタ.
  365.      *
  366.      * @return void 
  367.      */
  368.     function destroy() {
  369.         parent::destroy();
  370.     }
  371.  
  372.     //---- 取得文字列の変換
  373.     function lfConvertParam() {
  374.         /*
  375.          *  文字列の変換
  376.          *  K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
  377.          *  C :  「全角ひら仮名」を「全角かた仮名」に変換
  378.          *  V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
  379.          *  n :  「全角」数字を「半角(ハンカク)」に変換
  380.          *  a :  全角英数字を半角英数字に変換する
  381.          */
  382.         // カラム名とコンバート情報
  383.         $arrConvList['customer_id'] = "n" ;
  384.         $arrConvList['name'] = "aKV" ;
  385.         $arrConvList['pref'] = "n" ;
  386.         $arrConvList['kana'] = "CKV" ;
  387.         $arrConvList['b_start_year'] = "n" ;
  388.         $arrConvList['b_start_month'] = "n" ;
  389.         $arrConvList['b_start_day'] = "n" ;
  390.         $arrConvList['b_end_year'] = "n" ;
  391.         $arrConvList['b_end_month'] = "n" ;
  392.         $arrConvList['b_end_day'] = "n" ;
  393.         $arrConvList['tel'] = "n" ;
  394.         $arrConvList['birth_month'] = "n" ;
  395.         $arrConvList['email'] = "a" ;
  396.         $arrConvList['buy_total_from'] = "n" ;
  397.         $arrConvList['buy_total_to'] = "n" ;
  398.         $arrConvList['buy_times_from'] = "n" ;
  399.         $arrConvList['buy_times_to'] = "n" ;
  400.         $arrConvList['start_year'] = "n" ;
  401.         $arrConvList['start_month'] = "n" ;
  402.         $arrConvList['start_day'] = "n" ;
  403.         $arrConvList['end_year'] = "n" ;
  404.         $arrConvList['end_month'] = "n" ;
  405.         $arrConvList['end_day'] = "n" ;
  406.         $arrConvList['page_rows'] = "n" ;
  407.         $arrConvList['buy_start_year'] = "n" ;      // 最終購入日 START 年
  408.         $arrConvList['buy_start_month'] = "n" ;     // 最終購入日 START 月
  409.         $arrConvList['buy_start_day'] = "n" ;       // 最終購入日 START 日
  410.         $arrConvList['buy_end_year'] = "n" ;            // 最終購入日 END 年
  411.         $arrConvList['buy_end_month'] = "n" ;       // 最終購入日 END 月
  412.         $arrConvList['buy_end_day'] = "n" ;         // 最終購入日 END 日
  413.         $arrConvList['buy_product_name'] = "aKV" ;  // 購入商品名
  414.         $arrConvList['buy_product_code'] = "aKV" ;  // 購入商品コード
  415.         $arrConvList['category_id'] = "" ;          // カテゴリ
  416.  
  417.         // 文字変換
  418.         foreach ($arrConvList as $key => $val) {
  419.             // POSTされてきた値のみ変換する。
  420.             if(isset($this->arrForm[$key])) {
  421.                 $this->arrForm[$key] = mb_convert_kana($this->arrForm[$key] ,$val);
  422.             }
  423.         }
  424.     }
  425.  
  426.     //---- 入力エラーチェック
  427.     function lfCheckError($array) {
  428.  
  429.         $objErr = new SC_CheckError($array);
  430.  
  431.         $objErr->doFunc(array("顧客コード", "customer_id", INT_LEN), array("NUM_CHECK","MAX_LENGTH_CHECK"));
  432.         $objErr->doFunc(array("都道府県", "pref", 2), array("NUM_CHECK","MAX_LENGTH_CHECK"));
  433.         $objErr->doFunc(array("顧客名", "name", STEXT_LEN), array("MAX_LENGTH_CHECK"));
  434.         $objErr->doFunc(array("顧客名(カナ)", "kana", STEXT_LEN), array("SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANABLANK_CHECK"));
  435.         $objErr->doFunc(array("誕生日(開始日)", "b_start_year", "b_start_month", "b_start_day"), array("CHECK_DATE"));
  436.         $objErr->doFunc(array("誕生日(終了日)", "b_end_year", "b_end_month", "b_end_day"), array("CHECK_DATE"));
  437.         $objErr->doFunc(array("誕生日(開始日)","誕生日(終了日)", "b_start_year", "b_start_month", "b_start_day", "b_end_year", "b_end_month", "b_end_day"), array("CHECK_SET_TERM"));
  438.         $objErr->doFunc(array("誕生月", "birth_month", 2), array("NUM_CHECK","MAX_LENGTH_CHECK"));
  439.         $objErr->doFunc(array('メールアドレス', "email", STEXT_LEN) ,array("EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
  440.         $objErr->doFunc(array('携帯メールアドレス', "email_mobile", STEXT_LEN) ,array("EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
  441.         $objErr->doFunc(array("電話番号", "tel", TEL_LEN), array("NUM_CHECK","MAX_LENGTH_CHECK"));
  442.         $objErr->doFunc(array("購入金額(開始)", "buy_total_from", INT_LEN), array("NUM_CHECK","MAX_LENGTH_CHECK"));
  443.         $objErr->doFunc(array("購入金額(終了)", "buy_total_to", INT_LEN), array("NUM_CHECK","MAX_LENGTH_CHECK"));
  444.         if ( (is_numeric($array["buy_total_from"]) && is_numeric($array["buy_total_to"]) ) && ($array["buy_total_from"] > $array["buy_total_to"]) ) $objErr->arrErr["buy_total_from"] .= "※ 購入金額の指定範囲が不正です。";
  445.         $objErr->doFunc(array("購入回数(開始)", "buy_times_from", INT_LEN), array("NUM_CHECK","MAX_LENGTH_CHECK"));
  446.         $objErr->doFunc(array("購入回数(終了)", "buy_times_to", INT_LEN), array("NUM_CHECK","MAX_LENGTH_CHECK"));
  447.         if ( (is_numeric($array["buy_times_from"]) && is_numeric($array["buy_times_to"]) ) && ($array["buy_times_from"] > $array["buy_times_to"]) ) $objErr->arrErr["buy_times_from"] .= "※ 購入回数の指定範囲が不正です。";
  448.         $objErr->doFunc(array("登録・更新日(開始日)", "start_year", "start_month", "start_day",), array("CHECK_DATE"));
  449.         $objErr->doFunc(array("登録・更新日(終了日)", "end_year", "end_month", "end_day"), array("CHECK_DATE"));
  450.         $objErr->doFunc(array("登録・更新日(開始日)","登録・更新日(終了日)", "start_year", "start_month", "start_day", "end_year", "end_month", "end_day"), array("CHECK_SET_TERM"));
  451.         $objErr->doFunc(array("表示件数", "page_rows", 3), array("NUM_CHECK","MAX_LENGTH_CHECK"));
  452.         $objErr->doFunc(array("最終購入日(開始日)", "buy_start_year", "buy_start_month", "buy_start_day",), array("CHECK_DATE"));   //最終購入日(開始日)
  453.         $objErr->doFunc(array("最終購入(終了日)", "buy_end_year", "buy_end_month", "buy_end_day"), array("CHECK_DATE"));            //最終購入日(終了日)
  454.         //購入金額(from) > 購入金額(to) の場合はエラーとする
  455.         $objErr->doFunc(array("最終購入日(開始日)","登録・更新日(終了日)", "buy_start_year", "buy_start_month", "buy_start_day", "buy_end_year", "buy_end_month", "buy_end_day"), array("CHECK_SET_TERM"));
  456.         $objErr->doFunc(array("購入商品コード", "buy_product_code", STEXT_LEN), array("MAX_LENGTH_CHECK"));                     //購入商品コード
  457.         $objErr->doFunc(array("購入商品名", "buy_product_name", STEXT_LEN), array("MAX_LENGTH_CHECK"));                         //購入商品名称
  458.  
  459.         return $objErr->arrErr;
  460.     }
  461.  
  462.     function lfSetWhere($arrForm){
  463.         foreach ($arrForm as $key => $val) {
  464.  
  465.             $val = sfManualEscape($val);
  466.  
  467.             if($val == "") continue;
  468.  
  469.             switch ($key) {
  470.             case 'product_id':
  471.                 $where .= " AND product_id = ?";
  472.                 $arrval[] = $val;
  473.                 break;
  474.             case 'product_class_id':
  475.                 $where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_class_id = ?)";
  476.                 $arrval[] = $val;
  477.                 break;
  478.             case 'name':
  479.                 $where .= " AND name ILIKE ?";
  480.                 $arrval[] = "%$val%";
  481.                 break;
  482.             case 'category_id':
  483.                 list($tmp_where, $tmp_arrval) = sfGetCatWhere($val);
  484.                 if($tmp_where != "") {
  485.                     $where.= " AND $tmp_where";
  486.                     $arrval = array_merge($arrval, $tmp_arrval);
  487.                 }
  488.                 break;
  489.             case 'product_code':
  490.                 $where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code ILIKE ? GROUP BY product_id)";
  491.                 $arrval[] = "%$val%";
  492.                 break;
  493.             case 'startyear':
  494.                 $date = sfGetTimestamp($_POST['startyear'], $_POST['startmonth'], $_POST['startday']);
  495.                 $where.= " AND update_date >= ?";
  496.                 $arrval[] = $date;
  497.                 break;
  498.             case 'endyear':
  499.                 $date = sfGetTimestamp($_POST['endyear'], $_POST['endmonth'], $_POST['endday']);
  500.                 $where.= " AND update_date <= ?";
  501.                 $arrval[] = $date;
  502.                 break;
  503.             case 'product_flag':
  504.                 global $arrSTATUS;
  505.                 $product_flag = sfSearchCheckBoxes($val);
  506.                 if($product_flag != "") {
  507.                     $where.= " AND product_flag LIKE ?";
  508.                     $arrval[] = $product_flag;
  509.                 }
  510.                 break;
  511.             case 'status':
  512.                 $tmp_where = "";
  513.                 foreach ($val as $element){
  514.                     if ($element != ""){
  515.                         if ($tmp_where == ""){
  516.                             $tmp_where.="AND (status LIKE ? ";
  517.                         }else{
  518.                             $tmp_where.="OR status LIKE ? ";
  519.                         }
  520.                         $arrval[]=$element;
  521.                     }
  522.                 }
  523.                 if ($tmp_where != ""){
  524.                     $tmp_where.=")";
  525.                     $where.= "$tmp_where";
  526.                 }
  527.                 break;
  528.             default:
  529.                 break;
  530.             }
  531.         }
  532.     }
  533. }
  534. ?>

Documentation generated on Tue, 28 Apr 2009 18:11:01 +0900 by phpDocumentor 1.4.2