<?php
class x_6y extends x_cn { 
function x_6z($x_6v = 0, $x_6w = 0) { 
$x_5c = Array(); 
$x_5c['x_1c'] = '{}'; 
$x_5c['x_77'] = 0; 
$x_5c['x_78'] = 0; 
$x_5c['x_1e'] = '{}'; 
$x_5c['x_7a'] = 0; 
$x_5c['x_7b'] = 0; 
$x_5c['x_1f'] = 'C'; 
$x_bt = $x_6w - $x_6v; 
if (0 == $x_bt) { 
$x_5c['x_1c'] = '{\'x_co\':' . ($x_6v - 1) .', \'x_cp\': ' . ($x_6v - 1) .'}'; 
$x_5c['x_77'] = $x_6v - 1; 
$x_5c['x_78'] = $x_6v - 1; 
$x_5c['x_1e'] = '{\'x_co\':' . ($x_6v + 1) .', \'x_cp\': ' . ($x_6v + 1) .'}'; 
$x_5c['x_7a'] = $x_6v + 1; 
$x_5c['x_7b'] = $x_6v + 1; 
$x_5c['x_1f'] = 'D'; 
} elseif ($x_bt > 0) { 
$x_cq = 'select AP_ID, AP_TYPE from AP_LIST where AP_BEGIN = ' . $x_6v . ' and AP_END =' . $x_6w; 
$this->x_cc($x_cq); 
$x_cr = Array(); 
$x_cr = $this->x_cs('assoc'); 
$x_cr = $x_cr[0]; 
if (!empty($x_cr)) { 
$x_ct = $x_cr['AP_TYPE']; 
$x_cq = 'select AP_BEGIN, AP_END 


											from AP_LIST


											where AP_END = ' . ($x_6v - 1) . ' and AP_TYPE =\'' . $x_ct . '\''; 
$this->x_cc($x_cq); 
$x_cu = Array(); 
$x_cu = $this->x_cs('assoc'); 
$x_cu = $x_cu[0]; 
$x_cq = 'select AP_BEGIN, AP_END 


											from AP_LIST


											where AP_BEGIN = ' . ($x_6w + 1) . ' and AP_TYPE =\'' . $x_ct . '\''; 
$this->x_cc($x_cq); 
$x_cv = Array(); 
$x_cv = $this->x_cs('assoc'); 
$x_cv = $x_cv[0]; 
if (!empty($x_cu)) { 
$x_5c['x_1c'] = '{\'x_co\':' . $x_cu['AP_BEGIN'] . ', \'x_cp\': ' . $x_cu['AP_END'] . '}'; 
$x_5c['x_77'] = $x_cu['AP_BEGIN']; 
$x_5c['x_78'] = $x_cu['AP_END']; 
} 
if (!empty($x_cv)) { 
$x_5c['x_1e'] = '{\'x_co\':' . $x_cv['AP_BEGIN'] . ', \'x_cp\': ' . $x_cv['AP_END'] . '}'; 
$x_5c['x_7a'] = $x_cv['AP_BEGIN']; 
$x_5c['x_7b'] = $x_cv['AP_END']; 
} 
$x_5c['x_1f'] = trim($x_ct); 
} 
} 
return $x_5c; 
} 
function x_ci( $x_6v = 0, 
$x_6w = 0, 
$x_cw = 5, 
$x_cx = false) { 
$x_5c = Array(); 
if ($x_6v != 0 && $x_6w != 0) { 
$x_cq = '	select 


									first(' . $x_cw . ') *


								from AP_LIST 


								where 


									((AP_BEGIN <= ' . $x_6v . ' and AP_END >= ' . $x_6v . ') 


									or (AP_END >= ' . $x_6w . ' and AP_BEGIN <= ' . $x_6w . ') 


									or (AP_BEGIN > ' . $x_6v . ' AND AP_END < ' . $x_6w . '))' 
. ($x_cx ? ' AND AP_TYPE = \'W\'' : '') . 
'order by AP_BEGIN asc;'; 
$this->x_cc($x_cq); 
$x_5c = $this->x_cs('assoc'); 
} 
return $x_5c; 
} 
function x_cy($x_84 = 'W', $x_4w = '') { 
$x_cq = ''; 
$x_5c = Array(); 
$x_cz = ''; 
switch ($x_84) { 
case 'W': 
$x_cq = '	SELECT


      									AP_ID as "apId",


      									AP_BEGIN as "apBegin",


      									AP_END as "apEnd"


									FROM AP_LIST


									WHERE AP_TYPE= \'' . $x_84 . ' \'


									ORDER BY AP_BEGIN'; 
$this->x_cc($x_cq); 
$x_as = $this->x_cs('assoc'); 
if (count($x_as) != 0) { 
$x_3u = Array(); 
foreach ($x_as as $x_cr) { 
$x_d0 = kp_getDate($x_cr['apBegin'], 'n'); 
$x_d1 = kp_getDate($x_cr['apEnd'], 'n'); 
$x_d2 = kp_getDate($x_cr['apBegin'], 'Y'); 
$x_d3 = kp_getDate($x_cr['apEnd'], 'Y'); 
$x_d4 = Array(); 
$x_d4['apId'] = $x_cr['apId']; 
$x_d4['start'] = $x_cr['apBegin']; 
$x_d4['end'] = $x_cr['apEnd']; 
$x_d4['startText'] = kp_getDate( $x_cr['apBegin'], 
$x_4w->x_d5(), 
true); 
$x_d4['endText'] = kp_getDate($x_cr['apEnd'], 
$x_4w->x_d5(), 
true); 
if (!isset($x_3u[$x_d2])) { 
$x_3u[$x_d2] = Array(); 
} 
if (!isset($x_3u[$x_d3])) { 
$x_3u[$x_d3] = Array(); 
} 
if (!isset($x_3u[$x_d2][$x_d0])) { 
$x_3u[$x_d2][$x_d0] = Array(); 
} 
if (!isset($x_3u[$x_d3][$x_d1])) { 
$x_3u[$x_d3][$x_d1] = Array(); 
} 
$x_3u[$x_d2][$x_d0][$x_cr['apId']] = $x_d4; 
$x_3u[$x_d3][$x_d1][$x_cr['apId']] = $x_d4; 
} 
$x_5c = $x_3u; 
if (!empty($x_5c)) { 
$x_d6 = Array(); 
foreach ($x_5c as $x_d7 => $x_7w) { 
$x_d8 = Array(); 
foreach ($x_7w as $x_d9 => $x_7v) { 
$x_da = Array(); 
$x_7p = 0; 
foreach ($x_7v as $x_cr) { 
$x_da[] = $x_7p . ':' 
. '{apId:' . $x_cr['apId'] 
. ',start:' . $x_cr['start'] 
. ',end:' . $x_cr['end'] 
. ',startText:\'' . htmlspecialchars($x_cr['startText']) . '\'' 
. ',endText:\'' . htmlspecialchars($x_cr['endText']) . '\'}'; 
$x_7p++; 
} 
$x_d8[] = $x_d9 . ':{' . implode(',', $x_da) .'}'; 
} 
$x_d6[] = $x_d7 . ':{' . implode(',', $x_d8) .'}'; 
} 
$x_cz = 'var x_db = {' . implode(',', $x_d6) . '};'; 
} 
} 
break; 
case 'M': 
$x_cq = '	SELECT


      									AP_ID as "apId",


      									AP_BEGIN as "apBegin",


      									AP_END as "apEnd"


									FROM AP_LIST


									WHERE AP_TYPE= \'' . $x_84 . ' \'


									ORDER BY AP_BEGIN'; 
$this->x_cc($x_cq); 
$x_as = $this->x_cs('assoc'); 
if (count($x_as) != 0) { 
$x_3u = Array(); 
foreach ($x_as as $x_cr) { 
$x_d0 = kp_getDate($x_cr['apBegin'], 'n'); 
$x_d2 = kp_getDate($x_cr['apBegin'], 'Y'); 
$x_d3 = kp_getDate($x_cr['apEnd'], 'Y'); 
$x_d4 = Array(); 
$x_d4['apId'] = $x_cr['apId']; 
$x_d4['start'] = $x_cr['apBegin']; 
$x_d4['end'] = $x_cr['apEnd']; 
$x_d4['startText'] = kp_getDate( $x_cr['apBegin'], 
$x_4w->x_d5(), 
true); 
$x_d4['endText'] = kp_getDate($x_cr['apEnd'], 
$x_4w->x_d5(), 
true); 
$x_d4['monthId'] = (1 == kp_getDate($x_cr['apBegin'], 'j') 
? kp_getDate($x_cr['apBegin'], 'n') : 'undefined'); 
if (!isset($x_3u[$x_d2])) { 
$x_3u[$x_d2] = Array(); 
} 
if (!isset($x_3u[$x_d3])) { 
$x_3u[$x_d3] = Array(); 
} 
$x_3u[$x_d2][] = $x_d4; 
if ($x_d2 != $x_d3) { 
$x_d1 = kp_getDate($x_cr['apEnd'], 'n'); 
$x_3u[$x_d3][] = $x_d4; 
} 
} 
$x_5c = $x_3u; 
if (!empty($x_5c)) { 
$x_d6 = Array(); 
foreach ($x_5c as $x_d7 => $x_7w) { 
$x_d8 = Array(); 
$x_7p = 0; 
foreach ($x_7w as $x_cr) { 
$x_d8[] = $x_7p . ':' 
. '{apId:' . $x_cr['apId'] 
. ',start:' . $x_cr['start'] 
. ',end:' . $x_cr['end'] 
. ',text: \'' . htmlspecialchars($x_cr['startText']) . ' - ' . htmlspecialchars($x_cr['endText']) . '\'' 
. ',monthId:\'' . $x_cr['monthId'] . '\'}'; 
$x_7p++; 
} 
$x_d6[] = $x_d7 . ':{' . implode(',', $x_d8) .'}'; 
} 
$x_cz = 'var x_dc = {' . implode(',', $x_d6) . '};'; 
} 
} 
break; 
} 
return $x_cz; 
} 
function x_dd($x_bd = 0, $x_bp = 0, $x_84 ='W') { 
if ($x_bd != 0 && $x_bp != 0 && $x_84 != '') { 
$x_23 = Array(); 
switch ($x_84) { 
case 'W': 
$x_23 = $this->x_de($x_bd, $x_bp); 
break; 
case 'M': 
$x_23 = $this->x_df($x_bd, $x_bp); 
break; 
} 
$x_5c = Array(); 
if (count($x_23) != 0 ) { 
foreach($x_23 as $x_1n) { 
$x_5c[] = $x_1n['apId']; 
} 
} 
return $x_5c; 
} 
} 
function x_dg($x_7w = 0, $x_7v = 0) { 
$x_7w = intval($x_7w); 
$x_7v = intval($x_7v); 
if ($x_7w >= 1970 && ($x_7v >= 1 && $x_7v <= 12)) { 
$x_dh = kp_getDay(mktime(0, 0, 0, $x_7v, 1, $x_7w)); 
$x_di = kp_getDay(mktime(0, 0, 0, ($x_7v + 1), 0, $x_7w)); 
$x_dj = $this->x_de($x_dh, $x_di); 
$x_dk = count($x_dj); 
if (kp_getDate($x_dj[0]['apBegin'], 'Y') == kp_getDate($x_dj[$x_dk - 1]['apEnd'], 'Y')) { 
$x_7n = 'j. n.'; 
} else { 
$x_7n = 'j. n. Y'; 
} 
$x_5c = Array(); 
foreach($x_dj as $x_dl) { 
$x_5c[] = Array('apId' => $x_dl['apId'], 
'apBegin' => kp_getDate($x_dl['apBegin'], $x_7n), 
'apEnd' => kp_getDate($x_dl['apEnd'], $x_7n)); 
} 
return $x_5c; 
} else { 
return Array(); 
} 
} 
function x_dm($x_7w = 0) { 
$x_7w = intval($x_7w); 
if ($x_7w >= 1970) { 
$x_dh = kp_getDay(mktime(0, 0, 0, 1, 1, $x_7w)); 
$x_di = kp_getDay(mktime(0, 0, 0, 12, 31, $x_7w)); 
$x_dn = $this->x_df($x_dh, $x_di); 
$x_dk = count($x_dn); 
if (kp_getDate($x_dn[0]['apBegin'], 'Y') == kp_getDate($x_dn[$x_dk - 1]['apEnd'], 'Y')) { 
$x_7n = 'j. n.'; 
} else { 
$x_7n = 'j. n. Y'; 
} 
$x_5c = Array(); 
foreach($x_dn as $x_do) { 
$x_5c[] = Array('apId' => $x_do['apId'], 
'apBegin' => kp_getDate($x_do['apBegin'], $x_7n), 
'apEnd' => kp_getDate($x_do['apEnd'], $x_7n)); 
} 
return $x_5c; 
} else { 
return Array(); 
} 
} 
function x_de($x_bd = 0, $x_bp = 0, $x_dp = false) { 
if ($x_bd && $x_bp != 0) { 
$x_cq = '	SELECT


      								AP_ID as "apId",


      								AP_BEGIN as "apBegin",


      								AP_END as "apEnd"


								FROM AP_LIST


								WHERE


									((AP_BEGIN <= ' . $x_bp . ') AND (AP_END >= ' . $x_bd . '))


									AND AP_TYPE = \'W\'


								ORDER BY 2'; 
$this->x_cc($x_cq); 
if (!$x_dp) { 
$x_as = $this->x_cs('assoc'); 
} else { 
$x_as = $this->x_cs('assoc', $x_dp); 
} 
return $x_as; 
} else { 
return false; 
} 
} 
function x_df($x_bd = 0, $x_bp = 0, $x_dp = false) { 
if ($x_bd && $x_bp != 0) { 
$x_cq = '	SELECT


      								AP_ID as "apId",


      								AP_BEGIN as "apBegin",


      								AP_END as "apEnd"


								FROM AP_LIST


								WHERE


									((AP_BEGIN <= ' . $x_bp . ') AND (AP_END > ' . $x_bd . '))


									AND AP_TYPE = \'M\'


								ORDER BY 2'; 
$this->x_cc($x_cq); 
if (!$x_dp) { 
$x_as = $this->x_cs('assoc'); 
} else { 
$x_as = $this->x_cs('assoc', $x_dp); 
} 
return $x_as; 
} else { 
return false; 
} 
} 
} 
?>