* @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__); $org_start = $this->maketime($event['start']); $org_end = $this->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'] = $this->time2array($start); $event['end'] = $this->time2array($end); $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; if($typo==0){ $sqla=$sqla." insert into phpgw_cal_id_repeat2 values($id,$dueno,$fechaini,$fechafin);"; } $vuelta=0; if($typo==1){ while (($fechaini)<=$starttime2||$vuelta<50){ $sqla=$sqla." insert into phpgw_cal_id_repeat2 values($id,$dueno,$fechaini,$fechafin);"; $n=1; if ($interval>1){ $n=$n*$interval; } $fechaini=$fechaini+($diaa*$interval); $fechafin=$fechafin+($diaa*$interval); $vuelta=$vuelta+1; } } $vuelta=0; if($typo==2){ while (($fechaini)<=$starttime2||$vuelta<54){ //echo "2 ".$GLOBALS['phpgw']->common->show_date($fechaini)."-".$GLOBALS['phpgw']->common->show_date($fechafin)." ".$titulo."
"; $sqla=$sqla." insert into phpgw_cal_id_repeat2 values($id,$dueno,$fechaini,$fechafin);"; //echo "Repetir segun dia de semana....."; // 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 // $fechaini=$fechaini+$semana; $fechafin=$fechafin+$semana; $vuelta=$vuelta+1; } } $vuelta=0; if($typo==4){ $mesanterior1=$datetimeini['month']; $mesanterior2=$datetimefin['month']; while (($fechaini)<=$starttime2||$vuelta<15){ //echo "3 ".$GLOBALS['phpgw']->common->show_date($fechaini)."-".$GLOBALS['phpgw']->common->show_date($fechafin)." ".$titulo."
"; $sqla=$sqla." insert into phpgw_cal_id_repeat2 values($id,$dueno,$fechaini,$fechafin);"; $n=1; if ($interval>1){ $n=$n*$interval; } //echo "mes1 ".$mes1."anterior ".$mesanterior1."
"; for($i=0;$i<$n;$i++){ $fechaini=$fechaini+$mesdia; $datetime = $GLOBALS['phpgw']->datetime->localdates($fechaini); $mes1=$datetime['month']; if($mes1==$mesanterior1){ $fechaini=$fechaini+$semana; $mesanterior1=$mes1; }else{ $mesanterior1=$mes1; } } $fechafin=$fechafin+$mesdia; $datetime2 = $GLOBALS['phpgw']->datetime->localdates($fechafin); $mes2=$datetime2['month']; if($mes2==$mesanterior2){ $fechafin=$fechafin+$semana; $mesanterior2=$mes2+1; }else{ $mesanterior2=$mes2; } $vuelta=$vuelta+1; } } $vuelta=0; if($typo==3){ while (($fechaini)<=$starttime2||$vuelta<10){ //echo "4 ".$GLOBALS['phpgw']->common->show_date($fechaini)."-".$GLOBALS['phpgw']->common->show_date($fechafin)." ".$titulo."
"; $sqla=$sqla." insert into phpgw_cal_id_repeat2 values($id,$dueno,$fechaini,$fechafin);"; //$fechaini=$fechaini+$mesfecha; $datetime = $GLOBALS['phpgw']->datetime->localdates($fechaini); //echo "
".$datetime['year']." ".$datetime['month']." ".$datetime['day']." ".$datetime['hour']." ".$datetime['minute']."
"; $n=1; if ($interval>1){ $n=$n*$interval; } $mes1=$datetime['month']+$n; if($datetime['day']>28 && $mes1==2 ){ $mes1=$datetime['month']+$n+1; } if($datetime['day']>30 && ($mes1==2||$mes1==4||$mes1==6||$mes1==9||$mes1==11)){ $mes1=$datetime['month']+$n+1; } $dia1=$datetime['day']; //validar lo de dia de semana ? //activar acorde al dia if($datetime['dow']!=0){ //echo "jjjjj"; } $fechaini = mktime($datetime['hour'],$datetime['minute'],0,$mes1,$dia1,$datetime['year']) - $tz_offset; //$fechafin=$fechafin+$mesfecha; $datetime = $GLOBALS['phpgw']->datetime->localdates($fechafin); $mes2=$datetime['month']+$n; if($datetime['day']>28 && $mes2==2 ){ $mes2=$datetime['month']+$n+1; } if($datetime['day']>30 && ($mes2==2||$mes2==4||$mes2==6||$mes2==9||$mes2==11)){ $mes2=$datetime['month']+$n+1; } $dia2=$datetime['day']; //echo "
".$datetime['year']." ".$datetime['month']." ".$datetime['day']." ".$datetime['hour']." ".$datetime['minute']."
"; //echo "
".$fechaini."
"; $fechafin = mktime($datetime['hour'],$datetime['minute'],0,$mes2,$dia2,$datetime['year']) - $tz_offset; $vuelta=$vuelta+1; } } $vuelta=0; if($typo==5){ while (($fechaini)<=$starttime2||$vuelta<5){ //echo "5 ".$GLOBALS['phpgw']->common->show_date($fechaini)."-".$GLOBALS['phpgw']->common->show_date($fechafin)." ".$titulo." ".$id." "."
"; $sqla=$sqla." insert into phpgw_cal_id_repeat2 values($id,$dueno,$fechaini,$fechafin);"; //$fechaini=$fechaini+$anual; //$fechafin=$fechafin+$anual; $datetime = $GLOBALS['phpgw']->datetime->localdates($fechaini); //echo "
".$datetime['year']." ".$datetime['month']." ".$datetime['day']." ".$datetime['hour']." ".$datetime['minute']."
"; //echo "
".$fechaini; $n=1; if ($interval>1){ $n=$n*$interval; } $an1=$datetime['year']+$n; $fechaini = mktime($datetime['hour'],$datetime['minute'],0,$datetime['month'],$datetime['day'],$an1) - $tz_offset; //$fechafin=$fechafin+$mesfecha; $datetime = $GLOBALS['phpgw']->datetime->localdates($fechafin); $an2=$datetime['year']+$n; $fechafin = mktime($datetime['hour'],$datetime['minute'],0,$datetime['month'],$datetime['day'],$an2) - $tz_offset; $vuelta=$vuelta+1; } } } $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'])); } // return $retval; $GLOBALS['phpgw']->common->phpgw_exit(); ?>