Weekkalender
Auteur: vinTage - 01 januari 2012 - 21:39 - Gekeurd door: Stijn - Hits: 6113 - Aantal punten: 5.00 (1 stem)
Een 'makkelijke' weekkalender.
De database:
CREATE TABLE `planning` (
`datum` varchar(10) NOT NULL,
`adres` varchar(250) NOT NULL,
`msg` varchar(750) NOT NULL
)
CREATE TABLE `planning` ( `datum` VARCHAR(10) NOT NULL, `adres` VARCHAR(250) NOT NULL, `msg` VARCHAR(750) NOT NULL )
Het script is gewoon copy/pasten en de database gegevenns aanpassen en gaan met die banaan kalender
|
Code: |
<?php
//onderstaande 2 regels aanpassen
mysql_connect('host', 'usernaam', 'password');
mysql_select_db('database');
//af! :P
$jaar = isset($_GET['jaar']) ? $_GET['jaar'] : date('Y');
$week = isset($_GET['week']) ? $_GET['week'] : date('W');
if ($week < 1)
{
$jaar -= 1;
$week = date("W", mktime(0, 0, 0, 12, 28, $jaar));
}
elseif ($week > date("W", mktime(0, 0, 0, 12, 28, $jaar)))
{
$week = 1;
$jaar += 1;
}
if (isset($_POST['opslaan']))
{
$qry = mysql_query("select datum from planning where datum = '" . mysql_real_escape_string($_GET['edit']) . "'") or die(mysql_error());
if (mysql_num_rows($qry) > 0)
{
mysql_query("update planning set adres = '" . mysql_real_escape_string($_POST['adres']) . "',
msg = '" . mysql_real_escape_string($_POST['msg']) . "' where datum ='" . mysql_real_escape_string($_POST['datum']) . "'") or die(mysql_error());
header("location: ?jaar=" . $jaar . "&week=" . $week);
exit;
}
else
{
mysql_query("insert into planning (datum, adres, msg)
values('" . mysql_real_escape_string($_GET['edit']) . "',
'" . mysql_real_escape_string($_POST['adres']) . "',
'" . mysql_real_escape_string($_POST['msg']) . "')") or die(mysql_error());
header("location: ?jaar=" . $jaar . "&week=" . $week);
exit;
}
}
//de html en css hieronder mag je editen, van de php afblijven als je niet weet waar het over gaat :p
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>planning</title>
<style type="text/css">
*{ margin:0; padding:0;}
body{font-family:Verdana, Geneva, sans-serif; font-size:small;}
.border{border:solid 2px #000;}
.br{border-right:solid 1px #000;}
.bl{border-left:solid 1px #000;}
.bb{border-bottom:solid 1px #000;}
.bbd{border-bottom:solid 2px #000;}
td{padding-left:2px; padding-right:2px;}
.active{background-color:#f5f5f5;}
#wrap{
width:1004px;
margin:0 auto;
margin-top: 10px;
}
a:link {
color: #EA960B;;
text-decoration: none;
}
a:visited {
color: #EA960B;;
text-decoration: none;
}
a:hover {
text-decoration: underline;
color: #EA960B;
}
a:active {
text-decoration: underline;
color: #EA960B;
}
b{color: #39f;}
</style>
<style type="text/css" media="print">
.noprint{display:none;}
input[type=text]{display:none}
b{color:#000}
</style>
</head>
<body>
<div id="wrap">
<div class="noprint">
Week nr: <a href="?jaar=<?php echo $jaar?>&week=<?php echo $week-1?>">« </a><?php echo $week?><a href="?jaar=<?php echo $jaar?>&week=<?php echo $week+1?>"> »</a>
<br />
Jaar: <a href="?jaar=<?php echo $jaar-1?>&week=<?php echo $week?>">« </a><?php echo $jaar?><a href="?jaar=<?php echo $jaar+1?>&week=<?php echo $week?>"> »</a>
<?php
if($jaar != date("Y") || $week != date("W"))
{
?>
<br />
<a href="<?php echo $_SERVER['SCRIPT_NAME']?>">Terug naar huidige week</a>
<?php
}
?>
<br />
<br />
</div>
<?php
function maak_datums($year, $weeknr, $dag, $dagnaam = false)
{
$dagen = array("maandag", "dinsdag", "woensdag", "donderdag", "vrijdag");
$w = $weeknr - 1;
return $dagnaam != false ? $dagen[$dag] . '<br />' . date("d-m-Y", strtotime("first monday January $year + $w weeks + $dag days")) : date("d-m-Y", strtotime("first monday January $year + $w weeks + $dag days"));
}
if (isset($_GET['edit']))
{
?>
<form method="post" action="<?php echo htmlentities($_SERVER['REQUEST_URI'])?>">
<?php
}
?>
<table width="1000" border="0" cellspacing="0" cellpadding="0" class="border">
<tr>
<td class="br bbd" width="80" valign="top"><b>Datum</b></td>
<td class="br bbd" width="300"><b>Wie & waar</b></td>
<td class="bbd"><b>Werkzaamheden</b></td>
</tr>
<?php
for ($i = 0; $i < 5; $i++)
{
$adres = '';
$msg = '';
$link_datum = maak_datums($jaar, $week, $i);
$q = mysql_query("select * from planning where datum = '" . $link_datum . "'") or die(mysql_error());
while ($row = mysql_fetch_array($q))
{
$adres = isset($_GET['edit']) ? $row['adres'] : nl2br(htmlentities($row['adres']));
$msg = isset($_GET['edit']) ? $row['msg'] : nl2br(htmlentities($row['msg']));
}
?>
<tr<?php if(isset($_GET['edit']) && $_GET['edit'] == $link_datum){?> class="active"<?php } ?> style="height:130px">
<td class="br <?php if($i <4){echo 'bbd';}?>" valign="top">
<?php echo maak_datums($jaar, $week, $i) == date("d-m-Y") ? "<b class='noprint'>vandaag<br /><br /></b>".maak_datums($jaar, $week, $i, true)."<br />" : maak_datums($jaar, $week, $i, true)."<br />";
if(isset($_GET['week']) && isset($_GET['jaar']))
{
?>
<a href="?jaar=<?php echo $_GET['jaar']?>&week=<?php echo $_GET['week']?>&edit=<?php echo $link_datum?>" class="noprint">edit</a>
<?php
}
else
{
?>
<a href="?edit=<?php echo $link_datum?>" class="noprint">edit</a>
<?php
}
if(isset($_GET['edit']) && $_GET['edit'] == $link_datum)
{
?>
<input name="opslaan" type="submit" value="bijwerken" /><input type="hidden" name="datum" value="<?php echo $link_datum?>" />
<?php
}
?>
</td>
<td class="br <?php if($i <4){echo 'bbd';}?>" valign="top"><?php if(isset($_GET['edit']) && $_GET['edit'] == $link_datum){?><textarea name="adres" rows="4" cols="25"><?php echo stripslashes($adres);?></textarea><?php } else { echo stripslashes($adres);}?></td>
<td class="<?php if($i <4){echo 'bbd';}?>" valign="top"><?php if(isset($_GET['edit']) && $_GET['edit'] == $link_datum){?><textarea name="msg" rows="4" cols="25"><?php echo stripslashes($msg);?></textarea><?php } else { echo stripslashes($msg);}?></td>
</tr>
<?php
}
?>
</table>
<?php
if(isset($_GET['edit']))
{
?>
</form>
<?php
}
?>
</div>
</body>
</html>
<?php //onderstaande 2 regels aanpassen //af! :P $jaar = isset($_GET['jaar']) ? $_GET['jaar'] : date('Y'); $week = isset($_GET['week']) ? $_GET['week'] : date('W'); if ($week < 1) { $jaar -= 1; $week = date("W", mktime(0, 0, 0, 12, 28, $jaar)); } elseif ($week > date("W", mktime(0, 0, 0, 12, 28, $jaar))) { $week = 1; $jaar += 1; } if (isset($_POST['opslaan'])) { { header("location: ?jaar=" . $jaar . "&week=" . $week); } else { header("location: ?jaar=" . $jaar . "&week=" . $week); } } //de html en css hieronder mag je editen, van de php afblijven als je niet weet waar het over gaat :p ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>planning</title> <style type="text/css"> *{ margin:0; padding:0;} body{font-family:Verdana, Geneva, sans-serif; font-size:small;} .border{border:solid 2px #000;} .br{border-right:solid 1px #000;} .bl{border-left:solid 1px #000;} .bb{border-bottom:solid 1px #000;} .bbd{border-bottom:solid 2px #000;} td{padding-left:2px; padding-right:2px;} .active{background-color:#f5f5f5;} #wrap{ width:1004px; margin:0 auto; margin-top: 10px; } a:link { color: #EA960B;; text-decoration: none; } a:visited { color: #EA960B;; text-decoration: none; } a:hover { text-decoration: underline; color: #EA960B; } a:active { text-decoration: underline; color: #EA960B; } b{color: #39f;} </style> <style type="text/css" media="print"> .noprint{display:none;} input[type=text]{display:none} b{color:#000} </style> </head> <body> <div id="wrap"> <div class="noprint"> Week nr: <a href="?jaar= <?php echo $jaar? >&week= <?php echo $week-1? >">« </a> <?php echo $week? ><a href="?jaar= <?php echo $jaar? >&week= <?php echo $week+1? >"> »</a> <br /> Jaar: <a href="?jaar= <?php echo $jaar-1? >&week= <?php echo $week? >">« </a> <?php echo $jaar? ><a href="?jaar= <?php echo $jaar+1? >&week= <?php echo $week? >"> »</a> <?php if($jaar != date("Y") || $week != date("W")) { ?> <br /> <a href=" <?php echo $_SERVER['SCRIPT_NAME']?>">Terug naar huidige week</a> <?php } ?> <br /> <br /> </div> <?php function maak_datums($year, $weeknr, $dag, $dagnaam = false) { $dagen = array("maandag", "dinsdag", "woensdag", "donderdag", "vrijdag"); $w = $weeknr - 1; return $dagnaam != false ? $dagen[$dag] . '<br />' . date("d-m-Y", strtotime("first monday January $year + $w weeks + $dag days")) : date("d-m-Y", strtotime("first monday January $year + $w weeks + $dag days")); } if (isset($_GET['edit'])) { ?> <form method="post" action=" <?php echo htmlentities($_SERVER['REQUEST_URI'])?>"> <?php } ?> <table width="1000" border="0" cellspacing="0" cellpadding="0" class="border"> <tr> <td class="br bbd" width="80" valign="top"><b>Datum</b></td> <td class="br bbd" width="300"><b>Wie & waar</b></td> <td class="bbd"><b>Werkzaamheden</b></td> </tr> <?php for ($i = 0; $i < 5; $i++) { $adres = ''; $msg = ''; $link_datum = maak_datums($jaar, $week, $i); { } ?> <tr <?php if(isset($_GET['edit']) && $_GET['edit'] == $link_datum){?> class="active" <?php } ?> style="height:130px"> <td class="br <?php if($i <4){echo 'bbd';}?>" valign="top"> <?php echo maak_datums ($jaar, $week, $i) == date("d-m-Y") ? "<b class='noprint'>vandaag<br /><br /></b>".maak_datums ($jaar, $week, $i, true)."<br />" : maak_datums ($jaar, $week, $i, true)."<br />"; { ?> <a href="?jaar= <?php echo $_GET['jaar']?>&week= <?php echo $_GET['week']?>&edit= <?php echo $link_datum? >" class="noprint">edit</a> <?php } else { ?> <a href="?edit= <?php echo $link_datum? >" class="noprint">edit</a> <?php } if(isset($_GET['edit']) && $_GET['edit'] == $link_datum) { ?> <input name="opslaan" type="submit" value="bijwerken" /><input type="hidden" name="datum" value=" <?php echo $link_datum? >" /> <?php } ?> </td> <td class="br <?php if($i <4){echo 'bbd';}?>" valign="top"> <?php if(isset($_GET['edit']) && $_GET['edit'] == $link_datum){?><textarea name="adres" rows="4" cols="25"> <?php echo stripslashes($adres);? ></textarea> <?php } else { echo stripslashes($adres);}?></td> <td class=" <?php if($i <4){echo 'bbd';}?>" valign="top"> <?php if(isset($_GET['edit']) && $_GET['edit'] == $link_datum){?><textarea name="msg" rows="4" cols="25"> <?php echo stripslashes($msg);? ></textarea> <?php } else { echo stripslashes($msg);}?></td> </tr> <?php } ?> </table> <?php { ?> </form> <?php } ?> </div> </body> </html>
Download code (.txt)
|
|
|
Stemmen |
Niet ingelogd. |
|