PDA

View Full Version : PopupCalendar patch


benles
20-03-05, 12:56 AM
Encapsulated for ease of use...


function PopupCalendar($fieldName, $date=null )
{
global $AppUI;

$id=uniqid('popcal');
$js = "
<script language=JavaScript>
function popCalendar_$id(){
idate =document.getElementById('".$fieldName."_idate').value;
window.open( 'index.php?m=public&a=calendar&dialog=1&callback=p opCalendar_callback_$id&date=' + idate + '&form=\"$formName\"', 'calwin', 'top=250,left=250,width=250, height=220, scollbars=false' );
}

function popCalendar_callback_$id(idate,fdate) {
document.getElementById('".$fieldName."_idate').value = idate;
document.getElementById('$fieldName').value = fdate;
}
</script>
";

$d = $date ? new CDate($date) : new CDate();
$d = $d ? $d->format( FMT_TIMESTAMP_DATE ) : "" ;

$html = "
<input type='hidden' name='".$fieldName."_idate' id='".$fieldName."_idate' value='$d' />
<input type='text' name='$fieldName' id='$fieldName' value='$date' class='text' disabled='disabled'/>
<a href='#' onClick='popCalendar_$id()'>
<img src='/images/calendar.gif' width='24' height='12' alt='" . $AppUI->_('Calendar') . "' border='0' />
</a>
";

return $js.$html;
}