fixed issue with hardcode location for ie specific ajax_calendar_ie.css, removed...
[openemr.git] / interface / main / calendar / modules / PostCalendar / pnadminapi.php
blobb8703ab3f9df8d3a986ce72597b695d2443906ef
1 <?php
2 @define('__POSTCALENDAR__','PostCalendar');
3 /**
4 * $Id$
6 * PostCalendar::PostNuke Events Calendar Module
7 * Copyright (C) 2002 The PostCalendar Team
8 * http://postcalendar.tv
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * To read the license please read the docs/license.txt or visit
25 * http://www.gnu.org/copyleft/gpl.html
29 //=========================================================================
30 // Require utility classes
31 //=========================================================================
32 $pcModInfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__));
33 $pcDir = pnVarPrepForOS($pcModInfo['directory']);
34 require_once("modules/$pcDir/common.api.php");
35 unset($pcModInfo,$pcDir);
37 function postcalendar_adminapi_buildHourSelect($args)
39 extract($args);
40 $time24hours = pnModGetVar(__POSTCALENDAR__,'time24hours');
42 if(!isset($hour)){
43 $hour = $time24hours ? date('H') : date('h');
46 $output =& new pnHTML();
47 $output->SetInputMode(_PNH_VERBATIMINPUT);
49 $options = array();
50 if($time24hours) {
51 for($i = 0; $i < 24; $i++) {
52 $sel = false;
53 if($i == $hour) {
54 $sel = true;
56 $options[$i]['id'] = $i;
57 $options[$i]['selected'] = $sel;
58 $options[$i]['name'] = $i < 10 ? '0'.$i : $i;
60 } else {
61 for($i = 0; $i < 12; $i++) {
62 $sel = false;
63 if($i == $hour) {
64 $sel = true;
66 $options[$i]['id'] = $i+1;
67 $options[$i]['selected'] = $sel;
68 $options[$i]['name'] = $i+1 < 10 ? '0'.$i+1 : $i+1;
72 $output->FormSelectMultiple('pc_hour',$options);
73 return $output->GetOutput();
75 function postcalendar_adminapi_getAdminListEvents($args)
77 extract($args);
78 list($dbconn) = pnDBGetConn();
79 $pntable = pnDBGetTables();
80 $events_table = $pntable['postcalendar_events'];
82 $sql = "SELECT pc_eid,
83 pc_title,
84 pc_time
85 FROM $events_table
86 WHERE pc_eventstatus = $type ";
87 if($sort == 'time') {
88 $sql .= "ORDER BY pc_time ";
89 } elseif($sort == 'title') {
90 $sql .= "ORDER BY pc_title ";
92 if($sdir == 0) {
93 $sql .= "DESC ";
94 } elseif($sdir == 1) {
95 $sql .= "ASC ";
97 $sql .= "LIMIT $offset,$offset_increment";
99 return $dbconn->Execute($sql);
102 function postcalendar_adminapi_buildAdminList($args)
104 extract($args);
105 $output =& new pnHTML();
106 $output->SetInputMode(_PNH_VERBATIMINPUT);
107 pnThemeLoad(pnUserGetTheme());
108 // get the theme globals :: is there a better way to do this?
109 global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5;
110 global $textcolor1, $textcolor2;
112 $formUrl = pnModUrl(__POSTCALENDAR__,'admin','adminevents');
113 $output->FormStart($formUrl);
114 $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
115 $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'"><tr><td>');
116 $output->Text('<center><font size="4"><b>'.$title.'</b></font></center>');
117 $output->Text('</td></tr></table>');
118 $output->Text('</td></tr></table>');
120 $output->Linebreak();
122 $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
123 $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'">');
124 if(!$result || $result->EOF) {
125 $output->Text('<tr><td width="100%" bgcolor="'.$bgcolor1.'" align="center"><b>'._PC_NO_EVENTS.'</b></td></tr>');
126 } else {
127 $output->Text('<tr><td bgcolor="'.$bgcolor1.'" align="center"><b>'._PC_EVENTS.'</b></td></tr>');
128 $output->Text('<table border="0" cellpadding="2" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'">');
130 // build sorting urls
131 if(!isset($sdir)) { $sdir = 1; }
132 else { $sdir = $sdir ? 0 : 1; }
134 $title_sort_url = pnModUrl(__POSTCALENDAR__,'admin',$function,array('offset'=>$offset,'sort'=>'title','sdir'=>$sdir));
135 $time_sort_url = pnModUrl(__POSTCALENDAR__,'admin',$function,array('offset'=>$offset,'sort'=>'time','sdir'=>$sdir));
136 $output->Text('<tr><td>select</td><td><a href="'.$title_sort_url.'">title</a></td><td><a href="'.$time_sort_url.'">timestamp</a><td></tr>');
137 // output the queued events
138 $count=0;
139 for(; !$result->EOF; $result->MoveNext()) {
140 list($eid,$title,$timestamp) = $result->fields;
141 $output->Text('<tr>');
142 $output->Text('<td align="center" valign="top">');
143 $output->FormCheckbox('pc_event_id[]', false, $eid);
144 $output->Text('</td>');
145 $output->Text('<td align="left" valign="top" width="100%">');
146 $output->URL(pnModURL(__POSTCALENDAR__,'admin','edit',array('pc_event_id'=>$eid)),
147 pnVarPrepHTMLDisplay(postcalendar_removeScriptTags($title)));
148 $output->Text('</td>');
149 $output->Text('<td align="left" valign="top" nowrap>');
150 $output->Text($timestamp);
151 $output->Text('</td>');
152 $output->Text('</tr>');
154 $count++;
156 $output->Text('</table>');
158 $output->Text('</td></tr></table>');
159 if($result->NumRows()) {
160 $output->Linebreak();
162 // action to take?
163 $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
164 $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'"><tr>');
165 $output->Text('<td align="left" valign="middle">');
167 $seldata[0]['id'] = _ADMIN_ACTION_VIEW;
168 $seldata[0]['selected'] = 1;
169 $seldata[0]['name'] = _PC_ADMIN_ACTION_VIEW;
171 $seldata[1]['id'] = _ADMIN_ACTION_APPROVE;
172 $seldata[1]['selected'] = 0;
173 $seldata[1]['name'] = _PC_ADMIN_ACTION_APPROVE;
175 $seldata[2]['id'] = _ADMIN_ACTION_HIDE;
176 $seldata[2]['selected'] = 0;
177 $seldata[2]['name'] = _PC_ADMIN_ACTION_HIDE;
179 $seldata[3]['id'] = _ADMIN_ACTION_DELETE;
180 $seldata[3]['selected'] = 0;
181 $seldata[3]['name'] = _PC_ADMIN_ACTION_DELETE;
183 $output->FormSelectMultiple('action', $seldata);
184 $output->FormHidden('thelist',$function);
185 $output->FormSubmit(_PC_PERFORM_ACTION);
186 $output->Text('</td>');
187 $output->Text('</tr></table>');
188 $output->Text('</td></tr></table>');
189 $output->Linebreak();
191 // start previous next links
192 $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="'.$bgcolor2.'"><tr><td>');
193 $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%" bgcolor="'.$bgcolor1.'"><tr>');
194 if($offset > 1) {
195 $output->Text('<td align="left">');
196 $next_link = pnModUrl(__POSTCALENDAR__,'admin',$function,array('offset'=>$offset-$offset_increment,'sort'=>$sort,'sdir'=>$sdir));
197 $output->Text('<a href="'.$next_link.'"><< '._PC_PREV.' '.$offset_increment.'</a>');
198 $output->Text('</td>');
199 } else {
200 $output->Text('<td align="left"><< '._PC_PREV.'</td>');
202 if($result->NumRows() >= $offset_increment) {
203 $output->Text('<td align="right">');
204 $next_link = pnModUrl(__POSTCALENDAR__,'admin',$function,array('offset'=>$offset+$offset_increment,'sort'=>$sort,'sdir'=>$sdir));
205 $output->Text('<a href="'.$next_link.'">'._PC_NEXT.' '.$offset_increment.' >></a>');
206 $output->Text('</td>');
207 } else {
208 $output->Text('<td align="right">'._PC_NEXT.' >></td>');
210 $output->Text('</tr></table>');
212 $output->Text('</td></tr></table>');
213 // end previous next links
214 $output->FormEnd();
216 return $output->GetOutput();
219 function postcalendar_adminapi_buildMinSelect($args)
221 extract($args);
223 if(!isset($min)){
224 $min = date('i');
227 $output =& new pnHTML();
228 $output->SetInputMode(_PNH_VERBATIMINPUT);
230 $options = array();
231 for ($i = 0; $i <= 45; $i+5) {
232 $options[$i]['id'] = $i;
233 $options[$i]['selected'] = false;
234 $options[$i]['name'] = $i < 10 ? '0'.$i+1 : $i+1;
237 $output->FormSelectMultiple('pc_min',$options);
238 return $output->GetOutput();
241 function postcalendar_adminapi_buildAMPMSelect($args)
243 extract($args);
245 $output =& new pnHTML();
246 $output->SetInputMode(_PNH_VERBATIMINPUT);
248 $options = array();
249 if(pnModGetVar(__POSTCALENDAR__,'time24hours')) {
250 return false;
251 } else {
252 $options[0]['id'] = 'AM';
253 $options[0]['selected'] = '';
254 $options[0]['name'] = 'AM';
255 $options[1]['id'] = 'PM';
256 $options[1]['selected'] = '';
257 $options[1]['name'] = 'PM';
260 $output->FormSelectMultiple('pc_ampm',$options);
261 return $output->GetOutput();
264 function postcalendar_adminapi_waiting($args)
265 { $output =& new pnHTML();
266 $output = "waiting<br />";
267 return $output->GetOutput();
270 function postcalendar_adminapi_updateCategories($args)
272 extract($args);
273 if(!isset($updates)) {
274 return false;
276 list($dbconn) = pnDBGetConn();
277 foreach($updates as $update) {
278 $result = $dbconn->Execute($update);
279 if($result === false) {
280 return false;
283 return true;
285 function postcalendar_adminapi_deleteCategories($args)
287 extract($args);
288 if(!isset($delete)) {
289 return false;
291 list($dbconn) = pnDBGetConn();
292 $result = $dbconn->Execute($delete);
293 if($result === false) {
294 return false;
296 return true;
298 function postcalendar_adminapi_addCategories($args)
300 extract($args);
301 if(!isset($name)) {
302 return false;
304 list($dbconn) = pnDBGetConn();
305 $pntable = pnDBGetTables();
307 $name = pnVarPrepForStore($name);
308 $desc = trim(pnVarPrepForStore($desc));
309 $value_cat_type = pnVarPrepForStore($value_cat_type);
310 $color = pnVarPrepForStore($color);
311 $recurrtype = pnVarPrepForStore($repeat);
312 $recurrspec = pnVarPrepForStore($spec);
313 $recurrfreq = pnVarPrepForStore($recurrfreq);
314 $duration = pnVarPrepForStore($duration);
315 $limitid = pnVarPrepForStore($limitid);
316 $end_date_flag = pnVarPrepForStore($end_date_flag);
317 $end_date_type = pnVarPrepForStore($end_date_type);
318 $end_date_freq = pnVarPrepForStore($end_date_freq);
319 $end_all_day = pnVarPrepForStore($end_all_day);
321 $sql = "INSERT INTO $pntable[postcalendar_categories]
322 (pc_catid,pc_catname,pc_catdesc,pc_catcolor,
323 pc_recurrtype,pc_recurrspec,pc_recurrfreq,pc_duration,
324 pc_dailylimit,pc_end_date_flag,pc_end_date_type,
325 pc_end_date_freq,pc_end_all_day,pc_cattype)
326 VALUES ('','$name','$desc','$color',
327 '$recurrtype','$recurrspec','$recurrfreq',
328 '$duration','$limitid','$end_date_flag','$end_date_type',
329 '$end_date_freq','$end_all_day','$value_cat_type')";
332 //print "sql is $sql \n";
333 $result = $dbconn->Execute($sql);
334 if($result === false) {
335 print $dbconn->ErrorMsg();
336 return false;
338 return true;
341 function postcalendar_adminapi_updateCategoryLimit($args)
343 extract($args);
344 if(!isset($updates)) {
345 return false;
347 list($dbconn) = pnDBGetConn();
348 foreach($updates as $update) {
349 $result = $dbconn->Execute($update);
350 if($result === false) {
351 return false;
354 return true;
357 function postcalendar_adminapi_deleteCategoryLimit($args)
359 extract($args);
360 if(!isset($delete)) {
361 return false;
363 list($dbconn) = pnDBGetConn();
364 $result = $dbconn->Execute($delete);
365 if($result === false) {
366 return false;
368 return true;
370 function postcalendar_adminapi_addCategoryLimit($args)
372 extract($args);
373 if(!isset($catid)) {
374 return false;
376 list($dbconn) = pnDBGetConn();
377 $pntable = pnDBGetTables();
379 $catid = pnVarPrepForStore($catid);
380 $starttime = pnVarPrepForStore($starttime);
381 $endtime = pnVarPrepForStore($endtime);
382 $limit = pnVarPrepForStore($limit);
384 $sql = "INSERT INTO $pntable[postcalendar_limits]
385 (pc_limitid,pc_catid,pc_starttime,pc_endtime,
386 pc_limit)
387 VALUES ('','$catid','$starttime',
388 '$endtime','$limit')";
390 $result = $dbconn->Execute($sql);
391 if($result === false) {
392 print $dbconn->ErrorMsg();
393 return false;
395 return true;