* @package timesheet * @copyright (c) 2005 by Ralf Becker * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @version $Id: index.php 22356 2006-08-26 16:32:29Z ralfbecker $ */ $phpgw_flags = Array( 'currentapp' => 'resources', 'noheader' => True, 'nonavbar' => True, 'noappheader' => True, 'noappfooter' => True, 'nofooter' => True ); $GLOBALS['phpgw_info']['flags'] = $phpgw_flags; include('../header.inc.php'); //ExecMethod('resources.uiresources.index',$parms); ////echo "tamannn".count($search)." ".$search[0]; $diaa=86400; $semana=604800; $mesdia=2419200;//(24*3600*7*4) $mesfecha=2592000;//(24*3600*7 $anual=31536000; $from =""; if (isset($idd)){ $from = ' and t1.location=\''.$idd.'\' '; } if (isset($starttime)){ if (isset($starttime2)){ $from =$from .' and (t2.recur_enddate<\''.$starttime2.'\' or t2.recur_enddate=0) '; } } //$sql2=" delete from phpgw_cal_id_repeat2 where login_id='".$this->bo->owner."'"; //$GLOBALS['phpgw']->db->query($sql2,__LINE__,__FILE__); // $this->bo = CreateObject('calendar.bocalendar',1); echo "ggg".check_repeating_events(1246905507); //$event['start']=1246905507; //$event['end']=1247160600; //$org_start = maketime($event['start']); //$org_end = maketime($event['end']); // $start = mktime($event['start']['hour'],$event['start']['min'],0,substr($date,4,2),substr($date,6,2),substr($date,0,4)); //$end = $org_end + $start - $org_start; //$event['start'] = time2array($start); //$event['end'] = time2array($end); echo "
1246905507"; echo "
1247160600"; echo "
".$event['start']['year']." ".$event['start']['month']." ".$event['start']['day'].$event['start']['hour']." ".$event['start']['min']; echo "
".$event['end']; echo "
."; echo "
"; $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'; echo $sql."
"; $sqla=""; $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__); while( $GLOBALS['phpgw']->db->next_record() ) { $vuelta=0; $fechaini=$GLOBALS['phpgw']->db->f('datetime'); $fechafin=$GLOBALS['phpgw']->db->f('edatetime'); $datetimeini = $GLOBALS['phpgw']->datetime->localdates($fechaini); $datetimefin = $GLOBALS['phpgw']->datetime->localdates($fechafin); $titulo=$GLOBALS['phpgw']->db->f('title'); $typo=$GLOBALS['phpgw']->db->f('recur_type'); $reference=$GLOBALS['phpgw']->db->f('reference'); if($reference>0){ } if($typo==''){ $typo=0; } $interval=$GLOBALS['phpgw']->db->f('recur_interval'); $id=$GLOBALS['phpgw']->db->f('cal_id'); //echo $id."cal_id
"; //echo $typo."tupo
"; $dueno=1120; } $GLOBALS['phpgw']->db->query($sqla,__LINE__,__FILE__); $from =""; /*if (isset($idd)){ $from = ' and t1.location=\''.$idd.'\' '; } if (isset($starttime)){ if (isset($starttime2)){ $from =$from .' and ((t5.datetime>\''.$starttime.'\' and t5.datetime<\''.$starttime2.'\' )'; $from =$from .' or( t5.edatetime>\''.$starttime.'\' and t5.edatetime<\''.$starttime2.'\' ) or (t5.datetime <\''.$starttime.'\' and t5.edatetime>\''.$starttime.'\'))'; }*/ // } $sql = ' select t1.cal_id ,t1.owner,t1.groups,t5.datetime,t5.edatetime, t1.priority ,t1.cal_type, t1.is_public , t1.title,t1.description,t1.location , 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 where t1.is_public =t2.list_id and t1.cal_id=t5.cal_id and t2.list_name=\'visibility\' and t1.priority=t3.list_id and t3.list_name=\'priority\' and t1.location=t4.name ' . $from. " order by 4 desc "; //.$search; //. 'WHERE (phpgw_cal_user.res_id = phpgw_cal.res_id) ' //. $where . $extra; //echo $sql; //if($this->debug) ////{ echo "FULL SQL : ".$sql."
\n"; //} //$resultado=pg_query($this->bo->connect(),$sql) or die("Error al mostrar"); $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__); while( $GLOBALS['phpgw']->db->next_record() ) { // //$valorfechaini=$this->bo->time2array($GLOBALS['phpgw']->db->f('datetime'),$alarm = 0); //$ini=$valorfechaini['mday']."/".$valorfechaini['month']."/".$valorfechaini['year']; $ini=$GLOBALS['phpgw']->common->show_date($GLOBALS['phpgw']->db->f('datetime'))."-".$GLOBALS['phpgw']->common->show_date($GLOBALS['phpgw']->db->f('edatetime')); } function time2array($time,$alarm = 0) { return array( 'year' => (int)(date('Y',$time)), 'month' => (int)(date('m',$time)), 'mday' => (int)(date('d',$time)), 'hour' => (int)(date('H',$time)), 'min' => (int)(date('i',$time)), 'sec' => (int)(date('s',$time)), 'alarm' => (int)($alarm) ); } function maketime($time) { return mktime(intval($time['hour']),intval($time['min']),intval($time['sec']),intval($time['month']),intval($time['mday']),intval($time['year'])); } function check_repeating_events($datetime) { echo "aaaa
"; $repeating_events = Array(); $cached_events = Array(); //$event = read_entry($cal_id); //$repeating_events[0] = $event; @reset($repeating_events); echo "aaaa
"; $search_date_full = date('Ymd',$datetime); $search_date_year = date('Y',$datetime); $search_date_month = date('m',$datetime); $search_date_day = date('d',$datetime); $search_date_dow = date('w',$datetime); $search_beg_day = mktime(0,0,0,$search_date_month,$search_date_day,$search_date_year); //$rpt_wdays $repeated = $repeating_events; $r_events = count($repeated); for ($i=0;$i<$r_events;$i++) { echo "aaaa
"; $rep_events = $this->repeating_events[$i]; $id = $rep_events['id']; $event_beg_day = mktime(0,0,0,$rep_events['start']['month'],$rep_events['start']['mday'],$rep_events['start']['year']); if($rep_events['recur_enddate']['month'] != 0 && $rep_events['recur_enddate']['mday'] != 0 && $rep_events['recur_enddate']['year'] != 0) { $event_recur_time = $this->maketime($rep_events['recur_enddate']); } else { $event_recur_time = mktime(0,0,0,1,1,2030); } $end_recur_date = date('Ymd',$event_recur_time); $full_event_date = date('Ymd',$event_beg_day); if($this->debug) { echo ''."\n"; echo ''."\n"; } // only repeat after the beginning, and if there is an rpt_end before the end date if (($search_date_full > $end_recur_date) || ($search_date_full < $full_event_date)) { continue; } if ($search_date_full == $full_event_date) { $this->sort_event($rep_events,$search_date_full); continue; } else { $freq = $rep_events['recur_interval']; $freq = $freq ? $freq : 1; $type = $rep_events['recur_type']; switch($type) { case MCAL_RECUR_DAILY: if($this->debug) { echo ''."\n"; } if ($freq == 1 && $rep_events['recur_enddate']['month'] != 0 && $rep_events['recur_enddate']['mday'] != 0 && $rep_events['recur_enddate']['year'] != 0 && $search_date_full <= $end_recur_date) { $this->sort_event($rep_events,$search_date_full); } elseif (floor(($search_beg_day - $event_beg_day)/86400) % ($freq ? $freq : 1)) { continue; } else { $this->sort_event($rep_events,$search_date_full); } break; case MCAL_RECUR_WEEKLY: if (floor(($search_beg_day - $event_beg_day)/604800) % ($freq ? $freq : 1)) { continue; } $check = 0; switch($search_date_dow) { case 0: $check = MCAL_M_SUNDAY; break; case 1: $check = MCAL_M_MONDAY; break; case 2: $check = MCAL_M_TUESDAY; break; case 3: $check = MCAL_M_WEDNESDAY; break; case 4: $check = MCAL_M_THURSDAY; break; case 5: $check = MCAL_M_FRIDAY; break; case 6: $check = MCAL_M_SATURDAY; break; } if ($rep_events['recur_data'] & $check) { $this->sort_event($rep_events,$search_date_full); } break; case MCAL_RECUR_MONTHLY_WDAY: if ((($search_date_year - $rep_events['start']['year']) * 12 + $search_date_month - $rep_events['start']['month']) % $freq) { continue; } if (($GLOBALS['phpgw']->datetime->day_of_week($rep_events['start']['year'],$rep_events['start']['month'],$rep_events['start']['mday']) == $GLOBALS['phpgw']->datetime->day_of_week($search_date_year,$search_date_month,$search_date_day)) && (ceil($rep_events['start']['mday']/7) == ceil($search_date_day/7))) { $this->sort_event($rep_events,$search_date_full); } break; case MCAL_RECUR_MONTHLY_MDAY: if ((($search_date_year - $rep_events['start']['year']) * 12 + $search_date_month - $rep_events['start']['month']) % ($freq ? $freq : 1)) { continue; } if ($search_date_day == $rep_events['start']['mday']) { $this->sort_event($rep_events,$search_date_full); } break; case MCAL_RECUR_YEARLY: if (($search_date_year - $rep_events['start']['year']) % ($freq ? $freq : 1)) { continue; } if (date('dm',$datetime) == date('dm',$event_beg_day)) { $this->sort_event($rep_events,$search_date_full); } break; } } } // end for loop } // return $retval; $GLOBALS['phpgw']->common->phpgw_exit(); ?>