This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/modules/core/list_calendar.inc.php
2011-05-03 09:49:01 +10:00

78 lines
2.4 KiB
PHP

<?php
/**
* AgileBill - Open Billing Software
*
* This body of work is free software; you can redistribute it and/or
* modify it under the terms of the Open AgileBill License
* License as published at http://www.agileco.com/agilebill/license1-4.txt
*
* Originally authored by Tony Landis, AgileBill LLC
*
* Recent modifications by Deon George
*
* @author Deon George <deonATleenooksDOTnet>
* @copyright 2009 Deon George
* @link http://osb.leenooks.net
*
* @link http://www.agileco.com/
* @copyright 2004-2008 Agileco, LLC.
* @license http://www.agileco.com/agilebill/license1-4.txt
* @author Tony Landis <tony@agileco.com>
* @package AgileBill
* @subpackage Template:Calendar
*/
/**
* The main AgileBill Template Calendar Method
*
* @package AgileBill
* @subpackage Template:Calendar
*/
function list_calender_add($field,$default,$css,$fid) {
# Set the date to current date if 'now' is set as $default
if ($default == 'now')
$default = date(UNIX_DATE_FORMAT,time());
$id = rand(9,999);
$ret = '';
if ($fid)
$ret .= sprintf('<input type="text" id="data_%s_%s_%s" name="%s[%s]" class="%s" size="10" value="%s"/>&nbsp;',$field,$fid,$id,$field,$fid,$css,$default);
else
$ret .= sprintf('<input type="text" id="data_%s_%s_%s" name="%s" class="%s" size="10" value="%s"/>&nbsp;',$field,$fid,$id,$field,$css,$default);
$ret .= sprintf('<input type="button" id="trigger_%s_%s_%s" value="+"/>',$field,$fid,$id);
$ret .= '<script type="text/javascript">Calendar.setup({';
$ret .= sprintf('inputField : "data_%s_%s_%s",',$field,$fid,$id);
$ret .= sprintf('ifFormat : "%s",',DEFAULT_DATE_FORMAT);
$ret .= sprintf('button : "trigger_%s_%s_%s"',$field,$fid,$id);
$ret .= '});</script>';
return $ret;
}
# @todo Remove?
function list_calender_add_static($field,$default,$css) {
return list_calender_add($field,$default,$css,'');
# Set the date to current date if 'now' is set as $default
if ($default == 'now')
$default = date(UNIX_DATE_FORMAT);
$id = rand(9,999);
$ret = '
<input type="text" id="data_'.$field.'_'.$id.'" name="'.$field.'" class="'.$css.'" size="10" value="'.$default.'" />&nbsp;
<input type="button" id="trigger_'.$field.'_'.$id.'" value="+">
<script type="text/javascript">
Calendar.setup(
{
inputField : "data_'.$field.'_'.$id.'",
ifFormat : "'.DEFAULT_DATE_FORMAT.'",
button : "trigger_'.$field.'_'.$id.'"
}
);
</script>
';
return $ret;
}
?>