KST001.php_bk20151118 14.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
<?php 
//*****************************************************************************
//* 
//* プログラム名:個人設定メニュー画面
//* プログラムID:KST001.php
//* 機能        :各種個人設定を行う
//* 作成者      :
//* 
//*****************************************************************************

header("Content-type: text/html; charset=EUC-JP");
include("include/session_start.inc");
include("include/SessionChk.inc");
include('./include/smarty.conf');

//ヘッダー
include("inc/header.inc");
//メニューセット
include("menu_opacity.php");
include('inc/KST001.inc');
include("inc/input_chk.inc");
include("inc/PWC001.inc");
include("inc/KIN001.inc");
include("inc/KIN002.inc");
include("inc/KST007.inc");
include("inc/KST014.inc");
include("inc/KST016.inc");
include("inc/KST017.inc");
include("include/Google_API_Info.inc");

//include("../../e-gru_admin/include/MTC_DBCON.inc");

////顧客No取得
//$strSQLf = "SELECT kokyaku_no " .
//			"FROM kokyaku_tbl ".
//			"Where forder_name='$PHP_FOLDER'";


//$objRecf = pg_exec($strSQLf);
//if($objRecf==false){
//	echo("SQL実行に失敗しました(SELECT)");
//	exit;
//}

//if (pg_numrows($objRecf)>0){
//	$objData = pg_fetch_object($objRecf, 0);
//	$kokyaku_no=$objData->kokyaku_no;
//}
//$sql = "SELECT * FROM menu_kanri_tbl WHERE kokyaku_no = $kokyaku_no ";
//$sql .= "AND kinou_no = 20";

//$strDBinc="include/dbcon.inc";

//include($strDBinc);

	//**** メニュー ****//
//	include("include/menu.inc");

//**** DB接続 ****//
$strDBinc="include/dbcon.inc";
include($strDBinc);

//*****************************************************************************
//* Googleカレンダー API連携
//*****************************************************************************

//エラーメッセージ
$KST024_Msg   = "";
$KST024_Color = "#ffffff";

if($code){

	//認証コードからリフレッシュトークン、アクセストークン取得
	$url = 'https://accounts.google.com/o/oauth2/token';
	$params = array(
	    'code'=>$code,
    	'client_id'=>CLIENT_ID,
	    'client_secret'=>CLIENT_SECRET,
    	'redirect_uri'=>CALLBACK,
	    'grant_type'=>'authorization_code'
	);

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$json = curl_exec($ch);
	curl_close($ch);

	$token_array = json_decode($json, true) ;

	if($token_array['access_token'] && $token_array['refresh_token']){

		//リフレッシュトークン、アクセストークンを更新
		$strSQL="DELETE FROM kojin_data_tbl WHERE seq=51 OR seq=52 AND syain_cd='$PHP_SYAIN_CD'";
		$objID = pg_exec($strSQL);
		$strSQL="INSERT INTO kojin_data_tbl (syain_cd, seq, memo) VALUES ('".$PHP_SYAIN_CD."',51, '".$token_array["access_token"]."')";
		$objID = pg_exec($strSQL);
		$strSQL="INSERT INTO kojin_data_tbl (syain_cd, seq, memo) VALUES ('".$PHP_SYAIN_CD."',52, '".$token_array["refresh_token"]."')";
		$objID = pg_exec($strSQL);


		//カレンダーID取得
		$strSQL="SELECT * FROM kojin_data_tbl WHERE seq=50 AND syain_cd='$PHP_SYAIN_CD'";
		$objID = pg_exec($strSQL);

		if($objID==false){
			echo("SQL実行に失敗しました(SELECT)");
			exit;
		}
		if (pg_numrows($objID) > 0){
			$objIDData=pg_fetch_object($objID, 0);
			$calender_id=$objIDData->memo;
		}else{
			$calender_id="";
		}

		if ($calender_id != ""){

			//カレンダーID・アクセストークンから予定取得
			$url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?access_token=".$token_array['access_token'];
			
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, $url);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
			$json = curl_exec($ch);
			curl_close($ch);

			$json = mb_convert_encoding($json, 'EUC-JP', 'UTF-8');
			$calender_array = json_decode(preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $json),true);  

			//予定取得エラー
			if(isset($calender_array['error']) && !empty($calender_array['error'])){
				$KST024_Msg = "Googleカレンダー連携に失敗しました。Googleアカウント・カレンダーIDをご確認の上、再度認証を行って下さい。";
				$KST024_Color = "#FDDFFD";

				//予定取得エラー時は、設定を削除
				$strSQL="DELETE FROM kojin_data_tbl WHERE seq=50 OR seq=51  OR seq=52 OR seq=53 AND syain_cd='$PHP_SYAIN_CD'";
				$objID = pg_exec($strSQL);
			}
		}


	}else{
		$KST024_Msg = "Googleカレンダー連携に失敗しました。Googleアカウント・カレンダーIDをご確認の上、再度認証を行って下さい。";
		$KST024_Color = "#FDDFFD";
	}


}

//*****************************************************************************


$strSQL="SELECT * FROM kojin_data_tbl WHERE seq=21 AND syain_cd='$PHP_SYAIN_CD'";
$objID = pg_exec($strSQL);

if($objID==false){
		echo("SQL実行に失敗しました(SELECT)");
		exit;
}
if (pg_numrows($objID) > 0){
		$objIDData=pg_fetch_object($objID, 0);
		$Google_URL=$objIDData->memo;
}else{
		$Google_URL="";
}

if ($Google_URL != ""){
		$aryUrl = split("/",$Google_URL);
		if (count($aryUrl)<8){
				$KST020_Msg = "設定されたURLが不正です。";
				$KST020_Color = "#FDDFFD";
		}else{
				$pDate      = date("Ymd");
				$Google_ID  = $aryUrl[5];
				$Google_Key = str_replace("private-", "", $aryUrl[6]);

				$Start_Date = substr($pDate,0,4)."-".substr($pDate,4,2)."-".substr($pDate,6,2);
				$End_Date = date("Y-m-d", mktime(0, 0, 0, substr($pDate,4,2), substr($pDate,6,2)+7, substr($pDate,0,4)));

				$feedURL = "http://www.google.com/calendar/feeds/".$Google_ID."/private-".$Google_Key."/basic?start-min=".$Start_Date."T00:00:00&start-max=".$End_Date."T23:59:59&orderby=starttime&sortorder=ascend";

				if($contents = @file_get_contents($feedURL, false)){
					$KST020_Msg = "";
					$KST020_Color = "#ffffff";
				}else{
						$KST020_Msg = "設定されたURLが不正です。";
						$KST020_Color = "#FDDFFD";
				}
		}

}else{
		$KST020_Msg = "";
		$KST020_Color = "#ffffff";
}

$kinou_flg[0]=1;
$kinou_flg[1]=1;
$kinou_flg[3]=1;
$kinou_flg[6]=1;
$kinou_flg[7]=1;

?>

<form name="e_gru">
<table width="100%" border="0" cellspacing="0">
    <tr>
      <td class="midashi">        <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <th width="50%" scope="col"><div align="left"><img src="image/kojin.gif" border="0"> 個人設定</div></th>
          <th width="50%" scope="col"><div align="right"><a href='javascript:Disp_Help("KSTHLP.htm")'><img src="image/help.gif" border="0"></a> <a href='javascript:Disp_Help("KSTHLP.htm")'> ヘルプ</a></div></th>
        </tr>
      </table>        <div align="right"></div></td>
    </tr>
  </table>
<span class="Tinnyfont"><br></span>
<span class="MiddleBold">&nbsp;個人設定メニュー</span>
<span class="Tinnyfont"><br><br></span>
<table class="mainColor" width="100%" border="0" cellspacing="1" cellpadding="1">
	<tr><td>
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<?php  if($kinou_flg[0]==1 || $kinou_flg[0]==""){ ?>
	<TR>
		<TD width="25%" height="25" align="reft" rowspan="7" class="toneDown"><span class="Normalfont">&nbsp;スケジュール設定</span></TD>
		<TD width="65%" height="25" align="reft" bgcolor ="#ffffff">
			<span class="Normalfont">&nbsp;<a href=javascript:dip_sub("KST002.php","KST002");>MYグループ設定</a></span>
			<SPAN ID=KST002></SPAN>
		</TD>
	</TR>
	<TR>
		<TD width="65%" height="25" align="reft" bgcolor ="#ffffff">
			<span class="Normalfont">&nbsp;<a href=javascript:dip_sub("KST003.php","KST003");>初期表示グループ設定</a></span>
			<SPAN ID=KST003></SPAN>
		</TD>
	</TR>
	<TR>
		<TD width="65%" height="25" align="reft" bgcolor ="#ffffff">
			<span class="Normalfont">&nbsp;<a href=javascript:dip_sub("KST019.php","KST019");>週間スケジュール表示開始日設定</a></span>
			<SPAN ID=KST019></SPAN>
		</TD>
	</TR>
	<TR>
		<TD width="65%" height="25" align="reft" bgcolor ="#ffffff">
			<span class="Normalfont">&nbsp;<a href=javascript:dip_sub("KST018.php","KST018");>祝祭日表示設定</a></span>
			<SPAN ID=KST018></SPAN>
		</TD>
	</TR>
	<TR>
		<TD width="65%" align="reft" bgcolor ="<?php echo $KST024_Color; ?>">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<TR>
					<TD align="reft" bgcolor ="<?php echo $KST024_Color; ?>">
						<span class="Normalfont">&nbsp;<a href=javascript:dip_sub("KST024.php","KST024");>Googleカレンダー(新方式)</a></span>
						<span class="Chufont">&nbsp;<?php echo $KST024_Msg; ?></span>
					</TD>
					<TD align="right" bgcolor ="<?php echo $KST024_Color; ?>">
						<span class="Normalfont">
							<a href='javascript:Disp_Help2("KST024HLP.htm")'><img src="image/help.gif" border="0"></a> <a href='javascript:Disp_Help2("KST024HLP.htm")'>設定方法</a>
							&nbsp;&nbsp;&nbsp;&nbsp;
						</span>
					</TD>
				</TR>
			</table>

			<SPAN ID=KST024></SPAN>
		</TD>
	</TR>
	<TR>
		<TD width="65%" align="reft" bgcolor ="<?php echo $KST020_Color; ?>">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<TR>
					<TD align="reft" bgcolor ="<?php echo $KST020_Color; ?>">
						<span class="Normalfont">&nbsp;<a href=javascript:dip_sub("KST020.php","KST020");>Googleカレンダー</a></span>
						<span class="Chufont">&nbsp;<?php echo $KST020_Msg; ?></span>
					</TD>
					<TD align="right" bgcolor ="<?php echo $KST020_Color; ?>">
						<span class="Normalfont">
							<a href='javascript:Disp_Help2("KST020HLP.htm")'><img src="image/help.gif" border="0"></a> <a href='javascript:Disp_Help2("KST020HLP.htm")'>取得方法</a>
							&nbsp;&nbsp;&nbsp;&nbsp;
						</span>
					</TD>
				</TR>
			</table>
			<SPAN ID=KST020></SPAN>
		</TD>
	</TR>
	<TR>
		<TD width="65%" align="reft" bgcolor ="#ffffff">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<TR>
					<TD align="reft" bgcolor ="#ffffff">
						<span class="Normalfont">&nbsp;<a href=javascript:dip_sub("KST021.php","KST021");>ICal</a></span>
					</TD>
					<TD align="right" bgcolor ="#ffffff">
						<span class="Normalfont">
							<a href='javascript:Disp_Help2("KST021HLP1.htm")'><img src="image/help.gif" border="0"></a> <a href='javascript:Disp_Help2("KST021HLP1.htm")'>ヘルプ</a>
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						</span>
					</TD>
				</TR>
			</table>
			<SPAN ID=KST021></SPAN>
		</TD>
	</TR>
<?php  } ?>
<!--	
	<TR>
		<TD width="350" height="25" align="reft" bgcolor ="#ffffff"><span class="Normalfont">&nbsp;<a href="KST005.php">出社状況設定</a></span></TD>
	</TR>
-->

<?php  if($PHP_MODE_FLG != 2){ ?>

	<?php  if($kinou_flg[7]==1){ ?>
		<TR>
			<TD width="25%" height="25" align="reft" class="toneDown"><span class="Normalfont">&nbsp;アドレス帳設定</span></TD>
			<TD width="65%" height="25" align="reft" bgcolor ="#ffffff"><span class="Normalfont">&nbsp;<a href=javascript:dip_sub("KST012.php","KST012");>初期表示グループ設定</a></span>
		<SPAN ID=KST012></SPAN>
		</TD>
		</TR>
	<?php  } ?>
	<?php  if($kinou_flg[6]==1){ ?>
		<!--
		<TR>
			<TD width="25%" height="25" align="reft" class="toneDown"><span class="Normalfont">&nbsp;取引先情報設定</span></TD>
			<TD width="65%" height="25" align="reft" bgcolor ="#ffffff"><span class="Normalfont">&nbsp;<a href=javascript:dip_sub("KST008.php","KST008");>初期表示グループ設定</a></span>
		<SPAN ID=KST008></SPAN>
		</TD>
		</TR>
		-->
	<?php  } ?>

<?php  } ?>

	<TR>
		<TD width="25%" height="25" align="reft" rowspan="2" class="toneDown"><span class="Normalfont">&nbsp;個人情報設定</span></TD>
		<TD width="65%" height="25" align="reft" bgcolor ="#ffffff"><span class="Normalfont">&nbsp;<a href=javascript:dip_sub("KIN001.php","KIN001");>個人情報設定</a></span>
	<SPAN ID=KIN001></SPAN>
	</TD>
	</TR>
	<TR>
		<TD width="65%" height="25" align="reft" bgcolor ="#ffffff"><span class="Normalfont">&nbsp;<a href=javascript:dip_sub("PWC001.php","PWC001");>パスワード変更</a></span>
		<SPAN ID=PWC001></SPAN>
		</TD>
	</TR>

<?php  if($PHP_MODE_FLG != 2){ ?>

	<?php  if($kinou_flg[1]==1){ ?>
		<TR>
			<TD width="25%" height="25" align="reft" class="toneDown"><span class="Normalfont">&nbsp;電話メモ設定</span></TD>
			<TD width="65%" height="25" align="reft" bgcolor ="#ffffff"><span class="Normalfont">&nbsp;<a href=javascript:dip_sub("KST014.php","KST014");>転送アドレス設定</a></span>
		<SPAN ID=KST014></SPAN>
		</TD>
		</TR>
	<?php  } ?>


	<?php 
		if((int)$PHP_MOBILE_FLG!=1){
	?>
		<TR>
			<TD width="25%" height="25" align="reft" class="toneDown"><span class="Normalfont">&nbsp;携帯電話版設定</span></TD>
			<TD width="65%" height="25" align="reft" bgcolor ="#ffffff"><span class="Normalfont">&nbsp;<a href=javascript:dip_sub("URL001.php","URL001");>携帯電話版URL送信</a></span>
		<SPAN ID=URL001></SPAN>
		</TD>
		</TR>
	<?php 
		}
	?>

<?php  } ?>

<?php  if($PHP_MODE_FLG != 2){ ?>

	<?php  if($kinou_flg[3]==1){  ?>
		 
		<TR>
			<TD width="25%" height="25" align="reft" class="toneDown"><span class="Normalfont">&nbsp;お知らせメール設定</span></TD>
			<TD width="65%" height="25" align="reft" bgcolor ="#ffffff"><span class="Normalfont">&nbsp;<a href=javascript:dip_sub("KST013.php","KST013");>お知らせメール設定</a></span>
		<SPAN ID=KST013></SPAN>
		</TD>
		</TR>
	<?php  } ?>

<?php  } ?>
	
	<TR>
		<TD width="25%" height="25" align="reft" class="toneDown"><span class="Normalfont">&nbsp;新着表示設定</span></TD>
		<TD width="65%" height="25" align="reft" bgcolor ="#ffffff"><span class="Normalfont">&nbsp;<a href=javascript:dip_sub("KST016.php","KST016");>新着表示設定</a></span>
	<SPAN ID=KST016></SPAN>
	</TD>
	</TR>
	<TR>
		<TD width="25%" height="25" align="reft" class="toneDown"><span class="Normalfont">&nbsp;ToDo・マイノート表示設定</span></TD>
		<TD width="65%" height="25" align="reft" bgcolor ="#ffffff"><span class="Normalfont">&nbsp;<a href=javascript:dip_sub("KST022.php","KST022");>ToDo・マイノート表示設定</a></span>
	<SPAN ID=KST022></SPAN>
	</TD>
	</TR>
	<TR>
		<TD width="25%" height="25" align="reft" class="toneDown"><span class="Normalfont">&nbsp;ログイン状況表示設定</span></TD>
		<TD width="65%" height="25" align="reft" bgcolor ="#ffffff"><span class="Normalfont">&nbsp;<a href=javascript:dip_sub("KST017.php","KST017");>ログイン状況表示設定</a></span>
	<SPAN ID=KST017></SPAN>
	</TD>
	</TR>
	
<!--
	<TR>
		<TD width="25%" height="25" align="reft" class="toneDown"><span class="Normalfont">&nbsp;ボタンサイズ設定</span></TD>
		<TD width="65%" height="25" align="reft" bgcolor ="#ffffff"><span class="Normalfont">&nbsp;<a href=javascript:dip_sub("KST015.php","KST015");>ボタンサイズ設定</a></span>
	<SPAN ID=KST015></SPAN>
	</TD>
	</TR>
-->
</TABLE>
	</td>
	</TR>
</table>
<span class="Tinnyfont"><br></span>
<br>
<?php 
//コピーライト
include("include/copyright.inc");
?>
<input type="hidden" name="intsts" value="">
<input type="hidden" name="strsel" value="">
<input type="hidden" name="gcal_code" value="<?php echo $code ?>">

</form>
</BODY>
</HTML>