PRJ004.php
8.52 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
<?php
//*****************************************************************************
//*
//* プログラム名:プロジェクト管理
//* プログラムID:PRJ004.php
//* 機能 :タスク作成画面
//* 作成者 :
//*
//*****************************************************************************
header( "Content-type: text/html; charset=EUC-JP");
include("inc/session_start.inc");
include("inc/SessionChk.inc");
include("inc/mtc_comfunc.inc");
include('./include/smarty.conf');
$strDBinc="include/dbcon.inc";
include($strDBinc);
//社員リスト
$strSQL = "select sanka_list from prj_tbl where seq = ".$seq;
$objRec = pg_exec($strSQL);
if($objRec == false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
$objftc = pg_fetch_object($objRec, 0);
$syain_list = "";
$temp = trim($objftc->sanka_list);
if($temp != "/"){
$strwhere = str_replace("//", "", $temp);
$strwhere = substr($strwhere, 1, (strlen($strwhere) - 1));
$strwhere = str_replace("/", "' or syain_cd = '", $strwhere);
$strSQL2 = "select name_kj_sei, name_kj_mei, syain_cd from syain_tbl where syain_cd = '".$strwhere."' Order by disp_rank";
$objRec2 = pg_exec($strSQL2);
if($objRec2 == false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
for($i=0;$i<pg_numrows($objRec2);$i++){
$objftc2 = pg_fetch_object($objRec2, $i);
$syain_list .= "<OPTION value='".$objftc2->syain_cd."' selected>".($objftc2->name_kj_sei).($objftc2->name_kj_mei)."</option>";
}
}
$syain_list .= '<OPTION value="" > </OPTION>';
//カレンダー用 デフォは今日
$cal_st_y = date("Y");
$cal_st_m = date("m");
$cal_st_d = date("d");
$cal_ed_y = date("Y");
$cal_ed_m = date("m");
$cal_ed_d = date("d");
//mode → 1:タスク新規 2:タスク修正 3:タスク詳細新規 4:タスク詳細修正
if($mode == 1 || $mode == 3){
//社員リスト 追加先
$syain_add = '<OPTION value="" > </OPTION>';
//期間
//年
for ($i=Date("Y")-2;$i<=Date("Y")+2;$i++) {
if($i==Date("Y")){
$start_y .= "<OPTION value='".$i."' selected>".$i."年</OPTION>";
}else{
$start_y .= "<OPTION value='".$i."'>".$i."年</OPTION>";
}
}
//月
for ($i=1;$i<=12;$i++) {
if ($i == date("n")){
$start_m .= "<OPTION value='".sprintf('%02d', $i)."' selected>".$i."月</OPTION>";
}else{
$start_m .= "<OPTION value='".sprintf('%02d', $i)."'>".$i."月</OPTION>";
}
}
//日
for ($i=1;$i<=31;$i++) {
if ($i == date("j")){
$start_d .= "<OPTION value='".sprintf('%02d', $i)."' selected>".$i."日</OPTION>";
}else{
$start_d .= "<OPTION value='".sprintf('%02d', $i)."'>".$i."日</OPTION>";
}
}
//=終了
$end_y = $start_y;
$end_m = $start_m;
$end_d = $start_d;
//進捗単位
$strSQL = "select unit_seq, progress_unit, disp_rank from mst_prj_tbl order by disp_rank";
$objRec = pg_exec($strSQL);
if($objRec == false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
$strProgUnit = "";
for($i=0;$i<pg_numrows($objRec);$i++){
$objftc = pg_fetch_object($objRec, $i);
$strProgUnit .= "<option value='".$objftc->unit_seq."'>".$objftc->progress_unit."</option>";
}
//サブタスクはあるのか?
if($mode == 1){
$strSQL = "select seq, task_seq, task_sub_seq, task_name, task_naiyo, start_date, end_date, unit_seq, progress_max, progress, tanto_list, koshin_date from prj_task_tbl ";
$strSQL .= " where seq = ".$seq." and task_seq = ".$tseq." and task_sub_seq > 0";
$objRec = pg_exec($strSQL);
if($objRec == false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
if(pg_numrows($objRec)>0){
$flg_Sub = 1;
}
}
}else if($mode == 2 || $mode == 4){
$strSQL = "select seq, task_seq, task_sub_seq, task_name, task_naiyo, start_date, end_date, unit_seq, progress_max, progress, tanto_list, koshin_date from prj_task_tbl ";
$strSQL .= " where seq = ".$seq." and task_seq = ".$tseq." and task_sub_seq = ".$sseq;
$objRec = pg_exec($strSQL);
if($objRec == false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
$objftc = pg_fetch_object($objRec, 0);
//名称
$strTskName = htmlspecialchars(mtc_rtrim($objftc->task_name));
//内容
$strTskNaiyo = htmlspecialchars(mtc_rtrim($objftc->task_naiyo));
//社員リスト 追加先
$syain_add = "";
$temp = trim($objftc->tanto_list);
if($temp != "/"){
$strwhere = str_replace("//", "", $temp);
$strwhere = substr($strwhere, 1, (strlen($strwhere) - 1));
$strwhere = str_replace("/", "' or syain_cd = '", $strwhere);
$strSQL2 = "select name_kj_sei, name_kj_mei, syain_cd from syain_tbl where syain_cd = '".$strwhere."' Order by disp_rank";
$objRec2 = pg_exec($strSQL2);
if($objRec2 == false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
for($i=0;$i<pg_numrows($objRec2);$i++){
$objftc2 = pg_fetch_object($objRec2, $i);
$syain_add .= "<OPTION value='".$objftc2->syain_cd."' selected>".($objftc2->name_kj_sei).($objftc2->name_kj_mei)."</option>";
}
}
$syain_add .= '<OPTION value="" > </OPTION>';
$start_y = "";
$start_m = "";
$start_d = "";
$end_y = "";
$end_m = "";
$end_d = "";
//開始
//年
for ($i=Date("Y")-2;$i<=Date("Y")+2;$i++) {
if ($i == substr($objftc->start_date,0,4)){
$start_y .= "<OPTION value='".$i."' selected>".$i."年</OPTION>";
$cal_st_y = substr($objftc->start_date,0,4);
}else{
$start_y .= "<OPTION value='".$i."'>".$i."年</OPTION>";
}
}
//月
for ($i=1;$i<=12;$i++) {
if ($i == (int)substr($objftc->start_date,4,2)){
$start_m .= "<OPTION value='".sprintf('%02d', $i)."' selected>".$i."月</OPTION>";
$cal_st_m = substr($objftc->start_date,4,2);
}else{
$start_m .= "<OPTION value='".sprintf('%02d', $i)."'>".$i."月</OPTION>";
}
}
//日
for ($i=1;$i<=31;$i++) {
if ($i == (int)substr($objftc->start_date,6,2)){
$start_d .= "<OPTION value='".sprintf('%02d', $i)."' selected>".$i."日</OPTION>";
$cal_st_d = substr($objftc->start_date,6,2);
}else{
$start_d .= "<OPTION value='".sprintf('%02d', $i)."'>".$i."日</OPTION>";
}
}
//終了
//年
for ($i=Date("Y")-2;$i<=Date("Y")+2;$i++) {
if ($i == substr($objftc->end_date,0,4)){
$end_y .= "<OPTION value='".$i."' selected>".$i."年</OPTION>";
$cal_ed_y = substr($objftc->end_date,0,4);
}else{
$end_y .= "<OPTION value='".$i."'>".$i."年</OPTION>";
}
}
//月
for ($i=1;$i<=12;$i++) {
if ($i == (int)substr($objftc->end_date,4,2)){
$end_m .= "<OPTION value='".sprintf('%02d', $i)."' selected>".$i."月</OPTION>";
$cal_ed_m = substr($objftc->end_date,4,2);
}else{
$end_m .= "<OPTION value='".sprintf('%02d', $i)."'>".$i."月</OPTION>";
}
}
//日
for ($i=1;$i<=31;$i++) {
if ($i == (int)substr($objftc->end_date,6,2)){
$end_d .= "<OPTION value='".sprintf('%02d', $i)."' selected>".$i."日</OPTION>";
$cal_ed_d = substr($objftc->end_date,6,2);
}else{
$end_d .= "<OPTION value='".sprintf('%02d', $i)."'>".$i."日</OPTION>";
}
}
//進捗単位
$strSQL2 = "select unit_seq, progress_unit, disp_rank from mst_prj_tbl order by disp_rank";
$objRec2 = pg_exec($strSQL2);
if($objRec2 == false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
$strProgUnit = "";
for($i=0;$i<pg_numrows($objRec2);$i++){
$objftc2 = pg_fetch_object($objRec2, $i);
if($objftc->unit_seq == $objftc2->unit_seq){
$strProgUnit .= "<option value='".$objftc2->unit_seq."' selected>".$objftc2->progress_unit."</option>";
}else{
$strProgUnit .= "<option value='".$objftc2->unit_seq."'>".$objftc2->progress_unit."</option>";
}
}
//進捗マックス
$strProgMax = $objftc->progress_max;
//サブタスクはあるのか?
if($mode == 2){
$strSQL = "select seq, task_seq, task_sub_seq, task_name, task_naiyo, start_date, end_date, unit_seq, progress_max, progress, tanto_list, koshin_date from prj_task_tbl ";
$strSQL .= " where seq = ".$seq." and task_seq = ".$tseq." and task_sub_seq > 0";
$objRec = pg_exec($strSQL);
if($objRec == false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
if(pg_numrows($objRec)>0){
$flg_Sub = 1;
}
}
}
$o_smarty->assign('syain_list',$syain_list);
$o_smarty->assign('syain_add',$syain_add);
$o_smarty->assign('strProgUnit',$strProgUnit);
$o_smarty->assign('strProgMax',$strProgMax);
$o_smarty->assign('flg_Sub',$flg_Sub);
$o_smarty->assign('mode',$mode);
$o_smarty->assign('seq',(int)$seq);
$o_smarty->assign('tseq',(int)$tseq);
$o_smarty->assign('sseq',(int)$sseq);
$o_smarty->assign('start_y',$start_y);
$o_smarty->assign('start_m',$start_m);
$o_smarty->assign('start_d',$start_d);
$o_smarty->assign('end_y',$end_y);
$o_smarty->assign('end_m',$end_m);
$o_smarty->assign('end_d',$end_d);
$o_smarty->assign('strTskName',$strTskName);
$o_smarty->assign('strTskNaiyo',$strTskNaiyo);
$o_smarty->assign('calYMD',$cal_st_y."/".$cal_st_m."/".$cal_st_d);
$o_smarty->assign('calYMD2',$cal_ed_y."/".$cal_ed_m."/".$cal_ed_d);
$o_smarty->display('PRJ004.tpl');
?>