9 function BankingCalendarReplay($pResult, $pReply, $pOperation) {
10 $pReply[
'operation'] = $pOperation;
11 if (isset($pResult[
'data']) && count($pResult[
'data'])) $pReply[
'data'] = $pResult[
'data'];
12 if (isset($pResult[
'info']) && count($pResult[
'info'])) $pReply[
'info'] = $pResult[
'info'];
14 print json_encode(array(
"Results" => $pReply));
44 function BankingCalendarRead($pEnv, $pDbh, $pCu, $pYear) {
47 SELECT dates FROM cu_calendar 50 $sqlRs = db_query($sql, $pDbh);
52 throw new Exception(
"Failed to read calendar for " . $pYear);
54 $sqlReturn[
'calendar'] = db_fetch_assoc($sqlRs);
71 function BankingCalendarCreate($pEnv, $pDbh, $pCu, $pYear, $pDates) {
74 INSERT INTO cu_calendar 75 (cu, year, dates) VALUES ('$pCu', '$pYear', '$pDates')";
76 $sqlRs = db_query($sql, $pDbh);
78 throw new Exception(
"Failed to create calendar for " . $pYear);
81 $sqlReturn[
'calendar'] = db_fetch_assoc($sqlRs);
82 $sqlReturn[
'message'] =
"Calendar created successfully for ". $pYear;
99 function BankingCalendarUpdate($pEnv, $pDbh, $pCu, $pYear, $pDates) {
100 $sqlReturn = array();
103 SET dates = '$pDates' 105 AND year = '$pYear'";
106 $sqlRs = db_query($sql, $pDbh);
108 throw new Exception(
"Failed to update calendar for " . $pYear);
111 $sqlReturn[
'calendar'] = db_fetch_assoc($sqlRs);
112 $sqlReturn[
'message'] =
"Calendar updated successfully for ". $pYear;
126 function BankingCalendarValidate($pEnv, $pCalendar, $pJson =
false) {
127 $cValidate = array();
128 $cCalendar = array();
130 if ($pCalendar ===
null) {
131 throw new Exception(
"Calendar data not found");
136 $cCalendar = trim($pCalendar);
137 $cCalendar = html_entity_decode($cCalendar);
138 $cCalendar = HCU_JsonDecode($cCalendar);
140 $cCalendar = $pCalendar;
143 if (!is_array($cCalendar)) {
144 throw new Exception(
"Calendar data is invalid");
148 if (isset($cCalendar[
'year'])) {
149 $cYear = trim($cCalendar[
'year']);
151 if (strlen($cYear) !== 4) {
152 throw new Exception(
"Calendar year is invalid");
155 $cValidate[
'validate'][
'year'] = $cYear;
157 throw new Exception(
"Calendar year is missing");
161 if (isset($cCalendar[
'dates'])) {
162 $cDates = $cCalendar[
'dates'];
166 if (!is_array($cDates)) {
167 throw new Exception(
"Calendar date list is invalid");
171 $cDates = HCU_JsonEncode($cDates);
172 $cDates = trim($cDates);
175 if ($cDates ===
"") {
176 throw new Exception(
"Calendar dates list is missing");
179 $cValidate[
'validate'][
'dates'] = $cDates;
181 throw new Exception(
"Calendar dates list is missing");