| 3 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
* Smarty plugin
|
|
|
5 |
* -------------------------------------------------------------
|
|
|
6 |
* Type: function
|
|
|
7 |
* Name: datepick
|
|
|
8 |
* Purpose: for use with datepick miniapp.
|
|
|
9 |
* pick dates from calendar and populate forms.
|
|
|
10 |
* Input: form: the name of the form (required)
|
|
|
11 |
* field: the name of the form field(s) to populate.
|
|
|
12 |
* This can be one of two formats: a single text field,
|
|
|
13 |
* or a triple year/month/day dropdown created by
|
|
|
14 |
* {html_select_date}. If left blank, it is assumed that
|
|
|
15 |
* that it will use the default format of {html_select_date}
|
|
|
16 |
* Examples:
|
|
|
17 |
* <form name="myForm">
|
|
|
18 |
*
|
|
|
19 |
* {html_select_date}
|
|
|
20 |
* {datepick form="myForm"}
|
|
|
21 |
*
|
|
|
22 |
* {html_select_date prefix="myDate"}
|
|
|
23 |
* {datepick form="myForm" field="myDate_Year,myDate_Month,myDate_Day"}
|
|
|
24 |
*
|
|
|
25 |
* <input type=text name="curr_date" size=10>
|
|
|
26 |
* {datepick form="myForm" field="curr_date"} {* single text field *}
|
|
|
27 |
*
|
|
|
28 |
* </form>
|
|
|
29 |
* -------------------------------------------------------------
|
|
|
30 |
*/
|
|
|
31 |
function smarty_function_datepick( $params, &$smarty )
|
|
|
32 |
{
|
|
|
33 |
setlocale(LC_TIME,"de_DE");
|
|
|
34 |
// be sure equation parameter is present
|
|
|
35 |
if ( empty($params["form"]) )
|
|
|
36 |
{
|
|
|
37 |
$smarty->trigger_error( "datepick: missing form parameter" );
|
|
|
38 |
return;
|
|
|
39 |
}
|
|
|
40 |
extract( $params );
|
|
|
41 |
|
|
|
42 |
if ( empty($theme) )
|
|
|
43 |
{
|
|
|
44 |
$theme = 'default';
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
if ( strstr($field, ',') )
|
|
|
48 |
{
|
|
|
49 |
// dropdown fields
|
|
|
50 |
$date_fields = explode( ',', $field );
|
|
|
51 |
echo
|
|
|
52 |
'<a href="javascript:void(0)" onclick="javascript:datepick3(\'' .
|
|
|
53 |
$theme . '\',document.' . $form . '.' . $date_fields[0] .
|
|
|
54 |
',document.' . $form . '.' . $date_fields[1] .
|
|
|
55 |
',document.' . $form . '.' . $date_fields[2] .
|
|
|
56 |
')"><img src="/smarty_datepick/images/' . $theme .
|
|
|
57 |
'/cal_icon.gif" width="21" height="22" border="0"></a>';
|
|
|
58 |
} elseif ( empty($field) )
|
|
|
59 |
{
|
|
|
60 |
if(!empty($field_id))
|
|
|
61 |
{
|
|
|
62 |
// text field
|
|
|
63 |
echo
|
|
|
64 |
'<a href="javascript:void(0)" onclick="javascript:datepick(\'' .
|
|
|
65 |
$theme . '\',\''.$field_id.
|
|
|
66 |
'\')"><img src="/smarty_datepick/images/' . $theme .
|
|
|
67 |
'/cal_icon.gif" border=0></a>';
|
|
|
68 |
}
|
|
|
69 |
else
|
|
|
70 |
{
|
|
|
71 |
// dropdown default
|
|
|
72 |
echo
|
|
|
73 |
'<a href="javascript:void(0)" onclick="javascript:datepick3(\'' .
|
|
|
74 |
$theme . '\',document.' . $form .
|
|
|
75 |
'.Date_Year,document.' . $form .
|
|
|
76 |
'.Date_Month,document.' . $form .
|
|
|
77 |
'.Date_Day)"><img src="/smarty_datepick/images/' . $theme .
|
|
|
78 |
'/cal_icon.gif" width="21" height="22" border="0"></a>';
|
|
|
79 |
}
|
|
|
80 |
}
|
|
|
81 |
else
|
|
|
82 |
{
|
|
|
83 |
// text field
|
|
|
84 |
echo
|
|
|
85 |
'<a href="javascript:void(0)" onclick="javascript:datepick(\'' .
|
|
|
86 |
$theme . '\',document.' . $form . '.' . $field .
|
|
|
87 |
')"><img src="/smarty_datepick/images/' . $theme .
|
|
|
88 |
'/cal_icon.gif" border=0></a>';
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
/* vim: set expandtab: */
|
|
|
93 |
|
|
|
94 |
?>
|