[4362] | 1 | <?php |
---|
| 2 | /** |
---|
| 3 | * TimeSheet - index |
---|
| 4 | * |
---|
| 5 | * @link http://www.egroupware.org |
---|
| 6 | * @author Ralf Becker <RalfBecker-AT-outdoor-training.de> |
---|
| 7 | * @package timesheet |
---|
| 8 | * @copyright (c) 2005 by Ralf Becker <RalfBecker-AT-outdoor-training.de> |
---|
| 9 | * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
---|
| 10 | * @version $Id: index.php 22356 2006-08-26 16:32:29Z ralfbecker $ |
---|
| 11 | */ |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | |
---|
| 16 | $phpgw_flags = Array( |
---|
| 17 | 'currentapp' => 'resources', |
---|
| 18 | 'noheader' => True, |
---|
| 19 | 'nonavbar' => True, |
---|
| 20 | 'noappheader' => True, |
---|
| 21 | 'noappfooter' => True, |
---|
| 22 | 'nofooter' => True |
---|
| 23 | ); |
---|
| 24 | |
---|
| 25 | $GLOBALS['phpgw_info']['flags'] = $phpgw_flags; |
---|
| 26 | include('../header.inc.php'); |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | //ExecMethod('resources.uiresources.index',$parms); |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | ////echo "tamannn".count($search)." ".$search[0]; |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | $diaa=86400; |
---|
| 39 | $semana=604800; |
---|
| 40 | $mesdia=2419200;//(24*3600*7*4) |
---|
| 41 | $mesfecha=2592000;//(24*3600*7 |
---|
| 42 | $anual=31536000; |
---|
| 43 | $from =""; |
---|
| 44 | if (isset($idd)){ |
---|
| 45 | |
---|
| 46 | $from = ' and t1.location=\''.$idd.'\' '; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | if (isset($starttime)){ |
---|
| 50 | if (isset($starttime2)){ |
---|
| 51 | |
---|
| 52 | $from =$from .' and (t2.recur_enddate<\''.$starttime2.'\' or t2.recur_enddate=0) '; |
---|
| 53 | } |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | //$sql2=" delete from phpgw_cal_id_repeat2 where login_id='".$this->bo->owner."'"; |
---|
| 57 | //$GLOBALS['phpgw']->db->query($sql2,__LINE__,__FILE__); |
---|
| 58 | |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | $org_start = $this->maketime($event['start']); |
---|
| 65 | $org_end = $this->maketime($event['end']); |
---|
| 66 | $start = mktime($event['start']['hour'],$event['start']['min'],0,substr($date,4,2),substr($date,6,2),substr($date,0,4)); |
---|
| 67 | $end = $org_end + $start - $org_start; |
---|
| 68 | $event['start'] = $this->time2array($start); |
---|
| 69 | $event['end'] = $this->time2array($end); |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | $sql = ' select t1.cal_id, t2.recur_type, t2.recur_use_end, t2.recur_enddate, t2.recur_interval, t2.recur_data,t2.recur_exception ,case when t1.datetime is null then 0 else t1.datetime end, case when t1.edatetime is null then 0 else t1.edatetime end, t1.title from phpgw_cal t1 left outer join phpgw_cal_repeats t2 on (t1.cal_id=t2.cal_id ) and t1.cal_id not in (select t1.reference from phpgw_cal t1 left outer join phpgw_cal_repeats t2 on (t1.cal_id=t2.cal_id )) order by t1.mdatetime desc'; |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | echo $sql."<br>"; |
---|
| 87 | |
---|
| 88 | $sqla=""; |
---|
| 89 | |
---|
| 90 | $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__); |
---|
| 91 | while( $GLOBALS['phpgw']->db->next_record() ) |
---|
| 92 | { |
---|
| 93 | $vuelta=0; |
---|
| 94 | $fechaini=$GLOBALS['phpgw']->db->f('datetime'); |
---|
| 95 | $fechafin=$GLOBALS['phpgw']->db->f('edatetime'); |
---|
| 96 | $datetimeini = $GLOBALS['phpgw']->datetime->localdates($fechaini); |
---|
| 97 | $datetimefin = $GLOBALS['phpgw']->datetime->localdates($fechafin); |
---|
| 98 | $titulo=$GLOBALS['phpgw']->db->f('title'); |
---|
| 99 | $typo=$GLOBALS['phpgw']->db->f('recur_type'); |
---|
| 100 | |
---|
| 101 | $reference=$GLOBALS['phpgw']->db->f('reference'); |
---|
| 102 | |
---|
| 103 | if($reference>0){ |
---|
| 104 | |
---|
| 105 | } |
---|
| 106 | if($typo==''){ |
---|
| 107 | $typo=0; |
---|
| 108 | } |
---|
| 109 | $interval=$GLOBALS['phpgw']->db->f('recur_interval'); |
---|
| 110 | $id=$GLOBALS['phpgw']->db->f('cal_id'); |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | //echo $id."cal_id<br>"; |
---|
| 115 | //echo $typo."tupo<br>"; |
---|
| 116 | |
---|
| 117 | $dueno=1120; |
---|
| 118 | |
---|
| 119 | if($typo==0){ |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | $sqla=$sqla." insert into phpgw_cal_id_repeat2 values($id,$dueno,$fechaini,$fechafin);"; |
---|
| 125 | |
---|
| 126 | } |
---|
| 127 | $vuelta=0; |
---|
| 128 | |
---|
| 129 | |
---|
| 130 | |
---|
| 131 | if($typo==1){ |
---|
| 132 | while (($fechaini)<=$starttime2||$vuelta<50){ |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | $sqla=$sqla." insert into phpgw_cal_id_repeat2 values($id,$dueno,$fechaini,$fechafin);"; |
---|
| 138 | |
---|
| 139 | |
---|
| 140 | $n=1; |
---|
| 141 | if ($interval>1){ |
---|
| 142 | $n=$n*$interval; |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | |
---|
| 146 | $fechaini=$fechaini+($diaa*$interval); |
---|
| 147 | $fechafin=$fechafin+($diaa*$interval); |
---|
| 148 | |
---|
| 149 | $vuelta=$vuelta+1; |
---|
| 150 | } |
---|
| 151 | } |
---|
| 152 | $vuelta=0; |
---|
| 153 | |
---|
| 154 | |
---|
| 155 | |
---|
| 156 | |
---|
| 157 | |
---|
| 158 | |
---|
| 159 | |
---|
| 160 | |
---|
| 161 | |
---|
| 162 | |
---|
| 163 | |
---|
| 164 | if($typo==2){ |
---|
| 165 | while (($fechaini)<=$starttime2||$vuelta<54){ |
---|
| 166 | |
---|
| 167 | |
---|
| 168 | |
---|
| 169 | |
---|
| 170 | //echo "2 ".$GLOBALS['phpgw']->common->show_date($fechaini)."-".$GLOBALS['phpgw']->common->show_date($fechafin)." ".$titulo."<br>"; |
---|
| 171 | $sqla=$sqla." insert into phpgw_cal_id_repeat2 values($id,$dueno,$fechaini,$fechafin);"; |
---|
| 172 | |
---|
| 173 | //echo "Repetir segun dia de semana....."; |
---|
| 174 | // en base de datos se guarda la sumatoria de los dias, segun lunes 2,martes,4 miercoles 8, jueves 16, viernes 32, sabado 64, domingo 1 |
---|
| 175 | // |
---|
| 176 | |
---|
| 177 | $fechaini=$fechaini+$semana; |
---|
| 178 | $fechafin=$fechafin+$semana; |
---|
| 179 | $vuelta=$vuelta+1; |
---|
| 180 | } |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | |
---|
| 184 | $vuelta=0; |
---|
| 185 | if($typo==4){ |
---|
| 186 | $mesanterior1=$datetimeini['month']; |
---|
| 187 | $mesanterior2=$datetimefin['month']; |
---|
| 188 | while (($fechaini)<=$starttime2||$vuelta<15){ |
---|
| 189 | |
---|
| 190 | //echo "3 ".$GLOBALS['phpgw']->common->show_date($fechaini)."-".$GLOBALS['phpgw']->common->show_date($fechafin)." ".$titulo."<br>"; |
---|
| 191 | |
---|
| 192 | |
---|
| 193 | $sqla=$sqla." insert into phpgw_cal_id_repeat2 values($id,$dueno,$fechaini,$fechafin);"; |
---|
| 194 | |
---|
| 195 | |
---|
| 196 | $n=1; |
---|
| 197 | if ($interval>1){ |
---|
| 198 | $n=$n*$interval; |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | |
---|
| 202 | //echo "mes1 ".$mes1."anterior ".$mesanterior1."<br>"; |
---|
| 203 | |
---|
| 204 | |
---|
| 205 | for($i=0;$i<$n;$i++){ |
---|
| 206 | |
---|
| 207 | |
---|
| 208 | $fechaini=$fechaini+$mesdia; |
---|
| 209 | |
---|
| 210 | $datetime = $GLOBALS['phpgw']->datetime->localdates($fechaini); |
---|
| 211 | $mes1=$datetime['month']; |
---|
| 212 | |
---|
| 213 | |
---|
| 214 | if($mes1==$mesanterior1){ |
---|
| 215 | $fechaini=$fechaini+$semana; |
---|
| 216 | $mesanterior1=$mes1; |
---|
| 217 | }else{ |
---|
| 218 | $mesanterior1=$mes1; |
---|
| 219 | } |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | |
---|
| 223 | $fechafin=$fechafin+$mesdia; |
---|
| 224 | $datetime2 = $GLOBALS['phpgw']->datetime->localdates($fechafin); |
---|
| 225 | |
---|
| 226 | $mes2=$datetime2['month']; |
---|
| 227 | if($mes2==$mesanterior2){ |
---|
| 228 | $fechafin=$fechafin+$semana; |
---|
| 229 | $mesanterior2=$mes2+1; |
---|
| 230 | }else{ |
---|
| 231 | $mesanterior2=$mes2; |
---|
| 232 | } |
---|
| 233 | |
---|
| 234 | $vuelta=$vuelta+1; |
---|
| 235 | } |
---|
| 236 | } |
---|
| 237 | $vuelta=0; |
---|
| 238 | if($typo==3){ |
---|
| 239 | while (($fechaini)<=$starttime2||$vuelta<10){ |
---|
| 240 | |
---|
| 241 | |
---|
| 242 | |
---|
| 243 | |
---|
| 244 | |
---|
| 245 | //echo "4 ".$GLOBALS['phpgw']->common->show_date($fechaini)."-".$GLOBALS['phpgw']->common->show_date($fechafin)." ".$titulo."<br>"; |
---|
| 246 | $sqla=$sqla." insert into phpgw_cal_id_repeat2 values($id,$dueno,$fechaini,$fechafin);"; |
---|
| 247 | //$fechaini=$fechaini+$mesfecha; |
---|
| 248 | $datetime = $GLOBALS['phpgw']->datetime->localdates($fechaini); |
---|
| 249 | //echo "<br>".$datetime['year']." ".$datetime['month']." ".$datetime['day']." ".$datetime['hour']." ".$datetime['minute']."<BR>"; |
---|
| 250 | $n=1; |
---|
| 251 | if ($interval>1){ |
---|
| 252 | $n=$n*$interval; |
---|
| 253 | } |
---|
| 254 | $mes1=$datetime['month']+$n; |
---|
| 255 | if($datetime['day']>28 && $mes1==2 ){ |
---|
| 256 | $mes1=$datetime['month']+$n+1; |
---|
| 257 | } |
---|
| 258 | if($datetime['day']>30 && ($mes1==2||$mes1==4||$mes1==6||$mes1==9||$mes1==11)){ |
---|
| 259 | $mes1=$datetime['month']+$n+1; |
---|
| 260 | } |
---|
| 261 | $dia1=$datetime['day']; |
---|
| 262 | |
---|
| 263 | //validar lo de dia de semana ? |
---|
| 264 | //activar acorde al dia |
---|
| 265 | if($datetime['dow']!=0){ |
---|
| 266 | //echo "jjjjj"; |
---|
| 267 | } |
---|
| 268 | |
---|
| 269 | |
---|
| 270 | |
---|
| 271 | $fechaini = mktime($datetime['hour'],$datetime['minute'],0,$mes1,$dia1,$datetime['year']) - $tz_offset; |
---|
| 272 | |
---|
| 273 | //$fechafin=$fechafin+$mesfecha; |
---|
| 274 | $datetime = $GLOBALS['phpgw']->datetime->localdates($fechafin); |
---|
| 275 | $mes2=$datetime['month']+$n; |
---|
| 276 | if($datetime['day']>28 && $mes2==2 ){ |
---|
| 277 | $mes2=$datetime['month']+$n+1; |
---|
| 278 | } |
---|
| 279 | if($datetime['day']>30 && ($mes2==2||$mes2==4||$mes2==6||$mes2==9||$mes2==11)){ |
---|
| 280 | $mes2=$datetime['month']+$n+1; |
---|
| 281 | } |
---|
| 282 | $dia2=$datetime['day']; |
---|
| 283 | |
---|
| 284 | //echo "<br>".$datetime['year']." ".$datetime['month']." ".$datetime['day']." ".$datetime['hour']." ".$datetime['minute']."<BR>"; |
---|
| 285 | |
---|
| 286 | //echo "<br>".$fechaini."<br>"; |
---|
| 287 | |
---|
| 288 | $fechafin = mktime($datetime['hour'],$datetime['minute'],0,$mes2,$dia2,$datetime['year']) - $tz_offset; |
---|
| 289 | |
---|
| 290 | |
---|
| 291 | |
---|
| 292 | $vuelta=$vuelta+1; |
---|
| 293 | } |
---|
| 294 | } |
---|
| 295 | |
---|
| 296 | $vuelta=0; |
---|
| 297 | if($typo==5){ |
---|
| 298 | while (($fechaini)<=$starttime2||$vuelta<5){ |
---|
| 299 | |
---|
| 300 | //echo "5 ".$GLOBALS['phpgw']->common->show_date($fechaini)."-".$GLOBALS['phpgw']->common->show_date($fechafin)." ".$titulo." ".$id." "."<br>"; |
---|
| 301 | $sqla=$sqla." insert into phpgw_cal_id_repeat2 values($id,$dueno,$fechaini,$fechafin);"; |
---|
| 302 | //$fechaini=$fechaini+$anual; |
---|
| 303 | //$fechafin=$fechafin+$anual; |
---|
| 304 | |
---|
| 305 | $datetime = $GLOBALS['phpgw']->datetime->localdates($fechaini); |
---|
| 306 | //echo "<br>".$datetime['year']." ".$datetime['month']." ".$datetime['day']." ".$datetime['hour']." ".$datetime['minute']."<BR>"; |
---|
| 307 | |
---|
| 308 | //echo "<br>".$fechaini; |
---|
| 309 | $n=1; |
---|
| 310 | |
---|
| 311 | if ($interval>1){ |
---|
| 312 | $n=$n*$interval; |
---|
| 313 | } |
---|
| 314 | |
---|
| 315 | $an1=$datetime['year']+$n; |
---|
| 316 | $fechaini = mktime($datetime['hour'],$datetime['minute'],0,$datetime['month'],$datetime['day'],$an1) - $tz_offset; |
---|
| 317 | |
---|
| 318 | //$fechafin=$fechafin+$mesfecha; |
---|
| 319 | $datetime = $GLOBALS['phpgw']->datetime->localdates($fechafin); |
---|
| 320 | $an2=$datetime['year']+$n; |
---|
| 321 | |
---|
| 322 | |
---|
| 323 | |
---|
| 324 | |
---|
| 325 | |
---|
| 326 | $fechafin = mktime($datetime['hour'],$datetime['minute'],0,$datetime['month'],$datetime['day'],$an2) - $tz_offset; |
---|
| 327 | |
---|
| 328 | |
---|
| 329 | |
---|
| 330 | |
---|
| 331 | |
---|
| 332 | $vuelta=$vuelta+1; |
---|
| 333 | } |
---|
| 334 | } |
---|
| 335 | |
---|
| 336 | |
---|
| 337 | } |
---|
| 338 | |
---|
| 339 | $GLOBALS['phpgw']->db->query($sqla,__LINE__,__FILE__); |
---|
| 340 | |
---|
| 341 | |
---|
| 342 | |
---|
| 343 | $from =""; |
---|
| 344 | /*if (isset($idd)){ |
---|
| 345 | |
---|
| 346 | $from = ' and t1.location=\''.$idd.'\' '; |
---|
| 347 | } |
---|
| 348 | |
---|
| 349 | if (isset($starttime)){ |
---|
| 350 | if (isset($starttime2)){ |
---|
| 351 | |
---|
| 352 | $from =$from .' and ((t5.datetime>\''.$starttime.'\' and t5.datetime<\''.$starttime2.'\' )'; |
---|
| 353 | $from =$from .' or( t5.edatetime>\''.$starttime.'\' and t5.edatetime<\''.$starttime2.'\' ) or (t5.datetime <\''.$starttime.'\' and t5.edatetime>\''.$starttime.'\'))'; |
---|
| 354 | }*/ |
---|
| 355 | // } |
---|
| 356 | |
---|
| 357 | $sql = ' select t1.cal_id ,t1.owner,t1.groups,t5.datetime,t5.edatetime, |
---|
| 358 | t1.priority ,t1.cal_type, t1.is_public , |
---|
| 359 | t1.title,t1.description,t1.location , |
---|
| 360 | t2.list_descripcion as publico,t3.list_descripcion as priority ,t4.name as namelocation,t1.reference from phpgw_cal t1, phpgw_listas t2, phpgw_listas t3 ,phpgw_resources t4,phpgw_cal_id_repeat2 t5 |
---|
| 361 | where t1.is_public =t2.list_id and t1.cal_id=t5.cal_id and t2.list_name=\'visibility\' |
---|
| 362 | and t1.priority=t3.list_id and t3.list_name=\'priority\' |
---|
| 363 | and t1.location=t4.name ' |
---|
| 364 | . $from. " order by 4 desc "; |
---|
| 365 | //.$search; |
---|
| 366 | //. 'WHERE (phpgw_cal_user.res_id = phpgw_cal.res_id) ' |
---|
| 367 | //. $where . $extra; |
---|
| 368 | |
---|
| 369 | |
---|
| 370 | //echo $sql; |
---|
| 371 | |
---|
| 372 | |
---|
| 373 | |
---|
| 374 | //if($this->debug) |
---|
| 375 | ////{ |
---|
| 376 | echo "FULL SQL : ".$sql."<br>\n"; |
---|
| 377 | //} |
---|
| 378 | |
---|
| 379 | //$resultado=pg_query($this->bo->connect(),$sql) or die("Error al mostrar"); |
---|
| 380 | |
---|
| 381 | |
---|
| 382 | $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__); |
---|
| 383 | while( $GLOBALS['phpgw']->db->next_record() ) |
---|
| 384 | { |
---|
| 385 | // |
---|
| 386 | |
---|
| 387 | //$valorfechaini=$this->bo->time2array($GLOBALS['phpgw']->db->f('datetime'),$alarm = 0); |
---|
| 388 | //$ini=$valorfechaini['mday']."/".$valorfechaini['month']."/".$valorfechaini['year']; |
---|
| 389 | $ini=$GLOBALS['phpgw']->common->show_date($GLOBALS['phpgw']->db->f('datetime'))."-".$GLOBALS['phpgw']->common->show_date($GLOBALS['phpgw']->db->f('edatetime')); |
---|
| 390 | |
---|
| 391 | |
---|
| 392 | |
---|
| 393 | |
---|
| 394 | |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | function time2array($time,$alarm = 0) |
---|
| 398 | { |
---|
| 399 | return array( |
---|
| 400 | 'year' => (int)(date('Y',$time)), |
---|
| 401 | 'month' => (int)(date('m',$time)), |
---|
| 402 | 'mday' => (int)(date('d',$time)), |
---|
| 403 | 'hour' => (int)(date('H',$time)), |
---|
| 404 | 'min' => (int)(date('i',$time)), |
---|
| 405 | 'sec' => (int)(date('s',$time)), |
---|
| 406 | 'alarm' => (int)($alarm) |
---|
| 407 | ); |
---|
| 408 | } |
---|
| 409 | |
---|
| 410 | |
---|
| 411 | |
---|
| 412 | function maketime($time) |
---|
| 413 | { |
---|
| 414 | return mktime(intval($time['hour']),intval($time['min']),intval($time['sec']),intval($time['month']),intval($time['mday']),intval($time['year'])); |
---|
| 415 | } |
---|
| 416 | |
---|
| 417 | |
---|
| 418 | |
---|
| 419 | // return $retval; |
---|
| 420 | |
---|
| 421 | |
---|
| 422 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 423 | |
---|
| 424 | ?> |
---|
| 425 | |
---|