main.inc
8.81 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
<?PHP
//*****************************************************************************
//*
//* プログラム名:e-イベント
//* プログラムID:main.inc
//* 機能 :イベント表示画面
//* 作成者 :
//*
//*****************************************************************************
header("Content-type: text/html; charset=shift-jis");
include('../_include/smarty.conf');
//*** DB接続 ***//
include("../../include/dbcon.inc");
include("../../ini.php");
$o_smarty->assign('_SYS_ROOT_URL_', $_SYS_ROOT_URL_);
//*** 実行フォルダ取得 ***//
//echo $_SERVER["SCRIPT_FILENAME"];
$str_Url = split("/", $_SERVER["SCRIPT_FILENAME"]);
$DP_Foldar = $str_Url[count($str_Url)-2];
//*** カレンダー表示スタイル取得 ***//
$strSQL = "SELECT ";
$strSQL .= " style_name, ";
$strSQL .= " temp_name ";
$strSQL .= "FROM ";
$strSQL .= " mst_group, ";
$strSQL .= " group_style_tbl, ";
$strSQL .= " mst_style, ";
$strSQL .= " mst_template ";
$strSQL .= "WHERE";
$strSQL .= " mst_group.group_cd = group_style_tbl.group_cd AND ";
$strSQL .= " mst_group.group_foldar = '".$DP_Foldar."' AND ";
$strSQL .= " group_style_tbl.group_style = mst_style.style_id AND ";
$strSQL .= " group_style_tbl.group_template = mst_template.temp_id ";
$objRec = pg_exec($strSQL);
if($objRec==false){
echo("エラー(SELECT)");
exit;
}
if(pg_numrows($objRec) <= 0){
$color_css = "color1.css";
$template_name = "calendar01.tpl";
}else{
$objData = pg_fetch_object($objRec, 0);
$color_css = $objData->style_name;
$template_name = $objData->temp_name;
}
$o_smarty->assign('color_css', $color_css);
//*** ヘッダー情報取得 ***//
$strSQL = "SELECT ";
$strSQL .= " mst_group.group_cd, ";
$strSQL .= " header_memo, ";
$strSQL .= " type ";
$strSQL .= "FROM ";
$strSQL .= " mst_group, ";
$strSQL .= " group_header_tbl ";
$strSQL .= "WHERE";
$strSQL .= " mst_group.group_cd = group_header_tbl.group_cd AND ";
$strSQL .= " group_foldar = '".$DP_Foldar."' ";
$objRec = pg_exec($strSQL);
if($objRec==false){
echo("エラー(SELECT)");
exit;
}
if(pg_numrows($objRec) <= 0){
$header_memo = '<img src="'.$_ROOT_URL_.'/image/base_header.jpg" />';
}else{
$objData = pg_fetch_object($objRec, 0);
$cboColor_Chk = $objData->header_memo;
switch($objData->type){
case "1":
$header_memo = '<img src="'.$_ROOT_URL_.'/image/base_header'.(int)substr($cboColor_Chk,1,2).'.jpg" />';
break;
case "2":
$strSQL = "SELECT ";
$strSQL .= " * ";
$strSQL .= "FROM ";
$strSQL .= " group_file_tbl ";
$strSQL .= "WHERE";
$strSQL .= " group_cd = '".$objData->group_cd."' AND ";
$strSQL .= " file_id = ".(int)$cboColor_Chk." ";
$objFileRec = pg_exec($strSQL);
if($objFileRec==false){
echo("エラー(SELECT)");
exit;
}
$objFileData = pg_fetch_object($objFileRec, 0);
$header_memo = '<img src="'.$_ROOT_URL_.'/image/header_'.$objData->group_cd."_".(int)$cboColor_Chk.'.'.$objFileData->file_type.'" />';
break;
case "3":
break;
default:
break;
}
}
$o_smarty->assign('header_memo',$header_memo);
// ユーザー定義関数を取り込む
require('../../function/calender.inc' );
require('../../function/operatezero.inc');
//CSVファイルのパス
$ddir = "data/event/";
//カレンダー 色の配列
$clender = array("#FDDFFD","#ccffcc","#ccffcc","#ccffcc","#ccffcc","#ccffcc","#CCF8FB");
$schedule = array("#FDDFFD","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#CCF8FB");
//*** 基準日取得 ***//
if($main_year == "" && $main_mon=="" && $strMainDate==""){
$main_year = date("Y");
$main_mon = date("n");
}else{
if ($strMainDate!=""){
$main_year=substr($strMainDate, 0, 4);
$main_mon=substr($strMainDate, 4, 2);
}
}
$strDispDate[0]=date("Ymd", mktime (0,0,0,$main_mon-1,"01",$main_year));
$strDispDate[1]=date("Y").date("m")."01";
$strDispDate[2]=date("Ymd", mktime (0,0,0,$main_mon+1,"01",$main_year));
$o_smarty->assign('strDispDate',$strDispDate);
//*** 表示年 ***//
$Year_Data = "";
for ($intI = $main_year-1 ; $intI <= $main_year+1 ; $intI++) {
$Year_Data .= "<option value=".$intI;
if ($main_year==$intI){
$Year_Data .= " selected";
}
$Year_Data .= ">".$intI."年</option>";
}
$o_smarty->assign('Year_Data',$Year_Data);
//*** 表示月 ***//
$Month_Data = "";
for ($intI = 1 ; $intI <= 12 ; $intI++) {
$Month_Data .= "<option value=".sprintf('%02d', $intI);
if ($main_mon == $intI){
$Month_Data .= " selected";
}
$Month_Data .= ">".$intI."月</option>";
}
$o_smarty->assign('Month_Data',$Month_Data);
//*** カレンダー作成 ***/
//MAX日付取得
$main_day = "01";
$dateMax = date("j", mktime (0,0,0,$main_mon+1,$main_day-1,$main_year));
//カレンダー空白数(前)
$intbefor = date("w", mktime (0,0,0,$main_mon,$main_day,$main_year));
//カレンダー空白数(後)
$intafter = date("w", mktime (0,0,0,$main_mon,$dateMax,$main_year));
$intafter = 6-$intafter;
//ループ基準日取得
$strWkDate = date("Y/m/d", mktime (0,0,0,$main_mon,$main_day-$intbefor,$main_year));
list($chk_year,$chk_mon,$chk_day)=split("/", $strWkDate);
for($intCnt = 0; $intCnt < $intbefor+$dateMax+$intafter ; $intCnt++) {
$strWkDate=date("Y/m/d", mktime (0,0,0,$chk_mon,$chk_day+$intCnt,$chk_year));
$strcalender[$intCnt]=$strWkDate;
}
//テーブル作成
$strCalData = array();
$intRow = 0;
$intCol = 0;
for($intI = 0; $intI < count($strcalender) ; $intI++) {
list($chk_year,$chk_mon,$chk_day)=split("/", $strcalender[$intI]);
$intYoubi=date("w", mktime (0,0,0,$chk_mon,$chk_day,$chk_year));
//テーブル開始
if (($intI % 7 == 0) && ($intI!=0)){
$intRow = $intRow + 1;
$intCol = 0;
}
//日付表示
if ($chk_mon==$main_mon){
//日付編集
if (substr($chk_mon,0,1) == 0){
$input_mon = substr($chk_mon,1,1);
}else{
$input_mon = $chk_mon;
}
if (substr($chk_day,0,1) == 0){
$input_day = substr($chk_day,1,1);
}else{
$input_day = $chk_day;
}
$strCalData[$intRow][$intCol] = $chk_day;
$strCalData[$intRow][$intCol] .= " <a href=# onclick=\"return event_input('".$chk_year.",".$input_mon.",".$input_day."')\"><img src=\"".$_SYS_ROOT_URL_."/image/write.gif\" width=\"17\" height=\"19\" border=\"0\" alt=\"イベントを登録する\"></a>";
$strCalData[$intRow][$intCol] .= "<ul>";
//データの取得
$file_name = $ddir."eventmst".fun_addzero($main_mon).".csv";
//読み込んだテーブルのレコード数を格納する変数
$tbl_cnt=0;
$month_dat=fun_csvread($month_dat,$file_name);
//データ出力
for ($intdataCnt=0; $intdataCnt < count($month_dat)+1; $intdataCnt++){
if (trim($month_dat[$intdataCnt][0]) == $chk_year.$chk_mon.$chk_day){
$strCalData[$intRow][$intCol] .= '<script language="javascript" type="text/javascript">';
$strCalData[$intRow][$intCol] .= '<!--';
$strCalData[$intRow][$intCol] .= "message[".$intdataCnt."] = '".$month_dat[$intdataCnt][11]."';";
$strCalData[$intRow][$intCol] .= '-->';
$strCalData[$intRow][$intCol] .= '</script>';
$strCalData[$intRow][$intCol] .= '<INPUT type="hidden" name="HidMsg'.$intdataCnt.'" value="'.$month_dat[$intdataCnt][11].'">';
if($month_dat[$intdataCnt][10] == ""){
$month_dat[$intdataCnt][2] = str_replace("<","<",$month_dat[$intdataCnt][2]);
$month_dat[$intdataCnt][2] = str_replace(">",">",$month_dat[$intdataCnt][2]);
//ポップアップの内容が無い場合はJSをはずす
if($month_dat[$intdataCnt][11] == "") {
//<table>タグは、Wiondows IE6.0のバグ回避
$strCalData[$intRow][$intCol] .= '<li class="mainTxt">'.$month_dat[$intdataCnt][2].'</li>';
}else{
$strCalData[$intRow][$intCol] .= '<li><table><tr><td>';
$strCalData[$intRow][$intCol] .= '<span onMouseover="Mover('.$intdataCnt.')" onMouseout="Mout('.$intdataCnt.')">'.$month_dat[$intdataCnt][2].'<span>';
$strCalData[$intRow][$intCol] .= '</td></tr></table></li>';
}
}else{
$month_dat[$intdataCnt][2] = str_replace("<","<",$month_dat[$intdataCnt][2]);
$month_dat[$intdataCnt][2] = str_replace(">",">",$month_dat[$intdataCnt][2]);
$strCalData[$intRow][$intCol] .= '<li><table><tr><td>';
$strCalData[$intRow][$intCol] .= '<a href="'.$month_dat[$intdataCnt][10].'" target="_blank" onMouseover="Mover('.$intdataCnt.')"';
$strCalData[$intRow][$intCol] .= 'onMouseout="Mout('.$intdataCnt.')">'.$month_dat[$intdataCnt][2].'</a>';
$strCalData[$intRow][$intCol] .= '</td></tr></table></li>';
}
// イベントが無い月はポップアップのJavaScriptは読み込まない
if (!($month_dat[$intdataCnt][2] == "")){
$popup_js = "yes";
}
}
}
$strCalData[$intRow][$intCol] .= "</ul>\n\n";
}else{
$strCalData[$intRow][$intCol] = "";
}
$intCol = $intCol+1;
}
$o_smarty->assign('strCalData',$strCalData);
$o_smarty->assign('popup_js',$popup_js);
$o_smarty->display('cl_header.tpl');
$o_smarty->display($template_name);
$o_smarty->display('cl_footer.tpl');
?>