<?php
global $user;
$dbhost=
$dbuser=
$dbpassword=
$dbname=drupal
$link=mysql_connect($dbhost,$dbuser,$dbpassword)or die ('Error connecting to mysql');
mysql_select_db($dbname, $link);
$query = "select value from profile_values where uid='" . $user->uid . "' and fid='2'";
$result = mysql_query($query);
$array = mysql_fetch_array($result);
$dir = 'paystubs/'.$array['value'];
mysql_close($link);
?>
<h2>Month</h2>
<ul>
<?php
monthlist($_GET['mon'],$dir);
?>
</ul>
<h2><?php month($_GET['mon']);?> Pay Stubs</h2>
<?php
if (file_exists($dir))
{
if ($dir_list = opendir($dir))
{
while(($filename = readdir($dir_list)) !== false)
{
if($filename !=".." && $filename !="." && (substr($filename,0,2) == $_GET['mon'] || substr($filename,1,2) == $_GET['mon']))
{
$cleanfilename = substr($filename, 0, strrpos($filename, '.'));
$dir_array[]=$cleanfilename;
}
}
if(isset($dir_array))
{
sort($dir_array);
foreach($dir_array as $value)
{
?>
<p><a target ="_blank" href="<?php echo $dir . "/" . $value; ?>"><?php echo $value;?></a></p>
<?php
}
closedir($dir_list);
}
}
}
else
{
echo "Error finding file list";
}
?>
<?php
function monthlist($mon,$dir)
{
$avail;
if(file_exists($dir))
{
if($new_list = opendir($dir))
{
while(($filename = readdir($new_list)) !== false)
{
if($filename !=".." && $filename !=".")
{
$month[] = substr($filename,0,2);
}
}
if(isset($month))
{
foreach($month as $value)
{
$avail[$value] = true;
}
}
closedir($new_list);
}
}
?>
<?php if($avail['01']) { ?>
<li><a href="?mon=01">January</a></li>
<?php } if($avail['02']) { ?>
<li><a href="?mon=02">February</a></li>
<?php } if($avail['03']) { ?>
<li><a href="?mon=03">March</a></li>
<?php } if($avail['04']) { ?>
<li><a href="?mon=04">April</a></li>
<?php } if($avail['05']) { ?>
<li><a href="?mon=05">May</a></li>
<?php } if($avail['06']) { ?>
<li><a href="?mon=06">June</a></li>
<?php } if($avail['07']) { ?>
<li><a href="?mon=07">July</a></li>
<?php } if($avail['08']) { ?>
<li><a href="?mon=08">August</a></li>
<?php } if($avail['09']) { ?>
<li><a href="?mon=09">September</a></li>
<?php } if($avail['10']) { ?>
<li><a href="?mon=10">October</a></li>
<?php } if($avail['11']) { ?>
<li><a href="?mon=11">November</a></li>
<?php } if($avail['12']) { ?>
<li><a href="?mon=12">December</a></li>
<?php } return;
}
function month($mon)
{
switch ($mon)
{
case "01":
{
echo "January";
break;
}
case "02":
{
echo "February";
break;
}
case "03":
{
echo "March";
break;
}
case "04":
{
echo "April";
break;
}
case "05":
{
echo "May";
break;
}
case "06":
{
echo "June";
break;
}
case "07":
{
echo "July";
break;
}
case "08":
{
echo "August";
break;
}
case "09":
{
echo "September";
break;
}
case "10":
{
echo "October";
break;
}
case "11":
{
echo "November";
break;
}
case "12":
{
echo "December";
break;
}
}
}
?>
Its ugly and ideally I would like to see a calendar where the user can select the month and year, the calendar loads the paystub information and creates links within the dates that there are paystubs for. Im not super proficient in php so im not really sure where to start, I found a calendar written in php here
I don't want anyone to do this for me but i could really use some direction here.
Thanks!,
Jordan

New Topic/Question
Reply




MultiQuote







|