• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

calendar/freetime.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                                                                                       |
00005         |       Dateplaner Modul - inbox                                                                                                  |                                                                                                     
00006         +-----------------------------------------------------------------------------+
00007         | Copyright (c) 2004 ILIAS open source & University of Applied Sciences Bremen|
00008         |                                                                             |
00009         | This program is free software; you can redistribute it and/or               |
00010         | modify it under the terms of the GNU General Public License                 |
00011         | as published by the Free Software Foundation; either version 2              |
00012         | of the License, or (at your option) any later version.                      |
00013         |                                                                             |
00014         | This program is distributed in the hope that it will be useful,             |
00015         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00016         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00017         | GNU General Public License for more details.                                |
00018         |                                                                             |
00019         | You should have received a copy of the GNU General Public License           |
00020         | along with this program; if not, write to the Free Software                 |
00021         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00022         +-----------------------------------------------------------------------------+
00023 */
00030 // include DP freetime functions
00031 include_once    ('.'.DATEPLANER_ROOT_DIR.'/includes/inc.freetime.php');
00032                 
00033 
00034 /* ------------------------------------  generate frames --------------------------- */
00035 // -----------------------------------------  fixed ---------------------------------//
00036 // the left frame is not used 
00037 $left   = '';
00038 
00039 // right frame is curently not used
00040 $right  = '';
00041 
00042 // the up frame is detect by the interface 
00043 
00044 // down frame is curently not used
00045 $downtext = '';
00046 // --------------------------------------  end fixed  -------------------------------//
00047 
00048 //get start- and end-time for the view-area
00049 $viewTsBegin = strtotime($_SESSION[DP_Starttime]);
00050 if ($DP_Endtime=="24:00:00"){
00051 $viewTsEnd = strtotime("23:59:59");
00052 }else{
00053 $viewTsEnd = strtotime($_SESSION[DP_Endtime]);
00054 }
00055 
00056 //convert the strings into timestamps 
00057 $beginsek=((intval(date(H,$viewTsBegin))*3600)+intval((date(i,$viewTsBegin))*60)+intval(date(s,$viewTsBegin)));
00058 $endsek=((intval(date(H,$viewTsEnd))*3600)+intval((date(i,$viewTsEnd))*60)+intval(date(s,$viewTsEnd)));
00059 
00060 //round the timestamps to 15min-chunks
00061 $startDisplayQuarters=floor($beginsek/900);
00062 $endDisplayQuarters=ceil($endsek/900);
00063 
00064 //tables for the results of database-query
00065 $dStartTime = array(array());
00066 $dEndTime = array(array());
00067 
00068 //table for view
00069 $dTargetTable = array(array());
00070 
00071 //boolean variable   
00072 $pError="";
00073 
00074 //detect a wrong entered date
00075 if (str2date($_POST[date2])<0){
00076 echo "Wrong date-format error<br>";
00077 $pError=true;
00078 }
00079 else{
00080 $pError=false;
00081 }
00082 
00083 //detect if a groups is selected
00084 if ($_POST[DateValuesGroup_id]==0){
00085 echo "Please select a group first<br>";
00086 $pError=true;
00087 }
00088 else{
00089 $pError=false;
00090 }
00091 
00092 //if an error occured, echo a 'back'-button otherwise continue
00093 if ($pError==true){
00094 echo '[<a href="javascript:history.back()"><b>back</b></a>]';
00095 }
00096 else{
00097 //every week begins @ monday (monday==0;... sunday==6);
00098 $weekTs= str2date($_POST[date2]);
00099 $weekTs= mktime(0,0,0,date("m",$weekTs),(date("d",$weekTs)-((date("w",$weekTs)+6))%7),date("Y",$weekTs)); 
00100 
00101 // set variables 4 table-header
00102 $S_Datum = setDateInTblHead($weekTs) ;
00103 
00104 //get DB-result 4 current week
00105 for ($j=0;$j<7;$j++){
00106         $begin= $weekTs+((24*60*60)*$j);        //start of day 
00107         $end= $begin+((24*60*60)-1); //end of day
00108         $groupIDs=$_POST[DateValuesGroup_id];           //groupIds
00109         $groupDates[$j]= getGroupDatesForDisplay($groupIDs, $begin, $end, $DB); //get dates
00110 }
00111 //clear display-data
00112 for ($j=0;$j<7;$j++){
00113         $dTargetTable[$j]=array_fill(0, 96, 0);
00114 }
00115 
00116 
00117 //get groupDates out of DB-result and round them to 15min chunks 
00118 for($j=0;$j<7;$j++)
00119 {
00120         for($i=0;$i<sizeof($groupDates[$j]);$i++){
00121                 if ($groupDates[$j]!=""){               
00122                         $tsBegin=$groupDates[$j][$i][1];
00123                         $tsEnd=$groupDates[$j][$i][2];
00124 
00125                         $beginsek=((intval(date(H,$tsBegin))*3600)+intval((date(i,$tsBegin))*60)+intval(date(s,$tsBegin)));
00126                         $endsek=((intval(date(H,$tsEnd))*3600)+intval((date(i,$tsEnd))*60)+intval(date(s,$tsEnd)));
00127 
00128                         $beginQuarter=floor($beginsek/900);
00129                         $endQuarter=ceil($endsek/900);
00130 
00131                         $dStartTime[$j][$i]=$beginQuarter;
00132                         $dEndTime[$j][$i]=$endQuarter;
00133                 }
00134         }
00135 }
00136 
00137 //prepare display-data 
00138 for($j=0;$j<7;$j++){
00139         for($i=0;$i<sizeof($dStartTime[$j]);++$i){
00140                 $start=$dStartTime[$j][$i];
00141                 $end=$dEndTime[$j][$i];
00142 
00143                 for($start;$start<=$end-1;++$start){
00144                         $dTargetTable[$j][$start]+=1;
00145                 }
00146         }
00147 }
00148                 
00149 //display calculated data
00150 for($i=$startDisplayQuarters; $i <=$endDisplayQuarters-1; $i++){
00151         $htmlBuffer=$htmlBuffer. "<TR class=\"small\">";
00152         // show time
00153         $min=$i*15;
00154     if($min%30==0) {$htmlBuffer=$htmlBuffer. "\n<TH class='tblheader' rowspan='2'>";
00155                 $hour = ($min-$min%60)/60 ;
00156                 $quarter= $min%60;
00157                 if ($quarter==0){$quarter="00";}
00158                 $htmlBuffer=$htmlBuffer. $hour.":".$quarter;
00159                 $htmlBuffer=$htmlBuffer. "</TH>\n";
00160         }
00161         // show occupied and free quarters      
00162         for($j=0;$j<7;$j++){
00163                 $actTS=$weekTs+($min*60)+($j*24*60*60); 
00164                 if ($dTargetTable[$j][$i]==0){
00165                         $htmlBuffer=$htmlBuffer. "<TD ".$DP_CSS[tblrow02]." align=\"top\"".'>';
00166                         $htmlBuffer=$htmlBuffer. '<a TITLE='.$DP_language[free]."&nbsp;".$hour.":".$quarter.' href="javascript:document.feedback.timestamp.value='.$actTS.';document.getElementsByName('."'feedback'".')[0].submit()'.'">';
00167                         $htmlBuffer=$htmlBuffer. '<img src=".'.DATEPLANER_ROOT_DIR.$templatefolder."/".$actualtemplate.'/images/filler.gif" width="60" height="10" border="0"></a>'."</TD>\n"; 
00168                 }
00169                 else{
00170 
00171                   $htmlBuffer=$htmlBuffer. "<TD ".$DP_CSS[tblrow03]." align=\"top\"".'>';
00172                   $htmlBuffer=$htmlBuffer. '<img src=".'.DATEPLANER_ROOT_DIR.$templatefolder."/".$actualtemplate.'/images/filler.gif" width="60" height="10" border="0" >'."</TD>\n";
00173                   
00174                 }
00175         }
00176         $htmlBuffer=$htmlBuffer."</TR>\n";
00177 }
00178 }
00179 eval ("\$main = \"".$Gui->getTemplate("freetime_main")."\";");
00180 // -----------------------------------------  fixed ---------------------------------//
00181 // frameset template not used
00182 // main template
00183 eval("doOutput(\"".$Gui->getTemplate("main")."\");"); 
00184 // --------------------------------------  end fixed --------------------------------//
00185 exit;
00186 ?>

Generated on Fri Dec 13 2013 17:56:47 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1