From 24f16fc191dbe87ceea4fc1492f0ff0c45a2d657 Mon Sep 17 00:00:00 2001 From: bettina Date: Fri, 20 Jul 2001 04:39:50 +0000 Subject: [PATCH] update --- phpgwapi/inc/class.matrixview.inc.php | 591 ++++++++++++++------------ 1 file changed, 313 insertions(+), 278 deletions(-) diff --git a/phpgwapi/inc/class.matrixview.inc.php b/phpgwapi/inc/class.matrixview.inc.php index bb1cf73826..bae6177032 100644 --- a/phpgwapi/inc/class.matrixview.inc.php +++ b/phpgwapi/inc/class.matrixview.inc.php @@ -1,54 +1,52 @@ * - * class for creating matrix like timeframes for items * - * * - * this matrix is having the days of actual month in the x-axis and the * - * items, which could be projects, in the y-axis. * - * You will see a top-down view of all items and their associated * - * timeframes. You probably saw this in projectmanagement apps * - * * - * Copyright (C) 2000, 2001 Marc Logemann * - * -------------------------------------------------------------------------* - * This library is part of the phpGroupWare API * - * http://www.phpgroupware.org/api * - * ------------------------------------------------------------------------ * - * This library is free software; you can redistribute it and/or modify it * - * under the terms of the GNU Lesser General Public License as published by * - * the Free Software Foundation; either version 2.1 of the License, * - * or any later version. * - * This library is distributed in the hope that it will be useful, but * - * WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License * - * along with this library; if not, write to the Free Software Foundation, * - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - \**************************************************************************/ + /**************************************************************************\ + * phpGroupWare API - Matrix View Generator * + * This file written by Marc Logemann * + * class for creating matrix like timeframes for items * + * * + * this matrix is having the days of actual month in the x-axis and the * + * items, which could be projects, in the y-axis. * + * You will see a top-down view of all items and their associated * + * timeframes. You probably saw this in projectmanagement apps * + * * + * Copyright (C) 2000, 2001 Marc Logemann * + * -------------------------------------------------------------------------* + * This library is part of the phpGroupWare API * + * http://www.phpgroupware.org/api * + * ------------------------------------------------------------------------ * + * This library is free software; you can redistribute it and/or modify it * + * under the terms of the GNU Lesser General Public License as published by * + * the Free Software Foundation; either version 2.1 of the License, * + * or any later version. * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public License * + * along with this library; if not, write to the Free Software Foundation, * + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + \**************************************************************************/ + /* $Id$ */ - /* $Id$ */ + class matrixview + { + var $sumdays = 0; + var $month = 0; + var $monthname = ''; + var $year = 0; + var $day = 0; -class matrixview { + var $items_content = array(); + var $items_count = 0; + + var $arr_second_dim = 0; + var $image1pix = 'images/pix.gif'; + + var $color_headerfield = '#FFFF33'; + var $color_emptyfield = '#CCCCCC'; - var $sumdays = 0; - - var $month = 0; - var $monthname = ""; - var $year = 0; - var $day = 0; + var $selection = 1; - var $items_content = array(); - var $items_count = 0; - - var $arr_second_dim = 0; - var $image1pix = "images/pix.gif"; - - var $color_headerfield = "#FFFF33"; - var $color_emptyfield = "#CCCCCC"; - - var $selection = 1; - /** * * construtor: graphview class @@ -61,20 +59,21 @@ class matrixview { * @param int year (for example: 2001) * */ - function matrixview ($month_int = 0, $year_int = 0) - { - global $phpgw; - for($i;$i<32;$i++) + function matrixview ($month_int = 0, $year_int = 0) { - if(checkdate($month_int,$i,$year_int)) $days++; + global $phpgw; + + for($i;$i<32;$i++) + { + if(checkdate($month_int,$i,$year_int)) $days++; + } + + $this->month = $month_int; + $this->year = $year_int; + $this->set1PixelGif($phpgw->common->get_image_path('todo').'/pix.gif'); } - - $this->month = $month_int; - $this->year = $year_int; - $this->set1PixelGif($phpgw->common->get_image_path('todo').'/pix.gif'); - } - + /** * * set a Period for a specified item @@ -92,232 +91,268 @@ class matrixview { * otherwise true */ - function setPeriod ($item, $fromdate, $todate, $color="#990033") - { - $fyear = substr($fromdate,0,4); - $fmonth = substr($fromdate,4,2); - $fday = substr($fromdate,6,2); - - $tyear = substr($todate,0,4); - $tmonth = substr($todate,4,2); - $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)); - $this->day = $dinfo[mday]; - } - - $go = 1; - $i = 0; - $z = 0; - - while($go==1) + function setPeriod ($item, $fromdate, $todate, $color='#990033') { + $fyear = substr($fromdate,0,4); + $fmonth = substr($fromdate,4,2); + $fday = substr($fromdate,6,2); + + $tyear = substr($todate,0,4); + $tmonth = substr($todate,4,2); + $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)); + $this->day = $dinfo[mday]; + } + + $go = 1; + $i = 0; + $z = 0; + + while($go == 1) + { + // calculates fromdate // echo date("d/m/Y", mktime(0,0,0, $fmonth, $fday+$i, $fyear)); echo "
"; - $datinfo = getdate(mktime(0,0,0, $fmonth, $fday+$i, $fyear)); + + $datinfo = getdate(mktime(0,0,0, $fmonth, $fday+$i, $fyear)); - if($datinfo["mon"]==$this->month - && $datinfo["year"]==$this->year - && $datinfo["mday"]<=$this->day) - { - $t = $datinfo["mday"]; - $this->items_content[$this->items_count][$t] = "x"; - } + if($datinfo['mon'] == $this->month + && $datinfo['year'] == $this->year + && $datinfo['mday'] <= $this->day) + { + $t = $datinfo['mday']; + $this->items_content[$this->items_count][$t] = 'x'; + } - if (mktime(0,0,0, $fmonth, $fday+$i, $fyear) >= - mktime(0,0,0, $this->month+1, 0, $this->year) - || - mktime(0,0,0, $fmonth, $fday+$i, $fyear) >= - mktime(0,0,0, $tmonth, $tday, $tyear)) $go = 0 - ; - $i++; - } - - $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++; -} - -/** -* -* sets the color for empty dayfields -* -* @param string color in hexadecimal (ex. "#336699") -*/ - -function setEmptyFieldColor ($color) -{ - $this->color_emptyfield=$color; -} - -/** -* -* sets the color for calendar day fields -* -* @param string color in hexadecimal (ex. "#336699") -*/ - -function setHeaderFieldColor ($color) -{ - $this->color_headerfield=$color; -} - -/** -* -* sets a new path for 1pixel (pix.gif) gif needed for the table -* default is set actual script dir + /images -* -* @param string path and name to 1pixel gif -*/ - -function set1PixelGif ($filepath) -{ - $this->image1pix=$filepath; -} - -/** -* -* disable selection of new timeframe -* -*/ - -function diableSelection () -{ - $this->selection=0; -} - -/** -* -* return the html code for the matrix -* -* will return the complete html code for the matrix. -* In the calling program you can do some other -* operations on it, because it wont be echoed directly -* -* @return string html code for the matrix -*/ - -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 "
\n"; - echo "\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 "\n"; - echo "\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 "\n"; - } - echo "\n"; - $this->out_ruler(); - } - echo "
" . $itemname . " 
"; - echo "
\n"; -} - -/** -* -* private class for out method -* -* should not be used from external -* -*/ - -function out_header () -{ - echo "\n"; - echo "sumdays+1; echo "\" bgcolor=black>image1pix . "\">\n"; - echo "\n"; - echo "\n"; - echo "" . lang("Projectname") . "\n"; - for($i=1;$i<$this->sumdays+1;$i++) - { - echo "color_headerfield; echo "\">" . sprintf("%02d",$i) . "\n"; - } - echo "\n"; - - echo "\n"; - echo "sumdays+1; echo "\" bgcolor=black>image1pix ."\">\n"; - echo "\n"; -} - -/** -* -* private class for out method -* -* should not be used from external -* -*/ - -function out_ruler () -{ - echo "\n"; - echo "sumdays+1; echo "\" bgcolor=\"#999999\">image1pix ."\">\n"; - echo "\n"; -} - -/** -* -* private class for out method -* -* should not be used from external -* -*/ - -function out_monthyear($form_link) -{ - global $phpgw; - - echo "
\n"; - echo ""; - echo "\n"; - echo "\n"; - - if($this->selection==1) - { - echo "\n"; + + $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++; + } + + /** + * + * sets the color for empty dayfields + * + * @param string color in hexadecimal (ex. "#336699") + */ + + function setEmptyFieldColor ($color) + { + $this->color_emptyfield=$color; + } + + /** + * + * sets the color for calendar day fields + * + * @param string color in hexadecimal (ex. "#336699") + */ + + function setHeaderFieldColor ($color) + { + $this->color_headerfield=$color; + } + + /** + * + * sets a new path for 1pixel (pix.gif) gif needed for the table + * default is set actual script dir + /images + * + * @param string path and name to 1pixel gif + */ + + function set1PixelGif ($filepath) + { + $this->image1pix=$filepath; + } + + /** + * + * disable selection of new timeframe + * + */ + + function diableSelection () + { + $this->selection=0; + } + + /** + * + * return the html code for the matrix + * + * will return the complete html code for the matrix. + * In the calling program you can do some other + * operations on it, because it wont be echoed directly + * + * @return string html code for the matrix + */ + + 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 '
' . "\n"; + echo '

"; echo lang($this->monthname); echo " "; echo $this->year; echo "

" . lang("Month") . ": "; - echo lang("Year") . ": "; - echo "  "; - echo "
' . "\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 '' . "\n"; + echo '' . "\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 '' . "\n"; + } + + echo '' . "\n"; + $this->out_ruler(); + } + + echo '
' . $itemname . ' 
'; + echo '' . "\n"; + } + + /** + * + * private class for out method + * + * should not be used from external + * + */ + + function out_header () + { + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . lang('Title') . '' . "\n"; + + for($i=1;$i<$this->sumdays+1;$i++) + { + echo '' . sprintf("%02d",$i) . '' . "\n"; + } + + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + } + + /** + * + * private class for out method + * + * should not be used from external + * + */ + + function out_ruler () + { + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + } + + /** + * + * private class for out method + * + * should not be used from external + * + */ + + function out_monthyear($form_link) + { + global $phpgw; + + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + + if($this->selection == 1) + { + echo '' . "\n"; + } + + echo '' . "\n"; + echo '

'; echo lang($this->monthname); echo ' '; echo $this->year; echo '

' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '    '; + echo '
' . "\n"; + echo '
' . "\n"; + } } - - echo "\n"; - echo "\n"; - echo "\n"; -} - -} ?>