18 require_once dirname(__FILE__).
'/../../calendar_event/calendar_event_edit_fns.inc';
42 $this->static_screens[
'details'][
'force_unlock'] = FALSE;
59 $freq = $asset->attr(
'frequency');
60 if (!$freq) $freq =
' ';
61 $stop_date_attr =& $asset->getAttribute(
'stop_date');
62 if (($stopdate = $stop_date_attr->getTimestamp()) == -1) {
66 if ($asset->writeAccess(
'attributes')) {
68 <script type=
"text/javascript" src=
"<?php echo sq_web_path('data').'/asset_types/calendar_event_recurring/js/frequency_chooser.js'?>"></script>
70 <table border=
"0" cellpadding=
"0" cellspacing=
"0" width=
"100%" style=
"white-space: nowrap">
71 <tr style=
"height: 11ex">
73 <!-- Overall Frequency Types -->
74 <td style=
"width: 12ex; vertical-align: top">
76 <input type=
"radio" <?php echo ((($freq{0} ==
'D') || !$freq) ?
'checked="checked" ' :
'') ?> name=
"<?php echo $prefix; ?>_frequency" id=
"<?php echo $prefix; ?>_frequency_daily" value=
"daily" onkeypress=
"this.click();" onclick=
"showFreqOptions('<?php echo $prefix; ?>', 'Daily'); checkBox('<?php echo $prefix?>_frequency_type_DED');" />
77 <label
for=
"<?php echo $prefix; ?>_frequency_daily">Daily</label>
80 <input type=
"radio" <?php echo (($freq{0} ==
'W') ?
'checked="checked" ' :
'') ?> name=
"<?php echo $prefix; ?>_frequency" id=
"<?php echo $prefix; ?>_frequency_weekly" value=
"weekly" onkeypress=
"this.click();" onclick=
"showFreqOptions('<?php echo $prefix; ?>', 'Weekly'); checkBox('<?php echo $prefix?>_frequency_type_WEW');" />
81 <label
for=
"<?php echo $prefix; ?>_frequency_weekly">Weekly</label>
84 <input type=
"radio" <?php echo (($freq{0} ==
'M') ?
'checked="checked" ' :
'') ?> name=
"<?php echo $prefix; ?>_frequency" id=
"<?php echo $prefix; ?>_frequency_monthly" value=
"monthly" onkeypress=
"this.click();" onclick=
"showFreqOptions('<?php echo $prefix; ?>', 'Monthly'); checkBox('<?php echo $prefix?>_frequency_type_M');" />
85 <label
for=
"<?php echo $prefix; ?>_frequency_monthly">Monthly</label>
90 <td style=
"vertical-align: top; ">
92 <!-- Daily Options -->
93 <div
id=
"<?php echo $prefix; ?>DailyOptions" style=
"display: <?php echo (($freq{0} == 'D') ? 'block' : 'none') ?>">
94 <input type=
"radio" <?php echo ((($freq ==
'DED') || !$freq) ?
'checked="checked" ' :
'')?> name=
"<?php echo $prefix; ?>_frequency_type" id=
"<?php echo $prefix; ?>_frequency_type_DED" value=
"DED" /><?php echo translate(
'cal_event_every_day'); ?>
98 <input type=
"text" size=
"2" value=
"<?php echo trim(substr($freq, 3)); ?>" name=
"<?php echo $prefix; ?>_num_days" onkeypress=
"this.click();" onclick=
"checkBox('<?php echo $prefix?>_frequency_type_DEDx');" />
99 <?php $x_days_tb = ob_get_contents();
101 <br /><input type=
"radio" <?php echo ((($freq !=
'DED') && (substr($freq, 0, 3) ==
'DED')) ?
'checked="checked" ' :
'')?> name=
"<?php echo $prefix; ?>_frequency_type" id=
"<?php echo $prefix; ?>_frequency_type_DEDx" value=
"DEDx" /><?php echo translate(
'cal_event_every_x_days', $x_days_tb); ?>
102 <br /><input type=
"radio" <?php echo (((substr($freq, 0, 3) ==
'DWD')) ?
'checked="checked" ' :
'')?> name=
"<?php echo $prefix; ?>_frequency_type" id=
"<?php echo $prefix; ?>_frequency_type_DWD" value=
"DWD" /><?php echo translate(
'cal_event_every_weekday'); ?>
103 <br /><input type=
"radio" <?php echo (((substr($freq, 0, 3) ==
'DWE')) ?
'checked="checked" ' :
'')?> name=
"<?php echo $prefix; ?>_frequency_type" id=
"<?php echo $prefix; ?>_frequency_type_DWE" value=
"DWE" /><?php echo translate(
'cal_event_every_weekend'); ?>
106 <!-- Weekly Options -->
107 <div
id=
"<?php echo $prefix; ?>WeeklyOptions" style=
"display: <?php echo (($freq{0} == 'W') ? 'block' : 'none') ?>">
111 <a href=
"javascript: document.getElementById('<?php echo $prefix ?>_start_day').focus();" id=
"<?php echo $prefix ?>_week_day"></a>
112 <?php $week_link = ob_get_contents();
117 <a
id=
"<?php echo $prefix ?>_week_day_4" href=
"javascript: document.getElementById('<?php echo $prefix ?>_start_day').focus();"></a>
118 <?php $x_weeks_link = ob_get_contents();
123 <input type=
"text" size=
"2" value=
"<?php echo substr($freq, 3); ?>" name=
"<?php echo $prefix ?>_num_weeks" onkeypress=
"this.click();" onclick=
"checkBox('<?php echo $prefix?>_frequency_type_WEWx');" />
124 <?php $x_weeks_tb = ob_get_contents();
126 <input type=
"radio" <?php echo ((($freq ==
'WEW') || !$freq) ?
'checked="checked" ' :
'')?> name=
"<?php echo $prefix; ?>_frequency_type" id=
"<?php echo $prefix; ?>_frequency_type_WEW" value=
"WEW" /><?php echo translate(
'cal_event_every_week', $week_link); ?>
127 <br /><input type=
"radio" <?php echo ((($freq !=
'WEW') && (substr($freq,0,3) ==
'WEW')) ?
'checked="checked" ' :
'')?> name=
"<?php echo $prefix; ?>_frequency_type" id=
"<?php echo $prefix; ?>_frequency_type_WEWx" value=
"WEWx" /><?php echo translate(
'cal_event_every_x_weeks', $x_weeks_tb, $x_weeks_link); ?>
130 <!-- Monthly options -->
131 <table border=
"0" cellpadding=
"0" cellspacing=
"0" id=
"<?php echo $prefix; ?>MonthlyOptions" style=
"display: <?php echo (($freq{0} == 'M') ? 'block' : 'none') ?>"><tr>
133 <td style=
"width: 25ex; vertical-align: top">
137 <input type=
"text" size=
"2" value=
"<?php echo substr($freq, 3); ?>" name=
"<?php echo $prefix ?>_num_months" onkeypress=
"this.click();" onclick=
"checkBox('<?php echo $prefix?>_frequency_type_Mx');" />
138 <?php $x_months_tb = ob_get_contents();
141 <input type=
"radio" <?php echo ((($freq{0}==
'M') && (strlen($freq) == 3)) ?
'checked="checked" ' :
''); ?> name=
"<?php echo $prefix; ?>_frequency_type" id=
"<?php echo $prefix; ?>_frequency_type_M" value=
"M"><?php echo translate(
'cal_event_every_month'); ?>
142 <br /><input type=
"radio" <?php echo ((($freq{0}==
'M') && (strlen($freq) != 3)) ?
'checked="checked" ' :
''); ?> name=
"<?php echo $prefix; ?>_frequency_type" id=
"<?php echo $prefix; ?>_frequency_type_Mx" value=
"Mx"><?php echo translate(
'cal_event_every_x_months', $x_months_tb); ?>
144 <td style=
"width: 60ex">
148 <a href=
"javascript: document.getElementById('<?php echo $prefix ?>_start_day').focus();" id=
"<?php echo $prefix; ?>_month_date_ord"></a>
149 <?php $mfn_month_link = ob_get_contents();
152 <input type=
"radio" <?php echo ((($freq{0} !=
'M') || (substr($freq, 0, 3) ==
'MFN')) ?
'checked="checked" ' :
''); ?> name=
"<?php echo $prefix; ?>_monthly_type" value=
"MFN" /><?php echo translate(
'cal_event_month_on_day', $mfn_month_link) ?><span
id=
"<?php echo $prefix; ?>_month_date_warning" style=
"display: none"><?php echo translate(
'cal_event_when_it_exists') ?></span><br />
157 <a href=
"javascript: document.getElementById('<?php echo $prefix ?>_start_day').focus();" id=
"<?php echo $prefix; ?>_month_week_ord"></a>
158 <?php $mfw_month_link = ob_get_contents();
163 <a href=
"javascript: document.getElementById('<?php echo $prefix ?>_start_day').focus();" id=
"<?php echo $prefix; ?>_week_day_2"></a>
164 <?php $mfw_day_link = ob_get_contents();
166 <input type=
"radio" <?php echo ((substr($freq, 0, 3) ==
'MFW') ?
'checked="checked" ' :
''); ?>name=
"<?php echo $prefix; ?>_monthly_type" value=
"MFW" /><?php echo translate(
'cal_event_month_on_weekday', $mfw_month_link, $mfw_day_link) ?> <span
id=
"<?php echo $prefix; ?>_month_week_warning" style=
"display: none"><?php echo translate(
'cal_event_when_it_exists') ?></span><br />
171 <a href=
"javascript: document.getElementById('<?php echo $prefix ?>_start_day').focus();" id=
"<?php echo $prefix; ?>_reverse_month_date_ord"></a><a href=
"javascript: document.getElementById('<?php echo $prefix ?>_start_day').focus();"><?php echo translate(
'last') ?></a>
172 <?php $mrn_month_link = ob_get_contents();
174 <input type=
"radio" <?php echo ((substr($freq, 0, 3) ==
'MRN') ?
'checked="checked" ' :
''); ?> name=
"<?php echo $prefix; ?>_monthly_type" value=
"MRN" /><?php echo translate(
'cal_event_month_on_last_day', $mrn_month_link) ?> <span
id=
"<?php echo $prefix ?>_reverse_month_date_warning" style=
"display: none"><?php echo translate(
'cal_event_when_it_exists') ?></span><br />
179 <a href=
"javascript: document.getElementById('<?php echo $prefix ?>_start_day').focus();" id=
"<?php echo $prefix; ?>_reverse_month_week_ord"></a><a href=
"javascript: document.getElementById('<?php echo $prefix ?>_start_day').focus();"><?php echo translate(
'last') ?></a>
180 <?php $mrw_month_link = ob_get_contents();
185 <a href=
"javascript: document.getElementById('<?php echo $prefix ?>_start_day').focus();" id=
"<?php echo $prefix; ?>_week_day_3"></a>
186 <?php $mrw_day_link = ob_get_contents();
188 <input type=
"radio" <?php echo ((substr($freq, 0, 3) ==
'MRW') ?
'checked="checked" ' :
''); ?> name=
"<?php echo $prefix; ?>_monthly_type" value=
"MRW" /><?php echo translate(
'cal_event_month_on_last_weekday', $mrw_month_link, $mrw_day_link) ?> <span
id=
"<?php echo $prefix; ?>_reverse_month_week_warning" style=
"display: none"><?php echo translate(
'cal_event_when_it_exists') ?></span>
200 parent::printDateChooser($prefix.
'_stop', $stopdate);
201 $date_chooser = ob_get_contents();
203 <input type=
"radio" name=
"<?php echo $prefix; ?>_stop_date_selected" value=
"0" <?php echo ($stopdate ?
'' :
'checked="checked" '); ?> onkeypress=
"this.click();" onclick=
"disableDateField('<?php echo $prefix; ?>_stop')" /><?php echo ucfirst(translate(
'cal_event_recur_until_further_notice')); ?>
204 <br /><input type=
"radio" <?php echo ($stopdate ?
'checked="checked" ' :
''); ?> name=
"<?php echo $prefix; ?>_stop_date_selected" value=
"1" onkeypress=
"this.click();" onclick=
"enableDateField('<?php echo $prefix; ?>_stop')" /><?php echo ucfirst(translate(
'cal_event_recur_until_date',
'')).$date_chooser; ?>
210 <script type=
"text/javascript"><!--
212 updateValues(
'<?php echo $prefix; ?>');
217 hidden_field($prefix.
'_frequency_field_printed', 1);
220 echo $asset->getFriendlyFrequency();
242 if (!(isset($_REQUEST[$prefix.
'_frequency_field_printed']) && ($_REQUEST[$prefix.
'_frequency_field_printed'] == 1))) {
247 if (isset($_REQUEST[$prefix.
'_stop_date_selected']) && ($_REQUEST[$prefix.
'_stop_date_selected'])) {
248 $_REQUEST[$prefix.
'_stop_year'] = (int)$_REQUEST[$prefix.
'_stop_year'];
249 if (($_REQUEST[$prefix.
'_stop_year'] < 1900) || ($_REQUEST[$prefix.
'_stop_year'] > 2100)) {
250 trigger_localised_error(
'CAL0039', E_USER_WARNING);
253 $_REQUEST[$prefix.
'_stop_month'] = (int)$_REQUEST[$prefix.
'_stop_month'];
254 if (($_REQUEST[$prefix.
'_stop_month'] < 1) || ($_REQUEST[$prefix.
'_stop_month'] > 12)) {
255 trigger_localised_error(
'CAL0040', E_USER_WARNING);
258 $_REQUEST[$prefix.
'_stop_day'] = (int)$_REQUEST[$prefix.
'_stop_day'];
259 if (($_REQUEST[$prefix.
'_stop_day'] < 1) || ($_REQUEST[$prefix.
'_stop_day'] > 31)) {
260 trigger_localised_error(
'CAL0041', E_USER_WARNING);
263 $res &= $asset->setAttrValue(
'stop_date', sprintf(
'%04d-%02d-%02d', $_REQUEST[$prefix.
'_stop_year'], $_REQUEST[$prefix.
'_stop_month'], $_REQUEST[$prefix.
'_stop_day']).
' --:--:--');
265 $res &= $asset->setAttrValue(
'stop_date',
'---------- --:--:--');
270 if (empty($_REQUEST[$prefix.
'_frequency_type'])) {
271 $_REQUEST[$prefix.
'_frequency_type'] =
'';
274 switch ($_REQUEST[$prefix.
'_frequency_type']) {
279 $frequency = $_REQUEST[$prefix.
'_frequency_type'];
283 if ((($interval = (
int)$_REQUEST[$prefix.
'_num_days']) > 0)) {
284 $frequency =
'DED'.$interval;
286 trigger_localised_error(
'CAL0042', E_USER_WARNING);
292 if ((($interval = (
int)$_REQUEST[$prefix.
'_num_weeks']) > 0)) {
293 $frequency =
'WEW'.$interval;
295 trigger_localised_error(
'CAL0043', E_USER_WARNING);
301 if (isset($_REQUEST[$prefix.
'_monthly_type']) && in_array($_REQUEST[$prefix.
'_monthly_type'], Array(
'MFN',
'MFW',
'MRN',
'MRW'))) {
302 $frequency = $_REQUEST[$prefix.
'_monthly_type'];
304 trigger_localised_error(
'CAL0044', E_USER_WARNING);
310 if (in_array($_REQUEST[$prefix.
'_monthly_type'], Array(
'MFN',
'MFW',
'MRN',
'MRW'))) {
311 if ((($interval = (
int)$_REQUEST[$prefix.
'_num_months']) > 0)) {
312 $frequency = $_REQUEST[$prefix.
'_monthly_type'].$interval;
314 trigger_localised_error(
'CAL0045', E_USER_WARNING);
318 trigger_localised_error(
'CAL0046', E_USER_WARNING);
327 $res &= $asset->setAttrValue(
'frequency', $frequency);
345 if ($asset->writeAccess(
'attributes')) {
346 $this->
paintStartEndChooser($asset, $prefix, Array(
'onchange'=>
'updateValues(\''.$prefix.
'\');
', 'onkeyup
'=>'updateValues(\
''.$prefix.
'\');
'));
348 echo $asset->getFriendlyDatesAndTimes();
352 }//end paintRecurringStartEndChooser()
365 function processRecurringStartEndChooser(&$asset, &$o, $prefix)
367 $this->processStartEndChooser($asset, $o, $prefix);
369 }//end processRecurringStartEndChooser()