Various changes and fixes (#7424)
[openemr.git] / interface / main / calendar / modules / PostCalendar / pnadminapi.php
blob65096812cef99afe7c732b8ec572f1494c814ff6
1 <?php
3 /**
4 * Admin API for the calendar
6 * @package OpenEMR
7 * @link https://www.open-emr.org
8 * @copyright Copyright (c) 2002 The PostCalendar Team
9 * @copyright Copyright (c) 2021 Brady Miller <brady.g.miller@gmail.com>
10 * @author The PostCalendar Team
11 * @author Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 //=========================================================================
16 // Require utility classes
17 //=========================================================================
19 if (!defined('__POSTCALENDAR__')) {
20 define('__POSTCALENDAR__', 'PostCalendar');
23 $pcModInfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__));
24 $pcDir = pnVarPrepForOS($pcModInfo['directory']);
25 require_once("modules/$pcDir/common.api.php");
26 unset($pcModInfo, $pcDir);
30 function postcalendar_adminapi_updateCategories($args)
32 extract($args);
33 if (!isset($updates)) {
34 return false;
37 list($dbconn) = pnDBGetConn();
38 foreach ($updates as $update) {
39 $result = $dbconn->Execute($update);
40 if ($result === false) {
41 return false;
45 return true;
47 function postcalendar_adminapi_deleteCategories($args)
49 extract($args);
50 if (!isset($delete)) {
51 return false;
54 list($dbconn) = pnDBGetConn();
55 $result = $dbconn->Execute($delete);
56 if ($result === false) {
57 return false;
60 return true;
62 function postcalendar_adminapi_addCategories($args)
64 extract($args);
65 if (!isset($name)) {
66 return false;
69 list($dbconn) = pnDBGetConn();
70 $pntable = pnDBGetTables();
72 $name = pnVarPrepForStore($name);
73 $constantid = trim(pnVarPrepForStore($constantid));
74 $desc = trim(pnVarPrepForStore($desc));
75 $value_cat_type = pnVarPrepForStore($value_cat_type);
76 $color = pnVarPrepForStore($color);
77 $recurrtype = pnVarPrepForStore($repeat);
78 $recurrspec = pnVarPrepForStore($spec);
79 $recurrfreq = pnVarPrepForStore($recurrfreq);
80 $duration = pnVarPrepForStore($duration);
81 $limitid = pnVarPrepForStore($limitid);
82 $end_date_flag = pnVarPrepForStore($end_date_flag);
83 $end_date_type = pnVarPrepForStore($end_date_type);
84 $end_date_freq = pnVarPrepForStore($end_date_freq);
85 $end_all_day = pnVarPrepForStore($end_all_day);
86 $active = pnVarPrepForStore($active);
87 $sequence = pnVarPrepForStore($sequence);
88 $aco = pnVarPrepForStore($aco);
90 $sql = "INSERT INTO $pntable[postcalendar_categories]
91 (pc_catid,pc_catname,pc_constant_id,pc_catdesc,pc_catcolor,
92 pc_recurrtype,pc_recurrspec,pc_recurrfreq,pc_duration,
93 pc_dailylimit,pc_end_date_flag,pc_end_date_type,
94 pc_end_date_freq,pc_end_all_day,pc_cattype,pc_active,pc_seq,aco_spec)
95 VALUES ('','$name','$constantid','$desc','$color',
96 '$recurrtype','$recurrspec','$recurrfreq',
97 '$duration','$limitid','$end_date_flag','$end_date_type',
98 '$end_date_freq','$end_all_day','$value_cat_type','$active','$sequence','$aco')";
101 //print "sql is $sql \n";
102 $result = $dbconn->Execute($sql);
103 if ($result === false) {
104 print $dbconn->ErrorMsg();
105 return false;
108 return true;