source: contrib/Resources/index23.php @ 4362

Revision 4362, 10.2 KB checked in by afernandes, 13 years ago (diff)

Ticket #1416 - Disponibilizado módulo de recursos para a comunidade

  • Property svn:executable set to *
Line 
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 ="";
44if (isset($idd)){
45
46                        $from = ' and t1.location=\''.$idd.'\' ';
47                        }
48
49if (isset($starttime)){
50if (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                        //                      $this->bo = CreateObject('calendar.bocalendar',1);
61                        echo "ggg".check_repeating_events(1246905507);
62                        //$event['start']=1246905507;
63                        //$event['end']=1247160600;
64               
65                        //$org_start = maketime($event['start']);
66                        //$org_end   = maketime($event['end']);
67                //      $start = mktime($event['start']['hour'],$event['start']['min'],0,substr($date,4,2),substr($date,6,2),substr($date,0,4));
68                        //$end   = $org_end + $start - $org_start;
69                        //$event['start'] = time2array($start);
70                        //$event['end']   = time2array($end);
71                       
72                       
73                        echo "<br>1246905507";         
74                        echo "<br>1247160600";         
75        echo "<br>".$event['start']['year']." ".$event['start']['month']." ".$event['start']['day'].$event['start']['hour']."  ".$event['start']['min'];               
76        echo "<br>".$event['end'];             
77                echo "<br>.";           
78                echo "<br>";           
79                       
80                       
81                       
82                       
83                       
84                       
85                       
86
87
88$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';
89
90
91
92echo $sql."<br>";
93
94$sqla="";
95
96$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
97while( $GLOBALS['phpgw']->db->next_record() )
98{
99$vuelta=0;     
100$fechaini=$GLOBALS['phpgw']->db->f('datetime');
101$fechafin=$GLOBALS['phpgw']->db->f('edatetime');
102$datetimeini = $GLOBALS['phpgw']->datetime->localdates($fechaini);
103$datetimefin = $GLOBALS['phpgw']->datetime->localdates($fechafin);
104$titulo=$GLOBALS['phpgw']->db->f('title');
105$typo=$GLOBALS['phpgw']->db->f('recur_type');
106
107$reference=$GLOBALS['phpgw']->db->f('reference');
108
109if($reference>0){
110
111}
112if($typo==''){
113$typo=0;
114}
115$interval=$GLOBALS['phpgw']->db->f('recur_interval');
116$id=$GLOBALS['phpgw']->db->f('cal_id');
117
118
119
120//echo $id."cal_id<br>";
121//echo $typo."tupo<br>";
122
123$dueno=1120;
124
125
126}
127
128$GLOBALS['phpgw']->db->query($sqla,__LINE__,__FILE__);
129
130
131
132$from ="";
133/*if (isset($idd)){
134
135                        $from = ' and t1.location=\''.$idd.'\' ';
136                        }
137
138if (isset($starttime)){
139if (isset($starttime2)){
140
141                        $from =$from .' and ((t5.datetime>\''.$starttime.'\' and t5.datetime<\''.$starttime2.'\' )';
142$from =$from .' or( t5.edatetime>\''.$starttime.'\' and t5.edatetime<\''.$starttime2.'\' ) or (t5.datetime <\''.$starttime.'\' and t5.edatetime>\''.$starttime.'\'))';
143}*/
144                //      }
145
146                        $sql = ' select t1.cal_id ,t1.owner,t1.groups,t5.datetime,t5.edatetime,
147t1.priority ,t1.cal_type, t1.is_public ,
148t1.title,t1.description,t1.location ,
149t2.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
150where t1.is_public =t2.list_id and t1.cal_id=t5.cal_id and t2.list_name=\'visibility\'
151and t1.priority=t3.list_id and t3.list_name=\'priority\'
152and t1.location=t4.name '
153                                        . $from. " order by 4 desc ";
154                                        //.$search;
155                                        //. 'WHERE (phpgw_cal_user.res_id = phpgw_cal.res_id) '
156                                        //. $where . $extra;
157
158
159//echo $sql;
160
161
162
163                        //if($this->debug)
164                        ////{
165                                echo "FULL SQL : ".$sql."<br>\n";
166                        //}
167
168 //$resultado=pg_query($this->bo->connect(),$sql) or die("Error al mostrar");
169
170
171$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
172while( $GLOBALS['phpgw']->db->next_record() )
173                        {
174                        //     
175
176//$valorfechaini=$this->bo->time2array($GLOBALS['phpgw']->db->f('datetime'),$alarm = 0);
177//$ini=$valorfechaini['mday']."/".$valorfechaini['month']."/".$valorfechaini['year'];
178$ini=$GLOBALS['phpgw']->common->show_date($GLOBALS['phpgw']->db->f('datetime'))."-".$GLOBALS['phpgw']->common->show_date($GLOBALS['phpgw']->db->f('edatetime'));
179
180
181
182
183
184                        }
185               
186function time2array($time,$alarm = 0)
187                {
188                        return array(
189                                'year'  => (int)(date('Y',$time)),
190                                'month' => (int)(date('m',$time)),
191                                'mday'  => (int)(date('d',$time)),
192                                'hour'  => (int)(date('H',$time)),
193                                'min'   => (int)(date('i',$time)),
194                                'sec'   => (int)(date('s',$time)),
195                                'alarm' => (int)($alarm)
196                        );
197                }
198                       
199               
200                       
201                        function maketime($time)
202                {
203                        return mktime(intval($time['hour']),intval($time['min']),intval($time['sec']),intval($time['month']),intval($time['mday']),intval($time['year']));
204                }
205                       
206function check_repeating_events($datetime)
207                {
208                        echo "aaaa<br>";
209                        $repeating_events = Array();
210                        $cached_events = Array();
211                        //$event = read_entry($cal_id);
212                        //$repeating_events[0] = $event;
213                        @reset($repeating_events);
214                                                echo "aaaa<br>";
215                       
216                        $search_date_full = date('Ymd',$datetime);
217                        $search_date_year = date('Y',$datetime);
218                        $search_date_month = date('m',$datetime);
219                        $search_date_day = date('d',$datetime);
220                        $search_date_dow = date('w',$datetime);
221                        $search_beg_day = mktime(0,0,0,$search_date_month,$search_date_day,$search_date_year);
222                        //$rpt_wdays
223                        $repeated = $repeating_events;
224                        $r_events = count($repeated);
225                        for ($i=0;$i<$r_events;$i++)
226                        {
227                                echo "aaaa<br>";
228                                $rep_events = $this->repeating_events[$i];
229                                $id = $rep_events['id'];
230                                $event_beg_day = mktime(0,0,0,$rep_events['start']['month'],$rep_events['start']['mday'],$rep_events['start']['year']);
231                                if($rep_events['recur_enddate']['month'] != 0 && $rep_events['recur_enddate']['mday'] != 0 && $rep_events['recur_enddate']['year'] != 0)
232                                {
233                                        $event_recur_time = $this->maketime($rep_events['recur_enddate']);
234                                }
235                                else
236                                {
237                                        $event_recur_time = mktime(0,0,0,1,1,2030);
238                                }
239                                $end_recur_date = date('Ymd',$event_recur_time);
240                                $full_event_date = date('Ymd',$event_beg_day);
241
242                                if($this->debug)
243                                {
244                                        echo '<!-- check_repeating_events - Processing ID - '.$id.' -->'."\n";
245                                        echo '<!-- check_repeating_events - Recurring End Date - '.$end_recur_date.' -->'."\n";
246                                }
247
248                                // only repeat after the beginning, and if there is an rpt_end before the end date
249                                if (($search_date_full > $end_recur_date) || ($search_date_full < $full_event_date))
250                                {
251                                        continue;
252                                }
253
254                                if ($search_date_full == $full_event_date)
255                                {
256                                        $this->sort_event($rep_events,$search_date_full);
257                                        continue;
258                                }
259                                else
260                                {
261                                        $freq = $rep_events['recur_interval'];
262                                        $freq = $freq ? $freq : 1;
263                                        $type = $rep_events['recur_type'];
264                                        switch($type)
265                                        {
266                                                case MCAL_RECUR_DAILY:
267                                                        if($this->debug)
268                                                        {
269                                                                echo '<!-- check_repeating_events - MCAL_RECUR_DAILY - '.$id.' -->'."\n";
270                                                        }
271                                                       
272                                                        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)
273                                                        {
274                                                                $this->sort_event($rep_events,$search_date_full);
275                                                        }
276                                                        elseif (floor(($search_beg_day - $event_beg_day)/86400) % ($freq ? $freq : 1))
277                                                        {
278                                                                continue;
279                                                        }
280                                                        else
281                                                        {
282                                                                $this->sort_event($rep_events,$search_date_full);
283                                                        }
284                                                        break;
285                                                case MCAL_RECUR_WEEKLY:
286                                                        if (floor(($search_beg_day - $event_beg_day)/604800)  % ($freq ? $freq : 1))
287                                                        {
288                                                                continue;
289                                                        }
290                                                        $check = 0;
291                                                        switch($search_date_dow)
292                                                        {
293                                                                case 0:
294                                                                        $check = MCAL_M_SUNDAY;
295                                                                        break;
296                                                                case 1:
297                                                                        $check = MCAL_M_MONDAY;
298                                                                        break;
299                                                                case 2:
300                                                                        $check = MCAL_M_TUESDAY;
301                                                                        break;
302                                                                case 3:
303                                                                        $check = MCAL_M_WEDNESDAY;
304                                                                        break;
305                                                                case 4:
306                                                                        $check = MCAL_M_THURSDAY;
307                                                                        break;
308                                                                case 5:
309                                                                        $check = MCAL_M_FRIDAY;
310                                                                        break;
311                                                                case 6:
312                                                                        $check = MCAL_M_SATURDAY;
313                                                                        break;
314                                                        }
315                                                        if ($rep_events['recur_data'] & $check)
316                                                        {
317                                                                $this->sort_event($rep_events,$search_date_full);
318                                                        }
319                                                        break;
320                                                case MCAL_RECUR_MONTHLY_WDAY:
321                                                        if ((($search_date_year - $rep_events['start']['year']) * 12 + $search_date_month - $rep_events['start']['month']) % $freq)
322                                                        {
323                                                                continue;
324                                                        }
325
326                                                        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)) &&
327                                                                (ceil($rep_events['start']['mday']/7) == ceil($search_date_day/7)))
328                                                        {
329                                                                $this->sort_event($rep_events,$search_date_full);
330                                                        }
331                                                        break;
332                                                case MCAL_RECUR_MONTHLY_MDAY:
333                                                        if ((($search_date_year - $rep_events['start']['year']) * 12 + $search_date_month - $rep_events['start']['month'])  % ($freq ? $freq : 1))
334                                                        {
335                                                                continue;
336                                                        }
337                                                        if ($search_date_day == $rep_events['start']['mday'])
338                                                        {
339                                                                $this->sort_event($rep_events,$search_date_full);
340                                                        }
341                                                        break;
342                                                case MCAL_RECUR_YEARLY:
343                                                        if (($search_date_year - $rep_events['start']['year']) % ($freq ? $freq : 1))
344                                                        {
345                                                                continue;
346                                                        }
347                                                        if (date('dm',$datetime) == date('dm',$event_beg_day))
348                                                        {
349                                                                $this->sort_event($rep_events,$search_date_full);
350                                                        }
351                                                        break;
352                                        }
353                                }
354                        }       // end for loop
355                }       
356                       
357                //      return $retval;
358       
359       
360        $GLOBALS['phpgw']->common->phpgw_exit();
361
362?>
363
Note: See TracBrowser for help on using the repository browser.