<?php
trait FUNCTN {
/*----------------------------------------------------------------------------*/
/* Construct                                                                  */
/*----------------------------------------------------------------------------*/
    private function __construct($CL) {
        $CL['LG']->cLog('T0001');
        // 共通クラスを保持
        $this->CL = $CL;
    }
    
/*----------------------------------------------------------------------------*/
/* Clone                                                                      */
/*----------------------------------------------------------------------------*/
    public final function __clone() {
        $CL['LG']->cLog('S0002');
    }
    
/*----------------------------------------------------------------------------*/
/* Variable                                                                   */
/*----------------------------------------------------------------------------*/
/*------------------------------------*/
/* Public                             */
/*------------------------------------*/


/*------------------------------------*/
/* Private                            */
/*------------------------------------*/
    private static $instance = [];

/*------------------------------------*/
/* Protected                          */
/*------------------------------------*/
    protected $CL;


/*----------------------------------------------------------------------------*/
/* Public Function                                                            */
/*----------------------------------------------------------------------------*/
    // インスタンス作成
    public static function getInstance($CL) {
        $CL['LG']->cLog('T0002');
        $class = get_called_class();
        if (!isset(self::$instance[$class])) self::$instance[$class] = new $class($CL);
        return self::$instance[$class];
    }


/*--------------------------------------------------------*/
/* Url系                                                  */
/*--------------------------------------------------------*/
    /*--------------------------------------------------------------------------*/
    /* 現在のURLを取得する                                                      */
    /* Arg1:flg                                                                 */
    /*      gAddGetURL_nonDel        :URLのパラメタを削除しない                 */
    /*      gAddGetURL_delParam      :URLのパラメタ(全て)を削除する             */
    /*      gAddGetURL_delParamLang  :URLのパラメタ(lang)を削除する             */
    /*      gAddGetURL_delParamSame1 :URLのパラメタ(lang/pages/Reset)を削除する */
    /*      gAddGetURL_delParamSame2 :URLのパラメタ(lang/xls)を削除する         */
    /* Ret :現在のURL                                                           */
    /*--------------------------------------------------------------------------*/
    public function gCurrentURL($flg) {
        $this->CL['LG']->cLog('T0002');
        $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
        switch ($flg) {
            case $this->CL['DF']->gAddGetURL_nonDel:            // URLのパラメタを削除しない
                return $url;
            case $this->CL['DF']->gAddGetURL_delParam:          // URLのパラメタ(全て)を削除する
                return strtok($url, '?');
            case $this->CL['DF']->gAddGetURL_delParamLang:      // URLのパラメタ(lang)を削除する
                $url = preg_replace('/[&|?]lang=[0-2]/', '', $url);
                return $url;
            case $this->CL['DF']->gAddGetURL_delParamSame1:     // URLのパラメタ(lang/pages/Reset)を削除する
                $url = preg_replace('/[&|?]xls=on/', '', $url);
                $url = preg_replace('/[&|?]lang=[0-2]/', '', $url);
                $url = preg_replace('/[&|?]pages=[0-9]*/', '', $url);
                $url = preg_replace('/[&|?]Reset=(%|[a-z]|[A-Z]|[0-9])*/', '', $url);
                return $url;
            case $this->CL['DF']->gAddGetURL_delParamSame2:     // URLのパラメタ(lang/xls)を削除する
                $url = preg_replace('/[&|?]xls=on/', '', $url);
                $url = preg_replace('/[&|?]lang=[0-2]/', '', $url);
                return $url;
        }
    }
    
    /*--------------------------------------------------------------------------*/
    /* 現在のURLにパラメタを付与する                                            */
    /* Arg1:param                                                               */
    /*      パラメタ文字列                                                      */
    /* Arg2:flg                                                                 */
    /*      gAddGetURL_nonDel        :URLのパラメタを削除しない                 */
    /*      gAddGetURL_delParam      :URLのパラメタ(全て)を削除する             */
    /*      gAddGetURL_delParamLang  :URLのパラメタ(lang)を削除する             */
    /*      gAddGetURL_delParamSame1 :URLのパラメタ(lang/pages/Reset)を削除する */
    /*      gAddGetURL_delParamSame2 :URLのパラメタ(lang/xls)を削除する         */
    /* Ret :現在のURLにパラメタを付与したURL                                    */
    /*--------------------------------------------------------------------------*/
    public function gAddGetURL($param, $flg) {
        $this->CL['LG']->cLog('T0002');
        $url = self::gCurrentURL($flg).'?&'.$param;
        
        if (strpos($url, '?') === false) {
            return $url;
        } else {
            // 文字列に'?'が含まれる場合、文字列の'??'は一律'?'に置換
            $url = str_replace('??', '?', $url);
            
            if (substr_count($url, '?&') > 0) {
                // '?&'は'&'に置換
                $url = str_replace('?&', '&', $url);
            }
            
            if (substr_count($url, '.php&') > 0) {
                // '.php'直後に'&'が存在する場合、'?'に置換
                $url = str_replace('.php&', '.php?', $url);
            }
        }
        return $url;
    }
    
    /*------------------------------------------------------------*/
    /* 現在のファイル名を取得する                                 */
    /* Arg1:flg                                                   */
    /*      gCurrentFile_nonDel       :URLのパラメタを削除しない  */
    /*      gCurrentFile_delParam     :URLのパラメタを削除する    */
    /*      gCurrentFile_delExtension :拡張子を削除する           */
    /* Ret :現在のURL                                             */
    /*------------------------------------------------------------*/
    public function gCurrentFile($flg) {
        $this->CL['LG']->cLog('T0002');
        $file = basename($_SERVER['PHP_SELF']);
        
        switch ($flg) {
            case $this->CL['DF']->gCurrentFile_nonDel:          // URLのパラメタを削除しない
                return $file;
            case $this->CL['DF']->gCurrentFile_delParam:        // URLのパラメタを削除する
                return strtok($file, '?');
            case $this->CL['DF']->gCurrentFile_delExtension:    // 拡張子を削除する
                $file = pathinfo($file);
                return $file['filename'];
        }
    }
    /*------------------------------------------------------------*/
    /* 指定されたファイルの最終更新日時を取得する                         */
    /* Arg1:file        :最終更新日時を取得する対象のファイル           */
    /* Arg2:flg                                                   */
    /*      1    : SSMMHHDDMMYYYY                                 */
    /*      else : YYYYMMDDHHMMSS                                 */
    /* Ret :ファイルの最終更新日時を文字列に変換したもの                  */
    /*------------------------------------------------------------*/
    public function gFileUpdateDate($file, $flg = NULL) {
        $this->CL['LG']->cLog('T0002');
        $ret = '';

        $DateTime = filemtime($file);
        if ($flg == '1') {
            $ret = date("siHdmY", $DateTime);
        } else {
            $ret = date("YmdHis", $DateTime);
        }
        return $ret;
        
    }
    
/*--------------------------------------------------------*/
/* セッション                                             */
/*--------------------------------------------------------*/
    /*------------------------------------------------------------*/
    /* デフォルトセッションを設定する(会社)                       */
    /*                                                            */
    /* Arg1:No                                                    */
    /*      ログインNo                                            */
    /* Arg2:DBHost                                                */
    /*      ホスト名(個別DB)                                      */
    /* Arg3:DBUser                                                */
    /*      ユーザ名(個別DB)                                      */
    /* Arg4:DBPassWord                                            */
    /*      パスワード(個別DB)                                    */
    /* Arg5:DBName                                                */
    /*      DB名(個別DB)                                          */
    /*------------------------------------------------------------*/
    public function setSessionLogin($LoginNo, $DBHost, $DBUser, $DBPassWord, $DBName) {
        $this->CL['LG']->cLog('T0002');
        
        // 会社情報をセット
        $_SESSION[$this->CL['DF']->SysID]['CompanyID'] = $LoginNo;
//        $_SESSION[$this->CL['DF']->SysID]['DBHost'] = $DBHost;
//        $_SESSION[$this->CL['DF']->SysID]['DBUser'] = $DBUser;
//        $_SESSION[$this->CL['DF']->SysID]['DBPassWord'] = $DBPassWord;
        $_SESSION[$this->CL['DF']->SysID]['DBName'] = $DBName;
    }
    
    /*------------------------------------------------------------*/
    /* デフォルトセッションを設定する(ユーザ)                     */
    /*                                                            */
    /* Arg1:Login                                                 */
    /*      ログイン済                                            */
    /* Arg2:DefLangID                                             */
    /*      主に使用する言語                                      */
    /* Arg3:UserName                                              */
    /*      ユーザ名                                              */
    /* Arg4:AuthorityID                                           */
    /*      ユーザ権限ID                                          */
    /* Arg5:Userid                                                */
    /*      ユーザID                                              */
    /* Arg6:Locale                                                */
    /*      ロケール                                              */
    /*------------------------------------------------------------*/
    public function setSessionUser($Login, $DefLangID, $UserName, $AuthorityID, $Userid, $Locale) {
        $this->CL['LG']->cLog('T0002');
        
//        if (!isset($_SESSION[$this->CL['DF']->SysID])) {
//            $_SESSION[$this->CL['DF']->SysID] = array();
//        }
//        if (!is_array($_SESSION[$this->CL['DF']->SysID])) {
//            $_SESSION[$this->CL['DF']->SysID] = array();
//        }
        
        // ユーザ情報をセット
        $_SESSION[$this->CL['DF']->SysID]['LanguageID'] = $DefLangID;
        $_SESSION[$this->CL['DF']->SysID]['UserID'] = $Userid;
        $_SESSION[$this->CL['DF']->SysID]['UserName'] = $UserName;
        $_SESSION[$this->CL['DF']->SysID]['AuthorityID'] = $AuthorityID;
        $_SESSION[$this->CL['DF']->SysID]['Locale'] = $Locale;
        $_SESSION[$this->CL['DF']->SysID]['Login'] = $Login;
        $_SESSION[$this->CL['DF']->SysID]['ErrLevel'] = $this->CL['CF']->ErrLevel;
    }
    
    /*------------------------------------------------------------*/
    /* セッションを全削除する                                     */
    /*                                                            */
    /*------------------------------------------------------------*/
    public function delSession() {
        $this->CL['LG']->cLog('T0002');
        $_SESSION[$this->CL['DF']->SysID] = array();
        
        if (isset($_COOKIE[session_name()])) {
            setcookie(session_name(), '', time()-42000, '/');
        }
        
        session_destroy();
    }
    
    /*------------------------------------------------------------*/
    /* デフォルトセッション以外を削除する                         */
    /*                                                            */
    /* Arg1:class                                                 */
    /*      現在のクラス名の略称                                  */
    /* Arg2:arr                                                   */
    /*      削除対象外の配列名称                                  */
    /*------------------------------------------------------------*/
    public function unsetSession($class, $arr = NULL) {
        $this->CL['LG']->cLog('T0002');
        $abbr = substr($class, $this->CL['DF']->RngClass, $this->CL['DF']->LenClass);
        
        if ((isset($_SESSION[$this->CL['DF']->SysID]['abbr'])) && ($_SESSION[$this->CL['DF']->SysID]['abbr'] == $abbr)) {
            // 同じクラス内の遷移ならば何もしない
        } else {
            // 異るクラスからの遷移ならばデフォルトセッション以外を削除
            // デフォルトセッションをバックアップ
            $bk['CompanyID']   = $_SESSION[$this->CL['DF']->SysID]['CompanyID'];
//            $bk['DBHost']      = $_SESSION[$this->CL['DF']->SysID]['DBHost'];
//            $bk['DBUser']      = $_SESSION[$this->CL['DF']->SysID]['DBUser'];
//            $bk['DBPassWord']  = $_SESSION[$this->CL['DF']->SysID]['DBPassWord'];
            $bk['DBName']      = $_SESSION[$this->CL['DF']->SysID]['DBName'];
            $bk['LanguageID']  = $_SESSION[$this->CL['DF']->SysID]['LanguageID'];
            $bk['UserID']      = $_SESSION[$this->CL['DF']->SysID]['UserID'];
            $bk['UserName']    = $_SESSION[$this->CL['DF']->SysID]['UserName'];
            $bk['AuthorityID'] = $_SESSION[$this->CL['DF']->SysID]['AuthorityID'];
            $bk['Locale']      = $_SESSION[$this->CL['DF']->SysID]['Locale'];
            $bk['Login']       = $_SESSION[$this->CL['DF']->SysID]['Login'];
            $bk['ErrLevel']    = $_SESSION[$this->CL['DF']->SysID]['ErrLevel'];
            $bk['abbr']        = $abbr;
            
            // 削除対象外をバックアップ
            if (!empty($arr) && !is_null($arr)) {
                for ($i = 0, $c = count($arr); $i < $c; $i++) {
                    if (isset($_SESSION[$this->CL['DF']->SysID][$arr[$i]])) {
                        $bk[$arr[$i]] = $_SESSION[$this->CL['DF']->SysID][$arr[$i]];
                    }
                }
            }
            
            $_SESSION[$this->CL['DF']->SysID] = array();
            $_SESSION[$this->CL['DF']->SysID] = $bk;
        }
    }
    
/*--------------------------------------------------------*/
/* フォーマット変更                                       */
/*--------------------------------------------------------*/
    /*------------------------------------------------------------*/
    /* 取引IDのフォーマットを変更する                             */
    /* Arg1:flg                                                   */
    /*      gTrnIDFmt1 : YYYYMMDD-NNNNNN → YYYYMMDD              */
    /*      gTrnIDFmt2 : YYYYMMDD-NNNNNN → NNNNNN                */
    /*      gTrnIDFmt3 : YYYYMMDD-NNNNNN → YYYYMMDD<BR>-NNNNNN   */
    /*      gTrnIDFmt4 : 取引ID桁数揃え                           */
    /*      gTrnIDFmt5 : YYYYMMDD<BR>-NNNNNN → YYYYMMDD-NNNNNN   */
    /* Arg2:val1                                                  */
    /*      flg:gTrnIDFmt1:YYYYMMDD-NNNNNN                        */
    /*      flg:gTrnIDFmt2:YYYYMMDD-NNNNNN                        */
    /*      flg:gTrnIDFmt3:YYYYMMDD-NNNNNN                        */
    /*      flg:gTrnIDFmt4:通番(0パディング無し)                  */
    /*      flg:gTrnIDFmt5:YYYYMMDD<BR>-NNNNNN                    */
    /* Ret :                                                      */
    /*      flg:gTrnIDFmt1:YYYYMMDD                               */
    /*      flg:gTrnIDFmt2:NNNNNN                                 */
    /*      flg:gTrnIDFmt3:YYYYMMDD<BR>-NNNNNN                    */
    /*      flg:gTrnIDFmt4:通番(0パディング有り)                  */
    /*      flg:gTrnIDFmt5:YYYYMMDD-NNNNNN                        */
    /*------------------------------------------------------------*/
    public function gTrnIDFmt($flg, $val1) {
        $this->CL['LG']->cLog('T0002');
        switch ($flg) {
            case $this->CL['DF']->gTrnIDFmt1:     // YYYYMMDD-NNNNNN → YYYYMMDD
                $ret = substr($val1, $this->CL['DF']->RngTrnYM, $this->CL['DF']->LenTrnYM);
                break;
            case $this->CL['DF']->gTrnIDFmt2:     // YYYYMMDD-NNNNNN → NNNNNN
                $ret = substr($val1, $this->CL['DF']->RngTrnNO, $this->CL['DF']->LenTrnNO);
                break;
            case $this->CL['DF']->gTrnIDFmt3:     // YYYYMMDD-NNNNNN → YYYYMMDD<BR>-NNNNNN
                $ret =str_replace('-', $this->CL['DF']->BR.'-', $val1);
                break;
            case $this->CL['DF']->gTrnIDFmt4:     // 取引ID桁数揃え
                $ret = self::gIntDigitFmt($val1, $this->CL['DF']->LenTrnNO);
                break;
            case $this->CL['DF']->gTrnIDFmt5:     // YYYYMMDD<BR>-NNNNNN → YYYYMMDD-NNNNNN
                $ret =str_replace($this->CL['DF']->BR.'-', '-', $val1);
                break;
        }
        return $ret;
    }
    
    /*------------------------------------------------------------*/
    /* 勘定科目名称のフォーマットを変更する                       */
    /* Arg1:flg                                                   */
    /*      gAccKindNameFmt1 : K1+K2+K3+K4+K5 → K1/K2/K3/K4/K5   */
    /*      gAccKindNameFmt2 : K1-K2-K3-K4-K5 → K1               */
    /*      gAccKindNameFmt3 : K1-K2-K3-K4-K5 → K2               */
    /*      gAccKindNameFmt4 : K1-K2-K3-K4-K5 → K3               */
    /*      gAccKindNameFmt5 : K1-K2-K3-K4-K5 → K4               */
    /*      gAccKindNameFmt6 : K1-K2-K3-K4-K5 → K5               */
    /* Arg2:val1                                                  */
    /*      flg:gAccKindNameFmt1:K1                               */
    /*      flg:gAccKindNameFmt2:無し                             */
    /*      flg:gAccKindNameFmt3:無し                             */
    /*      flg:gAccKindNameFmt4:無し                             */
    /*      flg:gAccKindNameFmt5:無し                             */
    /*      flg:gAccKindNameFmt6:無し                             */
    /* Arg3:val2                                                  */
    /*      flg:gAccKindNameFmt1:K2                               */
    /*      flg:gAccKindNameFmt2:無し                             */
    /*      flg:gAccKindNameFmt3:無し                             */
    /*      flg:gAccKindNameFmt4:無し                             */
    /*      flg:gAccKindNameFmt5:無し                             */
    /*      flg:gAccKindNameFmt6:無し                             */
    /* Arg4:val3                                                  */
    /*      flg:gAccKindNameFmt1:K3                               */
    /*      flg:gAccKindNameFmt2:無し                             */
    /*      flg:gAccKindNameFmt3:無し                             */
    /*      flg:gAccKindNameFmt4:無し                             */
    /*      flg:gAccKindNameFmt5:無し                             */
    /*      flg:gAccKindNameFmt6:無し                             */
    /* Arg5:val4                                                  */
    /*      flg:gAccKindNameFmt1:K4                               */
    /*      flg:gAccKindNameFmt2:無し                             */
    /*      flg:gAccKindNameFmt3:無し                             */
    /*      flg:gAccKindNameFmt4:無し                             */
    /*      flg:gAccKindNameFmt5:無し                             */
    /*      flg:gAccKindNameFmt6:無し                             */
    /* Arg6:val5                                                  */
    /*      flg:gAccKindNameFmt1:K5                               */
    /*      flg:gAccKindNameFmt2:無し                             */
    /*      flg:gAccKindNameFmt3:無し                             */
    /*      flg:gAccKindNameFmt4:無し                             */
    /*      flg:gAccKindNameFmt5:無し                             */
    /*      flg:gAccKindNameFmt6:無し                             */
    /* Ret :                                                      */
    /*      flg:gAccKindNameFmt1:K1/K2/K3/K4/K5                   */
    /*      flg:gAccKindNameFmt2:K1                               */
    /*      flg:gAccKindNameFmt3:K2                               */
    /*      flg:gAccKindNameFmt4:K3                               */
    /*      flg:gAccKindNameFmt5:K4                               */
    /*      flg:gAccKindNameFmt6:K5                               */
    /*------------------------------------------------------------*/
    public function gAccKindNameFmt($flg, $val1, $val2 = NULL, $val3 = NULL, $val4 = NULL, $val5 = NULL) {
        $this->CL['LG']->cLog('T0002');
        switch ($flg) {
            case $this->CL['DF']->gAccKindNameFmt1:     // K1+K2+K3+K4+K5 → K1/K2/K3/K4/K5
                if ($val1 == NULL) {
                    $ret = '';
                } else if ($val2 == NULL) {
                    $ret = $val1;
                } else if ($val3 == NULL) {
                    $ret = $val1.'/'.$val2;
                } else if ($val4 == NULL) {
                    $ret = $val1.'/'.$val2.'/'.$val3;
                } else if ($val5 == NULL) {
                    $ret = $val1.'/'.$val2.'/'.$val3.'/'.$val4;
                } else {
                    $ret = $val1.'/'.$val2.'/'.$val3.'/'.$val4.'/'.$val5;
                }
                break;
            case $this->CL['DF']->gAccKindNameFmt2:     // K1-K2-K3-K4-K5 → K1
                $ret = substr($val1, $this->CL['DF']->RngAccKind1ID, $this->CL['DF']->LenAccKind1ID);
                break;
            case $this->CL['DF']->gAccKindNameFmt3:     // K1-K2-K3-K4-K5 → K2
                $ret = substr($val1, $this->CL['DF']->RngAccKind2ID, $this->CL['DF']->LenAccKind2ID);
                break;
            case $this->CL['DF']->gAccKindNameFmt4:     // K1-K2-K3-K4-K5 → K3
                $ret = substr($val1, $this->CL['DF']->RngAccKind3ID, $this->CL['DF']->LenAccKind3ID);
                break;
            case $this->CL['DF']->gAccKindNameFmt5:     // K1-K2-K3-K4-K5 → K4
                $ret = substr($val1, $this->CL['DF']->RngAccKind4ID, $this->CL['DF']->LenAccKind4ID);
                break;
            case $this->CL['DF']->gAccKindNameFmt6:     // K1-K2-K3-K4-K5 → K5
                $ret = substr($val1, $this->CL['DF']->RngAccKind5ID, $this->CL['DF']->LenAccKind5ID);
                break;
        }
        return $ret;
    }
    
    /*------------------------------------------------------------*/
    /* 勘定科目名称のフォーマットを変更する                       */
    /* Arg1:AccLName                                              */
    /*      勘定科目名称(大項目)                                  */
    /* Arg2:AccMName                                              */
    /*      勘定科目名称(中項目)                                  */
    /* Arg3:AccSName                                              */
    /*      勘定科目名称(小項目)                                  */
    /* Ret :画面表示用勘定科目名称                                */
    /*------------------------------------------------------------*/
    public function gAccNameFmt($AccLName = NULL, $AccMName = NULL, $AccSName = NULL) {
        $this->CL['LG']->cLog('T0002');
        if ($AccLName == NULL) {
            $ret = '';
        } else if ($AccMName == NULL) {
            $ret = $AccLName;
        } else if ($AccSName == NULL) {
            $ret = $AccLName.'/'.$AccMName;
        } else {
            $ret = $AccLName.'/'.$AccMName.'/'.$AccSName;
        }
        return $ret;
    }
    
    /*------------------------------------------------------------*/
    /* ページングのフォーマットを変更する                         */
    /* Arg1:LineS                                                 */
    /*      開始ページ(行数)位置                                  */
    /* Arg2:LineE                                                 */
    /*      終了ページ(行数)位置                                  */
    /* Arg3:ResultCntAll                                          */
    /*      総ページ(行)数                                        */
    /* Ret :画面表示用ページ文言                                  */
    /*------------------------------------------------------------*/
    public function gPageFmt($LineS, $LineE, $ResultCntAll) {
        $this->CL['LG']->cLog('T0002');
        return ' ('.$LineS.' - '.$LineE.' / '.$ResultCntAll.')';
    }
    
    /*------------------------------------------------------------*/
    /* 勘定科目コードのフォーマットを変更する                     */
    /*     (大文字は固定長、小文字は可変長)                       */
    /* Arg1:flg                                                   */
    /*      gAccFmt1 : L+M+S → L-M-S                             */
    /*      gAccFmt2 : L-M-S → l                                 */
    /*      gAccFmt3 : L-M-S → m                                 */
    /*      gAccFmt4 : L-M-S → s                                 */
    /*      gAccFmt5 : L-M-S → L                                 */
    /*      gAccFmt6 : L-M-S → M                                 */
    /*      gAccFmt7 : L-M-S → S                                 */
    /* Arg2:val1                                                  */
    /*      flg:gAccFmt1:L                                        */
    /*      flg:gAccFmt2:L-M-S                                    */
    /*      flg:gAccFmt3:L-M-S                                    */
    /*      flg:gAccFmt4:L-M-S                                    */
    /*      flg:gAccFmt5:L-M-S                                    */
    /*      flg:gAccFmt6:L-M-S                                    */
    /*      flg:gAccFmt7:L-M-S                                    */
    /* Arg3:val2                                                  */
    /*      flg:gAccFmt1:M                                        */
    /*      flg:gAccFmt2:無し                                     */
    /*      flg:gAccFmt3:無し                                     */
    /*      flg:gAccFmt4:無し                                     */
    /*      flg:gAccFmt5:無し                                     */
    /*      flg:gAccFmt6:無し                                     */
    /*      flg:gAccFmt7:無し                                     */
    /* Arg4:val3                                                  */
    /*      flg:gAccFmt1:S                                        */
    /*      flg:gAccFmt2:無し                                     */
    /*      flg:gAccFmt3:無し                                     */
    /*      flg:gAccFmt4:無し                                     */
    /*      flg:gAccFmt5:無し                                     */
    /*      flg:gAccFmt6:無し                                     */
    /*      flg:gAccFmt7:無し                                     */
    /* Ret :                                                      */
    /*      flg:gAccFmt1:L-M-S                                    */
    /*      flg:gAccFmt2:l                                        */
    /*      flg:gAccFmt3:m                                        */
    /*      flg:gAccFmt4:s                                        */
    /*      flg:gAccFmt5:L                                        */
    /*      flg:gAccFmt6:M                                        */
    /*      flg:gAccFmt7:S                                        */
    /*------------------------------------------------------------*/
    public function gAccFmt($flg, $val1, $val2 = NULL, $val3 = NULL) {
        $this->CL['LG']->cLog('T0002');
        switch ($flg) {
            case $this->CL['DF']->gAccFmt1:     // L+M+S → L-M-S
                $l = self::gIntDigitFmt($val1, $this->CL['DF']->LenAccLID);
                $m = self::gIntDigitFmt($val2, $this->CL['DF']->LenAccMID);
                $s = self::gIntDigitFmt($val3, $this->CL['DF']->LenAccSID);
                $ret = $l.'-'.$m.'-'.$s;
                break;
            case $this->CL['DF']->gAccFmt2:     // L-M-S → l
                $l = (int)substr($val1, $this->CL['DF']->RngAccLID, $this->CL['DF']->LenAccLID);
                $ret = $l;
                break;
            case $this->CL['DF']->gAccFmt3:     // L-M-S → m
                $m = (int)substr($val1, $this->CL['DF']->RngAccMID, $this->CL['DF']->LenAccMID);
                $ret = $m;
                break;
            case $this->CL['DF']->gAccFmt4:     // L-M-S → s
                $s = (int)substr($val1, $this->CL['DF']->RngAccSID, $this->CL['DF']->LenAccSID);
                $ret = $s;
                break;
            case $this->CL['DF']->gAccFmt5:     // L-M-S → L
                $l = substr($val1, $this->CL['DF']->RngAccLID, $this->CL['DF']->LenAccLID);
                $ret = $l;
                break;
            case $this->CL['DF']->gAccFmt6:     // L-M-S → M
                $m = substr($val1, $this->CL['DF']->RngAccMID, $this->CL['DF']->LenAccMID);
                $ret = $m;
                break;
            case $this->CL['DF']->gAccFmt7:     // L-M-S → S
                $s = substr($val1, $this->CL['DF']->RngAccSID, $this->CL['DF']->LenAccSID);
                $ret = $s;
                break;
        }
        return $ret;
    }
    
    /*---------------------------------------------------------------------*/
    /* 年月日のフォーマットを変更する                                      */
    /*     (大文字は固定長(ex:09)、小文字は可変長(ex:9))                   */
    /* Arg1:flg                                                            */
    /*      gDateFmt1  : YYYYMMDD → YYYY/MM/DD                            */
    /*      gDateFmt2  : YYYY-MM-DD JJ:MM:SS → YYYY-MM-DD<BR>JJ:MM:SS     */
    /*      gDateFmt3  : yyyy+mm → yyyy/mm/dd(dd:月初)                    */
    /*      gDateFmt4  : yyyy+mm → yyyy/mm/dd(dd:月末)                    */
    /*      gDateFmt5  : YYYY-MM → YYYY                                   */
    /*      gDateFmt6  : YYYY-MM → MM                                     */
    /*      gDateFmt7  : YYYYMM → YYYY-MM                                 */
    /*      gDateFmt8  : YYYYMMDD → YYYY                                  */
    /*      gDateFmt9  : YYYYMMDD → MM                                    */
    /*      gDateFmt10 : YYYYMMDD → DD                                    */
    /*      gDateFmt11 : mm → MM                                          */
    /*      gDateFmt12 : dd → DD                                          */
    /*      gDateFmt13 : yyyy+mm+dd → YYYY/MM/DD                          */
    /*      gDateFmt14 : yyyy+mm+dd → YYYYMMDD                            */
    /*      gDateFmt15 : yyyy+mm → yyyy-mm                                */
    /*      gDateFmt16 : yyyy+mm → yyyy/mm                                */
    /*      gDateFmt17 : YYYY-MM-DD<BR>JJ:MM:SS → YYYY-MM-DDTJJ:MM:SS.000 */
    /*      gDateFmt18 : yyyy+mm → yyyy/mm or [All]                       */
    /*      gDateFmt19 : YYYY-MM-DD JJ:MM:SS → YYYY-MM-DDTJJ:MM:SS.000    */
    /*      gDateFmt20 : YYYYMMDDJJMMSS → YYYY/MM/DD JJ:MM:SS             */
    /*      gDateFmt21 : yyyy+mm → dd(dd:月末)                            */
    /*      gDateFmt22 : YYYYMM (val1) +/- (val2) months                  */
    /*      gDateFmt23 : YYYYMMDD (val1) +/- (val2) days                  */
    /*      gDateFmt24 : YYYYMMDD (val1) - YYYYMMDD (val2)                */
    /* Arg2:val1                                                           */
    /*      flg:gDateFmt1:YYYYMMDD                                         */
    /*      flg:gDateFmt2:YYYY-MM-DD JJ:MM:SS                              */
    /*      flg:gDateFmt3:yyyy                                             */
    /*      flg:gDateFmt4:yyyy                                             */
    /*      flg:gDateFmt5:YYYY-MM                                          */
    /*      flg:gDateFmt6:YYYY-MM                                          */
    /*      flg:gDateFmt7:YYYYMM                                           */
    /*      flg:gDateFmt8:YYYYMMDD                                         */
    /*      flg:gDateFmt9:YYYYMMDD                                         */
    /*      flg:gDateFmt10:YYYYMMDD                                        */
    /*      flg:gDateFmt11:mm                                              */
    /*      flg:gDateFmt12:dd                                              */
    /*      flg:gDateFmt13:yyyy                                            */
    /*      flg:gDateFmt14:yyyy                                            */
    /*      flg:gDateFmt15:yyyy                                            */
    /*      flg:gDateFmt16:yyyy                                            */
    /*      flg:gDateFmt17:YYYY-MM-DD<BR>JJ:MM:SS                          */
    /*      flg:gDateFmt18:yyyy                                            */
    /*      flg:gDateFmt19:YYYY-MM-DD JJ:MM:SS                             */
    /*      flg:gDateFmt20:YYYYMMDDJJMMSS                                  */
    /*      flg:gDateFmt21:yyyy                                            */
    /*      flg:gDateFmt22:YYYYMM                                          */
    /*      flg:gDateFmt23:YYYYMMDD                                        */
    /*      flg:gDateFmt24:YYYYMMDD                                        */
    /* Arg3:val2                                                           */
    /*      flg:gDateFmt1:無し                                             */
    /*      flg:gDateFmt2:無し                                             */
    /*      flg:gDateFmt3:mm                                               */
    /*      flg:gDateFmt4:mm                                               */
    /*      flg:gDateFmt5:無し                                             */
    /*      flg:gDateFmt6:無し                                             */
    /*      flg:gDateFmt7:無し                                             */
    /*      flg:gDateFmt8:無し                                             */
    /*      flg:gDateFmt9:無し                                             */
    /*      flg:gDateFmt10:無し                                            */
    /*      flg:gDateFmt11:無し                                            */
    /*      flg:gDateFmt12:無し                                            */
    /*      flg:gDateFmt13:mm                                              */
    /*      flg:gDateFmt14:mm                                              */
    /*      flg:gDateFmt15:mm                                              */
    /*      flg:gDateFmt16:mm                                              */
    /*      flg:gDateFmt17:無し                                            */
    /*      flg:gDateFmt18:mm                                              */
    /*      flg:gDateFmt19:無し                                            */
    /*      flg:gDateFmt20:無し                                            */
    /*      flg:gDateFmt21:mm                                              */
    /*      flg:gDateFmt22:mm （加算・減算月数）                              */
    /*      flg:gDateFmt23:dd （加算・減算日数）                              */
    /*      flg:gDateFmt24:YYYYMMDD                                        */
    /* Arg4:val3                                                           */
    /*      flg:gDateFmt1:無し                                             */
    /*      flg:gDateFmt2:無し                                             */
    /*      flg:gDateFmt3:無し                                             */
    /*      flg:gDateFmt4:無し                                             */
    /*      flg:gDateFmt5:無し                                             */
    /*      flg:gDateFmt6:無し                                             */
    /*      flg:gDateFmt7:無し                                             */
    /*      flg:gDateFmt8:無し                                             */
    /*      flg:gDateFmt9:無し                                             */
    /*      flg:gDateFmt10:無し                                            */
    /*      flg:gDateFmt11:無し                                            */
    /*      flg:gDateFmt12:無し                                            */
    /*      flg:gDateFmt13:dd                                              */
    /*      flg:gDateFmt14:dd                                              */
    /*      flg:gDateFmt15:無し                                            */
    /*      flg:gDateFmt16:無し                                            */
    /*      flg:gDateFmt17:無し                                            */
    /*      flg:gDateFmt18:'All'                                           */
    /*      flg:gDateFmt19:無し                                            */
    /*      flg:gDateFmt20:無し                                            */
    /*      flg:gDateFmt21:無し                                            */
    /*      flg:gDateFmt22:無し                                            */
    /*      flg:gDateFmt23:無し                                            */
    /*      flg:gDateFmt24:無し                                            */
    /* Ret :                                                               */
    /*      flg:gDateFmt1:YYYY/MM/DD                                       */
    /*      flg:gDateFmt2:YYYY-MM-DD<BR>JJ:MM:SS                           */
    /*      flg:gDateFmt3:yyyy/mm/dd(dd:月初)                              */
    /*      flg:gDateFmt4:yyyy/mm/dd(dd:月末)                              */
    /*      flg:gDateFmt5:YYYY                                             */
    /*      flg:gDateFmt6:MM                                               */
    /*      flg:gDateFmt7:YYYY-MM                                          */
    /*      flg:gDateFmt8:YYYY                                             */
    /*      flg:gDateFmt9:MM                                               */
    /*      flg:gDateFmt10:DD                                              */
    /*      flg:gDateFmt11:MM                                              */
    /*      flg:gDateFmt12:DD                                              */
    /*      flg:gDateFmt13:YYYY/MM/DD                                      */
    /*      flg:gDateFmt14:YYYYMMDD                                        */
    /*      flg:gDateFmt15:yyyy-mm                                         */
    /*      flg:gDateFmt16:yyyy/mm                                         */
    /*      flg:gDateFmt17:YYYY-MM-DDTJJ:MM:SS.000                         */
    /*      flg:gDateFmt18:yyyy/mm or [All]                                */
    /*      flg:gDateFmt19:YYYY-MM-DDTJJ:MM:SS.000                         */
    /*      flg:gDateFmt20:YYYY/MM/DD JJ:MM:SS                             */
    /*      flg:gDateFmt21:dd(dd:月末)                                     */
    /*      flg:gDateFmt22:YYYYMM                                          */
    /*      flg:gDateFmt23:YYYYMMDD                                        */
    /*      flg:gDateFmt24:dd(dd:difference)                               */
    /*---------------------------------------------------------------------*/
    public function gDateFmt($flg, $val1, $val2 = NULL, $val3 = NULL) {
        $this->CL['LG']->cLog('T0002');
        $ret = '';
        switch ($flg) {
            case $this->CL['DF']->gDateFmt1:     // YYYYMMDD → YYYY/MM/DD
                if ($val1 != '') {
                    $y = substr($val1, $this->CL['DF']->RngYear2, $this->CL['DF']->LenYear);
                    $m = substr($val1, $this->CL['DF']->RngMonth2, $this->CL['DF']->LenMonth);
                    $d = substr($val1, $this->CL['DF']->RngDay2, $this->CL['DF']->LenDay);
                    $ret = $y.'/'.$m.'/'.$d;
                }
                break;
            case $this->CL['DF']->gDateFmt2:     // YYYY-MM-DD JJ:MM:SS → YYYY-MM-DD<BR>JJ:MM:SS
                $buf = str_replace(' ', $this->CL['DF']->BR, $val1);
                $ret = $buf;
                break;
            case $this->CL['DF']->gDateFmt3:     // yyyy+mm → yyyy/mm/dd(dd:月初)
                $y = $val1;
                $m = $val2;
                $d = 1;
                $ret = $y.'/'.$m.'/'.$d;
                break;
            case $this->CL['DF']->gDateFmt4:     // yyyy+mm → yyyy/mm/dd(dd:月末)
                $y = $val1;
                $m = $val2;
                $d  = date_create();
                date_date_set($d, $val1, $val2, 1); 
                $ret = $y.'/'.$m.'/'.date_format($d, 't');
                break;
            case $this->CL['DF']->gDateFmt5:     // YYYY-MM → YYYY
                $y = substr($val1, $this->CL['DF']->RngYear, $this->CL['DF']->LenYear);
                $ret = $y;
                break;
            case $this->CL['DF']->gDateFmt6:     // YYYY-MM → MM
                $m = substr($val1, $this->CL['DF']->RngMonth, $this->CL['DF']->LenMonth);
                $ret = $m;
                break;
            case $this->CL['DF']->gDateFmt7:     // YYYYMM → YYYY-MM
                if ($val1 != '') {
                    $y = substr($val1, $this->CL['DF']->RngYear2, $this->CL['DF']->LenYear);
                    $m = substr($val1, $this->CL['DF']->RngMonth2, $this->CL['DF']->LenMonth);
                    $ret = $y.'-'.$m;
                }
                break;
            case $this->CL['DF']->gDateFmt8:     // YYYYMMDD → YYYY
                $y = substr($val1, $this->CL['DF']->RngYear2, $this->CL['DF']->LenYear);
                $ret = $y;
                break;
            case $this->CL['DF']->gDateFmt9:     // YYYYMMDD → MM
                $m = substr($val1, $this->CL['DF']->RngMonth2, $this->CL['DF']->LenMonth);
                $ret = $m;
                break;
            case $this->CL['DF']->gDateFmt10:    // YYYYMMDD → DD
                $d = substr($val1, $this->CL['DF']->RngDay2, $this->CL['DF']->LenDay);
                $ret = $d;
                break;
            case $this->CL['DF']->gDateFmt11:    // mm → MM
                $m = self::gIntDigitFmt($val1, $this->CL['DF']->LenMonth);
                $ret = $m;
                break;
            case $this->CL['DF']->gDateFmt12:    // dd → DD
                $d = self::gIntDigitFmt($val1, $this->CL['DF']->LenDay);
                $ret = $d;
                break;
            case $this->CL['DF']->gDateFmt13:    // yyyy+mm+dd → YYYY/DD/DD
                if ($val1 != '' || $val2 != '' || $val3 != '') {
                    $y = $val1;
                    $m = self::gIntDigitFmt($val2, $this->CL['DF']->LenMonth);
                    $d = self::gIntDigitFmt($val3, $this->CL['DF']->LenDay);
                    $ret = $y.'/'.$m.'/'.$d;
                }
                break;
            case $this->CL['DF']->gDateFmt14:    // yyyy+mm+dd → YYYYDDDD
                if ($val1 != '' || $val2 != ''|| $val3 != '') {
                    $y = $val1;
                    $m = self::gIntDigitFmt($val2, $this->CL['DF']->LenMonth);
                    $d = self::gIntDigitFmt($val3, $this->CL['DF']->LenDay);
                    $ret = $y.$m.$d;
                }
                break;
            case $this->CL['DF']->gDateFmt15:    // yyyy+mm → yyyy-mm
                if ($val1 != '' || $val2 != '') {
                    $y = self::gIntDigitFmt($val1, $this->CL['DF']->LenYear);
                    $m = self::gIntDigitFmt($val2, $this->CL['DF']->LenMonth);
                    $ret = $y.'-'.$m;
                }
                break;
            case $this->CL['DF']->gDateFmt16:    // yyyy+mm → yyyy/mm
                if ($val1 != '' || $val2 != '') {
                    $y = self::gIntDigitFmt($val1, $this->CL['DF']->LenYear);
                    $m = self::gIntDigitFmt($val2, $this->CL['DF']->LenMonth);
                    $ret = $y.'/'.$m;
                }
                break;
            case $this->CL['DF']->gDateFmt17:     // YYYY-MM-DD<BR>JJ:MM:SS → YYYY-MM-DDTJJ:MM:SS.000
                if ($val1 == '-') {
                    $ret = $val1;
                } else {
                    $buf = str_replace($this->CL['DF']->BR, 'T', $val1).'.000';
                    $ret = $buf;
                }
                break;
            case $this->CL['DF']->gDateFmt18:     // yyyy+mm → yyyy/mm or [All]
                if (($val1 == $this->CL['DF']->YearAll) && ($val2 == $this->CL['DF']->MonthAll)) {
                    $ret = '['.$val3.']';
                } else {
                    if ($val1 != '' || $val2 != '') {
                        $y = $val1;
                        $m = $val2;
                        $ret = $y.'/'.$m;
                    }
                }
                break;
            case $this->CL['DF']->gDateFmt19:     // YYYY-MM-DD JJ:MM:SS → YYYY-MM-DDTJJ:MM:SS.000
                $buf = str_replace(' ', 'T', $val1).'.000';
                $ret = $buf;
                break;
            case $this->CL['DF']->gDateFmt20:     // YYYYMMDDJJMMSS → YYYY/MM/DD JJ:MM:SS
                if ($val1 != '') {
                    $ye = substr($val1, $this->CL['DF']->RngYear2, $this->CL['DF']->LenYear);
                    $mo = substr($val1, $this->CL['DF']->RngMonth2, $this->CL['DF']->LenMonth);
                    $da = substr($val1, $this->CL['DF']->RngDay2, $this->CL['DF']->LenDay);
                    $ho = substr($val1, $this->CL['DF']->RngHour2, $this->CL['DF']->LenHour);
                    $mi = substr($val1, $this->CL['DF']->RngMin2, $this->CL['DF']->LenMin);
                    $se = substr($val1, $this->CL['DF']->RngSec2, $this->CL['DF']->LenSec);
                    $ret = $ye.'/'.$mo.'/'.$da.' '.$ho.':'.$mi.':'.$se;
                }
                break;
            case $this->CL['DF']->gDateFmt21:     // yyyy+mm → dd(dd:月末)
                $d  = date_create();
                date_date_set($d, $val1, $val2, 1); 
                $ret = date_format($d, 't');
                break;
            case $this->CL['DF']->gDateFmt22:     // YYYYMM (val1) + (val2) months
                if ($val1 != '') {
                    $ye = intval(substr($val1, $this->CL['DF']->RngYear2, $this->CL['DF']->LenYear));
                    $mo = intval(substr($val1, $this->CL['DF']->RngMonth2, $this->CL['DF']->LenMonth));
                    if (is_string($val2)) {
                        $val2 = intval($val2);
                    }
                    $mo += $val2;
                    // 月が0以下になったときの対応
                    while ($mo < 1) {
                        $mo += 12;
                        $ye -= 1;
                    }
                    // 月が13以上になったときの対応
                    while ($mo > 12) {
                        $mo -= 12;
                        $ye += 1;
                    }
                    $ret = self::gIntDigitFmt($ye, $this->CL['DF']->LenYear).self::gIntDigitFmt($mo, $this->CL['DF']->LenMonth);
                }
                break;
            case $this->CL['DF']->gDateFmt23:     // YYYYMMDD (val1) + (val2) days
                if ($val1 != '') {
                    $ye = intval(substr($val1, $this->CL['DF']->RngYear2, $this->CL['DF']->LenYear));
                    $mo = intval(substr($val1, $this->CL['DF']->RngMonth2, $this->CL['DF']->LenMonth));
                    $dy = intval(substr($val1, $this->CL['DF']->RngDay2, $this->CL['DF']->LenDay));
                    if (is_string($val2)) {
                        $val2 = intval($val2);
                    }
                    $ddate = date_create();
                    date_date_set($ddate, $ye, $mo, $dy);
                    date_modify($ddate, $val2.' day'); 
//                    $ddate += $val2 * 60 * 60 * 24;

                    $ret = date_format($ddate, 'Ymd');
                }
                break;
            case $this->CL['DF']->gDateFmt24:     // YYYYMMDD (val1) - YYYYMMDD (val2) 
                if ($val1 != '') {
                    $ye = intval(substr($val1, $this->CL['DF']->RngYear2, $this->CL['DF']->LenYear));
                    $mo = intval(substr($val1, $this->CL['DF']->RngMonth2, $this->CL['DF']->LenMonth));
                    $dy = intval(substr($val1, $this->CL['DF']->RngDay2, $this->CL['DF']->LenDay));
                    $ddate1 = date_create();
                    date_date_set($ddate1, $ye, $mo, $dy);
                    
                    if ($val2 != '') {
                        $ye = intval(substr($val2, $this->CL['DF']->RngYear2, $this->CL['DF']->LenYear));
                        $mo = intval(substr($val2, $this->CL['DF']->RngMonth2, $this->CL['DF']->LenMonth));
                        $dy = intval(substr($val2, $this->CL['DF']->RngDay2, $this->CL['DF']->LenDay));
                        $ddate2 = date_create();
                        date_date_set($ddate2, $ye, $mo, $dy);
                        
                        $ret = date_diff($ddate2, $ddate1)->format('%a');
                        if (date_diff($ddate2, $ddate1)->invert != 0) {
                            $ret *= -1;
                        }
                    }
                }
                break;
        }
        return $ret;
    }
    
    /*------------------------------------------------------------*/
    /* 数値のフォーマットを変更する                               */
    /* Arg1:int                                                   */
    /* Ret :int(カンマ無し、小数点有りフォーマット)               */
    /*------------------------------------------------------------*/
    public function gIntFmt($int) {
        $this->CL['LG']->cLog('T0002');
        if ($int == '-' || $int == '') {
            return 0;
        } else {
            return str_replace(',', '', $int);
        }
    }
    
    /*------------------------------------------------------------*/
    /* 数値のフォーマットを変更する                               */
    /* Arg1:int                                                   */
    /* Arg2:digit                                                 */
    /*      桁数                                                  */
    /* Ret :int(0パディングされた数字)                            */
    /*------------------------------------------------------------*/
    public function gIntDigitFmt($int, $digit) {
        $this->CL['LG']->cLog('T0002');
        return str_pad($int, $digit, $this->CL['DF']->ZERO, STR_PAD_LEFT);
    }
    
    /*------------------------------------------------------------*/
    /* 数値のフォーマットを変更する                                     */
    /* Arg1:dec                                                   */
    /* Arg2:flg                                                   */
    /*      gDecFmt_ShowZero : 戻り値が0の場合、0を戻す               */
    /*      gDecFmt_HideZero : 戻り値が0の場合、空白を戻す(Def)       */
    /* Ret :dec(カンマ有り、小数点以下はLenDecで指定された桁数で表示)     */
    /*------------------------------------------------------------*/
    public function gDecFmt($dec, $flg = NULL, $len = NULL) {
        $this->CL['LG']->cLog('T0002');
        $_len = $len;
        if (is_null($len)) {
            $_len = $this->CL['DF']->LenDec;
        }
        if (($flg == $this->CL['DF']->gDecFmt_HideZero) || ($flg == NULL)) {
            if ($dec == 0) {
                return '';
            }
        }
        
        // 千位毎にカンマ (','),小数(3桁まで)の前にドット ('.')
        $dec = number_format($dec, $_len, '.', ',');
        
        return $dec;
    }
    
    /*------------------------------------------------------------*/
    /* 数値のフォーマットを変更する                                     */
    /* Arg1:dec                                                   */
    /* Arg2:flg                                                   */
    /*      gDecFmt_ShowZero : 戻り値が0の場合、0を戻す               */
    /*      gDecFmt_HideZero : 戻り値が0の場合、空白を戻す(Def)       */
    /* Ret :dec(カンマ有り、小数点以下なし)                            */
    /*------------------------------------------------------------*/
    public function gNumFmt($dec, $flg = NULL) {
        $this->CL['LG']->cLog('T0002');
        if (($flg == $this->CL['DF']->gDecFmt_HideZero) || ($flg == NULL)) {
            if ($dec == 0) {
                return '';
            }
        }
        
        // 千位毎にカンマ (','),小数(3桁まで)の前にドット ('.')
        $dec = number_format($dec, 0, '.', ',');
        
        return $dec;
    }
    
    /*------------------------------------------------------------*/
    /* 日付の差を求める                                              */
    /* Arg1:date1                                                 */
    /*      YYYYMMDD                                              */
    /* Arg2:date2                                                 */
    /*      YYYYMMDD                                              */
    /* Ret :int(date2 - date1)                                    */
    /*------------------------------------------------------------*/
    public function gDateDiff($date1, $date2) {
        $this->CL['LG']->cLog('T0002');
        
        // convert to time type data
        $datestamp1 = new DateTime(self::gDateFmt($this->CL['DF']->gDateFmt1, $date1));
        $datestamp2 = new DateTime(self::gDateFmt($this->CL['DF']->gDateFmt1, $date2));
        
        $diff = date_diff($datestamp1, $datestamp2, false);
        if ($diff->invert == 1) {
            return -1 * $diff->days;
        } else {
            return $diff->days;
        }
        return false;
    }
    
    /*------------------------------------------------------------*/
    /* 数値を丸める(四捨五入)                                     */
    /* Arg1:int                                                   */
    /* Arg2:digit                                                 */
    /*      四捨五入桁数                                          */
    /* Arg3:unit                                                  */
    /*      切捨単位                                              */
    /* Ret :int(丸めた数値)                                       */
    /*------------------------------------------------------------*/
    public function gRoundVal($int, $digit, $unit) {
        $this->CL['LG']->cLog('T0002');
        return round($int, $digit)/$unit;
    }
    
    /*------------------------------------------------------------*/
    /* 比率を求める                                               */
    /* Arg1:divided                                               */
    /*      割られる数                                            */
    /* Arg2:crack                                                 */
    /*      割る数                                                */
    /* Arg3:digit                                                 */
    /*      四捨五入桁数(小数点以下)                              */
    /* Ret :比率                                                  */
    /*      (割られる数/割る数)*100+'%'                           */
    /*      割る数が0の場合空白                                   */
    /*------------------------------------------------------------*/
    public function gRoundVal2($divided, $crack, $digit) {
        $this->CL['LG']->cLog('T0002');
        if (($crack == 0) || (!isset($crack))) {
            return self::gDecFmt(0, $this->CL['DF']->gDecFmt_ShowZero,$digit).'%';
        } else {
            return self::gDecFmt(round((($divided/$crack)*100), $digit), $this->CL['DF']->gDecFmt_ShowZero,$digit).'%';
        }
    }
    
    /*------------------------------------------------------------*/
    /* 増減率を求める                                             */
    /* Arg1:current                                               */
    /*      当月                                                  */
    /* Arg2:prev                                                  */
    /*      前月                                                  */
    /* Arg3:digit                                                 */
    /*      四捨五入桁数(小数点以下)                              */
    /* Ret :増減率                                                */
    /*      ((当月-前月)/前月)*100+'%'                            */
    /*      前月0の場合空白                                       */
    /*------------------------------------------------------------*/
    public function gRoundVal3($current, $prev, $digit) {
        $this->CL['LG']->cLog('T0002');
        if (($prev == 0) || (!isset($prev))) {
            return self::gDecFmt(0, $this->CL['DF']->gDecFmt_ShowZero,$digit).'%';
        } else if ($current == $prev) {
            return self::gDecFmt(0, $this->CL['DF']->gDecFmt_ShowZero,$digit).'%';
        } else {
            return self::gDecFmt(round((($current-$prev)/$prev*100), $digit), $this->CL['DF']->gDecFmt_ShowZero,$digit).'%';
        }
    }
    
    /*------------------------------------------------------------*/
    /* 文字列(配列)からタグを削除する                             */
    /* Arg1:str                                                   */
    /*      文字列(配列)                                          */
    /* Arg2:tag                                                   */
    /*      削除するタグ(配列)                                    */
    /* Ret :タグを削除した文字列(配列)                            */
    /*------------------------------------------------------------*/
    public function dStrTag($str, $tag) {
        $this->CL['LG']->cLog('T0002');
        $ret = $str;
        for ($i = 0, $c = count($ret); $i < $c; $i++) {
            for ($j = 0, $cj = count($tag); $j < $cj; $j++) {
                $ret[$i] = str_replace($tag[$j], '', $ret[$i]);
            }
        }
        return $ret;
    }
    
    /*------------------------------------------------------------*/
    /* 文字列の置換                                               */
    /*     ただし文字列中最後の置換対象となる値は置換せず削除する */
    /* Arg1:search                                                */
    /*      探したい値                                            */
    /* Arg2:replace                                               */
    /*      見つかったsearchを置き換える値                        */
    /* Arg3:subject                                               */
    /*      検索・置換の対象となる文字列                          */
    /* Ret :置換後の文字列                                        */
    /*------------------------------------------------------------*/
    public function cStr($search, $replace, $subject) {
        $this->CL['LG']->cLog('T0002');
        // searchが何個存在するか
        $cnt = substr_count($subject, $search);
        
        // 最後のsearch以外を置換
        $ret = preg_replace('/'.$search.'/', $replace, $subject, $cnt-1);
        
        // 最後のsearchを削除
        $ret = str_replace($search, '', $ret);
        
        return $ret;
    }
    
/*--------------------------------------------------------*/
/* チェック                                               */
/*--------------------------------------------------------*/
    /*------------------------------------------------------------*/
    /* 会社名チェック                                             */
    /*      カラ以外ならtrue                                      */
    /* Arg1:companyname                                           */
    /*      会社名                                                */
    /* Ret :正常:true, 異常:false                                 */
    /*------------------------------------------------------------*/
    public function chkCompanyName($companyname) {
        $this->CL['LG']->cLog('T0002');
        if (empty($companyname)) {
            return false;
        } else {
            return true;
        }
    }
    
    /*-------------------------------------------------------------*/
    /* ユーザIDチェック                                            */
    /*      半角英数字のみかつ重複していなければtrue               */
    /* Arg1:userid                                                 */
    /*      ユーザID                                               */
    /* Arg2:flg                                                    */
    /*      chkUserID_noChk  :ユーザID重複をチェックしない         */
    /*      chkUserID_chkAdd :ユーザID重複をチェックする(追加用)   */
    /*      chkUserID_chkUpd :ユーザID重複をチェックしない(更新用) */
    /* Ret :正常:true, 異常:false                                  */
    /*-------------------------------------------------------------*/
    public function chkUserID($userid, $flg) {
        $this->CL['LG']->cLog('T0002');
        if ($flg == $this->CL['DF']->chkUserID_noChk) {
            return true;
        } else if ($flg == $this->CL['DF']->chkUserID_chkAdd) {
            if ((empty($userid)) || (!preg_match('/^[a-zA-Z0-9]+$/', $userid))) {
                // フォーマットエラー
                return false;
            } else {
                if ($this->CL['SW']->gUserIDSameCntVal($userid) > 0) {
                    // 追加するユーザIDが既存ならばNG
                    return false;
                } else {
                    return true;
                }
            }
        } else if ($flg == $this->CL['DF']->chkUserID_chkUpd) {
            // ユーザIDは変更できなくしたので常にtrue
            return true;
        }
    }
    
    /*------------------------------------------------------------*/
    /* ユーザ名チェック                                           */
    /*      半角英数字+半角空白のみならtrue                       */
    /* Arg1:username                                              */
    /*      ユーザ名                                              */
    /* Ret :正常:true, 異常:false                                 */
    /*------------------------------------------------------------*/
    public function chkUserName($username) {
        $this->CL['LG']->cLog('T0002');
        if ((empty($username)) || (!preg_match('/^[a-zA-Z0-9\x20]+$/', $username))) {
            return false;
        } else {
            return true;
        }
    }
    
    /*------------------------------------------------------------*/
    /* パスワードチェック                                         */
    /*      半角英数字のみならtrue                                */
    /* Arg1:password                                              */
    /*      パスワード                                            */
    /* Ret :正常:true, 異常:false                                 */
    /*------------------------------------------------------------*/
    public function chkPassWord($password) {
        $this->CL['LG']->cLog('T0002');
        if ((empty($password)) || (!preg_match('/^[a-zA-Z0-9\x20]+$/', $password))) {
            return false;
        } else {
            return true;
        }
    }
    
    /*------------------------------------------------------------*/
    /* メールアドレスチェック                                     */
    /*      現実的(RFC5322準拠/良いかは別問題)ならtrue            */
    /* Arg1:mail                                                  */
    /*      メールアドレス                                        */
    /* Ret :正常:true, 異常:false                                 */
    /*------------------------------------------------------------*/
    public function chkMailaAdress($mail) {
        $this->CL['LG']->cLog('T0002');
        if ((empty($mail)) || (!preg_match('/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/i', $mail))) {
            return false;
        } else {
            return true;
        }
    }
    
    /*---------------------------------------------------------------*/
    /* 勘定科目(小項目)名称チェック                                  */
    /*      カラ以外かつ重複していなければtrue                       */
    /* Arg1:AccSName                                                 */
    /*      勘定科目(小)名称                                         */
    /* Arg2:accno                                                    */
    /*     勘定科目NO                                                */
    /* Arg3:flg                                                      */
    /*      chkAccSName_noChk  :勘定科目ID重複をチェックしない       */
    /*      chkAccSName_chkAdd :勘定科目ID重複をチェックする(追加用) */
    /*      chkAccSName_chkUpd :勘定科目ID重複をチェックする(更新用) */
    /* Ret :正常:true, 異常:false                                    */
    /*---------------------------------------------------------------*/
    public function chkAccSName($AccSName, $accno, $flg) {
        $this->CL['LG']->cLog('T0002');
        if (empty($AccSName)) {
            return false;
        } else if ($flg == $this->CL['DF']->chkAccSName_noChk) {
            return true;
        } else if ($flg == $this->CL['DF']->chkAccSName_chkAdd) {
            if ($this->CL['SW']->gAccSNameIDSameCntVal($AccSName) > 0) {
                // 追加する勘定科目(小)名称が既存ならばNG
                return false;
            } else {
                return true;
            }
        } else if ($flg == $this->CL['DF']->chkAccSName_chkUpd) {
            $cnt = $this->CL['SW']->gAccSNameIDNOSameCntVal($AccSName, $accno);
            if ($cnt == 0) {
                // 変更する勘定科目(小)名称が別の勘定科目で存在しなければOK
                return true;
            } else {
                // 変更する勘定科目(小)名称が既存ならNG
                return false;
            }
        }
    }
    
    /*------------------------------------------------------------*/
    /* 勘定科目IDチェック                                             */
    /*      重複していなければtrue                                    */
    /* Arg1:accid                                                  */
    /*      勘定科目ID                                             */
    /* Arg2:flg                                                    */
    /*      chkDup_noChk  :勘定科目ID重複をチェックしない                */
    /*      chkDup_chkAdd :勘定科目ID重複をチェックする(追加用)         */
    /*      chkDup_chkUpd :勘定科目ID重複をチェックしない(更新用)        */
    /* Ret :重複無し:true, 重複有り:false                           */
    /*------------------------------------------------------------*/
    public function chkaccID($accid, $flg) {
        $this->CL['LG']->cLog('T0002');
        if ($accid == $this->CL['DF']->ZERO) {
            // '0'の場合はデータチェックを行う
        } else if (empty($accid)) {
            return false;
        } else if ($flg == $this->CL['DF']->chkDup_noChk) {
            return true;
        }
        
        if ($flg == $this->CL['DF']->chkDup_chkAdd) {
            // 追加する勘定科目IDが既存ならばNG
            if ($this->CL['SW']->gAccIDSameCntVal($accid) > 0) {
                return false;
            } else {
                return true;
            }
        } else if ($flg == $this->CL['DF']->chkDup_chkUpd) {
            // 勘定科目IDは更新時に変更できなくしたので常にtrue
            return true;
        }
    }

    /*------------------------------------------------------------*/
    /* 取引先名称チェック                                         */
    /*      カラ以外ならtrue                                      */
    /* Arg1:cltname                                               */
    /*      取引先名                                              */
    /* Ret :カラ以外:true, カラ:false                             */
    /*------------------------------------------------------------*/
    public function chkCltName($cltname) {
        $this->CL['LG']->cLog('T0002');
        if (empty($cltname)) {
            return false;
        } else {
            return true;
        }
    }
    
    /*------------------------------------------------------------*/
    /* 取引先IDチェック                                           */
    /*      重複していなければtrue                                */
    /* Arg1:cltid                                                 */
    /*      取引先ID                                              */
    /* Arg2:flg                                                   */
    /*      chkcltID_noChk  :ユーザID重複をチェックしない         */
    /*      chkcltID_chkAdd :ユーザID重複をチェックする(追加用)   */
    /*      chkcltID_chkUpd :ユーザID重複をチェックしない(更新用) */
    /* Ret :重複無し:true, 重複有り:false                         */
    /*------------------------------------------------------------*/
    public function chkcltID($cltid, $flg) {
        $this->CL['LG']->cLog('T0002');
        if (empty($cltid)) {
            return false;
        } else if ($flg == $this->CL['DF']->chkcltID_noChk) {
            return true;
        } else if ($flg == $this->CL['DF']->chkcltID_chkAdd) {
            // 追加する取引先IDが既存ならばNG
            if ($this->CL['SW']->gCltIDSameCntVal($cltid) > 0) {
                return false;
            } else {
                return true;
            }
        } else if ($flg == $this->CL['DF']->chkcltID_chkUpd) {
            // 取引先IDは更新時に変更できなくしたので常にtrue
            return true;
        }
    }
    
    /*------------------------------------------------------------*/
    /* 事業部名称チェック                                         */
    /*      カラ以外ならtrue                                      */
    /* Arg1:divname                                               */
    /*      事業部名                                              */
    /* Ret :カラ以外:true, カラ:false                             */
    /*------------------------------------------------------------*/
    public function chkDivName($divname) {
        $this->CL['LG']->cLog('T0002');
        if (empty($divname)) {
            return false;
        } else {
            return true;
        }
    }
    
    /*------------------------------------------------------------*/
    /* セグメント名称チェック                                         */
    /*      カラ以外ならtrue                                      */
    /* Arg1:segname                                               */
    /*      セグメント名                                              */
    /* Ret :カラ以外:true, カラ:false                             */
    /*------------------------------------------------------------*/
    public function chkSegName($segname) {
        $this->CL['LG']->cLog('T0002');
        if (empty($segname)) {
            return false;
        } else {
            return true;
        }
    }
    
    /*------------------------------------------------------------*/
    /* 通貨名称チェック                                              */
    /*      カラ以外ならtrue                                         */
    /* Arg1:curname                                               */
    /*      通貨名                                                */
    /* Ret :カラ以外:true, カラ:false                                */
    /*------------------------------------------------------------*/
    public function chkCurName($curname) {
        $this->CL['LG']->cLog('T0002');
        if (empty($curname)) {
            return false;
        } else {
            return true;
        }
    }
    
    /*------------------------------------------------------------*/
    /* 事業部IDチェック                                           */
    /*      重複していなければtrue                                */
    /* Arg1:divid                                                 */
    /*      事業部ID                                              */
    /* Arg2:flg                                                   */
    /*      chkdivID_noChk  :事業部ID重複をチェックしない         */
    /*      chkdivID_chkAdd :事業部ID重複をチェックする(追加用)   */
    /*      chkdivID_chkUpd :事業部ID重複をチェックしない(更新用) */
    /* Ret :重複無し:true, 重複有り:false                         */
    /*------------------------------------------------------------*/
    public function chkdivID($divid, $flg) {
        $this->CL['LG']->cLog('T0002');
        if (empty($divid)) {
            return false;
        } else if ($flg == $this->CL['DF']->chkdivID_noChk) {
            return true;
        } else if ($flg == $this->CL['DF']->chkdivID_chkAdd) {
            // 追加する事業部IDが既存ならばNG
            if ($this->CL['SW']->gdivIDSameCntVal($divid) > 0) {
                return false;
            } else {
                return true;
            }
        } else if ($flg == $this->CL['DF']->chkdivID_chkUpd) {
            // 事業部IDは更新時に変更できなくしたので常にtrue
            return true;
        }
    }

    /*------------------------------------------------------------*/
    /* セグメントIDチェック                                             */
    /*      重複していなければtrue                                   */
    /* Arg1:segid                                                 */
    /*      セグメントID                                             */
    /* Arg2:flg                                                   */
    /*      chksegID_noChk  :セグメントID重複をチェックしない             */
    /*      chksegID_chkAdd :セグメントID重複をチェックする(追加用)       */
    /*      chksegID_chkUpd :セグメントID重複をチェックしない(更新用)     */
    /* Ret :重複無し:true, 重複有り:false                           */
    /*------------------------------------------------------------*/
    public function chksegID($segid, $flg) {
        $this->CL['LG']->cLog('T0002');
        if (empty($segid)) {
            return false;
        } else if ($flg == $this->CL['DF']->chksegID_noChk) {
            return true;
        } else if ($flg == $this->CL['DF']->chksegID_chkAdd) {
            // 追加するセグメントIDが既存ならばNG
            if ($this->CL['SW']->gSegIDSameCntVal($segid) > 0) {
                return false;
            } else {
                return true;
            }
        } else if ($flg == $this->CL['DF']->chksegID_chkUpd) {
            // セグメントIDは更新時に変更できなくしたので常にtrue
            return true;
        }
    }

    /*------------------------------------------------------------*/
    /* 通貨IDチェック                                                */
    /*      重複していなければtrue                                   */
    /* Arg1:segid                                                 */
    /*      通貨ID                                                */
    /* Arg2:flg                                                   */
    /*      chkcurID_noChk  :通貨ID重複をチェックしない                */
    /*      chkcurID_chkAdd :通貨ID重複をチェックする(追加用)          */
    /*      chkcurID_chkUpd :通貨ID重複をチェックしない(更新用)         */
    /* Ret :重複無し:true, 重複有り:false                           */
    /*------------------------------------------------------------*/
    public function chkcurID($segid, $flg) {
        $this->CL['LG']->cLog('T0002');
        if (empty($segid)) {
            return false;
        } else if ($flg == $this->CL['DF']->chkcurID_noChk) {
            return true;
        } else if ($flg == $this->CL['DF']->chkcurID_chkAdd) {
            // 追加する通貨IDが既存ならばNG
            if ($this->CL['SW']->gCurIDSameCntVal($segid) > 0) {
                return false;
            } else {
                return true;
            }
        } else if ($flg == $this->CL['DF']->chkcurID_chkUpd) {
            // 通貨IDは更新時に変更できなくしたので常にtrue
            return true;
        }
    }

    /*------------------------------------------------------------*/
    /* 固定資産IDチェック                                            */
    /*      重複していなければtrue                                   */
    /* Arg1:FixAssetID                                           */
    /*      固定資産ID                                            */
    /* Arg2:flg                                                   */
    /*      chkDup_noChk  :事業部ID重複をチェックしない                */
    /*      chkDup_chkAdd :事業部ID重複をチェックする(追加用)          */
    /*      chkDup_chkUpd :事業部ID重複をチェックする(更新用)          */
    /* Arg3:FixAssetNo                                            */
    /*      flg == chkDup_chkUpd のときのシステム内固定資産番号        */
    /* Ret :重複無し:true, 重複有り:false                           */
    /*------------------------------------------------------------*/
    public function chkFixAssetID($FixAssetID, $flg, $FixAssetNo = -1) {
        $this->CL['LG']->cLog('T0002');
        if (empty($FixAssetID)) {
            return false;
        } else if ($flg == $this->CL['DF']->chkDup_noChk) {
            return true;
        } else if ($flg == $this->CL['DF']->chkDup_chkAdd) {
            // 追加する固定資産IDが既存ならばNG
            if ($this->CL['SW']->gFixAssetIDSameCntVal($FixAssetID) > 0) {
                return false;
            } else {
                return true;
            }
        } else if ($flg == $this->CL['DF']->chkDup_chkUpd) {
            // 同一固定資産番号以外で同一固定資産IDがある場合はNG
            if ($this->CL['SW']->gFixAssetIDSameCntVal($FixAssetID, $FixAssetNo) > 0) {
                return false;
            } else {
                return true;
            }
        }
    }
    
    /*------------------------------------------------------------*/
    /* 月次確定ステータス最新年月チェック                         */
    /* Arg1:LatestYear                                            */
    /*      最新年                                                */
    /* Arg2:LatestMonth                                           */
    /*      最新月                                                */
    /* Arg3:DataYear                                              */
    /*      データ年                                              */
    /* Arg4:DataMonth                                             */
    /*      データ月                                              */
    /* Ret :取引データ作成可:true, 取引データ作成不可:false       */
    /*------------------------------------------------------------*/
    public function cMoCfmMaxYM($LatestYear, $LatestMonth, $DataYear, $DataMonth) {
        $this->CL['LG']->cLog('T0002');
        if (!empty($LatestYear)) {
            if (($LatestYear > $DataYear) || (($LatestYear == $DataYear) && ($LatestMonth >= $DataMonth))) {
                // 最新の月次確定済年月以前の取引の場合、取引データ作成は不可
                return false;
            } else {
                // 最新の月次確定済年月以降の取引の場合、取引データ作成は可
                return true;
            }
        } else {
            // 最新の月次確定済年月が存在しない場合、取引データ作成は可
            return true;
        }
    }
    
    /*------------------------------------------------------------*/
    /* 月次確定ステータスチェック                                 */
    /* Arg1:trnkind                                               */
    /*      チェック対象クラス                                    */
    /*      trd :取引仕訳                                         */
    /*      adj :決算整理仕訳                                     */
    /* Arg2:trn                                                   */
    /*      チェック対象トランザクション                          */
    /*      upd :更新                                             */
    /*      add :追加                                             */
    /* Arg3:chk                                                   */
    /*      チェック対象データ種別                                */
    /*      trd :取引仕訳                                         */
    /*      adj :決算整理仕訳                                     */
    /* Arg4:sts                                                   */
    /*      cfmSts_UnCfm :未確定                                  */
    /*      cfmSts_Cfm   :確定済                                  */
    /*      cfmSts_Cls   :決算済                                  */
    /* Ret :取引データ作成可:true, 取引データ作成不可:false       */
    /*------------------------------------------------------------*/
    // 月次確定ステータスチェック(取引仕訳)
    public function cMoCfm($trnkind, $trn, $chk, $sts) {
        $this->CL['LG']->cLog('T0002');
        if ((($trnkind == $this->CL['DF']->trd) && ($trn == $this->CL['DF']->add)) ||
            (($trnkind == $this->CL['DF']->trd) && ($trn == $this->CL['DF']->upd)) ||
            (($trnkind == $this->CL['DF']->adj) && ($trn == $this->CL['DF']->add) && ($chk == $this->CL['DF']->adj)) ||
            (($trnkind == $this->CL['DF']->adj) && ($trn == $this->CL['DF']->upd) && ($chk == $this->CL['DF']->adj))) {
            // 取引仕分(追加)
            // 取引仕分(更新)
            // 決算整理仕訳(追加/決算整理仕訳)
            // 決算整理仕訳(更新/決算整理仕訳)
            switch ($sts) {
                case $this->CL['DF']->cfmSts_UnCfm:    // 未確定
                    return true;
                    break;
                case $this->CL['DF']->cfmSts_Cfm:      // 確定済
                    return false;
                    break;
                case $this->CL['DF']->cfmSts_Cls:      // 決算済
                    return false;
                    break;
                case NULL:                             // 存在しない
                    return true;
                    break;
            }
        } else if ((($trnkind == $this->CL['DF']->adj) && ($trn == $this->CL['DF']->add) && ($chk == $this->CL['DF']->trd)) ||
                   (($trnkind == $this->CL['DF']->adj) && ($trn == $this->CL['DF']->upd) && ($chk == $this->CL['DF']->trd))) {
            // 決算整理仕訳(追加/取引仕訳)
            // 決算整理仕訳(更新/取引仕訳)
            switch ($sts) {
                case $this->CL['DF']->cfmSts_UnCfm:    // 未確定
                    return false;
                    break;
                case $this->CL['DF']->cfmSts_Cfm:      // 確定済
                    return true;
                    break;
                case $this->CL['DF']->cfmSts_Cls:      // 決算済
                    return false;
                    break;
                case NULL:                             // 存在しない
                    return false;
                    break;
            }
        }
    }
    
/*--------------------------------------------------------*/
/* 検索条件文言作成                                       */
/*--------------------------------------------------------*/
    /*------------------------------------------------------------*/
    /* 検索条件文言作成(作成日)                                   */
    /* Arg*:省略                                                  */
    /* Ret :無し                                                  */
    /*------------------------------------------------------------*/
    public function saveSearchDate($searchdate, $syear, $smonth, $sday, $eyear, $emonth, $eday, $Everything) {
        $this->CL['LG']->cLog('T0002');
        if (isset($searchdate)) {
            // 表示用作成日
            $sdate = self::gDateFmt($this->CL['DF']->gDateFmt13, $syear, $smonth, $sday);
            $edate = self::gDateFmt($this->CL['DF']->gDateFmt13, $eyear, $emonth, $eday);
            $dispSearchDate = $sdate.' - '.$edate;
            
            // チェックボックス
            $DisabledChk = 'checked';
            $disabledSelect = '';
        } else {
            // 検索条件が設定されていない場合、全てを表示
            $dispSearchDate = '['.$Everything.']';
            
            // チェックボックス
            $DisabledChk = '';
            $disabledSelect = 'disabled';
        }
        return array($dispSearchDate, $DisabledChk, $disabledSelect);
    }
    
    /*------------------------------------------------------------*/
    /* 検索条件文言作成(勘定科目(大項目)名称)                     */
    /* Arg*:省略                                                  */
    /* Ret :無し                                                  */
    /*------------------------------------------------------------*/
    public function saveSerchAccL($AccLID, $rowAccLMSAll, $Everything) {
        $this->CL['LG']->cLog('T0002');
        if (isset($AccLID)) {
            if ($AccLID[0] == $this->CL['DF']->ALL) {
                $dispAccLName = '['.$Everything.']';
            } else {
                $dispAccLName = '';
                foreach ($AccLID as $value) {
                    for ($i = 0, $c = count($rowAccLMSAll); $i < $c; $i++) {
                        if ($value == $rowAccLMSAll[$i]['AccountsTitleLID']) {
                            $dispAccLName .= $rowAccLMSAll[$i]['AccountsTitleLName'].$this->CL['DF']->BR;
                            break;
                        }
                    }
                }
            }
        } else {
            $dispAccLName = '['.$Everything.']';
        }
        return $dispAccLName;
    }
    
    /*------------------------------------------------------------*/
    /* 検索条件文言作成(勘定科目(中項目)名称)                     */
    /* Arg*:省略                                                  */
    /* Ret :無し                                                  */
    /*------------------------------------------------------------*/
    public function saveSerchAccM($AccMID, $rowAccLMSAll, $Everything) {
        $this->CL['LG']->cLog('T0002');
        if (isset($AccMID)) {
            if ($AccMID[0] == $this->CL['DF']->ALL) {
                $dispAccMName = '['.$Everything.']';
            } else {
                $dispAccMName = '';
                foreach ($AccMID as $value) {
                    $wk = explode('-', $value);
                    for ($i = 0, $c = count($rowAccLMSAll); $i < $c; $i++) {
                        if (($wk[0] == $rowAccLMSAll[$i]['AccountsTitleLID']) && ($wk[1] == $rowAccLMSAll[$i]['AccountsTitleMID'])) {
                            $dispAccMName .= self::gAccNameFmt($rowAccLMSAll[$i]['AccountsTitleLName'], $rowAccLMSAll[$i]['AccountsTitleMName']).$this->CL['DF']->BR;
                            break;
                        }
                    }
                }
            }
        } else {
            $dispAccMName = '['.$Everything.']';
        }
        return $dispAccMName;
    }
    
    /*------------------------------------------------------------*/
    /* 検索条件文言作成(勘定科目(小項目)名称)                     */
    /* Arg*:省略                                                  */
    /* Ret :無し                                                  */
    /*------------------------------------------------------------*/
    public function saveSerchAccS($AccID, $rowAccLMSAll, $Everything) {
        $this->CL['LG']->cLog('T0002');
        if (!isset($AccID)) {
            return '['.$Everything.']';
        }
        if (is_array($AccID)) {
            if ($AccID[0] == $this->CL['DF']->ALL || $AccID[0] == '') {
                return '['.$Everything.']';
            }
            $dispAccSName = '';
            foreach ($AccID as $value) {
                for ($i = 0, $c = count($rowAccLMSAll); $i < $c; $i++) {
                    if ($value == $rowAccLMSAll[$i]['AccountsTitleID']) {
                        $dispAccSName .= $rowAccLMSAll[$i]['AccountsTitleSName'].$this->CL['DF']->BR;
                        break;
                    }
                }
            }
            return $dispAccSName;
        } else {
            if ($AccID == $this->CL['DF']->ALL || $AccID == '') {
                return '['.$Everything.']';
            }
            for ($i = 0, $c = count($rowAccLMSAll); $i < $c; $i++) {
                if ($AccID == $rowAccLMSAll[$i]['AccountsTitleID']) {
                    $dispAccSName .= $rowAccLMSAll[$i]['AccountsTitleSName'].$this->CL['DF']->BR;
                    return $dispAccSName;
                }
            }
        }
        return '';
    }
    
    /*------------------------------------------------------------*/
    /* 検索条件文言作成(表示数)                                   */
    /* Arg*:省略                                                  */
    /* Ret :無し                                                  */
    /*------------------------------------------------------------*/
    public function saveSerchPageRow($pageRowText, $Everything) {
        $this->CL['LG']->cLog('T0002');
        if (isset($pageRowText)) {
            if ($pageRowText == '') {
                $dispPageRow1 = '['.htmlspecialchars($Everything).']';
                $dispPageRow2 = '<input type="text" class="text-box" name="pageRowText" id="pageRowText" size="10" maxlength="20" value="">';
            } else {
                $dispPageRow1 = htmlspecialchars($pageRowText);
                $dispPageRow2 = '<input type="text" class="text-box" name="pageRowText" id="pageRowText" size="10" maxlength="20" value="'.htmlspecialchars($pageRowText).'">';
            }
        } else {
            $dispPageRow1 = '['.htmlspecialchars($Everything).']';
            $dispPageRow2 = '<input type="text" class="text-box" name="pageRowText" id="pageRowText" size="10" maxlength="20" value="">';
        }
        return array($dispPageRow1, $dispPageRow2);
    }
    
    /*------------------------------------------------------------*/
    /* 検索条件文言作成(キーワード)                               */
    /* Arg*:省略                                                  */
    /* Ret :無し                                                  */
    /*------------------------------------------------------------*/
    public function saveSerchText($searchText, $Everything) {
        $this->CL['LG']->cLog('T0002');
        if (isset($searchText)) {
            if ($searchText == '') {
                $dispSearchText1 = '['.htmlspecialchars($Everything).']';
                $dispSearchText2 = '<input type="text" class="text-box" name="searchText" id="searchText" size="20" maxlength="120" value="">';
            } else {
                $dispSearchText1 = htmlspecialchars($searchText);
                $dispSearchText2 = '<input type="text" class="text-box" name="searchText" id="searchText" size="20" maxlength="120" value="'.htmlspecialchars($searchText).'">';
            }
        } else {
            $dispSearchText1 = '['.htmlspecialchars($Everything).']';
            $dispSearchText2 = '<input type="text" class="text-box" name="searchText" id="searchText" size="20" maxlength="120" value="">';
        }
        return array($dispSearchText1, $dispSearchText2);
    }
    
    /*------------------------------------------------------------*/
    /* 検索条件文言作成(取引種別)                                 */
    /* Arg*:省略                                                  */
    /* Ret :無し                                                  */
    /*------------------------------------------------------------*/
    public function saveSerchTrnKind($TrnKindID, $rowTrnKind, $Everything, $Nothing) {
        $this->CL['LG']->cLog('T0002');
        if (isset($TrnKindID)) {
            if ($TrnKindID[0] == $this->CL['DF']->ALL) {
                $dispTrnKind = '['.$Everything.']';
            } else if ($TrnKindID[0] == '') {
                $dispTrnKind = '['.$Nothing.']';
            } else {
                $dispTrnKind = '';
                foreach ($TrnKindID as $value) {
                    for ($i = 0, $c = count($rowTrnKind); $i < $c; $i++) {
                        if ($value == $rowTrnKind[$i]['TransactionKindID']) {
                            $dispTrnKind .= $rowTrnKind[$i]['TransactionKindName'].$this->CL['DF']->BR;
                            break;
                        }
                    }
                }
            }
        } else {
            $dispTrnKind = '['.$Everything.']';
        }
        return $dispTrnKind;
    }
    
    /*------------------------------------------------------------*/
    /* 検索条件文言作成(仕訳帳)                                   */
    /* Arg*:省略                                                  */
    /* Ret :無し                                                  */
    /*------------------------------------------------------------*/
    public function saveSerchJnlKind($jnlKindID, $rowJnlKind, $Everything, $Nothing) {
        $this->CL['LG']->cLog('T0002');
        if (isset($jnlKindID)) {
            if ($jnlKindID[0] == $this->CL['DF']->ALL) {
                $dispJnlKind = '['.$Everything.']';
            } else if ($jnlKindID[0] == '') {
                $dispJnlKind = '['.$Nothing.']';
            } else {
                $dispJnlKind = '';
                foreach ($jnlKindID as $value) {
                    for ($i = 0, $c = count($rowJnlKind); $i < $c; $i++) {
                        if ($value == $rowJnlKind[$i]['JournalKindID']) {
                            $dispJnlKind .= $rowJnlKind[$i]['JournalKindName'].$this->CL['DF']->BR;
                            break;
                        }
                    }
                }
            }
        } else {
            $dispJnlKind = '['.$Everything.']';
        }
        return $dispJnlKind;
    }
    
    /*------------------------------------------------------------*/
    /* 検索条件文言作成(取引先)                                   */
    /* Arg*:省略                                                  */
    /* Ret :無し                                                  */
    /*------------------------------------------------------------*/
    public function saveSerchClt($cltid, $rowCltList, $Everything, $Nothing) {
        $this->CL['LG']->cLog('T0002');
        if (isset($cltid)) {
            if ($cltid[0] == $this->CL['DF']->ALL) {
                $dispCltName = '['.$Everything.']';
            } else if ($cltid[0] == '') {
                $dispCltName = '['.$Nothing.']';
            } else {
                $dispCltName = '';
                foreach ($cltid as $value) {
                    for ($i = 0, $c = count($rowCltList); $i < $c; $i++) {
                        if ($value == $rowCltList[$i]['ClientID']) {
                            $dispCltName .= $rowCltList[$i]['ClientName'].$this->CL['DF']->BR;
                            break;
                        }
                    }
                }
            }
        } else {
            $dispCltName = '['.$Everything.']';
        }
        return $dispCltName;
    }
    
    /*------------------------------------------------------------*/
    /* 検索条件文言作成(特殊仕訳帳)                               */
    /* Arg*:省略                                                  */
    /* Ret :無し                                                  */
    /*------------------------------------------------------------*/
    public function saveSerchSpeJnl($spejnlid, $rowSpeJnlList, $Everything, $Nothing) {
        $this->CL['LG']->cLog('T0002');
        if (isset($spejnlid)) {
            if ($spejnlid[0] == $this->CL['DF']->ALL) {
                $dispSpeJnalName = '['.$Everything.']';
            } else if ($spejnlid[0] == '') {
                $dispSpeJnalName = '['.$Nothing.']';
            } else {
                $dispSpeJnalName = '';
                foreach ($spejnlid as $value) {
                    for ($i = 0, $c = count($rowSpeJnlList); $i < $c; $i++) {
                        if ($value == $rowSpeJnlList[$i]['JournalKindID']) {
                            $dispSpeJnalName .= $rowSpeJnlList[$i]['JournalKindName'].$this->CL['DF']->BR;
                            break;
                        }
                    }
                }
            }
        } else {
            $dispSpeJnalName = '['.$Everything.']';
        }
        return $dispSpeJnalName;
    }
    
    /*------------------------------------------------------------*/
    /* 検索条件文言作成(取引ステータス)                           */
    /* Arg*:省略                                                  */
    /* Ret :無し                                                  */
    /*------------------------------------------------------------*/
    public function saveSerchTrnSts($TrnStsID, $rowTrnStsList, $Everything) {
        $this->CL['LG']->cLog('T0002');
        if (isset($TrnStsID)) {
            if ($TrnStsID[0] == $this->CL['DF']->ALL) {
                $dispTrnSts = '['.$Everything.']';
            } else {
                $dispTrnSts = '';
                if (!is_array($TrnStsID)) {
                    $TrnStsID = array($TrnStsID);
                }
                foreach ($TrnStsID as $value) {
                    for ($i = 0, $c = count($rowTrnStsList); $i < $c; $i++) {
                        if ($value == $rowTrnStsList[$i]['TransactionStatusID']) {
                            $dispTrnSts .= $rowTrnStsList[$i]['TransactionStatusName'].$this->CL['DF']->BR;
                            break;
                        }
                    }
                }
            }
        } else {
            $dispTrnSts = '['.$Everything.']';
        }
        return $dispTrnSts;
    }
    
    /*------------------------------------------------------------*/
    /* 検索条件文言作成(入力者)                                   */
    /* Arg*:省略                                                  */
    /* Ret :無し                                                  */
    /*------------------------------------------------------------*/
    public function saveSerchInputUser($Inputuserid, $rowUserList, $Everything) {
        $this->CL['LG']->cLog('T0002');
        if (isset($Inputuserid)) {
            if ($Inputuserid[0] == $this->CL['DF']->ALL) {
                $dispInputuser = '['.$Everything.']';
            } else {
                $dispInputuser = '';
                foreach ($Inputuserid as $value) {
                    for ($i = 0, $c = count($rowUserList); $i < $c; $i++) {
                        if ($value == $rowUserList[$i]['UserNo']) {
                            $dispInputuser .= $rowUserList[$i]['UserName'].$this->CL['DF']->BR;
                            break;
                        }
                    }
                }
            }
        } else {
            $dispInputuser = '['.$Everything.']';
        }
        return $dispInputuser;
    }
    
    /*------------------------------------------------------------*/
    /* 検索条件文言作成(汎用)                                      */
    /* Arg*:省略                                                  */
    /* Ret :無し                                                  */
    /*------------------------------------------------------------*/
    public function saveSerch($id, $rowList, $idField, $nameField, $Everything, $Nothing = '') {
        $this->CL['LG']->cLog('T0002');
        if (isset($id)) {
            if (is_array($id)) {
                if ($id[0] == $this->CL['DF']->ALL) {
                    $dispName = '['.$Everything.']';
                } else if ($id[0] == '') {
                    if ($Nothing == '') {
                        $dispName = '['.$Everything.']';
                    } else {
                        $dispName = '['.$Nothing.']';
                    }
                } else {
                    $dispName = '';
                    foreach ($id as $value) {
                        for ($i = 0, $c = count($rowList); $i < $c; $i++) {
                            if ($value == $rowList[$i][$idField]) {
                                $dispName .= $rowList[$i][$nameField].$this->CL['DF']->BR;
                                break;
                            }
                        }
                    }
                }
            } else {
                if ($id == $this->CL['DF']->ALL) {
                    $dispName = '['.$Everything.']';
                } else if ($id == '') {
                    if ($Nothing == '') {
                        $dispName = '['.$Everything.']';
                    } else {
                        $dispName = '['.$Nothing.']';
                    }
                } else {
                    for ($i = 0, $c = count($rowList); $i < $c; $i++) {
                        if ($id == $rowList[$i][$idField]) {
                            $dispName = $rowList[$i][$nameField].$this->CL['DF']->BR;
                            break;
                        }
                    }
                }
            }
        } else {
            $dispName = '['.$Everything.']';
        }
        return $dispName;
    }

/*--------------------------------------------------------*/
/* 各種共通関数                                           */
/*--------------------------------------------------------*/
    /*------------------------------------------------------------*/
    /* 会計期間取得                                                */
    /* Arg1:TrnDate                                               */
    /*      発生日                                                */
    /* Arg2:CloseMonth                                            */
    /*      年次決算の月（月末締とする）                               */
    /* Ret : array(fromdate, enddate)                             */
    /*       fromdate : YYYYMMDD 当該会計期間の最初の日             */
    /*       enddate  : YYYYMMDD 当該会計期間の最後の日             */
    /*------------------------------------------------------------*/
    public function gAccountTerm($TrnDate, $CloseMonth) {
        $this->CL['LG']->cLog('T0002');
        
        // 年月の取得
        $ye = intval(self::gDateFmt($this->CL['DF']->gDateFmt8, $TrnDate));
        $mo = intval(self::gDateFmt($this->CL['DF']->gDateFmt9, $TrnDate));

        // 12月末締の場合
        if ($CloseMonth == 12) {
            $fromdate = self::gDateFmt($this->CL['DF']->gDateFmt14, $ye, 1, 1);
            $enddate = self::gDateFmt($this->CL['DF']->gDateFmt14, $ye, 12, 31);
        } else if ($mo > $CloseMonth) {
            $fromdate = self::gDateFmt($this->CL['DF']->gDateFmt14, $ye, $CloseMonth + 1, 1);
            $enddate = self::gDateFmt($this->CL['DF']->gDateFmt14, $ye + 1, $CloseMonth, self::gDateFmt($this->CL['DF']->gDateFmt21, $ye + 1, $CloseMonth));
        } else {
            $fromdate = self::gDateFmt($this->CL['DF']->gDateFmt14, $ye - 1, $CloseMonth + 1, 1);
            $enddate = self::gDateFmt($this->CL['DF']->gDateFmt14, $ye, $CloseMonth, self::gDateFmt($this->CL['DF']->gDateFmt21, $ye, $CloseMonth));
        }

        return array($fromdate, $enddate);
    }
    
    /*------------------------------------------------------------*/
    /* 相手勘定科目の取得 （エンコード）                                */
    /* Arg1:TrnGenList[][]                                        */
    /*      少なくとも各行にDrCrFlgとAccountsTitleIDがあること            */
    /* Ret[0] : Dr側から見た相手勘定一覧（配列のJSON形式）              */
    /* Ret[1] : Cr側から見た相手勘定一覧（配列のJSON形式）              */
    /*------------------------------------------------------------*/
    public function gCounterAcc($TrnGenList) {
        $this->CL['LG']->cLog('T0002');
        
        $dracc = array();
        $cracc = array();
        
        for ($i = 0, $c = count($TrnGenList); $i < $c; $i++) {
            if ($TrnGenList[$i]['Status'] == $this->CL['DF']->true) {
                if ($TrnGenList[$i]['DrCrFlg'] == $this->CL['DF']->Dr) {
                    if (!in_array($TrnGenList[$i]['AccountsTitleID'], $dracc)) {
                        $dracc[] = $TrnGenList[$i]['AccountsTitleID'];
                    }
                } else {
                    if (!in_array($TrnGenList[$i]['AccountsTitleID'], $cracc)) {
                        $cracc[] = $TrnGenList[$i]['AccountsTitleID'];
                    }
                }
            }
        }
        return array(json_encode($cracc), json_encode($dracc));
    }
    
    /*------------------------------------------------------------*/
    /* 相手勘定科目の取得 （デコード）                                  */
    /* Arg1:ContraAccounts                                        */
    /*      相手勘定一覧（配列のJSON形式）                            */
    /* Arg2:flg                                                   */
    /*      区切り形式                                             */
    /*      true  = カンマ、スペースで区切る（Excel用）                   */
    /*      false = <br>で区切る（html用）                           */
    /* Ret : 相手勘定一覧（勘定科目の列記）                           */
    /*------------------------------------------------------------*/
    public function gCounterAccDecode($ContraAccounts, $flg = false) {
        $this->CL['LG']->cLog('T0002');
        
        if (!isset($ContraAccounts)) {
            return '';
        }
        if ($ContraAccounts == '') {
            return '';
        }
        
        $wk = json_decode($ContraAccounts);
        if (!is_array($wk)) {
            return $this->CL['SW']->gAccSNameVal($wk);
        }
        
        if (count($wk) == 0) {
            return '';
        }
        
        $ret = '';
        $conn = $this->CL['DF']->BR;
        if ($flg) {
            $conn = ', ';
        }
        foreach ($wk as $value) {
            if (mb_strlen($ret)) {
                $ret .= $conn;
            }
            $ret .= $this->CL['SW']->gAccSNameVal($value);
        }
        return $ret;
    }
    
    /*------------------------------------------------------------*/
    /* 会計期間内の2月29日の取得                                    */
    /* Arg1:TermFrom                                              */
    /*      YYYYMMDD 当該会計期間の最初の日                         */
    /* Arg2:TermTo                                                */
    /*      YYYYMMDD 当該会計期間の最後の日                         */
    /* Ret : 当該会計期間内の2月29日(YYYYMMDD)                      */
    /*------------------------------------------------------------*/
    public function g229inTerm($TermFrom, $TermTo) {
        $this->CL['LG']->cLog('T0002');
        
        $fromdate = substr($TermFrom, $this->CL['DF']->RngMonth2, $this->CL['DF']->LenMonth +  $this->CL['DF']->LenDay);
        
        if ('0229' > $fromdate) {
            return substr($TermFrom, $this->CL['DF']->RngYear2, $this->CL['DF']->LenYear).'0229';
        } else {
            return substr($TermTo, $this->CL['DF']->RngYear2, $this->CL['DF']->LenYear).'0229';
        }
    }
    
    /*------------------------------------------------------------*/
    /* 取引ID設定                                                 */
    /* Arg1:TrnDate                                               */
    /*      発生日                                                */
    /* Ret :次に付与する取引ID                                    */
    /*------------------------------------------------------------*/
    public function gNextTrnID($TrnDate) {
        $this->CL['LG']->cLog('T0002');
        $TrnLatestIDVal = $this->CL['SW']->gTrnLatestIDVal($TrnDate);
        
        // 最新のTrnLatestIDVal取得
        if ($TrnLatestIDVal == true) {
            // 当該日付が取引発生日のレコードが存在する場合、最新の次の番号を付与
            $BranchNum = self::gTrnIDFmt($this->CL['DF']->gTrnIDFmt2, $TrnLatestIDVal);
            $BranchNum = intval($BranchNum);
            $BranchNum++;
            $BranchNum = self::gTrnIDFmt($this->CL['DF']->gTrnIDFmt4, $BranchNum);
            $LatestTrnID = self::gTrnIDFmt($this->CL['DF']->gTrnIDFmt1, $TrnLatestIDVal).$BranchNum;
        } else {
            // 当該日付が取引発生日のレコードが存在しない場合、当該日付の最初の番号を付与
            $LatestTrnID = $TrnDate.'-'.$this->CL['DF']->InitTrnID;
        }
        return $LatestTrnID;
    }
    
    /*------------------------------------------------------------*/
    /* 取引ID設定(ver.2)                                          */
    /* Arg1:JnlKind                                               */
    /*      仕訳帳ID                                              */
    /* Arg2:TrnDate (YYYY or YYYYMM or YYYYMMDD)                  */
    /*      発生日                                                */
    /* Ret :次に付与する取引ID                                      */
    /*      $JnlKind.$TrnDate.'-'.DDDD                            */
    /*------------------------------------------------------------*/
    public function gNextTrnID2($JnlKind, $TrnDate) {
        $this->CL['LG']->cLog('T0002');
        $TrnLatestIDVal = $this->CL['SW']->gTrnLatestIDVal($JnlKind.$TrnDate);
        
        // 最新のTrnLatestIDVal取得
        if ($TrnLatestIDVal == true) {
            // 当該日付が取引発生日のレコードが存在する場合、最新の次の番号を付与
            $NumLength = strlen($TrnLatestIDVal) - strlen($JnlKind.$TrnDate.'-');
            $BranchNum = substr($TrnLatestIDVal, -1 * $NumLength);
            $BranchNum = intval($BranchNum);
            $BranchNum++;
            $BranchNum = self::gTrnIDFmt($this->CL['DF']->gTrnIDFmt4, $BranchNum);
            $LatestTrnID = $JnlKind.$TrnDate.'-'.$BranchNum;
        } else {
            // 当該日付が取引発生日のレコードが存在しない場合、当該日付の最初の番号を付与
            $LatestTrnID = $JnlKind.$TrnDate.'-'.$this->CL['DF']->InitTrnID;
        }
        return $LatestTrnID;
    }
    
    /*------------------------------------------------------------*/
    /* 各種仕訳帳表示用URL取得                                    */
    /* Arg1:JnlKindList                                           */
    /*      仕訳帳の一覧                                          */
    /* Arg2:JnlKind                                               */
    /*      取得対象の仕訳帳ID                                    */
    /* Ret :各種仕訳帳表示用URL                                   */
    /*------------------------------------------------------------*/
    public function gJnlUrl($JnlKindList, $JnlKind) {
        for ($i = 0; $i < count($JnlKindList); $i++) {
            if ($JnlKindList[$i]['JournalKindID'] == $JnlKind) {
                return $JnlKindList[$i]['Url'];
            }
        }
        return "";
    }
    
    /*------------------------------------------------------------*/
    /* カレンダー表示月数取得                                     */
    /* Arg1:flg                                                   */
    /*      gCalenMonth_bf :  過去表示年数を取得                  */
    /*      gCalenMonth_af :  未来表示年数を取得                  */
    /* Ret :示年数                                                */
    /*------------------------------------------------------------*/
    public function gCalenMonth($flg) {
        $this->CL['LG']->cLog('T0002');
        if ($flg == $this->CL['DF']->gCalenMonth_bf) {
            $val = ($this->CL['DF']->Past*$this->CL['DF']->NumMonth)+(date_format(new DateTime('now'), 'n')-1);
        } else if ($flg == $this->CL['DF']->gCalenMonth_af) {
            $val = ($this->CL['DF']->Future*$this->CL['DF']->NumMonth)+($this->CL['DF']->NumMonth-date_format(new DateTime('now'), 'n'));
        }
        return $val;
    }
    
    /*------------------------------------------------------------*/
    /* 前月を取得する                                             */
    /* Arg1:array                                                 */
    /*      [0]:年                                                */
    /*      [1]:月                                                */
    /* Ret :array                                                 */
    /*      [0]:年(前月)                                          */
    /*      [1]:月(前月)                                          */
    /*------------------------------------------------------------*/
    public function gPrevMonth($array) {
        $this->CL['LG']->cLog('T0002');
        if ($array[1] == 1) {
            $ret[0] = $array[0]-1;
            $ret[1] = $this->CL['DF']->NumMonth;
        } else {
            $ret[0] = $array[0];
            $ret[1] = $array[1]-1;
        }
        return $ret;
    }
    
    
    /*------------------------------------------------------------*/
    /* 翌月を取得する                                             */
    /* Arg1:array                                                 */
    /*      [0]:年                                                */
    /*      [1]:月                                                */
    /* Ret :array                                                 */
    /*      [0]:年(翌月)                                          */
    /*      [1]:月(翌月)                                          */
    /*------------------------------------------------------------*/
    public function gNextMonth($array) {
        $this->CL['LG']->cLog('T0002');
        if ($array[1] == $this->CL['DF']->NumMonth) {
            $ret[0] = $array[0]+1;
            $ret[1] = 1;
        } else {
            $ret[0] = $array[0];
            $ret[1] = $array[1]+1;
        }
        return $ret;
    }
    
    /*------------------------------------------------------------*/
    /* UTC時刻をロケール毎の時刻へ変更する                        */
    /* Arg1:MasterDate                                            */
    /*      マスタテーブルの作成時刻(Defineで定義)                */
    /* Arg2:date                                                  */
    /*      UTC時刻                                               */
    /* Arg3:flg                                                   */
    /*      gLocaleTime_space :YYYY-MM-DD JJ:MM:SSフォーマット    */
    /*      gLocaleTime_blank :YYYY-MM-DD<BR>JJ:MM:SSフォーマット */
    /* Ret :ロケール毎の時刻                                      */
    /*------------------------------------------------------------*/
    public function gLocaleTime($MasterDate, $date, $flg) {
        $this->CL['LG']->cLog('T0002');
        $ret = '';
        if ($date == $MasterDate) {
            // マスタテーブル(項目)用日付の場合、'-'を表示
            return '-';
        } else {
            if ($date == NULL) {
                return '';
            }
            // ロケールに応じた時刻へ変更
            $tz = date_default_timezone_get();
            date_default_timezone_set('UTC');
            $t = new DateTime($date);
            $t->setTimeZone(new DateTimeZone($_SESSION[$this->CL['DF']->SysID]['Locale']));
            $ret = $t->format('Y-m-d H:i:s');
            date_default_timezone_set($tz);
        }
        
        if ($flg == $this->CL['DF']->gLocaleTime_space) {
            return $ret;
        } else if ($flg == $this->CL['DF']->gLocaleTime_blank) {
            return self::gDateFmt($this->CL['DF']->gDateFmt2, $ret);
        }
    }
    
    /*------------------------------------------------------------*/
    /* リクエストパラメタを取得する                               */
    /*                                                            */
    /* Arg1:type                                                  */
    /*      GET     :リクエストパラメタ(_GET)の場合               */
    /*      POST    :リクエストパラメタ(_POST)の場合              */
    /*      SESSION :リクエストパラメタ(_SESSION)の場合           */
    /* Arg2:name                                                  */
    /*      name属性の値                                          */
    /* Arg3:ret                                                   */
    /*      typeにnameが存在しない場合の戻り値                    */
    /* Ret :指定したtype,nameの値、もしくはretの値                */
    /*------------------------------------------------------------*/
    public function filter_input($type, $name, $ret) {
        $this->CL['LG']->cLog('T0002');
        if ($type == $this->CL['DF']->GET) {
            if (isset($_GET[$name])) {
                return $_GET[$name];
            } else {
                return $ret;
            }
        } else if ($type == $this->CL['DF']->POST) {
            if (isset($_POST[$name])) {
                return $_POST[$name];
            } else {
                return $ret;
            }
        } else if ($type == $this->CL['DF']->SESSION) {
            if (isset($_SESSION[$this->CL['DF']->SysID][$name])) {
                return $_SESSION[$this->CL['DF']->SysID][$name];
            } else {
                return $ret;
            }
        } else {
            return NULL;
        }
    }
    
    /*-------------------------------------------------------------*/
    /* セレクトボックスに'selected'を付与する                      */
    /*      Arg1/Arg2が一致する場合、'selected'を返す              */
    /* Arg1:id                                                     */
    /*      セレクトボックスID                                     */
    /* Arg2:prm                                                    */
    /*      リクエストパラメタ(配列)/セレクトボックスID            */
    /* Ret :一致:'selected', 不一致:''                             */
    /*-------------------------------------------------------------*/
    public function addSelected($id, $prm) {
        $this->CL['LG']->cLog('T0002');
        if (is_array($prm)) {
            for ($i = 0, $c = count($prm); $i < $c; $i++) {
                if ($id == $prm[$i]) {
                    return ' selected';
                }
            }
        } else {
            if ($id == $prm) {
                return ' selected';
            }
        }
        return '';
    }
    
    /*-------------------------------------------------------------*/
    /* セレクトボックスのoption項目を作成する                              */
    /* Arg1:arr                                                    */
    /*      データ配列                                               */
    /* Arg2:valfield                                               */
    /*      データ配列内の値フィールド名                                 */
    /* Arg3:textfield                                              */
    /*      データ配列内の表記フィールド名                               */
    /* Arg4:ID                                                     */
    /*      データ配列内の表記フィールド名                               */
    /* Arg5:showcode                                              */
    /*      trueの場合、表示を [valfield] : [textfield] の形式にする   */
    /* Arg6:showblank                                             */
    /*      false以外の場合、最初にブランクをセットする                     */
    /*      その時の表記をセットする                                    */
    /* Arg7:showeverything                                         */
    /*      false以外の場合、最初に全てをセットする                     */
    /*      その時の表記をセットする                                    */
    /* Arg8:tagfields                                             */
    /*      付帯情報を追加する場合、フィールド名の配列をJSON形式で渡す      */
    /*      tag="" の中にフィールド名をキーにした配列のJSONで出力される      */
    /*      NULLまたは省略時は tag="" は出力されない                   */
    /* Ret :option宣言文字列                                       */
    /*-------------------------------------------------------------*/
    public function cSelectOption($arr, $valfield, $textfield, $ID = NULL, $showcode = false, $showblank = false, $showeverything = false, $tagfields = NULL) {
        $this->CL['LG']->cLog('T0002');
        $val = '';
        $tags = '';
        if ($tagfields != NULL) {
            $tagfields = json_decode($tagfields);
            if (!is_array($tagfields)) {
                $tagfields = array($tagfields);
            }
            $tagdetail = array();
            
            for ($j = 0; $j < count($tagfields); $j++) {
                $tagdetail[$tagfields[$j]] = '';
            }
            $tags = ' tag="'.htmlspecialchars(json_encode($tagdetail)).'"';
        }
        if (!$arr) {
            $arr = array();
        }
        if ($showeverything || $showeverything ==='') {
            $selected = self::addSelected($this->CL['DF']->ALL, $ID);
            $val .= '<option value=""'.$tags.$selected.'>'.htmlspecialchars($showeverything).'</option>';
        }
        if ($showblank || $showblank ==='') {
            $selected = self::addSelected('', $ID);
            $val .= '<option value=""'.$tags.$selected.'>'.htmlspecialchars($showblank).'</option>';
        }
        for ($i = 0, $c = count($arr); $i < $c; $i++) {
            $value = $arr[$i][$valfield];
            if ($showcode) {
                $view = $arr[$i][$valfield].':'.$arr[$i][$textfield];
            } else {
                $view = $arr[$i][$textfield];
            }
            
            $tags = '';
            if ($tagfields != NULL) {
                for ($j = 0; $j < count($tagfields); $j++) {
                    $tagdetail[$tagfields[$j]] = $arr[$i][$tagfields[$j]];
                }
                $tags = ' tag="'.htmlspecialchars(json_encode($tagdetail)).'"';
            }
            $selected = self::addSelected($value, $ID);
            $val .= '<option value="'.htmlspecialchars($value).'"'.$tags.$selected.'>'.htmlspecialchars($view).'</option>';
        }
        return $val;
    }
    
    /*------------------------------------------------------------*/
    /* ページング                                                 */
    /*      一覧表示時のページング文字列を作成する                */
    /* Arg1:PageRowText                                           */
    /*      当該ページ内件数                                      */
    /* Arg2:Pages                                                 */
    /*       現在のページ数                                       */
    /* Arg3:resultCntAll                                          */
    /*      検索条件に応じた総件数                                */
    /* Arg4:PageHead                                              */
    /*      ラベル(先頭)                                          */
    /* Arg5:PageTail                                              */
    /*      ラベル(前)                                            */
    /* Arg6:PagePrev                                              */
    /*     ラベル(次)                                             */
    /* Arg7:PageNext                                              */
    /*      ラベル(末尾)                                          */
    /* Ret :ページング文字列                                      */
    /*------------------------------------------------------------*/
    public function gPaging($PageRowText, $Pages, $resultCntAll, $PageHead, $PageTail, $PagePrev, $PageNext, $JSFunc = NULL) {
        $this->CL['LG']->cLog('T0002');
        $buf = array();
        $ret = array();
        
        // 表示数
        $buf['GetPageRowText'] = '';
        if (isset($PageRowText)) {
            $buf['GetPageRowText'] = $PageRowText;
        } else {
            $buf['GetPageRowText'] = NULL;
        }
        if ($PageRowText === '') {
            $PageRowText = $resultCntAll;
        }
        
        // ページ
        $buf['pages'] = '';
        if ((!isset($Pages)) || ($Pages == 1)) {
            $buf['pages'] = 1;
        } else {
            $buf['pages'] = $Pages;
        }
        
        // 開始行数
        $buf['LineS'] = '';
        if (isset($Pages)) {
            $buf['LineS'] = (($buf['pages']-1)*$PageRowText)+1;
        } else {
            if ($resultCntAll == 0) {
                $buf['LineS'] = 0;
            } else {
                $buf['LineS'] = 1;
            }
        }
        
        // 件数
        $buf['LineE'] = '';
        if (isset($Pages)) {
            if ((($buf['LineS']+$PageRowText)-1) > $resultCntAll) {
                $buf['LineE'] = $resultCntAll;
            } else {
                $buf['LineE'] = ($buf['LineS']+$PageRowText)-1;
            }
        } else if ((isset($PageRowText))) {
            if ((($buf['LineS']+$PageRowText)-1) == 0) {
                $buf['LineE'] = $resultCntAll;
            } else if ($PageRowText < $resultCntAll) {
                $buf['LineE'] = ($buf['LineS']+$PageRowText)-1;
            } else {
                $buf['LineE'] = $resultCntAll;
            }
        } else {
            $buf['LineE'] = $resultCntAll;
        }
        
        if ((isset($PageRowText)) && ($PageRowText < $resultCntAll) && ($PageRowText != '')) {
            // 総表示ページ数を計算
            $lastPage = ceil($resultCntAll/$PageRowText);
            $iFrom = 1;
            $iTo = 1;
            
            // 先頭
            $buf['PageHead'] = '';
            if ((isset($Pages)) && ($Pages > 1)) {
                // 2ページ以降
                if ($JSFunc == null) {
                    $url = self::gAddGetURL('pages=1', $this->CL['DF']->gAddGetURL_delParamSame1);
                } else {
                    $url = 'javascript:'.$JSFunc.'(\'pages=1\');';
                }
                $buf['PageHead'] = '<a href="'.$url.'">'.$PageHead.'</a>';
            } else {
                // 1ページ目
                $buf['PageHead'] = $PageHead;
            }
            
            // 末尾
            $buf['PageTail'] = '';
            if ((isset($Pages)) && ($Pages > 1)) {
                // 2ページ以降
                if ($Pages < $lastPage) {
                    if ($JSFunc == null) {
                        $url = self::gAddGetURL('pages='.$lastPage, $this->CL['DF']->gAddGetURL_delParamSame1);
                    } else {
                        $url = 'javascript:'.$JSFunc.'(\'pages='.$lastPage.'\');';
                    }
                    $buf['PageTail'] = '<a href="'.$url.'">'.$PageTail.'</a>';
                } else {
                    $buf['PageTail'] = $PageTail;
                }
            } else {
                // 1ページ目
                if ($JSFunc == null) {
                    $url = self::gAddGetURL('pages='.$lastPage, $this->CL['DF']->gAddGetURL_delParamSame1);
                } else {
                    $url = 'javascript:'.$JSFunc.'(\'pages='.$lastPage.'\');';
                }
                $buf['PageTail'] = '<a href="'.$url.'">'.$PageTail.'</a>';
            }
            
            // 前
            $buf['PagePrev'] = '';
            if ((isset($Pages)) && ($Pages > 1)) {
                // 2ページ以降
                if ($JSFunc == null) {
                    $url = self::gAddGetURL('pages='.($Pages-1), $this->CL['DF']->gAddGetURL_delParamSame1);
                } else {
                    $url = 'javascript:'.$JSFunc.'(\'pages='.($Pages-1).'\');';
                }
                $buf['PagePrev'] = '<a href="'.$url.'">'.$PagePrev.'</a>';
            } else {
                // 1ページ目
                $buf['PagePrev'] = $PagePrev;
            }
            
            // 次
            $buf['PageNext'] = '';
            if ((isset($Pages)) && ($Pages > 1)) {
                // 2ページ以降
                if ($Pages < $lastPage) {
                    if ($JSFunc == null) {
                        $url = self::gAddGetURL('pages='.($Pages+1), $this->CL['DF']->gAddGetURL_delParamSame1);
                    } else {
                        $url = 'javascript:'.$JSFunc.'(\'pages='.($Pages+1).'\');';
                    }
                    $buf['PageNext'] = '<a href="'.$url.'">'.$PageNext.'</a>';
                } else {
                    $buf['PageNext'] = $PageNext;
                }
            } else {
                // 1ページ目
                if ($JSFunc == null) {
                    $url = self::gAddGetURL('pages=2', $this->CL['DF']->gAddGetURL_delParamSame1);
                } else {
                    $url = 'javascript:'.$JSFunc.'(\'pages=2\');';
                }
                $buf['PageNext'] = '<a href="'.$url.'">'.$PageNext.'</a>';
            }
            
            // 前省略(...)
            $buf['OmitPrev'] = '';
            if ((isset($Pages)) && ($Pages > 1)) {
                // 2ページ以降
                if (($Pages > ($this->CL['DF']->showNum+1)) && ($lastPage >= (($this->CL['DF']->showNum*2)+1))) {
                    $buf['OmitPrev'] = '...';
                }
            }
            
            // 後省略(...)
            $buf['OmitNext'] = '';
            if ((isset($Pages)) && ($Pages > 1)) {
                // 2ページ以降
                if ((($lastPage-$Pages) > $this->CL['DF']->showNum) && ($lastPage >= (($this->CL['DF']->showNum*2)+1))) {
                    $buf['OmitNext'] = '...';
                }
            } else if ($lastPage >= (($this->CL['DF']->showNum*2)+1)) {
                // 1ページ目
                $buf['OmitNext'] = '...';
            }
            
            // iFrom/iTo
            if (isset($Pages)) {
                if ($lastPage <= (($this->CL['DF']->showNum*2)+1)) {
                    // 省略無し(全部で11ページ未満)
                    $iFrom = 1;
                    $iTo = $lastPage;
                } else if (($Pages > ($this->CL['DF']->showNum+1)) && (($Pages+$this->CL['DF']->showNum) < $lastPage)) {
                    // 前後が省略
                    $iFrom = $Pages-$this->CL['DF']->showNum;
                    $iTo = $Pages+$this->CL['DF']->showNum;
                } else if ($Pages > ($this->CL['DF']->showNum+1)) {
                    // 前だけ省略
                    $iFrom = $lastPage-($this->CL['DF']->showNum*2);
                    $iTo = $lastPage;
                } else {
                    // 後だけ省略
                    $iFrom = 1;
                    $iTo = (($this->CL['DF']->showNum*2)+1);
                }
            } else {
                // 1ページ目
                if ($lastPage >= (($this->CL['DF']->showNum*2)+1)) {
                    // 省略無し(全部で11ページ以上)
                    $iFrom = 1;
                    $iTo = (($this->CL['DF']->showNum*2)+1);
                } else {
                    // 省略無し(全部で11ページ未満)
                    $iFrom = 1;
                    $iTo = $lastPage;
                }
            }
            
            // ページ
            $buf['PageLink'] = array();
            if ((isset($Pages)) && ($Pages > 1)) {
                // 2ページ以降
                for ($i = $iFrom, $j = 0; ($i <= $lastPage) && ($i <= $iTo); $i++, $j++) {
                    if ($JSFunc == null) {
                        $url = self::gAddGetURL('pages='.$i, $this->CL['DF']->gAddGetURL_delParamSame1);
                    } else {
                        $url = 'javascript:'.$JSFunc.'(\'pages='.$i.'\');';
                    }
                    if ($Pages == $i) {
                        $buf['PageLink'][$j] = '<font class="italic-middle">'.$i.'</font>';
                    } else {
                        $buf['PageLink'][$j] = '<a href="'.$url.'">'.$i.'</a>';
                    }
                }
            } else {
                // 1ページ目
                for ($i = $iFrom, $j = 0; ($i <= $lastPage) && ($i <= $iTo); $i++, $j++) {
                    if ($JSFunc == null) {
                        $url = self::gAddGetURL('pages='.$i, $this->CL['DF']->gAddGetURL_delParamSame1);
                    } else {
                        $url = 'javascript:'.$JSFunc.'(\'pages='.$i.'\');';
                    }
                    if ($i == 1) {
                        $buf['PageLink'][$j] = '<font class="italic-middle">'.$i.'</font>';
                    } else {
                        $buf['PageLink'][$j] = '<a href="'.$url.'">'.$i.'</a>';
                    }
                }
            }
        }
        
        // 画面表示用作成
        $ret['View'] = '';
        if (($buf['GetPageRowText'] != NULL) && ($buf['GetPageRowText'] < $resultCntAll) && ($buf['GetPageRowText'] != '')) {
            $ret['View'] .= '[ '.$buf['PageHead'].' '.$buf['PagePrev'].' '.$buf['OmitPrev'];
            for ($i = 0, $c = count($buf['PageLink']); $i < $c; $i++) {
                $ret['View'] .= ' '.$buf['PageLink'][$i];
            }
            $ret['View'] .= $buf['OmitNext'].' '.$buf['PageNext'].' '.$buf['PageTail'].' ]';
        }
        
        $ret['LineS'] = $buf['LineS'];
        $ret['LineE'] = $buf['LineE'];
        $ret['PageN'] = $buf['pages'];
        $ret['PageE'] = $url = (isset($lastPage) ? $lastPage : 0);
        return $ret;
    }
    
    /*------------------------------------------------------------*/
    /* 現在のURLからクラス名を取得する                            */
    /*                                                            */
    /* Ret :クラス名                                              */
    /*------------------------------------------------------------*/
    public function getClassName() {
        $FileName = self::gCurrentFile($this->CL['DF']->gCurrentFile_delParam);
        
        return $this->CL['DF']->URL_Class[$FileName];
    }
    
    /*------------------------------------------------------------*/
    /* 各画面のユーザに応じた権限を取得する                       */
    /*                                                            */
    /* Arg1:Class                                                 */
    /*      クラス名                                              */
    /* Ret :権限有:true, 権限無:false                             */
    /*------------------------------------------------------------*/
    public function getAuth($Class) {
        $this->CL['LG']->cLog('T0002');
        // ログインユーザの権限取得
        $auth = $this->CL['SW']->gUserAuthIDVal();
        
        switch ($Class) {
            case $this->CL['DF']->class_COMPUS:    // 会社情報修正
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_CLNTAS:    // 取引先情報入力
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_CLNTUS:    // 取引先情報修正
            case $this->CL['DF']->class_CLNTUL:    // 取引先情報修正
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_CLNTDL:    // 取引先情報削除
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_PYTMAS:    // 支払期限情報入力
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_PYTMUS:    // 支払期限情報修正
            case $this->CL['DF']->class_PYTMUL:    // 支払期限情報修正
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_PYTMDL:    // 支払期限情報削除
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_CRLMAS:    // 与信枠情報入力
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_CRLMUS:    // 与信枠情報修正
            case $this->CL['DF']->class_CRLMUL:    // 与信枠情報修正
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_CRLMDL:    // 与信枠情報削除
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_SEGMAS:    // セグメント情報入力
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_SEGMUS:    // セグメント情報修正
            case $this->CL['DF']->class_SEGMUL:    // セグメント情報修正
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_SEGMDL:    // セグメント情報削除
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_CURRAS:    // 通貨情報入力
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_CURRUS:    // 通貨情報修正
            case $this->CL['DF']->class_CURRUL:    // 通貨情報修正
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_CURRDL:    // 通貨情報削除
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_BANKAS:    // 銀行情報入力
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_BANKUS:    // 銀行情報修正
            case $this->CL['DF']->class_BANKUL:    // 銀行情報修正
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_BANKDL:    // 銀行情報削除
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_BKACAS:    // 銀行口座情報入力
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_BKACUS:    // 銀行口座情報修正
            case $this->CL['DF']->class_BKACUL:    // 銀行口座情報修正
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_BKACDL:    // 銀行口座情報削除
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_DIVIAS:    // 事業部情報入力
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_DIVIUS:    // 事業部情報修正
            case $this->CL['DF']->class_DIVIUL:    // 事業部情報修正
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_DIVIDL:    // 事業部情報削除
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_ASSTAS:    // 資産種別情報入力
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_ASSTUS:    // 資産種別情報修正
            case $this->CL['DF']->class_ASSTUL:    // 資産種別情報修正
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_ASSTDL:    // 資産種別情報削除
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_FASSAS:    // 固定資産情報入力
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_FASSUS:    // 固定資産情報修正
            case $this->CL['DF']->class_FASSUL:    // 固定資産情報修正
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_FASSDL:    // 固定資産情報削除
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_FASSRS:    // 固定資産除却入力
            case $this->CL['DF']->class_FASSRL:    // 固定資産除却一覧
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_DEPRCL:    // 減価償却情報計算
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_USERAS:    // ユーザ情報入力
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_USERUS:    // ユーザ情報修正
            case $this->CL['DF']->class_USERUL:    // ユーザ情報修正
            case $this->CL['DF']->class_USERDL:    // ユーザ情報削除
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_USGRAS:
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:
                    case $this->CL['DF']->usrAuth_General:
                    case $this->CL['DF']->usrAuth_Audit:
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:
                    case $this->CL['DF']->usrAuth_System:
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_USGRUS:
            case $this->CL['DF']->class_USGRUL:
            case $this->CL['DF']->class_USGRDL:
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:
                    case $this->CL['DF']->usrAuth_General:
                    case $this->CL['DF']->usrAuth_Audit:
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:
                    case $this->CL['DF']->usrAuth_System:
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_ACCTAS:    // 勘定科目情報入力
            case $this->CL['DF']->class_ACCTUS:    // 勘定科目情報修正
            case $this->CL['DF']->class_ACCTUL:    // 勘定科目情報修正
            case $this->CL['DF']->class_ACCTAP:    // 勘定科目情報入力ポップアップ
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_ACCTDL:    // 勘定科目情報削除
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_JGTRES:    // 普通仕訳帳(取引仕訳)入力
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_JGTRPL:    // 普通仕訳帳(取引仕訳)承認
            case $this->CL['DF']->class_JGTRSL:    // 普通仕訳帳(取引仕訳)転記
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_JGTRCL:    // 普通仕訳帳(取引仕訳)確定
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_ALLTRL:    // 全取引参照
                switch ($auth) {
                        //return false;
                        //break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_GNRLTL:    // 総勘定元帳
            case $this->CL['DF']->class_GNRLGL:    // 総勘定元帳
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_SUBLGL:    // 補助元帳
            case $this->CL['DF']->class_SBLBLL:    // 残高一覧表
            case $this->CL['DF']->class_AGNGRL:    // Aging Report
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_UNADTB:    // 修正前試算表
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_JGADES:    // 普通仕訳帳(決算整理仕訳)入力
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_JGADPL:    // 普通仕訳帳(決算整理仕訳)承認
            case $this->CL['DF']->class_JGADSL:    // 普通仕訳帳(決算整理仕訳)転記
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_JGADCL:    // 普通仕訳帳(決算整理仕訳)確定
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_CLSMCL:    // 月次決算確定
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_ADJSTB:    // 修正後試算表
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_JGCMRL:    // 普通仕訳帳参照
                switch ($auth) {
                        //return false;
                        //break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
// ticket 0001856 start
//            default:
//                return false;
//                break;
// ticket 0001856 end
            case $this->CL['DF']->class_MNCWKS:    // 月次決算精算表
                switch ($auth) {
                        //return false;
                        //break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_BALSTL:    // 損益計算書
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_PRLOSL:    // 貸借対照表
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_OPBLUS:    // 開始残高変更
            case $this->CL['DF']->class_OPBDUS:    // 開始残高明細変更
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            case $this->CL['DF']->class_JSSTDS:    // 特殊仕訳帳(商品売上/国内)入力
            case $this->CL['DF']->class_JSSTDL:    // 特殊仕訳帳(商品売上/国内)確定
            case $this->CL['DF']->class_JSSTIS:    // 特殊仕訳帳(商品売上/国外)入力
            case $this->CL['DF']->class_JSSTIL:    // 特殊仕訳帳(商品売上/国外)確定
            case $this->CL['DF']->class_JSSGDS:    // 特殊仕訳帳(物品売上/国内)入力
            case $this->CL['DF']->class_JSSGDL:    // 特殊仕訳帳(物品売上/国内)確定
            case $this->CL['DF']->class_JSSGIS:    // 特殊仕訳帳(物品売上/国外)入力
            case $this->CL['DF']->class_JSSGIL:    // 特殊仕訳帳(物品売上/国外)確定
            case $this->CL['DF']->class_JSSSDS:    // 特殊仕訳帳(役務売上/国内)入力
            case $this->CL['DF']->class_JSSSDL:    // 特殊仕訳帳(役務売上/国内)確定
            case $this->CL['DF']->class_JSSSIS:    // 特殊仕訳帳(役務売上/国外)入力
            case $this->CL['DF']->class_JSSSIL:    // 特殊仕訳帳(役務売上/国外)確定
            case $this->CL['DF']->class_JSRCDS:    // 特殊仕訳帳(現金入金/国内)入力
            case $this->CL['DF']->class_JSRCDE:    // 特殊仕訳帳(現金入金/国内)確定
            case $this->CL['DF']->class_JSRCIS:    // 特殊仕訳帳(現金入金/国外)入力
            case $this->CL['DF']->class_JSRCIE:    // 特殊仕訳帳(現金入金/国外)確定
            case $this->CL['DF']->class_JSPTDS:    // 特殊仕訳帳(商品仕入/国内)入力
            case $this->CL['DF']->class_JSPTDE:    // 特殊仕訳帳(商品仕入/国内)確定
            case $this->CL['DF']->class_JSPTIS:    // 特殊仕訳帳(商品仕入/国外)入力
            case $this->CL['DF']->class_JSPTIE:    // 特殊仕訳帳(商品仕入/国外)確定
            case $this->CL['DF']->class_JSPGDS:    // 特殊仕訳帳(物品購入/国内)入力
            case $this->CL['DF']->class_JSPGDE:    // 特殊仕訳帳(物品購入/国内)確定
            case $this->CL['DF']->class_JSPGIS:    // 特殊仕訳帳(物品購入/国外)入力
            case $this->CL['DF']->class_JSPGIE:    // 特殊仕訳帳(物品購入/国外)確定
            case $this->CL['DF']->class_JSPSDS:    // 特殊仕訳帳(役務購入/国内)入力
            case $this->CL['DF']->class_JSPSDE:    // 特殊仕訳帳(役務購入/国内)確定
            case $this->CL['DF']->class_JSPSIS:    // 特殊仕訳帳(役務購入/国外)入力
            case $this->CL['DF']->class_JSPSIE:    // 特殊仕訳帳(役務購入/国外)確定
			
			case $this->CL['DF']->class_JSPIIS:    // 特殊仕訳帳(役務購入/国外)入力
            case $this->CL['DF']->class_JSPIIE:    // 特殊仕訳帳(役務購入/国外)確定
			
			case $this->CL['DF']->class_JSPDIS:    // 特殊仕訳帳(役務購入/国外)入力
			case $this->CL['DF']->class_JSPDIE:    // 特殊仕訳帳(役務購入/国外)確定
			case $this->CL['DF']->class_JSPRIS:    // 特殊仕訳帳(役務購入/国外)入力
			case $this->CL['DF']->class_JSPRIE:    // 特殊仕訳帳(役務購入/国外)確定
			
			
            case $this->CL['DF']->class_JSPYDS:    // 特殊仕訳帳(現金支払/国内)入力
            case $this->CL['DF']->class_JSPYDE:    // 特殊仕訳帳(現金支払/国内)確定
            case $this->CL['DF']->class_JSPYIS:    // 特殊仕訳帳(現金支払/国外)入力
            case $this->CL['DF']->class_JSPYIE:    // 特殊仕訳帳(現金支払/国外)確定
                switch ($auth) {
                    case $this->CL['DF']->usrAuth_Audit:            // 監査
                        return false;
                        break;
                    case $this->CL['DF']->usrAuth_Responsible:      // 担当
                    case $this->CL['DF']->usrAuth_General:          // 一般
                    case $this->CL['DF']->usrAuth_Administrator:    // 管理者
                    case $this->CL['DF']->usrAuth_System:           // システム管理者
                        return true;
                        break;
                }
                break;
            default:
                return false;
                break;
        }
    }
    
    /*------------------------------------------------------------*/
    /* 遷移確認チケット発行                                       */
    /*                                                            */
    /* Ret :チケット                                              */
    /*------------------------------------------------------------*/
    public function sTransition() {
        return md5(uniqid().mt_rand());
    }
    
    /*------------------------------------------------------------*/
    /* 遷移確認チケット確認                                       */
    /*                                                            */
    /* Ret :正常:true, 異常:false                                 */
    /*------------------------------------------------------------*/
    public function cTransition() {
        $this->CL['LG']->cLog('T0002');
        // 遷移確認
        if (isset($_SESSION['ticket'])) {
            // 正常
            unset($_SESSION['ticket']);
            return true;
        } else {
            // 異常
            return false;
        }
    }
    /*--------------------------------------------------------------------------*/
    /* 残高キーから残高情報（残高金額、勘定科目、税金情報を取得する）                     */
    /* Arg1:PresentCurrency                                                     */
    /*      表示通貨ID                                                          */
    /* Arg2:prm_ClientID                                                        */
    /*      相手先ID                                                            */
    /* Arg3:prm_Currency                                                        */
    /*      通貨ID                                                              */
    /* Arg4:prm_ControlNo                                                       */
    /*      残高キーNo.                                                          */
    /* Arg5:prm_Type                                                            */
    /*      取得対象勘定科目グループ（配列をJSON形式で表記）                           */
    /* Arg6:prm_OmitType                                                        */
    /*      取得除外勘定科目グループ（配列をJSON形式で表記）                           */
    /* Arg7:prm_OmitTrnID                                                       */
    /*      取得除外取引ID（現在変更中の取引は除外）                                 */
    /* Arg8:prm_AccID                                                           */
    /*      勘定科目IDが限定できる場合は勘定科目ID                                  */
    /* Arg9:prm_SegmentID                                                       */
    /*      セグメントが限定できる場合はセグメントID                                     */
    /* Ret :JSON形式の残高情報                                                   */
    /*--------------------------------------------------------------------------*/
    function gBalanceData($jnlkindid, $PresentCurrency, $prm_ClientID, $prm_Currency, $prm_ControlNo, $prm_Type, $prm_OmitType, $prm_OmitTrnID, $prm_AccID, $prm_SegmentID) {
        $this->CL['LG']->cLog('T0002');
//        // JavaScript側からのパラメータをSQL用のパラメータに変換する
//        $CashBankflg        = NULL;
//        $ARDmtflg           = NULL;
//        $ARIntflg           = NULL;
//        $SalesDmtflg        = NULL;
//        $SalesIntflg        = NULL;
//        $PurchaseStockflg   = NULL;
//        $PurchasenonStockflg    = NULL;
//        $PurchaseServiceflg = NULL;
//        $APDmtflg           = NULL;
//        $APIntflg           = NULL;
//        $PettyCashExpenseflg    = NULL;
//        $InputVATflg        = NULL;
//        $NonDeductibleInputVATflg                   = NULL;
//        $InputVATNotSubjectCorporateTaxDeductionflg = NULL;
//        $OutputVATflg       = NULL;
//        $SuspenseInputVATflg    = NULL;
//        $SuspenseOutputVATflg   = NULL;
//        $WithholdingTaxflg  = NULL;
//        $WithheldTaxflg     = NULL;
//        $ImportDutyflg      = NULL;
//        $PayableCustomsflg  = NULL;
//        
//        if (!is_array($this->prm_Type)) {
//            $this->prm_Type = json_decode($this->prm_Type);
//            if (!is_array($this->prm_Type)) {
//                $this->prm_Type = array($this->prm_Type);
//            }
//        }
//        
//        for ($i = 0; $i < count($this->prm_Type); $i++) {
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_CashBank) {
//                $CashBankflg        = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_ARDmt) {
//                $ARDmtflg           = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_ARInt) {
//                $ARIntflg           = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_SalesDmt) {
//                $SalesIntflg        = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_SalesInt) {
//                $SalesDmtflg        = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_PurchaseStock) {
//                $PurchaseStockflg   = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_PurchasenonStock) {
//                $PurchasenonStockflg    = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_PurchaseService) {
//                $PurchaseServiceflg = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_APDmt) {
//                $APDmtflg           = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_APInt) {
//                $APIntflg           = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_PettyCashExpense) {
//                $PettyCashExpenseflg    = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_InputVAT) {
//                $InputVATflg        = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_NonDeductibleInputVATflg) {
//                $NonDeductibleInputVATflg   = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_InputVATNotSubjectCorporateTaxDeductionflg) {
//                $InputVATNotSubjectCorporateTaxDeductionflg = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_OutputVAT) {
//                $OutputVATflg       = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_SuspenseInputVAT) {
//                $SuspenseInputVATflg    = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_SuspenseOutputVAT) {
//                $SuspenseOutputVATflg   = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_WithholdingTax) {
//                $WithholdingTaxflg  = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_WithheldTax) {
//                $WithheldTaxflg     = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_ImportDuty) {
//                $ImportDutyflg  = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_PayableCustoms) {
//                $PayableCustomsflg     = $CL['DF']->ClientChecked;
//            } 
//            if ($this->prm_Type[$i] == $CL['DF']->AccType_AllInputVAT) {
//                $InputVATflg        = $CL['DF']->ClientChecked;
//                $NonDeductibleInputVATflg   = $CL['DF']->ClientChecked;
//                $InputVATNotSubjectCorporateTaxDeductionflg = $CL['DF']->ClientChecked;
//            }
//        }
//        
//        if (!is_array($this->prm_OmitType)) {
//            $this->prm_OmitType = json_decode($this->prm_OmitType);
//            if (!is_array($this->prm_OmitType)) {
//                $this->prm_OmitType = array($this->prm_OmitType);
//            }
//        }
//        
//        for ($i = 0; $i < count($this->prm_OmitType); $i++) {
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_CashBank) {
//                $CashBankflg        = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_ARDmt) {
//                $ARDmtflg           = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_ARInt) {
//                $ARIntflg           = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_SalesDmt) {
//                $SalesIntflg        = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_SalesInt) {
//                $SalesDmtflg        = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_PurchaseStock) {
//                $PurchaseStockflg   = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_PurchasenonStock) {
//                $PurchasenonStockflg    = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_PurchaseService) {
//                $PurchaseServiceflg = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_APDmt) {
//                $APDmtflg           = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_APInt) {
//                $APIntflg           = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_PettyCashExpense) {
//                $PettyCashExpenseflg    = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_InputVAT) {
//                $InputVATflg        = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_NonDeductibleInputVATflg) {
//                $NonDeductibleInputVATflg   = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_InputVATNotSubjectCorporateTaxDeductionflg) {
//                $InputVATNotSubjectCorporateTaxDeductionflg = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_OutputVAT) {
//                $OutputVATflg       = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_SuspenseInputVAT) {
//                $SuspenseInputVATflg    = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_SuspenseOutputVAT) {
//                $SuspenseOutputVATflg   = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_WithholdingTax) {
//                $WithholdingTaxflg  = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_WithheldTax) {
//                $WithheldTaxflg     = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_ImportDuty) {
//                $ImportDutyflg  = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_PayableCustoms) {
//                $PayableCustomsflg     = $CL['DF']->ClientNonCheck;
//            } 
//            if ($this->prm_OmitType[$i] == $CL['DF']->AccType_AllInputVAT) {
//                $InputVATflg        = $CL['DF']->ClientNonCheck;
//                $NonDeductibleInputVATflg   = $CL['DF']->ClientNonCheck;
//                $InputVATNotSubjectCorporateTaxDeductionflg = $CL['DF']->ClientNonCheck;
//            }
//        }
//        
//        // 残高データ取得
//        $arraydata = $CL['SW']->gSubLedSearch($CL['DF']->NewestDate2, $CL['DF']->OldestDate2, $this->prm_ClientID, $this->prm_Currency, $this->prm_ControlNo, $this->prm_AccID, $CashBankflg, $ARDmtflg, $ARIntflg, 
//                            $SalesDmtflg, $SalesIntflg, $PurchaseStockflg, $PurchasenonStockflg, $PurchaseServiceflg, $APDmtflg, 
//                            $APIntflg, $PettyCashExpenseflg, $InputVATflg, $NonDeductibleInputVATflg, $InputVATNotSubjectCorporateTaxDeductionflg, $OutputVATflg, 
//                            $SuspenseInputVATflg, $SuspenseOutputVATflg, $WithholdingTaxflg, $WithheldTaxflg, $ImportDutyflg, $PayableCustomsflg);
        
        if (($prm_ControlNo == '') || (is_null($prm_ControlNo))) {
            return nl2br('');
        }
        
        $arraydata = self::gSubLedSearch($prm_ClientID, $prm_Currency, $prm_ControlNo, $prm_Type, $prm_OmitType, $prm_OmitTrnID, $prm_AccID, $prm_SegmentID);
// $this->CL['LG']->cLog('S0001', ['get SubLedSearch', '$prm_ClientID:'.$prm_ClientID, '$prm_Currency:'.$prm_Currency, '$prm_Type:'.json_encode($prm_Type), '$arraydata:'.json_encode($arraydata), '$_SESSION:'.json_encode($_SESSION), '$_POST:'.json_encode($_POST), '$_GET:'.json_encode($_GET)]);        // log_out for trace
// echo json_encode($arraydata);

        if (!$arraydata) {
            return nl2br('');
        }
        $arr = array();
        $ControlNo = NULL;
        $AccountsTitleID = NULL;
        $SegmentID = NULL;
        $amount = 0;
        $fxamount = 0;
        $TrnIDList = array();
        $taxinfo = array('WithHoldingTax' => array(), 'WithHeldTax' => array(), 'UdInputVAT' => array(), 'UdOutputVAT' => array(), 'InputVAT' => array());
        $accinfo = array();
        $findserviceflg = false;
        $findaptordflg = false;
        
        for ($i = 0; $i < count($arraydata); $i++) {
            // キーが変わったらデータを配列に書き出す
            if (($ControlNo != $arraydata[$i]['ControlNo']) || ($AccountsTitleID != $arraydata[$i]['AccountsTitleID']) || ($SegmentID != $arraydata[$i]['SegmentID'])) {
                if (($ControlNo != NULL) || ($AccountsTitleID != NULL) || ($SegmentID != NULL)) {
                    if ((($amount != 0) && ($prm_Currency == $PresentCurrency)) || (($fxamount != 0) && ($prm_Currency != $PresentCurrency))) {
                        if (!$findserviceflg) {
                            $accinfo = array();
                        }
//                        if ($findaptordflg) {
//                            $taxinfo = array('WithHoldingTax' => array(), 'WithHeldTax' => array(), 'UdInputVAT' => array(), 'UdOutputVAT' => array(), 'InputVAT' => array());
//                        }
                        $arr[] = array('ControlNo' => $ControlNo, 'AccountsTitleID' => $AccountsTitleID, 'SegmentID' => $SegmentID, 'amount' => $amount, 'fxamount' => $fxamount, 'accinfo' => $accinfo, 'taxinfo' => $taxinfo);
                    }
                }
                if ($AccountsTitleID != $arraydata[$i]['AccountsTitleID']) {
                    $AccLMSRow = $this->CL['SW']->gAccLMSRow($arraydata[$i]['AccountsTitleID']);
                }
                $ControlNo = $arraydata[$i]['ControlNo'];
                $AccountsTitleID = $arraydata[$i]['AccountsTitleID'];
                $SegmentID = $arraydata[$i]['SegmentID'];
                $amount = 0;
                $fxamount = 0;
                
                $TrnIDList = array();
                $taxinfo = array('WithHoldingTax' => array(), 'WithHeldTax' => array(), 'UdInputVAT' => array(), 'UdOutputVAT' => array(), 'InputVAT' => array(), 'OutputVAT' => array());
                $accinfo = array();
                $findserviceflg = false;
                $findaptordflg = false;
            }
            // 数字を足し込む
            // BSの勘定科目のみにする（とりあえず）
            if (!(($AccLMSRow['AccountsKind1ID'] == $this->CL['DF']->acc_OrdinaryPL) || ($AccLMSRow['AccountsKind1ID'] == $this->CL['DF']->acc_ExOrdinaryPL) || ($AccLMSRow['AccountsKind1ID']  == $this->CL['DF']->acc_CorporateTax))) {
                // 初期残高の場合
                if ($arraydata[$i]['datasource'] == '0') {
                    $amount += $arraydata[$i]['Amount'];
                    $fxamount += $arraydata[$i]['FxAmount'];
                // SubLedgerデータの場合
                } else if ($arraydata[$i]['datasource'] == '1') {
                    $amt = $arraydata[$i]['Amount'];
                    $fxamt = $arraydata[$i]['FxAmount'];
//                    if (($AccLMSRow['AccountsKind1ID'] == $this->CL['DF']->acc_Liabilities) || ($AccLMSRow['AccountsKind1ID'] == $this->CL['DF']->acc_Stockholders)) {
                    if ($AccLMSRow['DrCrFlg'] == $this->CL['DF']->Cr) {
                        $amt *= -1;
                        $fxamt *= -1;
                    }
                    if ($arraydata[$i]['DrCrFlg'] == $this->CL['DF']->Cr) {
                        $amt *= -1;
                        $fxamt *= -1;
                    }
                    $amount += $amt;
                    $fxamount += $fxamt;
                }
            }
            if ($arraydata[$i]['TransactionID'] == $prm_OmitTrnID) {
                continue;
            }
            if (($arraydata[$i]['JournalKindID'] == $this->CL['DF']->PurchaseServicesDmtKindID) ||($arraydata[$i]['JournalKindID'] == $this->CL['DF']->PurchaseServicesIntKindID) ||($arraydata[$i]['JournalKindID'] == $this->CL['DF']->SaleServicesDmtJnlKindID) ||($arraydata[$i]['JournalKindID'] == $this->CL['DF']->SaleServicesIntJnlKindID)) {
                $findserviceflg = true;
            }
            // 付帯情報（仮VAT、源泉徴収税）を取得する
            if (!array_key_exists($arraydata[$i]['TransactionID'] , $TrnIDList)) {
                $TrnIDList[$arraydata[$i]['TransactionID']] = $arraydata[$i]['TransactionID'];
                if ($arraydata[$i]['JournalKindID'] == $this->CL['DF']->GenJnlKindID) {
                    $JnlData = $this->CL['SW']->gTrnGenList($arraydata[$i]['TransactionID'], $arraydata[$i]['RevisionNo']);
                    for ($j = 0; $j < count($JnlData); $j++) {
                        // 税関への未払いまたは歳入局への未払いのチェック
                        if (($JnlData[$j]['PayableCustomsflg'] == $this->CL['DF']->ClientChecked) || ($JnlData[$j]['PayableRevDepflg'] == $this->CL['DF']->ClientChecked)) {
                            $findaptordflg = true;
                        }
                        // Input VAT for international cash payment (expense)
                        if (($jnlkindid == $this->CL['DF']->PaymentIntKindID) && ($JnlData[$j]['PurchaseServiceflg'] == $this->CL['DF']->ClientChecked)) {
                            if (!array_key_exists($JnlData[$j]['VATTypeAC'] , $taxinfo['InputVAT'])) {
                                $taxinfo['InputVAT'][$JnlData[$j]['VATTypeAC']] = array();
                                $taxinfo['InputVAT'][$JnlData[$j]['VATTypeAC']]['FxTaxableAmount_tax'] = 0;
                                $taxinfo['InputVAT'][$JnlData[$j]['VATTypeAC']]['FxTaxableAmount_trade'] = 0;
                            }
                            $fxamt = $JnlData[$j]['FxAmount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Cr) {
                                $fxamt *= -1;
                            }
                            $taxinfo['InputVAT'][$JnlData[$j]['VATTypeAC']]['FxTaxableAmount_trade'] += $fxamt;
                        }
                        // Output VAT for international cash receipt (expense)
                        if (($jnlkindid == $this->CL['DF']->ReceiptIntKindID) && ($JnlData[$j]['ServiceSalesflg'] == $this->CL['DF']->ClientChecked)) {
                            if (!array_key_exists($JnlData[$j]['VATTypeAC'] , $taxinfo['OutputVAT'])) {
                                $taxinfo['OutputVAT'][$JnlData[$j]['VATTypeAC']] = array();
                                $taxinfo['OutputVAT'][$JnlData[$j]['VATTypeAC']]['FxTaxableAmount_tax'] = 0;
                                $taxinfo['OutputVAT'][$JnlData[$j]['VATTypeAC']]['FxTaxableAmount_trade'] = 0;
                            }
                            $fxamt = $JnlData[$j]['FxAmount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Dr) {
                                $fxamt *= -1;
                            }
                            $taxinfo['OutputVAT'][$JnlData[$j]['VATTypeAC']]['FxTaxableAmount_trade'] += $fxamt;
                        }
                        // Input VAT for international cash payment (Input VAT)
                        if (($jnlkindid == $this->CL['DF']->PaymentIntKindID) && ($JnlData[$j]['InputVATflg'] == $this->CL['DF']->ClientChecked)) {
                            if (!array_key_exists($JnlData[$j]['VATType'] , $taxinfo['InputVAT'])) {
                                $taxinfo['InputVAT'][$JnlData[$j]['VATType']] = array();
                                $taxinfo['InputVAT'][$JnlData[$j]['VATType']]['FxTaxableAmount_tax'] = 0;
                                $taxinfo['InputVAT'][$JnlData[$j]['VATType']]['FxTaxableAmount_trade'] = 0;
                            }
                            $fxamt = $JnlData[$j]['FxAmount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Cr) {
                                $fxamt *= -1;
                            }
                            $taxinfo['InputVAT'][$JnlData[$j]['VATType']]['FxTaxableAmount_tax'] += $fxamt;
                        // Output VAT for international cash receipt (Output VAT)
                        } elseif (($jnlkindid == $this->CL['DF']->ReceiptIntKindID) && ($JnlData[$j]['OutputVATflg'] == $this->CL['DF']->ClientChecked)) {
                            if (!array_key_exists($JnlData[$j]['VATType'] , $taxinfo['OutputVAT'])) {
                                $taxinfo['OutputVAT'][$JnlData[$j]['VATType']] = array();
                                $taxinfo['OutputVAT'][$JnlData[$j]['VATType']]['FxTaxableAmount_tax'] = 0;
                                $taxinfo['OutputVAT'][$JnlData[$j]['VATType']]['FxTaxableAmount_trade'] = 0;
                            }
                            $fxamt = $JnlData[$j]['FxAmount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Dr) {
                                $fxamt *= -1;
                            }
                            $taxinfo['OutputVAT'][$JnlData[$j]['VATType']]['FxTaxableAmount_tax'] += $fxamt;
                        // Undue Input VAT
                        } else if ($JnlData[$j]['SuspenseInputVATflg'] == $this->CL['DF']->ClientChecked) {
                            if (!array_key_exists($JnlData[$j]['AccountsTitleID'] , $taxinfo['UdInputVAT'])) {
                                $taxinfo['UdInputVAT'][$JnlData[$j]['AccountsTitleID']] = array();
                                $taxinfo['UdInputVAT'][$JnlData[$j]['AccountsTitleID']]['Amount_tax'] = 0;
                                $taxinfo['UdInputVAT'][$JnlData[$j]['AccountsTitleID']]['Amount_trade'] = 0;
                                $taxinfo['UdInputVAT'][$JnlData[$j]['AccountsTitleID']]['TaxableAmount_tax'] = 0;
                            }
                            $amt = $JnlData[$j]['Amount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Cr) {
                                $amt *= -1;
                            }
                            $taxinfo['UdInputVAT'][$JnlData[$j]['AccountsTitleID']]['Amount_trade'] += $amt;
                        // Undue Output VAT
                        } else if ($JnlData[$j]['SuspenseOutputVATflg'] == $this->CL['DF']->ClientChecked) {
                            if (!array_key_exists($JnlData[$j]['AccountsTitleID'] , $taxinfo['UdOutputVAT'])) {
                                $taxinfo['UdOutputVAT'][$JnlData[$j]['AccountsTitleID']] = array();
                                $taxinfo['UdOutputVAT'][$JnlData[$j]['AccountsTitleID']]['Amount_tax'] = 0;
                                $taxinfo['UdOutputVAT'][$JnlData[$j]['AccountsTitleID']]['Amount_trade'] = 0;
                                $taxinfo['UdOutputVAT'][$JnlData[$j]['AccountsTitleID']]['TaxableAmount_tax'] = 0;
                            }
                            $amt = $JnlData[$j]['Amount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Dr) {
                                $amt *= -1;
                            }
                            $taxinfo['UdOutputVAT'][$JnlData[$j]['AccountsTitleID']]['Amount_trade'] += $amt;
                        // Purchase service expenses (for Withholding Tax)
                        } else if ($JnlData[$j]['PurchaseServiceflg'] == $this->CL['DF']->ClientChecked) {
                            if (!array_key_exists($JnlData[$j]['WHTType'] , $taxinfo['WithHoldingTax'])) {
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']] = array();
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['Amount_tax'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['Amount_trade'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['TaxableAmount_tax'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['FxTaxableAmount_tax'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['TaxableAmount_expense'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['FxTaxableAmount_expense'] = 0;
                            }
                            $amt = $JnlData[$j]['Amount'];
                            $fxamt = $JnlData[$j]['FxAmount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Cr) {
                                $amt *= -1;
                                $fxamt *= -1;
                            }
                            $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['TaxableAmount_expense'] += $amt;
                            $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['FxTaxableAmount_expense'] += $fxamt;
                        // Service sales (for Withheld Tax)
                        } else if ($JnlData[$j]['ServiceSalesflg'] == $this->CL['DF']->ClientChecked) {
                            if (!array_key_exists($JnlData[$j]['WHTType'] , $taxinfo['WithHeldTax'])) {
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']] = array();
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['Amount_tax'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['Amount_trade'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['TaxableAmount_tax'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['FxTaxableAmount_tax'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['TaxableAmount_expense'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['FxTaxableAmount_expense'] = 0;
                            }
                            $amt = $JnlData[$j]['Amount'];
                            $fxamt = $JnlData[$j]['FxAmount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Dr) {
                                $amt *= -1;
                                $fxamt *= -1;
                            }
                            $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['TaxableAmount_expense'] += $amt;
                            $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['FxTaxableAmount_expense'] += $fxamt;
                        // Withholding Tax
                        } else if ($JnlData[$j]['WithholdingTaxflg'] == $this->CL['DF']->ClientChecked) {
                            if (!array_key_exists($JnlData[$j]['WHTType'] , $taxinfo['WithHoldingTax'])) {
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']] = array();
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['Amount_tax'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['Amount_trade'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['TaxableAmount_tax'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['FxTaxableAmount_tax'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['TaxableAmount_expense'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['FxTaxableAmount_expense'] = 0;
                            }
                            $amt = $JnlData[$j]['Amount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Cr) {
                                $amt *= -1;
                            }
                            $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['Amount_trade'] += $amt;
                        // Withheld Tax
                        } else if ($JnlData[$j]['WithheldTaxflg'] == $this->CL['DF']->ClientChecked) {
                            if (!array_key_exists($JnlData[$j]['WHTType'] , $taxinfo['WithHeldTax'])) {
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']] = array();
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['Amount_tax'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['Amount_trade'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['TaxableAmount_tax'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['FxTaxableAmount_tax'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['TaxableAmount_expense'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['FxTaxableAmount_expense'] = 0;
                            }
                            $amt = $JnlData[$j]['Amount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Dr) {
                                $amt *= -1;
                            }
                            $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['Amount_trade'] += $amt;
                        } 
                        // account information (for adjustment)
                        if ($JnlData[$j]['PurchaseServiceflg'] == $this->CL['DF']->ClientChecked) {
                            if (!array_key_exists($JnlData[$j]['AccountsTitleID'] , $accinfo)) {
                                $accinfo[$JnlData[$j]['AccountsTitleID']] = array();
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['AccountsTitleSName'] = $JnlData[$j]['AccountsTitleID'].':'.$JnlData[$j]['AccountsTitleSName'];
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['VATType'] = $JnlData[$j]['VATTypeAC'];
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['WHTType'] = $JnlData[$j]['WHTTypeAC'];
                                if ($jnlkindid == $this->CL['DF']->PaymentIntKindID ) {
                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['WHTType'] = $JnlData[$j]['WHTTypeAC2'];
                                }
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountLC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountFC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['PaidAmountLC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['PaidAmountFC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['PaymentAmountLC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['PaymentAmountFC'] = 0;
                            }
                            $amt = $JnlData[$j]['Amount'];
                            $fxamt = $JnlData[$j]['FxAmount'];
                            if ((($jnlkindid == $this->CL['DF']->PaymentDmtKindID) || ($jnlkindid == $this->CL['DF']->PaymentIntKindID)) && ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Dr)) {
                                $amt *= -1;
                                $fxamt *= -1;
                            }
                            $accinfo[$JnlData[$j]['AccountsTitleID']]['PaidAmountLC'] += $amt;
                            $accinfo[$JnlData[$j]['AccountsTitleID']]['PaidAmountFC'] += $fxamt;
                            
                            $accinfo[$JnlData[$j]['AccountsTitleID']]['PaymentAmountLC'] = $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountLC'] - $accinfo[$JnlData[$j]['AccountsTitleID']]['PaidAmountLC'];
                            $accinfo[$JnlData[$j]['AccountsTitleID']]['PaymentAmountFC'] = $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountFC'] - $accinfo[$JnlData[$j]['AccountsTitleID']]['PaidAmountFC'];
                        }
                        // account information (for adjustment)
                        if ($JnlData[$j]['ServiceSalesflg'] == $this->CL['DF']->ClientChecked) {
                            if (!array_key_exists($JnlData[$j]['AccountsTitleID'] , $accinfo)) {
                                $accinfo[$JnlData[$j]['AccountsTitleID']] = array();
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['AccountsTitleSName'] = $JnlData[$j]['AccountsTitleID'].':'.$JnlData[$j]['AccountsTitleSName'];
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['VATType'] = $JnlData[$j]['VATTypeAC'];
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['WHTType'] = $JnlData[$j]['WHTTypeAC'];
                                if ($jnlkindid == $this->CL['DF']->ReceiptIntKindID ) {
                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['WHTType'] = $JnlData[$j]['WHTTypeAC2'];
                                }
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountLC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountFC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceivedAmountLC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceivedAmountFC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceiptAmountLC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceiptAmountFC'] = 0;
                            }
                            $amt = $JnlData[$j]['Amount'];
                            $fxamt = $JnlData[$j]['FxAmount'];
                            if ((($jnlkindid == $this->CL['DF']->ReceiptDmtKindID) || ($jnlkindid == $this->CL['DF']->ReceiptIntKindID)) && ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Cr)) {
                                $amt *= -1;
                                $fxamt *= -1;
                            }
                            $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceivedAmountLC'] += $amt;
                            $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceivedAmountFC'] += $fxamt;
                            
                            $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceiptAmountLC'] = $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountLC'] - $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceivedAmountLC'];
                            $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceiptAmountFC'] = $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountFC'] - $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceivedAmountFC'];
                        }
                    }
                } else {
                    $JnlData = $this->CL['SW']->gSpeJnlRow($arraydata[$i]['TransactionID'], $arraydata[$i]['RevisionNo'], NULL);
                    // $JnlDataのデータが国内役務仕入または国外役務売上の場合、VATありかどうかの確認を行う
                    $vatflg = false;
                    if ((count($JnlData) > 0) && (($JnlData[0]['JournalKindID'] == $this->CL['DF']->PurchaseServicesDmtKindID) || ($JnlData[0]['JournalKindID'] == $this->CL['DF']->SaleServicesIntJnlKindID))) {
                        for ($j = 0; $j < count($JnlData); $j++) {
                            if (($JnlData[$j]['SectionID'] == $this->CL['DF']->AccType_SuspenseInputVAT) || ($JnlData[$j]['SectionID'] == $this->CL['DF']->AccType_SuspenseOutputVAT)) {
                                $vatflg = true;
                            }
                        }
                    } else {
                        $vatflg = true;
                    }
                    for ($j = 0; $j < count($JnlData); $j++) {
                        // 税関への未払いまたは歳入局への未払いのチェック
                        if (($JnlData[$j]['SectionID'] == $this->CL['DF']->AccType_PayableCustoms) || ($JnlData[$j]['SectionID'] == $this->CL['DF']->AccType_PayableRevDep)) {
                            $findaptordflg = true;
                        }
                        if (($jnlkindid == $this->CL['DF']->PaymentIntKindID) || ($jnlkindid == $this->CL['DF']->ReceiptIntKindID)) {
                            $JnlData[$j]['WHTTypeAC'] = $JnlData[$j]['WHTTypeAC2'];
                        }
                        // Input VAT for international cash payment (expense)
                        if (($jnlkindid == $this->CL['DF']->PaymentIntKindID) && ($JnlData[$j]['SectionID'] == $this->CL['DF']->AccType_PurchaseService)) {
                            if (!array_key_exists($JnlData[$j]['VATTypeAC'] , $taxinfo['InputVAT'])) {
                                $taxinfo['InputVAT'][$JnlData[$j]['VATTypeAC']] = array();
                                $taxinfo['InputVAT'][$JnlData[$j]['VATTypeAC']]['FxTaxableAmount_tax'] = 0;
                                $taxinfo['InputVAT'][$JnlData[$j]['VATTypeAC']]['FxTaxableAmount_trade'] = 0;
                            }
                            $fxamt = $JnlData[$j]['FxAmount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Cr) {
                                $fxamt *= -1;
                            }
                            $taxinfo['InputVAT'][$JnlData[$j]['VATTypeAC']]['FxTaxableAmount_trade'] += $fxamt;
                        }
                        // Output VAT for international cash receipt (sales)
                        if (($jnlkindid == $this->CL['DF']->ReceiptIntKindID) && ($JnlData[$j]['SectionID'] == $this->CL['DF']->AccType_ServiceSales)) {
                            if (!array_key_exists($JnlData[$j]['VATTypeAC'] , $taxinfo['OutputVAT'])) {
                                $taxinfo['OutputVAT'][$JnlData[$j]['VATTypeAC']] = array();
                                $taxinfo['OutputVAT'][$JnlData[$j]['VATTypeAC']]['FxTaxableAmount_tax'] = 0;
                                $taxinfo['OutputVAT'][$JnlData[$j]['VATTypeAC']]['FxTaxableAmount_trade'] = 0;
                            }
                            $fxamt = $JnlData[$j]['FxAmount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Dr) {
                                $fxamt *= -1;
                            }
                            $taxinfo['OutputVAT'][$JnlData[$j]['VATTypeAC']]['FxTaxableAmount_trade'] += $fxamt;
                        }
                        // Input VAT for international cash payment (Input VAT)
                        if (($jnlkindid == $this->CL['DF']->PaymentIntKindID) && ($JnlData[$j]['SectionID'] == $this->CL['DF']->AccType_InputVAT)) {
                            if (!array_key_exists($JnlData[$j]['VATType'] , $taxinfo['InputVAT'])) {
                                $taxinfo['InputVAT'][$JnlData[$j]['VATType']] = array();
                                $taxinfo['InputVAT'][$JnlData[$j]['VATType']]['FxTaxableAmount_tax'] = 0;
                                $taxinfo['InputVAT'][$JnlData[$j]['VATType']]['FxTaxableAmount_trade'] = 0;
                            }
                            $fxamt = $JnlData[$j]['FxTaxableAmount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Cr) {
                                $fxamt *= -1;
                            }
                            $taxinfo['InputVAT'][$JnlData[$j]['VATType']]['FxTaxableAmount_tax'] += $fxamt;
                        // Output VAT for international cash receipt (Output VAT)
                        } else if (($jnlkindid == $this->CL['DF']->ReceiptIntKindID) && ($JnlData[$j]['SectionID'] == $this->CL['DF']->AccType_OutputVAT)) {
                            if (!array_key_exists($JnlData[$j]['VATType'] , $taxinfo['OutputVAT'])) {
                                $taxinfo['OutputVAT'][$JnlData[$j]['VATType']] = array();
                                $taxinfo['OutputVAT'][$JnlData[$j]['VATType']]['FxTaxableAmount_tax'] = 0;
                                $taxinfo['OutputVAT'][$JnlData[$j]['VATType']]['FxTaxableAmount_trade'] = 0;
                            }
                            $fxamt = $JnlData[$j]['FxTaxableAmount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Dr) {
                                $fxamt *= -1;
                            }
                            $taxinfo['OutputVAT'][$JnlData[$j]['VATType']]['FxTaxableAmount_tax'] += $fxamt;
                        // Undue Input VAT
                        } else if ($JnlData[$j]['SectionID'] == $this->CL['DF']->AccType_SuspenseInputVAT) {
                            if (!array_key_exists($JnlData[$j]['AccountsTitleID'] , $taxinfo['UdInputVAT'])) {
                                $taxinfo['UdInputVAT'][$JnlData[$j]['AccountsTitleID']] = array();
                                $taxinfo['UdInputVAT'][$JnlData[$j]['AccountsTitleID']]['Amount_tax'] = 0;
                                $taxinfo['UdInputVAT'][$JnlData[$j]['AccountsTitleID']]['Amount_trade'] = 0;
                                $taxinfo['UdInputVAT'][$JnlData[$j]['AccountsTitleID']]['TaxableAmount_tax'] = 0;
                            }
                            $amt = $JnlData[$j]['Amount'];
                            $amt2 = $JnlData[$j]['TaxableAmount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Cr) {
                                $amt *= -1;
                                $amt2 *= -1;
                            }
                            $taxinfo['UdInputVAT'][$JnlData[$j]['AccountsTitleID']]['Amount_tax'] += $amt;
                            $taxinfo['UdInputVAT'][$JnlData[$j]['AccountsTitleID']]['TaxableAmount_tax'] += $amt2;
                            
                        // Undue Output VAT
                        } else if ($JnlData[$j]['SectionID'] == $this->CL['DF']->AccType_SuspenseOutputVAT) {
                            if (!array_key_exists($JnlData[$j]['AccountsTitleID'] , $taxinfo['UdOutputVAT'])) {
                                $taxinfo['UdOutputVAT'][$JnlData[$j]['AccountsTitleID']] = array();
                                $taxinfo['UdOutputVAT'][$JnlData[$j]['AccountsTitleID']]['Amount_tax'] = 0;
                                $taxinfo['UdOutputVAT'][$JnlData[$j]['AccountsTitleID']]['Amount_trade'] = 0;
                                $taxinfo['UdOutputVAT'][$JnlData[$j]['AccountsTitleID']]['TaxableAmount_tax'] = 0;
                            }
                            $amt = $JnlData[$j]['Amount'];
                            $amt2 = $JnlData[$j]['TaxableAmount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Dr) {
                                $amt *= -1;
                                $amt2 *= -1;
                            }
                            $taxinfo['UdOutputVAT'][$JnlData[$j]['AccountsTitleID']]['Amount_tax'] += $amt;
                            $taxinfo['UdOutputVAT'][$JnlData[$j]['AccountsTitleID']]['TaxableAmount_tax'] += $amt2;
                        // Purchase service expenses (for Withholding Tax)
                        } else if ($JnlData[$j]['SectionID'] == $this->CL['DF']->AccType_PurchaseService) {
                            if (!array_key_exists($JnlData[$j]['WHTTypeAC'] , $taxinfo['WithHoldingTax'])) {
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTTypeAC']] = array();
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTTypeAC']]['Amount_tax'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTTypeAC']]['Amount_trade'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTTypeAC']]['TaxableAmount_tax'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTTypeAC']]['FxTaxableAmount_tax'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTTypeAC']]['TaxableAmount_expense'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTTypeAC']]['FxTaxableAmount_expense'] = 0;
                            }
                            $amt = $JnlData[$j]['Amount'];
                            $fxamt = $JnlData[$j]['FxAmount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Cr) {
                                $amt *= -1;
                                $fxamt *= -1;
                            }
                            $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTTypeAC']]['TaxableAmount_expense'] += $amt;
                            $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTTypeAC']]['FxTaxableAmount_expense'] += $fxamt;
                        // Service sales (for Withheld Tax)
                        } else if ($JnlData[$j]['SectionID'] == $this->CL['DF']->AccType_ServiceSales) {
                            if (!array_key_exists($JnlData[$j]['WHTTypeAC'] , $taxinfo['WithHeldTax'])) {
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTTypeAC']] = array();
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTTypeAC']]['Amount_tax'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTTypeAC']]['Amount_trade'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTTypeAC']]['TaxableAmount_tax'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTTypeAC']]['FxTaxableAmount_tax'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTTypeAC']]['TaxableAmount_sales'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTTypeAC']]['FxTaxableAmount_sales'] = 0;
                            }
                            $amt = $JnlData[$j]['Amount'];
                            $fxamt = $JnlData[$j]['FxAmount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Dr) {
                                $amt *= -1;
                                $fxamt *= -1;
                            }
                            $taxinfo['WithHeldTax'][$JnlData[$j]['WHTTypeAC']]['TaxableAmount_sales'] += $amt;
                            $taxinfo['WithHeldTax'][$JnlData[$j]['WHTTypeAC']]['FxTaxableAmount_sales'] += $fxamt;
                        // Withholding Tax
                        } else if ($JnlData[$j]['SectionID'] == $this->CL['DF']->AccType_WithholdingTax) {
                            if (!array_key_exists($JnlData[$j]['WHTType'] , $taxinfo['WithHoldingTax'])) {
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']] = array();
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['Amount_tax'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['Amount_trade'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['TaxableAmount_tax'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['FxTaxableAmount_tax'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['TaxableAmount_expense'] = 0;
                                $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['FxTaxableAmount_expense'] = 0;
                            }
                            $amt = $JnlData[$j]['Amount'];
                            $amt2 = $JnlData[$j]['TaxableAmount'];
                            $fxamt2 = $JnlData[$j]['FxTaxableAmount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Cr) {
                                $amt *= -1;
                                $amt2 *= -1;
                                $fxamt2 *= -1;
                            }
                            $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['Amount_tax'] += $amt;
                            $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['TaxableAmount_tax'] += $amt2;
                            $taxinfo['WithHoldingTax'][$JnlData[$j]['WHTType']]['FxTaxableAmount_tax'] += $fxamt2;
                        // Withheld Tax
                        } else if ($JnlData[$j]['SectionID'] == $this->CL['DF']->AccType_WithheldTax) {
                            if (!array_key_exists($JnlData[$j]['WHTType'] , $taxinfo['WithHeldTax'])) {
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']] = array();
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['Amount_tax'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['Amount_trade'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['TaxableAmount_tax'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['FxTaxableAmount_tax'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['TaxableAmount_sales'] = 0;
                                $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['FxTaxableAmount_sales'] = 0;
                            }
                            $amt = $JnlData[$j]['Amount'];
                            $amt2 = $JnlData[$j]['TaxableAmount'];
                            $fxamt2 = $JnlData[$j]['FxTaxableAmount'];
                            if ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Dr) {
                                $amt *= -1;
                                $amt2 *= -1;
                                $fxamt2 *= -1;
                            }
                            $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['Amount_tax'] += $amt;
                            $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['TaxableAmount_tax'] += $amt2;
                            $taxinfo['WithHeldTax'][$JnlData[$j]['WHTType']]['FxTaxableAmount_tax'] += $fxamt2;
                        } 

                        // purchase account information (for Appropriate)
                        if ($JnlData[$j]['SectionID'] == $this->CL['DF']->AccType_PurchaseService) {
                            if (!array_key_exists($JnlData[$j]['AccountsTitleID'] , $accinfo)) {
                                $accinfo[$JnlData[$j]['AccountsTitleID']] = array();
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['AccountsTitleSName'] = $JnlData[$j]['AccountsTitleID'].':'.$JnlData[$j]['AccountsTitleSName'];
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['VATType'] = '';
                                if ($vatflg) {
                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['VATType'] = $JnlData[$j]['VATTypeAC'];
                                }
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['WHTType'] = $JnlData[$j]['WHTTypeAC'];
                                if ($jnlkindid == $this->CL['DF']->PaymentIntKindID ) {
                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['WHTType'] = $JnlData[$j]['WHTTypeAC2'];
                                }
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountLC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountFC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['PaidAmountLC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['PaidAmountFC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['PaymentAmountLC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['PaymentAmountFC'] = 0;
                            }
                            $amt = $JnlData[$j]['Amount'];
                            $fxamt = $JnlData[$j]['FxAmount'];
                            if ((($jnlkindid == $this->CL['DF']->PaymentDmtKindID) || ($jnlkindid == $this->CL['DF']->PaymentIntKindID)) && ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Cr)) {
                                $amt *= -1;
                                $fxamt *= -1;
                            }
                            $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountLC'] += $amt;
                            $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountFC'] += $fxamt;
                            
                            $accinfo[$JnlData[$j]['AccountsTitleID']]['PaymentAmountLC'] = $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountLC'] - $accinfo[$JnlData[$j]['AccountsTitleID']]['PaidAmountLC'];
                            $accinfo[$JnlData[$j]['AccountsTitleID']]['PaymentAmountFC'] = $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountFC'] - $accinfo[$JnlData[$j]['AccountsTitleID']]['PaidAmountFC'];
                        }

                        // sales account information (for Appropriate)
                        if ($JnlData[$j]['SectionID'] == $this->CL['DF']->AccType_ServiceSales) {
                            if (!array_key_exists($JnlData[$j]['AccountsTitleID'] , $accinfo)) {
                                $accinfo[$JnlData[$j]['AccountsTitleID']] = array();
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['AccountsTitleSName'] = $JnlData[$j]['AccountsTitleID'].':'.$JnlData[$j]['AccountsTitleSName'];
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['VATType'] = '';
                                if ($vatflg) {
                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['VATType'] = $JnlData[$j]['VATTypeAC'];
                                }
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['WHTType'] = $JnlData[$j]['WHTTypeAC'];
                                if ($jnlkindid == $this->CL['DF']->PaymentIntKindID ) {
                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['WHTType'] = $JnlData[$j]['WHTTypeAC2'];
                                }
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountLC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountFC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceivedAmountLC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceivedAmountFC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceiptAmountLC'] = 0;
                                $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceiptAmountFC'] = 0;
                            }
                            $amt = $JnlData[$j]['Amount'];
                            $fxamt = $JnlData[$j]['FxAmount'];
                            if ((($jnlkindid == $this->CL['DF']->PaymentDmtKindID) || ($jnlkindid == $this->CL['DF']->PaymentIntKindID)) && ($JnlData[$j]['DrCrFlg'] == $this->CL['DF']->Dr)) {
                                $amt *= -1;
                                $fxamt *= -1;
                            }
                            $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountLC'] += $amt;
                            $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountFC'] += $fxamt;
                            
                            $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceiptAmountLC'] = $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountLC'] - $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceivedAmountLC'];
                            $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceiptAmountFC'] = $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountFC'] - $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceivedAmountFC'];
                        }

                        // account information (for payment)  ここは、コントロールNo.に関連する情報をチェックすること。また、詳細情報から勘定科目ごとの支払額を取り出す。
                        if ($JnlData[$j]['SectionID'] == $this->CL['DF']->AccType_All) {
                            if (($JnlData[$j]['JournalKindID'] == $this->CL['DF']->PaymentDmtKindID) || ($JnlData[$j]['JournalKindID'] == $this->CL['DF']->PaymentIntKindID)) {
                                if (($JnlData[$j]['ControlNo'] == $ControlNo) && ($JnlData[$j]['AccountsTitleID'] == $AccountsTitleID) && ($JnlData[$j]['SegmentID'] == $SegmentID)) {
                                    if ($JnlData[$j]['Remark'] == '') {
                                        $remark = json_decode($JnlData[$j]['Remark']);
                                        if (isset($remark->accinfo)) {
                                            for ($k = 0; $k < count($remark->accinfo); $k++) {
                                                if (!array_key_exists($remark->accinfo[$k]['AccountsTitleID'] , $accinfo)) {
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']] = array();
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['AccountsTitleSName'] = $remark->accinfo[$k]['AccountsTitleID'].':'.$this->CL['SW']->gAccSNameVal($remark->accinfo[$k]['AccountsTitleID']);
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['VATType'] = $remark->accinfo[$k]['VATType'];
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['WHTType'] = $remark->accinfo[$k]['WHTType'];
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountLC'] = 0;
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountFC'] = 0;
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['PaidAmountLC'] = 0;
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['PaidAmountFC'] = 0;
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['PaymentAmountLC'] = 0;
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['PaymentAmountFC'] = 0;
                                                }
                                                $accinfo[$JnlData[$j]['AccountsTitleID']]['PaidAmountLC'] += $remark->accinfo[$k]['PaymentAmountLC'];
                                                $accinfo[$JnlData[$j]['AccountsTitleID']]['PaidAmountFC'] += $remark->accinfo[$k]['PaymentAmountFC'];
                            
                                                $accinfo[$JnlData[$j]['AccountsTitleID']]['PaymentAmountLC'] = $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountLC'] - $accinfo[$JnlData[$j]['AccountsTitleID']]['PaidAmountLC'];
                                                $accinfo[$JnlData[$j]['AccountsTitleID']]['PaymentAmountFC'] = $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountFC'] - $accinfo[$JnlData[$j]['AccountsTitleID']]['PaidAmountFC'];
                                            }
                                        }
                                    }
                                }
                            } else if (($JnlData[$j]['JournalKindID'] == $this->CL['DF']->ReceiptDmtKindID) || ($JnlData[$j]['JournalKindID'] == $this->CL['DF']->ReceiptIntKindID)) {
                                if (($JnlData[$j]['ControlNo'] == $ControlNo) && ($JnlData[$j]['AccountsTitleID'] == $AccountsTitleID) && ($JnlData[$j]['SegmentID'] == $SegmentID)) {
                                    if ($JnlData[$j]['Remark'] == '') {
                                        $remark = json_decode($JnlData[$j]['Remark']);
                                        if (isset($remark->accinfo)) {
                                            for ($k = 0; $k < count($remark->accinfo); $k++) {
                                                if (!array_key_exists($remark->accinfo[$k]['AccountsTitleID'] , $accinfo)) {
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']] = array();
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['AccountsTitleSName'] = $remark->accinfo[$k]['AccountsTitleID'].':'.$this->CL['SW']->gAccSNameVal($remark->accinfo[$k]['AccountsTitleID']);
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['VATType'] = $remark->accinfo[$k]['VATType'];
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['WHTType'] = $remark->accinfo[$k]['WHTType'];
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountLC'] = 0;
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountFC'] = 0;
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceivedAmountLC'] = 0;
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceivedAmountFC'] = 0;
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceiptAmountLC'] = 0;
                                                    $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceiptAmountFC'] = 0;
                                                }
                                                $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceivedAmountLC'] += $remark->accinfo[$k]['ReceiptAmountLC'];
                                                $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceivedAmountFC'] += $remark->accinfo[$k]['ReceiptAmountFC'];
                            
                                                $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceiptAmountLC'] = $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountLC'] - $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceivedAmountLC'];
                                                $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceiptAmountFC'] = $accinfo[$JnlData[$j]['AccountsTitleID']]['AppropriatedAmountFC'] - $accinfo[$JnlData[$j]['AccountsTitleID']]['ReceivedAmountFC'];
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if (($ControlNo != NULL) || ($AccountsTitleID != NULL) || ($SegmentID != NULL)) {
            if ((($amount != 0) && ($prm_Currency == $PresentCurrency)) || (($fxamount != 0) && ($prm_Currency != $PresentCurrency))) {
                if (!$findserviceflg) {
                    $accinfo = array();
                }
//                if ($findaptordflg) {
//                    $taxinfo = array('WithHoldingTax' => array(), 'WithHeldTax' => array(), 'UdInputVAT' => array(), 'UdOutputVAT' => array(), 'InputVAT' => array());
//                }
                $arr[] = array('ControlNo' => $ControlNo, 'AccountsTitleID' => $AccountsTitleID, 'SegmentID' => $SegmentID, 'amount' => $amount, 'fxamount' => $fxamount, 'accinfo' => $accinfo, 'taxinfo' => $taxinfo);
            }
        }
        
        // JSON形式に変換
        $result = json_encode($arr);
        
        return nl2br($result);
    }

    /*--------------------------------------------------------------------------*/
    /* 残高情報内の勘定科目名称を現在の言語に置き換える                               */
    /* Arg1:balancedata                                                         */
    /*      JSON形式の残高情報                                                   */
    /* Ret :勘定科目名称を書き換えた後のJSON形式の残高情報                           */
    /*--------------------------------------------------------------------------*/
    function gBalanceDataAccountName($balancedata) {
        $this->CL['LG']->cLog('T0002');
        
        if (empty($balancedata)) {
            return $balancedata;
        }
        
        if (is_array($balancedata)) {
            return $balancedata;
        }
        
        $arr = json_decode($balancedata);
        
        if (!is_set($arr['accinfo'])) {
            return $balancedata;
        }
        
        if (!is_array($arr['accinfo'])) {
            return $balancedata;
        }
        
        foreach ($arr as $item => $value) {
            $arr['accinfo'][$item]['AccountsTitleSName'] = $arr['accinfo'][$item]['AccountsTitleID'].':'.$this->CL['SW']->gAccSNameVal($arr['accinfo'][$item]['AccountsTitleID']);
        }
        
        // JSON形式に変換
        $result = json_encode($arr);
        
        return nl2br($result);

    }

    /*--------------------------------------------------------------------------*/
    /* 補助元帳から残高に関するデータを抽出する                                        */
    /* Arg1:prm_ClientID                                                        */
    /*      相手先ID                                                            */
    /* Arg2:prm_Currency                                                        */
    /*      通貨ID                                                              */
    /* Arg3:prm_ControlNo                                                       */
    /*      残高キーNo.                                                          */
    /* Arg4:prm_Type                                                            */
    /*      取得対象勘定科目グループ（配列をJSON形式で表記）                           */
    /* Arg5:prm_OmitType                                                        */
    /*      取得除外勘定科目グループ（配列をJSON形式で表記）                           */
    /* Arg6:prm_OmitTrnID                                                       */
    /*      取得除外取引ID（現在変更中の取引は除外）                                 */
    /* Arg7:prm_AccID                                                           */
    /*      勘定科目IDが限定できる場合は勘定科目ID                                  */
    /* Arg7:prm_SegmentID                                                       */
    /*      セグメントが限定できる場合はセグメントID                                     */
    /* Ret :補助元帳から抽出した配列情報                                           */
    /*--------------------------------------------------------------------------*/
    function gSubLedSearch($prm_ClientID, $prm_Currency, $prm_ControlNo, $prm_Type, $prm_OmitType, $prm_OmitTrnID, $prm_AccID, $prm_SegmentID) {
        $this->CL['LG']->cLog('T0002');
        // JavaScript側からのパラメータをSQL用のパラメータに変換する
        $CashBankflg        = NULL;
        $ARDmtflg           = NULL;
        $ARIntflg           = NULL;
        $StockSalesflg        = NULL;
        $nonStockSalesflg        = NULL;
        $PurchaseStockflg   = NULL;
        $PurchasenonStockflg    = NULL;
        $PurchaseServiceflg = NULL;
        $APDmtflg           = NULL;
        $APIntflg           = NULL;
        $AccruedExpenseflg  = NULL;
        $AROthersflg    = NULL;
        $InputVATflg        = NULL;
        $ServiceSalesflg                   = NULL;
        $InputVATNotSubjectCorporateTaxDeductionflg = NULL;
        $OutputVATflg       = NULL;
        $SuspenseInputVATflg    = NULL;
        $SuspenseOutputVATflg   = NULL;
        $WithholdingTaxflg  = NULL;
        $WithheldTaxflg     = NULL;
        $ImportDutyflg      = NULL;
        $PayableCustomsflg  = NULL;
        $PayableRevDepflg   = NULL;
        $ExchangeGainflg    = NULL;
        $ExchangeLossflg    = NULL;
        
        if (!is_array($prm_Type)) {
            $prm_Type = json_decode($prm_Type);
            if (!is_array($prm_Type)) {
                $prm_Type = array($prm_Type);
            }
        }
        
        for ($i = 0; $i < count($prm_Type); $i++) {
            if ($prm_Type[$i] == $this->CL['DF']->AccType_CashBank) {
                $CashBankflg        = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_ARDmt) {
                $ARDmtflg           = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_ARInt) {
                $ARIntflg           = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_StockSales) {
                $nonStockSalesflg        = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_nonStockSales) {
                $StockSalesflg        = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_PurchaseStock) {
                $PurchaseStockflg   = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_PurchasenonStock) {
                $PurchasenonStockflg    = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_PurchaseService) {
                $PurchaseServiceflg = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_APDmt) {
                $APDmtflg           = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_APInt) {
                $APIntflg           = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_AccruedExpense) {
                $AccruedExpenseflg  = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_AROthers) {
                $AROthersflg    = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_InputVAT) {
                $InputVATflg        = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_ServiceSales) {
                $ServiceSalesflg   = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_InputVATNotSubjectCorporateTaxDeduction) {
                $InputVATNotSubjectCorporateTaxDeductionflg = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_OutputVAT) {
                $OutputVATflg       = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_SuspenseInputVAT) {
                $SuspenseInputVATflg    = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_SuspenseOutputVAT) {
                $SuspenseOutputVATflg   = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_WithholdingTax) {
                $WithholdingTaxflg  = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_WithheldTax) {
                $WithheldTaxflg     = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_ImportDuty) {
                $ImportDutyflg  = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_PayableCustoms) {
                $PayableCustomsflg  = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_PayableRevDep) {
                $PayableRevDepflg   = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_ExchangeGain) {
                $ExchangeGainflg    = $this->CL['DF']->ClientChecked;
            } 
            if ($prm_Type[$i] == $this->CL['DF']->AccType_ExchangeLoss) {
                $ExchangeLossflg    = $this->CL['DF']->ClientChecked;
            } 
        }
        
        if (!is_array($prm_OmitType)) {
            $prm_OmitType = json_decode($prm_OmitType);
            if (!is_array($prm_OmitType)) {
                $prm_OmitType = array($prm_OmitType);
            }
        }
        
        for ($i = 0; $i < count($prm_OmitType); $i++) {
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_CashBank) {
                $CashBankflg        = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_ARDmt) {
                $ARDmtflg           = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_ARInt) {
                $ARIntflg           = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_StockSales) {
                $nonStockSalesflg        = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_nonStockSales) {
                $StockSalesflg        = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_PurchaseStock) {
                $PurchaseStockflg   = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_PurchasenonStock) {
                $PurchasenonStockflg    = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_PurchaseService) {
                $PurchaseServiceflg = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_APDmt) {
                $APDmtflg           = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_APInt) {
                $APIntflg           = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_AccruedExpense) {
                $AccruedExpenseflg   = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_AROthers) {
                $AROthersflg    = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_InputVAT) {
                $InputVATflg        = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_ServiceSales) {
                $ServiceSalesflg   = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_InputVATNotSubjectCorporateTaxDeduction) {
                $InputVATNotSubjectCorporateTaxDeductionflg = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_OutputVAT) {
                $OutputVATflg       = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_SuspenseInputVAT) {
                $SuspenseInputVATflg    = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_SuspenseOutputVAT) {
                $SuspenseOutputVATflg   = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_WithholdingTax) {
                $WithholdingTaxflg  = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_WithheldTax) {
                $WithheldTaxflg     = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_ImportDuty) {
                $ImportDutyflg  = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_PayableCustoms) {
                $PayableCustomsflg  = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_PayableRevDep) {
                $PayableRevDepflg   = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_ExchangeGain) {
                $ExchangeGainflg    = $this->CL['DF']->ClientNonCheck;
            } 
            if ($prm_OmitType[$i] == $this->CL['DF']->AccType_ExchangeLoss) {
                $ExchangeLossflg    = $this->CL['DF']->ClientNonCheck;
            } 
        }
        
        // 残高データ取得
        return $this->CL['SW']->gSubLedSearch($this->CL['DF']->NewestDate2, $this->CL['DF']->OldestDate2, $prm_ClientID, $prm_Currency, $prm_ControlNo, $prm_AccID, $prm_SegmentID, $CashBankflg, $ARDmtflg, $ARIntflg, 
                        $StockSalesflg, $nonStockSalesflg, $PurchaseStockflg, $PurchasenonStockflg, $PurchaseServiceflg, $APDmtflg, 
                        $APIntflg, $AccruedExpenseflg, $AROthersflg, $InputVATflg, $ServiceSalesflg, $InputVATNotSubjectCorporateTaxDeductionflg, $OutputVATflg, 
                        $SuspenseInputVATflg, $SuspenseOutputVATflg, $WithholdingTaxflg, $WithheldTaxflg, $ImportDutyflg, $PayableCustomsflg, $PayableRevDepflg, $ExchangeGainflg, $ExchangeLossflg);
    }
    
    /*--------------------------------------------------------------------------*/
    /* 指定された日付以前で取引のある最後の日付を取得する                              */
    /* Arg1:TrnKindID                                                           */
    /*      取引仕訳か修正仕訳か                                                  */
    /* Arg2:JnlKindID                                                           */
    /*      伝票種別（普通仕訳帳/特殊仕訳帳）                                      */
    /* Arg3:edate                                                              */
    /*      指定された日付（未指定の場合、システム日付の月末）                           */
    /* Ret : 最後の取引の日付 (YYYYMMDD)、該当データがない場合はfalse                 */
    /*--------------------------------------------------------------------------*/
    public function gLatestTrnYearMonth($TrnKindID, $JnlKindID, $edate = NULL) {
        $this->CL['LG']->cLog('T0002');
        
        if (is_null($edate)) {
            $edate = date_format(new DateTime('now'), 'Ym').'99';
        }
        
        $result = $this->CL['SW']->gSpeJnlTrnList($TrnKindID, $this->CL['DF']->NewestDate2, $edate, NULL, $JnlKindID, NULL, NULL, NULL);
        
        if (!$result) {
            return false;
        }
        
        return $result[count($result) - 1]['TransactionDate'];
    }
    
/*--------------------------------------------------------*/
/* DB更新/追加系                                          */
/*--------------------------------------------------------*/
    /*--------------------------------------------------------------------------*/
    /* 月次確定ステータスを追加する                                             */
    /* Arg1:year                                                                */
    /*      月次確定ステータス追加対象年                                        */
    /* Ret :無し                                                                */
    /*--------------------------------------------------------------------------*/
    public function iMoCfmInfo($year) {
        $this->CL['LG']->cLog('T0002');
        if (is_array($year)) {
            $term0 = substr($year[0], $this->CL['DF']->RngYear2, $this->CL['DF']->LenYear + $this->CL['DF']->LenMonth);
            $term1 = substr($year[1], $this->CL['DF']->RngYear2, $this->CL['DF']->LenYear + $this->CL['DF']->LenMonth);
            for ($i = 1; $term0  <= $term1; $i++, $term0 = self::gDateFmt($this->CL['DF']->gDateFmt22, $term0, 1)) {
                $yr = intval(self::gDateFmt($this->CL['DF']->gDateFmt8, $term0));
                $mth = intval(self::gDateFmt($this->CL['DF']->gDateFmt9, $term0));
                if ($this->CL['SW']->gMoCfmRow($this->CL['DF']->trd, $yr, $mth) == false) {
                    // 当該年の月次確定ステータス情報が存在しない場合、ここで追加する
                    $result = true;
                    $result = $this->CL['SW']->iMoCfmInfo($this->CL['DF']->trd, $yr, $mth, $this->CL['DF']->cfmSts_UnCfm);
                    if ($result == false) {
                        $this->CL['LG']->cLog('E0032', array($this->CL['DF']->trd, $yr, $mth, $this->CL['DF']->cfmSts_UnCfm));
                    }
                    $result = $this->CL['SW']->iMoCfmInfo($this->CL['DF']->adj, $yr, $mth, $this->CL['DF']->cfmSts_UnCfm);
                    if ($result == false) {
                        $this->CL['LG']->cLog('E0032', array($this->CL['DF']->adj, $yr, $mth, $this->CL['DF']->cfmSts_UnCfm));
                    }
                } else {
                    // 当該年月の月次確定ステータス情報が存在する場合、何もしない
                    ;
                }
                
            }
        } else {
            for ($i = 1; $i <= $this->CL['DF']->NumMonth; $i++) {
                if ($this->CL['SW']->gMoCfmRow($this->CL['DF']->trd, $year, $i) == false) {
                    // 当該年の月次確定ステータス情報が存在しない場合、ここで追加する
                    $resutl = true;
                    $result = $this->CL['SW']->iMoCfmInfo($this->CL['DF']->trd, $year, $i, $this->CL['DF']->cfmSts_UnCfm);
                    if ($result == false) {
                        $this->CL['LG']->cLog('E0032', array($this->CL['DF']->trd, $year, $i, $this->CL['DF']->cfmSts_UnCfm));
                    }
                    $result = $this->CL['SW']->iMoCfmInfo($this->CL['DF']->adj, $year, $i, $this->CL['DF']->cfmSts_UnCfm);
                    if ($result == false) {
                        $this->CL['LG']->cLog('E0032', array($this->CL['DF']->adj, $year, $i, $this->CL['DF']->cfmSts_UnCfm));
                    }
                } else {
                    // 当該年月の月次確定ステータス情報が存在する場合、何もしない
                    ;
                }
            }
        }
    }
	
    /*--------------------------------------------------------------------------*/
    /* get data from api BOT						                              */
    /* Arg1:start_period                                                         */
    /*      date transection                                                  */
    /* Arg2:end_period                                                           */
    /*      date transection        				                             */
    /* Arg3:currency                                                             */
    /*      foreign currency                    							     */
    /*--------------------------------------------------------------------------*/
	public function api_exg_rate($start_period, $end_period, $currency = '',$day = 1,$period_date = ''){
		$arr_data = array();
		if($period_date == ''){
			
			$curl = curl_init();
			$url = "https://apigw1.bot.or.th/bot/public/Stat-ExchangeRate/v2/DAILY_AVG_EXG_RATE/?";
			
			if($start_period === $end_period){
				$date=date_create($start_period);
				date_add($date,date_interval_create_from_date_string("-".$day." days")); // tran date -1 day
				$s_start_period = date_format($date,"Y-m-d");
				
				$url .= "start_period=".$s_start_period;
				$url .= "&end_period=".$s_start_period;
			}
			// echo $url."<br>";
			if($currency !='' && $currency != null){
				$url .= "&currency=".$currency;
			}
			curl_setopt_array($curl, [
				CURLOPT_URL => $url,
				// CURLOPT_URL => "https://apigw1.bot.or.th/bot/public/Stat-ExchangeRate/v2/DAILY_AVG_EXG_RATE/?start_period=2022-05-11&end_period=2022-05-11&$currency=JPY",
				CURLOPT_RETURNTRANSFER => true,
				CURLOPT_ENCODING => "",
				CURLOPT_MAXREDIRS => 10,
				CURLOPT_TIMEOUT => 30,
				CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
				CURLOPT_CUSTOMREQUEST => "GET",
				CURLOPT_HTTPHEADER => [
					"X-IBM-Client-Id: 89e7b225-435b-41f1-9d54-a91e9fe1ff67",
					"accept: application/json"
				],
			]);

			$response = curl_exec($curl);
			$err = curl_error($curl);
			curl_close($curl); 
            unset($curl);
			
			if ($err) {
				echo "cURL Error #:" . $err;
			} else {
				$arr_data = json_decode($response, true); //json to array
				$period_date = $arr_data['result']['data']['data_detail']['0']['period'];
			}
			if(trim($period_date) != '' && trim($period_date) != null){
				return $arr_data;
				
			// Limit loop 10 times
			}else if($day <= 10){
				$day++;
				return self::api_exg_rate($start_period, $end_period, $currency ,$day ,$period_date);
			}
		}else{
			return false;
		}
		
	}
    
/*--------------------------------------------------------*/
/* その他                                                  */
/*--------------------------------------------------------*/
    /*--------------------------------------------------------------------------*/
    /* JavaScriptコードを圧縮する                                                   */
    /* Arg1:source                                                              */
    /*      圧縮対象のJavaScrpitコード                                            */
    /* Ret :圧縮後のJavaScriptコード                                              */
    /*--------------------------------------------------------------------------*/
    public function gJavaScriptPacked($source) {
        
        // JavsScript Packerの起動
        $source  = '(function () {'.$this->CL['DF']->LF.$source; // これを最初につけること。
        $source .= '} ());'.$this->CL['DF']->LF; // これを最後につけること。
        require 'javascript-packer/class.JavaScriptPacker.php';
        if (substr($_SERVER['SERVER_ADDR'], 0, 8) == '192.168.') {
            // Local addressの場合、無圧縮で返す。
            $packer = new JavaScriptPacker($source, 0, true, true);
//            return $source;
        } else {
            // そうでない場合は、圧縮する。
            $packer = new JavaScriptPacker($source, 62, true, true);
        }
        return $packer->pack();
    }
    
/*----------------------------------------------------------------------------*/
/* Private Function                                                           */
/*----------------------------------------------------------------------------*/

}
?>
