<?php
/**
 * @copyright ONE/DEPO Project
 * @license   PHP License 3.01 <http://www.php.net/license/3_01.txt>
 */


/**
 * @package     Onedepo.Db.Systeminfo
 * @access      public
 */
class Onedepo_Db_Systeminfo
{
    var $dbaccess;


    function selectAll()
    {
        $log =& LogFactory::getLog();
        $func_name = "Onedepo_Db_Systeminfo#selectAll";

        $db = $this->dbaccess->doConnect();
        $db->setFetchMode(DB_FETCHMODE_ASSOC);

        $sql  = "SELECT * FROM t_systeminfo";
        $sql .= " WHERE validflg=TRUE";
        
        $log->debug($sql, $func_name);

        $data = $db->getAll($sql, $params);
        $this->dbaccess->doClose($db);

        return $data;
    }
    
    /**
     * 更新取得
     *
     */
    function update($shopnm, $shopcontent, $buynote, $updcnt)
    {
        $log =& LogFactory::getLog();
        $func_name = "Onedepo_Db_Systeminfo#update";

        // 更新ユーザ
        $adminauth =& AdminAuthext::getInstance();
        $upduser = $adminauth->getAuthData("membernm");
        $log->debug("membernm", $upduser);
        //--

        $db = $this->dbaccess->doConnect();
        $params = array($shopnm, $shopcontent, $buynote, $upduser, $_SERVER['REMOTE_ADDR'], $updcnt);

        $sql  = "SELECT * FROM f_systeminfo_update (2, ?, ?, ?, ?, ?, ?);";
        $res = $db->getOne($sql, $params);

        if (DB::isError($res) || $res < 0) {
            $log->error("rollback ".$res->userinfo, $func_name);
            return false;
        }

        $this->dbaccess->doClose($db);
        return true;
    }

    /**
     * SEO設定更新
     *
     */
    function seo_update($meta_keywords, $meta_description, $updcnt)
    {
        $log =& LogFactory::getLog();
        $func_name = "Onedepo_Db_Systeminfo#seo_update";

        // 更新ユーザ
        $adminauth =& AdminAuthext::getInstance();
        $upduser = $adminauth->getAuthData("membernm");
        $log->debug("membernm", $upduser);
        //--

        $db = $this->dbaccess->doConnect();
        $params = array($meta_keywords, $meta_description, $upduser, $_SERVER['REMOTE_ADDR'], $updcnt);

        $sql  = "SELECT * FROM f_systeminfo_seo_update (2, ?, ?, ?, ?, ?);";
        $res = $db->getOne($sql, $params);

        if (DB::isError($res) || $res < 0) {
            $log->error("rollback ".$res->userinfo, $func_name);
            return false;
        }

        $this->dbaccess->doClose($db);
        return true;
    }
    
    /**
     * HTML設定更新
     *
     */
    function html_update($company_overview, $privacy_policy, $transaction_law, $permit_rule,$method_payment, $use_rule, $updcnt)
    {
        $log =& LogFactory::getLog();
        $func_name = "Onedepo_Db_Systeminfo#html_update";

        // 更新ユーザ
        $adminauth =& AdminAuthext::getInstance();
        $upduser = $adminauth->getAuthData("membernm");
        $log->debug("membernm", $upduser);
        //--

        $db = $this->dbaccess->doConnect();
        $params = array(
            $company_overview, 
            $privacy_policy, 
            $transaction_law, 
            $permit_rule, 
            $method_payment, 
            $use_rule, 
            
            $upduser,
            $_SERVER['REMOTE_ADDR'], 
            $updcnt
        );

        $sql  = "SELECT * FROM f_systeminfo_html_update (2, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
        $res = $db->getOne($sql, $params);

        if (DB::isError($res) || $res < 0) {
            $log->error("rollback ".$res->userinfo, $func_name);
            return false;
        }

        $this->dbaccess->doClose($db);
        return true;
    }
    
    /**
     * 銀行情報更新
     *
     */
    function bank_update($bankname, $shitenname, $shitennumberkey, $kouzadiv, $kouzanumberkey, $kouzaname, $updcnt)
    {
        $log =& LogFactory::getLog();
        $func_name = "Onedepo_Db_Systeminfo#bank_update";

        // 更新ユーザ
        $adminauth =& AdminAuthext::getInstance();
        $upduser = $adminauth->getAuthData("membernm");
        $log->debug("membernm", $upduser);
        //--

        $db = $this->dbaccess->doConnect();
        $params = array($bankname, $shitenname, $shitennumberkey, $kouzadiv, $kouzanumberkey, $kouzaname, $upduser, $_SERVER['REMOTE_ADDR'], $updcnt);

        $sql  = "SELECT * FROM f_systeminfo_bank_update (2, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
        $res = $db->getOne($sql, $params);

        if (DB::isError($res) || $res < 0) {
            
            $log->error("rollback ".$res->userinfo, $func_name);
            return false;
        }

        $this->dbaccess->doClose($db);
        return true;
    }
    
    /**
     * デザイン設定更新
     *
     */
    function design_update($design_css, $updcnt)
    {
        $log =& LogFactory::getLog();
        $func_name = "Onedepo_Db_Systeminfo#design_update";

        // 更新ユーザ
        $adminauth =& AdminAuthext::getInstance();
        $upduser = $adminauth->getAuthData("membernm");
        $log->debug("membernm", $upduser);
        //--

        $db = $this->dbaccess->doConnect();
        $params = array($design_css, $upduser, $_SERVER['REMOTE_ADDR'], $updcnt);

        $sql  = "SELECT * FROM f_systeminfo_design_update (2, ?, ?, ?, ?);";
        $res = $db->getOne($sql, $params);

        if (DB::isError($res) || $res < 0) {
            $log->error("rollback ".$res->userinfo, $func_name);
            return false;
        }

        $this->dbaccess->doClose($db);
        return true;
    }
}
?>
