<?php
//Smartyにアサインする変数を入れる連想配列
$assign_var = array();

define('SMARTY_DIR', '/home/app/smarty/');
require_once(SMARTY_DIR.'Smarty.class.php');

class CommonSmarty  extends Smarty {

  private $logger;

	function __construct() {
		parent::__construct();
		$this->compile_dir = './templates_c';
	}

	public function display($templatefile = '', $cache_id = NULL, $compile_id = NULL, $parent = NULL, $top = "0") {
		global $serverUtil;
    if($templatefile == '') {
      $templatefile = $serverUtil->getTemplateFile();
      $templatejs   = $serverUtil->getTemplateJsFile();
    } else {
      $t = $templatefile;
      $templatefile = $serverUtil->getProductDir() . "/" . "templates/" . $templatefile . ".tpl";
      $templatejs   = $serverUtil->getProductDir() . "/" . "templates/" . $t . "_js.tpl";
    }

		$this->assign("_ADMIN_SYSTEM_NAME", $GLOBALS['ADMIN_SYSTEM_NAME']);
		$this->assign("_CONTENT_BODY",      $templatefile);
    if( file_exists( $templatejs ) ) {
		  $this->assign("_CONTENT_JS",      $templatejs);
    }
    $this->assign("_COMPANY_NAME",       $GLOBALS['COMPANY_NAME']);
		$this->assign("_SYSTEM_NAME",       $GLOBALS['SYSTEM_NAME']);
		$this->assign("_SCRIPT_NAME",       $GLOBALS['SCRIPT_NAME']);
    $this->assign("_SYSTEM_ACCD",       $GLOBALS['SYSTEM_ACCD']);
    $this->assign("_SYSTEM_VEND",       $GLOBALS['SYSTEM_VEND']);

		$this->assign("SID", 	session_id() );

		$this->assign("_SYSTEM_NAME_EN",    $GLOBALS['SYSTEM_NAME_EN']);
		$this->assign("APP_ROOT",           $GLOBALS['APP_ROOT']);
		$this->assign("API_URL",            $GLOBALS['API_URL']);
//		$this->assign("REP_URL", 	          $GLOBALS['REP_URL']);
		$this->assign("_SYSTEM_NAME_EN_UNAGR_CNT",  $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["UNAGR_CNT"]);
		$this->assign("_SYSTEM_NAME_EN_CHGCD",      $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGCD"]);
		$this->assign("_SYSTEM_NAME_EN_CHGNM",      $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGNM"]);
		$this->assign("_SYSTEM_NAME_EN_LGKTKTCD",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["LGKTKTCD"]); //ログイン拠点
		$this->assign("_SYSTEM_NAME_EN_LGKTKTNM",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["LGKTKTNM"]); //ログイン拠点名称
		$this->assign("_SYSTEM_NAME_EN_SDDAY",      $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]['SDDAY'] );
		$this->assign("_SYSTEM_NAME_EN_ACCD",      $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]['ACCD'] );
    $this->assign("_SYSTEM_NAME_EN_VEND",      $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]['VEND'] );

    //社員権限
    $this->assign("_SYSTEM_NAME_EN_CHGAT0",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT0"]);
		$this->assign("_SYSTEM_NAME_EN_CHGAT1",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT1"]);
		$this->assign("_SYSTEM_NAME_EN_CHGAT2",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT2"]);
		$this->assign("_SYSTEM_NAME_EN_CHGAT3",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT3"]);
		$this->assign("_SYSTEM_NAME_EN_CHGAT4",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT4"]);
		$this->assign("_SYSTEM_NAME_EN_CHGAT5",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT5"]);
		$this->assign("_SYSTEM_NAME_EN_CHGAT6",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT6"]);
		$this->assign("_SYSTEM_NAME_EN_CHGAT7",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT7"]);
		$this->assign("_SYSTEM_NAME_EN_CHGAT8",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT8"]);
		$this->assign("_SYSTEM_NAME_EN_CHGAT9",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT9"]);
    $this->assign("_SYSTEM_NAME_EN_CHGAT10",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT10"]);
    $this->assign("_SYSTEM_NAME_EN_CHGAT11",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT11"]);
    $this->assign("_SYSTEM_NAME_EN_CHGAT12",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT12"]);
    $this->assign("_SYSTEM_NAME_EN_CHGAT13",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT13"]);
    $this->assign("_SYSTEM_NAME_EN_CHGAT14",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT14"]);
    $this->assign("_SYSTEM_NAME_EN_CHGAT15",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT15"]);
    $this->assign("_SYSTEM_NAME_EN_CHGAT16",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT16"]);
    $this->assign("_SYSTEM_NAME_EN_CHGAT17",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT17"]);
    $this->assign("_SYSTEM_NAME_EN_CHGAT18",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT18"]);
    $this->assign("_SYSTEM_NAME_EN_CHGAT19",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT19"]);
    $this->assign("_SYSTEM_NAME_EN_CHGAT20",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["CHGAT20"]);

    $this->assign("_SYSTEM_NAME_EN_IPADDRESS",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["IPADDRESS"]);

    $this->assign("_REPORT_URL",     $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["REPORT_URL"]);  //iReport用
    $this->assign("_PAGE_LINE",      $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["PAGE_LINE"]);  //1ページの行数
    $csvfmturl = "../../csvformat/";
    $this->assign("_CSVFMT_URL",      $csvfmturl);  //23.01.23 CSV取込フォーマットダウンロード用のヘッダーURL

    $this->assign("_ROOT_URL",     $serverUtil->getURL()."/".$GLOBALS['HOSP_SUB_DIR_ORG']);  //ログアウト用

		$this->assign("_PRODUCT_ID",    $serverUtil->getProductId() );
		$this->assign("_PRODUCT_NAME",  $serverUtil->getProductName() );
    $this->assign("_SYSTEM_NO",  $GLOBALS['SYSTEM_NO'] );
		$this->assign("_LAST_UPDATE", 	$serverUtil->getProjectLastUpdate());

		//ワンタイムトークンの設定
		$serverUtil->createToken();
    $dir = $serverUtil->getProjectDir();

    if ($top == "1") {  //login
      parent::display($dir."/templates/index.tpl");
    } else {
		   parent::display($dir."/templates/all_content.tpl");
    }

	}

}


?>
