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

modules/dateplaner/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 */
00033 // include DP freetime functions
00034 include_once    ('.'.DATEPLANER_ROOT_DIR.'/includes/inc.freetime.php');
00035                 
00036 
00037 /* ------------------------------------  generate frames --------------------------- */
00038 // -----------------------------------------  fixed ---------------------------------//
00039 // the left frame is not used 
00040 $left   = '';
00041 
00042 // right frame is curently not used
00043 $right  = '';
00044 
00045 // the up frame is detect by the interface 
00046 
00047 // down frame is curently not used
00048 $downtext = '';
00049 // --------------------------------------  end fixed  -------------------------------//
00050 
00051 //get start- and end-time for the view-area
00052 $viewTsBegin = strtotime($_SESSION[DP_Starttime]);
00053 if ($DP_Endtime=="24:00:00"){
00054 $viewTsEnd = strtotime("23:59:59");
00055 }else{
00056 $viewTsEnd = strtotime($_SESSION[DP_Endtime]);
00057 }
00058 
00059 //convert the strings into timestamps 
00060 $beginsek=((intval(date(H,$viewTsBegin))*3600)+intval((date(i,$viewTsBegin))*60)+intval(date(s,$viewTsBegin)));
00061 $endsek=((intval(date(H,$viewTsEnd))*3600)+intval((date(i,$viewTsEnd))*60)+intval(date(s,$viewTsEnd)));
00062 
00063 //round the timestamps to 15min-chunks
00064 $startDisplayQuarters=floor($beginsek/900);
00065 $endDisplayQuarters=ceil($endsek/900);
00066 
00067 //tables for the results of database-query
00068 $dStartTime = array(array());
00069 $dEndTime = array(array());
00070 
00071 //table for view
00072 $dTargetTable = array(array());
00073 
00074 //boolean variable   
00075 $pError="";
00076 
00077 //detect a wrong entered date
00078 if (str2date($_POST[date2])<0){
00079 echo "Wrong date-format error<br>";
00080 $pError=true;
00081 }
00082 else{
00083 $pError=false;
00084 }
00085 
00086 //detect if a groups is selected
00087 if ($_POST[DateValuesGroup_id]==0){
00088 echo "Please select a group first<br>";
00089 $pError=true;
00090 }
00091 else{
00092 $pError=false;
00093 }
00094 
00095 //if an error occured, echo a 'back'-button otherwise continue
00096 if ($pError==true){
00097 echo '[<a href="javascript:history.back()"><b>back</b></a>]';
00098 }
00099 else{
00100 //every week begins @ monday (monday==0;... sunday==6);
00101 $weekTs= str2date($_POST[date2]);
00102 $weekTs= mktime(0,0,0,date("m",$weekTs),(date("d",$weekTs)-((date("w",$weekTs)+6))%7),date("Y",$weekTs)); 
00103 
00104 // set variables 4 table-header
00105 $S_Datum = setDateInTblHead($weekTs) ;
00106 
00107 //get DB-result 4 current week
00108 for ($j=0;$j<7;$j++){
00109         $begin= $weekTs+((24*60*60)*$j);        //start of day 
00110         $end= $begin+((24*60*60)-1); //end of day
00111         $groupIDs=$_POST[DateValuesGroup_id];           //groupIds
00112         $groupDates[$j]= getGroupDatesForDisplay($groupIDs, $begin, $end, $DB); //get dates
00113 }
00114 //clear display-data
00115 for ($j=0;$j<7;$j++){
00116         $dTargetTable[$j]=array_fill(0, 96, 0);
00117 }
00118 
00119 
00120 //get groupDates out of DB-result and round them to 15min chunks 
00121 for($j=0;$j<7;$j++)
00122 {
00123         for($i=0;$i<sizeof($groupDates[$j]);$i++){
00124                 if ($groupDates[$j]!=""){               
00125                         $tsBegin=$groupDates[$j][$i][1];
00126                         $tsEnd=$groupDates[$j][$i][2];
00127 
00128                         $beginsek=((intval(date(H,$tsBegin))*3600)+intval((date(i,$tsBegin))*60)+intval(date(s,$tsBegin)));
00129                         $endsek=((intval(date(H,$tsEnd))*3600)+intval((date(i,$tsEnd))*60)+intval(date(s,$tsEnd)));
00130 
00131                         $beginQuarter=floor($beginsek/900);
00132                         $endQuarter=ceil($endsek/900);
00133 
00134                         $dStartTime[$j][$i]=$beginQuarter;
00135                         $dEndTime[$j][$i]=$endQuarter;
00136                 }
00137         }
00138 }
00139 
00140 //prepare display-data 
00141 for($j=0;$j<7;$j++){
00142         for($i=0;$i<sizeof($dStartTime[$j]);++$i){
00143                 $start=$dStartTime[$j][$i];
00144                 $end=$dEndTime[$j][$i];
00145 
00146                 for($start;$start<=$end-1;++$start){
00147                         $dTargetTable[$j][$start]+=1;
00148                 }
00149         }
00150 }
00151                 
00152 //display calculated data
00153 for($i=$startDisplayQuarters; $i <=$endDisplayQuarters-1; $i++){
00154         $htmlBuffer=$htmlBuffer. "<TR class=\"small\">";
00155         // show time
00156         $min=$i*15;
00157     if($min%30==0) {$htmlBuffer=$htmlBuffer. "\n<TH class='tblheader' rowspan='2'>";
00158                 $hour = ($min-$min%60)/60 ;
00159                 $quarter= $min%60;
00160                 if ($quarter==0){$quarter="00";}
00161                 $htmlBuffer=$htmlBuffer. $hour.":".$quarter;
00162                 $htmlBuffer=$htmlBuffer. "</TH>\n";
00163         }
00164         // show occupied and free quarters      
00165         for($j=0;$j<7;$j++){
00166                 $actTS=$weekTs+($min*60)+($j*24*60*60); 
00167                 if ($dTargetTable[$j][$i]==0){
00168                         $htmlBuffer=$htmlBuffer. "<TD ".$DP_CSS[tblrow02]." align=\"top\"".'>';
00169                         $htmlBuffer=$htmlBuffer. '<a TITLE='.$DP_language[free]."&nbsp;".$hour.":".$quarter.' href="javascript:document.feedback.timestamp.value='.$actTS.';document.getElementsByName('."'feedback'".')[0].submit()'.'">';
00170                         $htmlBuffer=$htmlBuffer. '<img src=".'.DATEPLANER_ROOT_DIR.$templatefolder."/".$actualtemplate.'/images/filler.gif" width="60" height="10" border="0"></a>'."</TD>\n"; 
00171                 }
00172                 else{
00173 
00174                   $htmlBuffer=$htmlBuffer. "<TD ".$DP_CSS[tblrow03]." align=\"top\"".'>';
00175                   $htmlBuffer=$htmlBuffer. '<img src=".'.DATEPLANER_ROOT_DIR.$templatefolder."/".$actualtemplate.'/images/filler.gif" width="60" height="10" border="0" >'."</TD>\n";
00176                   
00177                 }
00178         }
00179         $htmlBuffer=$htmlBuffer."</TR>\n";
00180 }
00181 }
00182 eval ("\$main = \"".$Gui->getTemplate("freetime_main")."\";");
00183 // -----------------------------------------  fixed ---------------------------------//
00184 // frameset template not used
00185 // main template
00186 eval("doOutput(\"".$Gui->getTemplate("main")."\");"); 
00187 // --------------------------------------  end fixed --------------------------------//
00188 exit;
00189 ?>

Generated on Fri Dec 13 2013 09:06:37 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1