This commit is contained in:
bettina 2001-07-20 04:39:50 +00:00
parent a1f975abe2
commit 24f16fc191

View File

@ -26,15 +26,13 @@
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/
/* $Id$ */
class matrixview {
class matrixview
{
var $sumdays = 0;
var $month = 0;
var $monthname = "";
var $monthname = '';
var $year = 0;
var $day = 0;
@ -42,10 +40,10 @@ class matrixview {
var $items_count = 0;
var $arr_second_dim = 0;
var $image1pix = "images/pix.gif";
var $image1pix = 'images/pix.gif';
var $color_headerfield = "#FFFF33";
var $color_emptyfield = "#CCCCCC";
var $color_headerfield = '#FFFF33';
var $color_emptyfield = '#CCCCCC';
var $selection = 1;
@ -61,6 +59,7 @@ class matrixview {
* @param int year (for example: 2001)
*
*/
function matrixview ($month_int = 0, $year_int = 0)
{
global $phpgw;
@ -92,7 +91,7 @@ class matrixview {
* otherwise true
*/
function setPeriod ($item, $fromdate, $todate, $color="#990033")
function setPeriod ($item, $fromdate, $todate, $color='#990033')
{
$fyear = substr($fromdate,0,4);
$fmonth = substr($fromdate,4,2);
@ -103,7 +102,9 @@ class matrixview {
$tday = substr($todate,6,2);
if(mktime(0,0,0, $tmonth, $tday, $tyear) < mktime(0,0,0, $this->month+1,0,$this->year))
{
$this->day = $tday;
}
else
{
$dinfo = getdate(mktime(0,0,0, $this->month+1,0,$this->year));
@ -116,16 +117,18 @@ class matrixview {
while($go == 1)
{
// calculates fromdate
// echo date("d/m/Y", mktime(0,0,0, $fmonth, $fday+$i, $fyear)); echo "<br>";
$datinfo = getdate(mktime(0,0,0, $fmonth, $fday+$i, $fyear));
if($datinfo["mon"]==$this->month
&& $datinfo["year"]==$this->year
&& $datinfo["mday"]<=$this->day)
if($datinfo['mon'] == $this->month
&& $datinfo['year'] == $this->year
&& $datinfo['mday'] <= $this->day)
{
$t = $datinfo["mday"];
$this->items_content[$this->items_count][$t] = "x";
$t = $datinfo['mday'];
$this->items_content[$this->items_count][$t] = 'x';
}
if (mktime(0,0,0, $fmonth, $fday+$i, $fyear) >=
@ -139,7 +142,9 @@ class matrixview {
$this->items_content[$this->items_count][0] = $item;
$this->items_color[$this->items_count] = $color;
// increase number of items in two-dimensional array
$this->items_count++;
}
@ -204,37 +209,47 @@ function diableSelection ()
function out($form_link)
{
// get days of desired month (month submitted in constructor)
$in = getdate(mktime(0,0,0, $this->month+1,0,$this->year));
$this->sumdays = $in[mday];
$this->monthname = $in[month];
$this->out_monthyear($form_link);
echo "<div align=\"center\">\n";
echo "<table border=0>\n";
echo '<div align="center">' . "\n";
echo '<table border="0">' . "\n";
$this->out_header();
// loop through number of items
for($z=0;$z<$this->items_count;$z++)
{
// seperate color and name from first array element
$itemname = $this->items_content[$z][0];
$itemcolor = $this->items_color[$z];
echo "<tr>\n";
echo "<td>" . $itemname . "</td>\n";
echo '<tr>' . "\n";
echo '<td>' . $itemname . '</td>' . "\n";
// loop through days of desired month
for($r=1;$r<$this->sumdays+1;$r++)
{
if($this->items_content[$z][$r]=="x") $color = $itemcolor; else $color = $this->color_emptyfield;
echo "<td bgcolor=\"$color\">&nbsp;</td>\n";
if($this->items_content[$z][$r] == 'x') $color = $itemcolor; else $color = $this->color_emptyfield;
echo '<td bgcolor="' . $color . '">&nbsp;</td>' . "\n";
}
echo "</tr>\n";
echo '</tr>' . "\n";
$this->out_ruler();
}
echo "</table>";
echo "</div>\n";
echo '</table>';
echo '</div>' . "\n";
}
/**
@ -247,20 +262,21 @@ function out($form_link)
function out_header ()
{
echo "<tr>\n";
echo "<td height=\"1\" colspan=\""; echo $this->sumdays+1; echo "\" bgcolor=black><img src=\"" . $this->image1pix . "\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . lang("Projectname") . "</td>\n";
echo '<tr>' . "\n";
echo '<td height="1" colspan="'; echo $this->sumdays+1; echo '" bgcolor="black"><img src="' . $this->image1pix . '"></td>' . "\n";
echo '</tr>' . "\n";
echo '<tr>' . "\n";
echo '<td>' . lang('Title') . '</td>' . "\n";
for($i=1;$i<$this->sumdays+1;$i++)
{
echo "<td bgcolor=\""; echo $this->color_headerfield; echo "\">" . sprintf("%02d",$i) . "</td>\n";
echo '<td bgcolor="'; echo $this->color_headerfield; echo '">' . sprintf("%02d",$i) . '</td>' . "\n";
}
echo "</tr>\n";
echo "<tr>\n";
echo "<td height=\"1\" colspan=\""; echo $this->sumdays+1; echo "\" bgcolor=black><img src=\"" . $this->image1pix ."\"></td>\n";
echo "</tr>\n";
echo '</tr>' . "\n";
echo '<tr>' . "\n";
echo '<td height="1" colspan="'; echo $this->sumdays+1; echo '" bgcolor="black"><img src="' . $this->image1pix . '"></td>' . "\n";
echo '</tr>' . "\n";
}
/**
@ -273,9 +289,9 @@ function out_header ()
function out_ruler ()
{
echo "<tr>\n";
echo "<td colspan=\""; echo $this->sumdays+1; echo "\" bgcolor=\"#999999\"><img src=\"" . $this->image1pix ."\"></td>\n";
echo "</tr>\n";
echo '<tr>' . "\n";
echo '<td colspan="'; echo $this->sumdays+1; echo '" bgcolor="#999999"><img src="' . $this->image1pix .'"></td>' . "\n";
echo '</tr>' . "\n";
}
/**
@ -290,34 +306,53 @@ function out_monthyear($form_link)
{
global $phpgw;
echo "<form action=\"" . $form_link . "\" method=\"post\">\n";
echo "<table border=0 width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr>\n";
echo "<td align=\"center\"><h2>"; echo lang($this->monthname); echo " "; echo $this->year; echo "</h2></td>\n";
echo '<form action="' . $form_link . '" method="post">' . "\n";
echo '<table border="0" width="100%" cellpadding="0" cellspacing="0">' . "\n";
echo '<tr>' . "\n";
echo '<td align="center"><h2>'; echo lang($this->monthname); echo ' '; echo $this->year; echo '</h2></td>' . "\n";
if($this->selection == 1)
{
echo "<td align=\"right\">" . lang("Month") . ": <select name=\"month\"";
echo '<td align="right">' . "\n";
echo '<select name="month"';
for($i=0;$i<13;$i++)
{
if($this->month==$i) $sel = " selected"; else unset($sel);
echo "<option value=\"$i\"$sel>$i</option>"; }
echo "</select>";
echo lang("Year") . ": <select name=\"year\"";
for($i = date("Y") -2;$i<date("Y")+5;$i++)
if ($this->month == $i)
{
if($this->year==$i) $sel = " selected"; else unset($sel);
echo "<option value=\"$i\"$sel>$i</option>";
$sel = ' selected';
}
echo "</select>";
echo "&nbsp;<input type=\"submit\" name=\"selection\" value=\"" . lang("Select") . "\">&nbsp;";
echo "</td>\n";
else
{
unset($sel);
}
echo '<option value="' . $i . '"' . $sel . '>' . $i . '</option>';
}
echo "</tr>\n";
echo "</table>\n";
echo "</form>\n";
echo '</select>' . "\n";
echo '<select name="year"';
for($i = date('Y') -2;$i<date('Y')+5;$i++)
{
if($this->year == $i)
{
$sel = ' selected';
}
else
{
unset($sel);
}
echo '<option value="' . $i . '"' . $sel . '>' . $i .'</option>';
}
echo '</select>' . "\n";
echo '&nbsp;&nbsp;<input type="submit" name="selection" value="' . lang('Filter') . '">&nbsp;&nbsp;';
echo '</td>' . "\n";
}
echo '</tr>' . "\n";
echo '</table>' . "\n";
echo '</form>' . "\n";
}
}
?>