Implement jquery datepicker! woohoo

This commit is contained in:
james 2009-09-10 04:24:47 +00:00
parent 80c743eb1a
commit a2018771e7

View File

@ -31,22 +31,30 @@
,"important_dates"
);
?>
<script type="text/javascript">
$(document).ready(function() {
$(".date").datepicker({ dateFormat: 'yy-mm-dd', showOn: 'button', buttonText: "<?=i18n("calendar")?>" });
});
</script>
<?
$error_ids = array();
if($_POST['action']=="save")
{
if($_POST['savedates'])
{
foreach($_POST['savedates'] as $key=>$val)
{
$v = mysql_escape_string(stripslashes($val));
if($_POST['action']=="save") {
if($_POST['savedates']) {
foreach($_POST['savedates'] as $key=>$val) {
//put the date and time back together
$d = mysql_escape_string(stripslashes($val));
$t =mysql_escape_string(stripslashes($_POST['savetimes'][$key]));
$v="$d $t";
mysql_query("UPDATE dates SET date='$v' WHERE year='".$config['FAIRYEAR']."' AND id='$key'");
}
}
echo happy(i18n("Dates successfully saved"));
}
echo "<form method=\"post\" action=\"dates.php\">";
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
echo "<table>";
@ -65,8 +73,7 @@ $dates = array('fairdate' => array() ,
/* Now copy the SQL data into the above array */
$q=mysql_query("SELECT * FROM dates WHERE year='".$config['FAIRYEAR']."' ORDER BY date");
while($r=mysql_fetch_object($q))
{
while($r=mysql_fetch_object($q)) {
$dates[$r->name]['description'] = $r->description;
$dates[$r->name]['id'] = $r->id;
$dates[$r->name]['date'] = $r->date;
@ -111,11 +118,15 @@ chkafter('fairdate','postwinners');
foreach($dates as $d) {
$e = '';
if($error_ids[$d['id']]) {
$e = "<font color=red size=-1>* ".$error_ids[$d['id']]."</font>";
$e = "<span style=\"color: red;\">*</span> ".$error_ids[$d['id']]."</font>";
}
echo "<tr><td>".i18n($d['description'])."</td><td><input type=\"text\" name=\"savedates[{$d['id']}]\" value=\"{$d['date']}\" />{$e}</td></tr>";
list($_d,$_t)=split(" ",$d['date']);
echo "<tr><td>".i18n($d['description'])."</td>";
echo "<td><input size=\"10\" class=\"date\" type=\"text\" name=\"savedates[{$d['id']}]\" value=\"{$_d}\" />";
echo "<input size=\"10\" type=\"text\" name=\"savetimes[{$d['id']}]\" value=\"{$_t}\" />";
echo "{$e}</td></tr>";
}
echo "</table>";
echo "<input type=\"submit\" value=\"".i18n("Save Dates")."\" />\n";
echo "</form>";