1 | <?php |
---|
2 | /** |
---|
3 | * @copyright 2005-2006 OpenPNE Project |
---|
4 | * @license http://www.php.net/license/3_01.txt PHP License 3.01 |
---|
5 | */ |
---|
6 | |
---|
7 | class biz_page_fh_biz_schedule_edit extends OpenPNE_Action |
---|
8 | { |
---|
9 | function execute($requests) |
---|
10 | { |
---|
11 | |
---|
12 | $u = $GLOBALS['AUTH']->uid(); |
---|
13 | |
---|
14 | if (!biz_isPermissionSchedule($u, $requests['schedule_id'])) { |
---|
15 | handle_kengen_error(); |
---|
16 | } |
---|
17 | |
---|
18 | $form_val['subject'] = $requests['subject']; |
---|
19 | $form_val['body'] = $requests['body']; |
---|
20 | |
---|
21 | $sessid = session_id(); |
---|
22 | |
---|
23 | $schedule = db_schedule_biz_schedule4biz_schedule_id($requests['schedule_id']); |
---|
24 | |
---|
25 | if (empty($requests['target_id']) || ($requests['target_id'] == $u)) { |
---|
26 | //自分自身 |
---|
27 | $target_id = $u; |
---|
28 | $this->set('is_h', true); //判別フラグ |
---|
29 | $this->set('inc_navi',fetch_inc_navi('h')); |
---|
30 | } else { |
---|
31 | //他人 |
---|
32 | $target_id = $requests['target_id']; |
---|
33 | $this->set('is_f', true); //判別フラグ |
---|
34 | $this->set('inc_navi',fetch_inc_navi('f')); |
---|
35 | } |
---|
36 | |
---|
37 | //プロフィール |
---|
38 | $this->set("target_member", db_common_c_member4c_member_id($u)); |
---|
39 | $this->set("form_val", $form_val); |
---|
40 | |
---|
41 | //カレンダー関係 |
---|
42 | //カレンダー開始用変数 |
---|
43 | $year = date("Y"); |
---|
44 | $month= date("n"); |
---|
45 | //カレンダー用変数 |
---|
46 | $date_val= array( |
---|
47 | 'year' => $year, |
---|
48 | 'month' => $month, |
---|
49 | 'day' => null, |
---|
50 | ); |
---|
51 | $this->set("date_val", $date_val); |
---|
52 | |
---|
53 | //日記のカレンダー |
---|
54 | $calendar = db_common_diary_monthly_calendar($year, $month, $u); |
---|
55 | |
---|
56 | $this->set("calendar", $calendar['days']); |
---|
57 | $this->set("ym", $calendar['ym']); |
---|
58 | |
---|
59 | //日付関連 |
---|
60 | if ($requests['rep_type']) { |
---|
61 | $begin_date = biz_getRepeatBegin($requests['schedule_id']); |
---|
62 | } else { |
---|
63 | $begin_date = $requests['begin_date']; |
---|
64 | } |
---|
65 | |
---|
66 | $nowyear = date("Y", strtotime($begin_date)); |
---|
67 | $nowmonth = date("m", strtotime($begin_date)); |
---|
68 | $nowday = date("d", strtotime($begin_date)); |
---|
69 | |
---|
70 | for ($i = $nowyear; $i <= $nowyear+10; $i++) { |
---|
71 | if ($i == $nowyear) { |
---|
72 | $years = '<option value="'.$i.'" selected>'; |
---|
73 | } else { |
---|
74 | $years .= '<option value="'.$i.'">'; |
---|
75 | } |
---|
76 | $years .= $i.'年'; |
---|
77 | } |
---|
78 | |
---|
79 | for ($i = 1; $i <= 12; $i++) { |
---|
80 | $i_f = sprintf("%02d",$i); //月は常に二桁 |
---|
81 | if ($i == $nowmonth) { |
---|
82 | $monthes .= '<option value="'.$i_f.'" selected>'; |
---|
83 | } else { |
---|
84 | $monthes .= '<option value="'.$i_f.'">'; |
---|
85 | } |
---|
86 | $monthes .= $i.'月'; |
---|
87 | } |
---|
88 | |
---|
89 | for ($i = 1; $i <= 31; $i++) { |
---|
90 | $i_f = sprintf("%02d",$i); //日は常に二桁 |
---|
91 | if ($i == $nowday) { |
---|
92 | $days .= '<option value="'.$i_f.'" selected>'; |
---|
93 | } else { |
---|
94 | $days .= '<option value="'.$i_f.'">'; |
---|
95 | } |
---|
96 | $days .= $i.'日'; |
---|
97 | } |
---|
98 | |
---|
99 | $hours = biz_makeSerialArray(23); //時 |
---|
100 | $mins = biz_makeSerialArray(55, 0, 5); //分 |
---|
101 | $wk = array('日', '月', '火', '水', '木', '金', '土'); //週 |
---|
102 | $rp_count = biz_makeSerialArray(12, 1); //繰り返し回数 |
---|
103 | $bn_num = biz_makeSerialArray(31, 1); //日数 |
---|
104 | |
---|
105 | $this->set('years', $years); |
---|
106 | $this->set('monthes', $monthes); |
---|
107 | $this->set('days', $days); |
---|
108 | $this->set('hours', $hours); |
---|
109 | $this->set('mins', $mins); |
---|
110 | $this->set('wk', $wk); |
---|
111 | $this->set('rp_count', $rp_count); |
---|
112 | $this->set('bn_num', $bn_num); |
---|
113 | |
---|
114 | $this->set('title', $requests['title']); |
---|
115 | $this->set('value', $requests['value']); |
---|
116 | if (!is_null($requests['begin_time'])) { |
---|
117 | $this->set('begin_hour', date("G", strtotime($requests['begin_time']))); |
---|
118 | } |
---|
119 | |
---|
120 | if (!is_null($requests['begin_time'])) { |
---|
121 | $begin_min = date("i", strtotime($requests['begin_time'])); |
---|
122 | if (substr($begin_min, 0, 1) == '0') { |
---|
123 | $begin_min = substr($begin_min, 1,1); |
---|
124 | } |
---|
125 | } |
---|
126 | |
---|
127 | if (!is_null($requests['begin_time'])) { |
---|
128 | $this->set('begin_min', $begin_min); |
---|
129 | } |
---|
130 | if (!is_null($requests['finish_time'])) { |
---|
131 | $this->set('finish_hour', date("G", strtotime($requests['finish_time']))); |
---|
132 | } else { |
---|
133 | $this->set('finish_hour', null); |
---|
134 | } |
---|
135 | |
---|
136 | if (!is_null($requests['finish_time'])) { |
---|
137 | $finish_min = date("i", strtotime($requests['finish_time'])); |
---|
138 | } |
---|
139 | if (substr($begin_min, 0, 1) == '0') { |
---|
140 | $finish_min = substr($finish_min, 1,1); |
---|
141 | } |
---|
142 | |
---|
143 | if (!is_null($requests['begin_time'])) { |
---|
144 | $this->set('finish_min', $finish_min); |
---|
145 | } else { |
---|
146 | $this->set('finish_min', null); |
---|
147 | } |
---|
148 | |
---|
149 | if ($requests['rep_type']) { |
---|
150 | $is_rep = true; |
---|
151 | } else { |
---|
152 | $is_rep = false; |
---|
153 | } |
---|
154 | |
---|
155 | $dayofweek = array(); |
---|
156 | |
---|
157 | for ($i = 0; $i <= 6; $i++) { |
---|
158 | if ($requests['rep_type'] & (1 << $i)) { |
---|
159 | array_push($dayofweek, 1); |
---|
160 | } else { |
---|
161 | array_push($dayofweek, 0); |
---|
162 | } |
---|
163 | } |
---|
164 | |
---|
165 | $this->set('rep_type', $dayofweek); |
---|
166 | $this->set('is_rep', $is_rep); |
---|
167 | |
---|
168 | $this->set('schedule_id', $requests['schedule_id']); |
---|
169 | |
---|
170 | $repeat_begin = biz_getRepeatBegin($requests['schedule_id']); |
---|
171 | $repeat_finish = biz_getRepeatFinish($requests['schedule_id']); |
---|
172 | $repeat_term = strtotime($repeat_finish) - strtotime($repeat_begin); |
---|
173 | |
---|
174 | $daycount = $repeat_term / (24 * 60 * 60) / 7; |
---|
175 | |
---|
176 | $this->set('repeat_begin_date', $repeat_begin); |
---|
177 | $this->set('repeat_term', intval($daycount)); |
---|
178 | |
---|
179 | $biz_group_count = db_group_count_biz_group4c_member_id($target_id); |
---|
180 | $biz_group_list = db_group_biz_group_list4c_member_id($target_id, 1, $biz_group_count); |
---|
181 | |
---|
182 | $this->set('biz_group_list', $biz_group_list[0]); |
---|
183 | $this->set('target_biz_group_id', $schedule['biz_group_id']); |
---|
184 | |
---|
185 | $this->set('public_flag', $schedule['public_flag']); |
---|
186 | |
---|
187 | return 'success'; |
---|
188 | } |
---|
189 | } |
---|
190 | |
---|
191 | ?> |
---|