source: contrib/Resources/inc/class.uiresourcescal.inc.php @ 4362

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

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

Line 
1<?php
2  /**************************************************************************\
3  * eGroupWare - resources                                                    *
4  * http://www.eGroupWare.org                                                *
5  * Maintained and further developed by RalfBecker@outdoor-training.de       *
6  * Based on Webresources by Craig Knudsen <cknudsen@radix.net>               *
7  *          http://www.radix.net/~cknudsen                                  *
8  * Originaly modified by Mark Peters <skeeter@phpgroupware.org>             *
9  * --------------------------------------------                             *
10  *  This program is free software; you can redistribute it and/or modify it *
11  *  under the terms of the GNU General Public License as published by the   *
12  *  Free Software Foundation; either version 2 of the License, or (at your  *
13  *  option) any later version.                                              *
14  \**************************************************************************/
15
16
17        class uiresourcescal
18        {
19                var $dbb;
20                var $template;
21                var $cat;
22                var $debug = False;
23                var $cat_id;
24                var $theme;
25                var $link_tpl;
26                var $public_functions = array(
27               
28                'search4' => True,'search5' => True             
29                );
30
31
32
33
34        var $prefs;
35       
36        var $bo;
37
38        var $link;
39       
40        var $tmpl;
41
42        var $html;
43
44        var $duration_format = ',';     // comma is necessary!
45       
46       
47
48
49var $optionldap;
50
51
52               
53
54
55        function search4()
56                {
57                        $this->bo = CreateObject('resources.boresources',1);
58                       
59$this->today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime);
60
61
62
63               
64                        $error = '';
65
66
67
68                        $matches = 0;
69
70
71if (isset($_REQUEST['fecha'])){
72list($dia,$mes,$ano)=split("/",$_REQUEST['fecha']);
73if (isset($_REQUEST['fecha2'])){
74list($dia2,$mes2,$ano2)=split("/",$_REQUEST['fecha2']);
75}else{
76        list($dia2,$mes2,$ano2)=split("/",$_REQUEST['fecha']);
77       
78}
79if(isset($_REQUEST['hora'])){
80list($horai,$minutoi,$horaf,$minutof)=split(":",$_REQUEST['hora']);
81}else{
82        $horai=0;
83        $minutoi=0;
84        $horaf=23;
85        $minutof=59;
86}
87        $starttimea = $this->bo->maketime2(0,0,0,$dia,$mes,$ano,'am') - $GLOBALS['phpgw']->datetime->tz_offset;
88
89
90}else{
91        $localtime = $GLOBALS['phpgw']->datetime->users_localtime;
92        $ano = date('Y',$localtime);
93        $mes = date('m',$localtime);
94        $dia = date('d',$localtime);                                   
95        $ano2 = date('Y',$localtime);
96        $mes2 = date('m',$localtime);
97        $dia2 = date('d',$localtime);
98        $horai=0;
99        $minutoi=0;
100        $horaf=23;
101        $minutof=59;
102
103
104
105}
106
107$pm='pm';
108if($horaf<12){
109        $pm='am';
110}else{
111        $horaf=$horaf-12;
112}
113$am='am';
114if($horai>11){
115        $am='pm';
116        $horai=$horai-12;
117       
118}
119
120
121        $starttime = $this->bo->maketime2($horai,$minutoi,0,$dia,$mes,$ano,$am) - $GLOBALS['phpgw']->datetime->tz_offset;
122$starttime2 = $this->bo->maketime2($horaf,$minutof,59,$dia2,$mes2,$ano2,$pm) - $GLOBALS['phpgw']->datetime->tz_offset;
123
124$location='';
125if($_GET['id']!=''){
126$location=$_GET['id'];}else{
127$location='n/a';}
128
129                $date_to_eval = sprintf("%04d%02d%02d",$ano,$mes,$dia);
130               
131               
132               
133if($_GET['calid']!='0'){
134$l_ids=array($_GET['calid']);
135}else{
136        $l_ids=0;
137}
138$events=$this->bo->overlap($starttime,$starttime2,Array(),0,$l_ids,'False',$location);
139
140                                print_debug('Date',$date_to_eval);
141                                print_debug('Count',count($events));
142
143if(count($events)>0){
144                                foreach($events as $event)
145                                {
146                                        if ($this->bo->rejected_no_show($event))
147                                        {
148                                                continue;       // user does not want to see rejected events
149                                        }
150                                        if ($event['recur_type'])       // calculate start- + end-datetime for recuring events
151                                        {
152                                                $this->bo->set_recur_date($event,$date_to_eval);
153                                        }
154                               
155
156                                }
157}
158                        $date_to_eval = sprintf("%04d%02d%02d",$ano,$mes,$dia);
159
160                        $matches = count($event);
161
162$hay="Para el ".$dia."/".$mes."/".$ano."  en la sala: ".$location ." y a la hora indicada esta ocupada por:";
163                               
164                        if ($matches == 1)
165                        {
166                                $quantity = lang('1 match found').'.';
167                        }
168                        elseif ($matches > 0)
169                        {
170                                $quantity = lang('%1 matches found',$matches).'.';
171                        }
172                        else
173                        {
174                                $nohay="Para el ".$dia."/".$mes."/".$ano."  en la sala: ".$location ." y a la hora indicada por ud esta disponible.";
175                               
176                        }
177
178       
179
180$script='';
181
182               
183
184       
185
186        ?>
187        <html>
188        <head>
189        <title>Expresso CNTI [Recursos]</title>
190                <meta http-equiv="content-type" content="text/html; charset=utf-8" />
191                <meta name="language" content="es-es" />
192                <link rel="icon" href="calendar/templates/default/images/navbar.png" type="image/x-ico" />
193                <link rel="shortcut icon" href="calendar/templates/default/images/navbar.png" />
194                <META http-equiv="Default-Style" content="eGroupWareStyle">
195               
196                <script src="phpgwapi/templates/default/js/simple_show_hide.js" type="text/javascript">
197                </script>
198                <!-- This solves the Internet Explorer PNG-transparency bug, but only for IE 5.5 and higher -->
199                <!--[if lt IE 7]>
200                <script src="/expresso/phpgwapi/templates/default/js/pngfix.js" type="text/javascript">
201                </script>
202                <![endif]-->
203
204                <style type="text/css">
205<!--
206        .row_on { color: #000000; background-color: #f4f8fb; }
207        .row_off { color: #000000; background-color: #ffffff; }
208        .th { color: #000000; background-color: #D3DCE3; }
209       
210-->
211</style>
212<LINK href="phpgwapi/templates/default/css/base.css" type="text/css" rel="StyleSheet"><LINK href="phpgwapi/templates/default/css/azul.css" type="text/css" rel="StyleSheet"><LINK href="/expresso/calendar/templates/default/app.css" type="text/css" rel="StyleSheet">
213
214                <link rel="stylesheet" type="text/css" media="all" href="phpgwapi/js/jscalendar/calendar-win2k-cold-1.css" title="" />
215<script type="text/javascript" src="phpgwapi/js/jscalendar/calendar.js"></script>
216<script type="text/javascript" src="phpgwapi/inc/jscalendar-setup.php"></script>
217
218
219                <script src="phpgwapi/templates/default/js/cookieManager.js" type="text/javascript"></script>
220        </head>
221
222        <!-- we don't need body tags anymore, do we?) we do!!! onload!! LK -->
223        <body  bgcolor="#FFFFFF" alink="red" link="blue" vlink="blue" >
224
225        <?php
226
227        if(count($events)>0){
228               
229               
230        echo $hay;?><br><br>
231                <table><tr class="th">
232       
233<td width="150">Nombre</td>
234               
235<td width="300">Descripci&oacute;n</td>
236                       
237       
238<td width="100">Responsable</td>
239
240<td width="100">Hora</td>
241
242                       
243                        </tr>
244       
245        <?php
246       
247       
248                        foreach($events  as $id => $data)
249                        {
250
251                                $datetime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
252
253
254if($data['public']==1){
255        $descripcion=$data['description'];
256        $name=$data['title'];
257}else{
258        $descripcion='-';
259        $name='Privado';
260}
261
262$dueno=$this->get_account_name($data['owner'],'gecos');
263echo "<tr><td>".$name."</td><td>".$descripcion."</td><td>".$dueno."</td><td> ".$GLOBALS['phpgw']->common->show_hour($this->bo->maketime($data['start']))."-".$GLOBALS['phpgw']->common->show_hour($this->bo->maketime($data['end']))."</td></tr>";
264
265
266
267
268                        }
269                        }else{         
270                                echo $nohay;
271                        }
272                        ?>
273
274               
275                </table>
276        </td>
277        </tr>
278        </table>
279        </body>
280        </html>
281
282        <?php
283       
284
285                /*      if($matches > 0)
286                        {
287                //              $p->parse('rows','search_list_footer',True);
288                        }*/
289
290                //      $p->pparse('out','search');
291                }
292               
293
294
295
296
297        function search5()
298                {
299                        $this->bo = CreateObject('resources.boresources',1);
300                       
301$this->today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime);
302
303
304
305               
306                        $error = '';
307
308
309
310                        $matches = 0;
311
312
313if (isset($_REQUEST['fecha'])){
314list($dia,$mes,$ano)=split("/",$_REQUEST['fecha']);
315if (isset($_REQUEST['fecha2'])){
316list($dia2,$mes2,$ano2)=split("/",$_REQUEST['fecha2']);
317}else{
318        list($dia2,$mes2,$ano2)=split("/",$_REQUEST['fecha']);
319       
320}
321if(isset($_REQUEST['hora'])){
322list($horai,$minutoi,$horaf,$minutof)=split(":",$_REQUEST['hora']);
323}else{
324        $horai=0;
325        $minutoi=0;
326        $horaf=23;
327        $minutof=59;
328}
329        $starttimea = $this->bo->maketime2(0,0,0,$dia,$mes,$ano,'am') - $GLOBALS['phpgw']->datetime->tz_offset;
330
331
332}else{
333        $localtime = $GLOBALS['phpgw']->datetime->users_localtime;
334        $ano = date('Y',$localtime);
335        $mes = date('m',$localtime);
336        $dia = date('d',$localtime);                                   
337        $ano2 = date('Y',$localtime);
338        $mes2 = date('m',$localtime);
339        $dia2 = date('d',$localtime);
340        $horai=0;
341        $minutoi=0;
342        $horaf=23;
343        $minutof=59;
344
345
346
347}
348
349$pm='pm';
350if($horaf<12){
351        $pm='am';
352}else{
353        $horaf=$horaf-12;
354}
355$am='am';
356if($horai>11){
357        $am='pm';
358        $horai=$horai-12;
359       
360}
361
362
363        $starttime = $this->bo->maketime2($horai,$minutoi,0,$dia,$mes,$ano,$am) - $GLOBALS['phpgw']->datetime->tz_offset;
364$starttime2 = $this->bo->maketime2($horaf,$minutof,59,$dia2,$mes2,$ano2,$pm) - $GLOBALS['phpgw']->datetime->tz_offset;
365
366$location='';
367if($_GET['id']!=''){
368$location=$_GET['id'];}else{
369$location='n/a';}
370
371                $date_to_eval = sprintf("%04d%02d%02d",$ano,$mes,$dia);
372                //echo $_GET['participants'].size;
373
374
375               
376               
377                 
378//$participantes=Array($_GET['participants']);
379                $partes=split(",",$_GET['participants']);
380
381                                        $l_participants = array();
382
383                for ($i = 0; $i < count($partes); $i++) {
384    $l_participants[$partes[$i]]='U';
385}       
386
387if($_GET['calid']!='0'){
388$l_ids=array($_GET['calid']);
389}else{
390        $l_ids=0;
391}
392
393                                       
394$events=$this->bo->overlap($starttime,$starttime2,$l_participants,0,$l_ids,'False');
395
396
397//$events=$this->bo->overlap($starttime,$starttime2,Array(),0,0,'False',$location);
398
399                                print_debug('Date',$date_to_eval);
400                                print_debug('Count',count($events));
401
402if(count($events)>0){
403                                foreach($events as $event)
404                                {
405                                        if ($this->bo->rejected_no_show($event))
406                                        {
407                                                continue;       // user does not want to see rejected events
408                                        }
409                                        if ($event['recur_type'])       // calculate start- + end-datetime for recuring events
410                                        {
411                                                $this->bo->set_recur_date($event,$date_to_eval);
412                                        }
413                               
414
415                                }
416}
417                        $date_to_eval = sprintf("%04d%02d%02d",$ano,$mes,$dia);
418
419                        $matches = count($event);
420
421$hay="Para el ".$dia."/".$mes."/".$ano."  y a la hora indicada por ud esta(n) ocupados los participantes:";
422                               
423                        if ($matches == 1)
424                        {
425                                $quantity = lang('1 match found').'.';
426                        }
427                        elseif ($matches > 0)
428                        {
429                                $quantity = lang('%1 matches found',$matches).'.';
430                        }
431                        else
432                        {
433                                $nohay="Para el ".$dia."/".$mes."/".$ano." y a la hora indicada por ud estan disponible los participantes.";
434                               
435                        }
436
437       
438
439$script='';
440
441       
442
443        ?>
444        <html>
445        <head>
446        <title>Expresso CNTI [Recursos]</title>
447                <meta http-equiv="content-type" content="text/html; charset=utf-8" />
448                <meta name="language" content="es-es" />
449                <link rel="icon" href="calendar/templates/default/images/navbar.png" type="image/x-ico" />
450                <link rel="shortcut icon" href="calendar/templates/default/images/navbar.png" />
451                <META http-equiv="Default-Style" content="eGroupWareStyle">
452               
453                <script src="phpgwapi/templates/default/js/simple_show_hide.js" type="text/javascript">
454                </script>
455                <!-- This solves the Internet Explorer PNG-transparency bug, but only for IE 5.5 and higher -->
456                <!--[if lt IE 7]>
457                <script src="/expresso/phpgwapi/templates/default/js/pngfix.js" type="text/javascript">
458                </script>
459                <![endif]-->
460
461                <style type="text/css">
462<!--
463        .row_on { color: #000000; background-color: #f4f8fb; }
464        .row_off { color: #000000; background-color: #ffffff; }
465        .th { color: #000000; background-color: #D3DCE3; }
466       
467-->
468</style>
469<LINK href="phpgwapi/templates/default/css/base.css" type="text/css" rel="StyleSheet"><LINK href="phpgwapi/templates/default/css/azul.css" type="text/css" rel="StyleSheet"><LINK href="/expresso/calendar/templates/default/app.css" type="text/css" rel="StyleSheet">
470
471                <link rel="stylesheet" type="text/css" media="all" href="phpgwapi/js/jscalendar/calendar-win2k-cold-1.css" title="" />
472<script type="text/javascript" src="phpgwapi/js/jscalendar/calendar.js"></script>
473<script type="text/javascript" src="phpgwapi/inc/jscalendar-setup.php"></script>
474
475
476                <script src="phpgwapi/templates/default/js/cookieManager.js" type="text/javascript"></script>
477        </head>
478
479        <!-- we don't need body tags anymore, do we?) we do!!! onload!! LK -->
480        <body  bgcolor="#FFFFFF" alink="red" link="blue" vlink="blue" >
481
482        <?php           
483if(count($events)>0){
484       
485       
486        echo $hay;?><br><br>
487                <table><tr class="th">
488       
489<td width="150">Nombre</td>
490               
491<td width="300">Descripci&oacute;n</td>
492                       
493       
494<td width="100">Responsable</td>
495
496<td width="100">Participantes</td>
497
498
499<td width="100">Hora</td>
500
501                       
502                        </tr>
503       
504        <?php
505       
506       
507                        foreach($events  as $id => $data)
508                        {
509
510                                $datetime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
511
512
513if($data['public']==1){
514        $descripcion=$data['description'];
515        $name=$data['title'];
516}else{
517        $descripcion='-';
518        $name='Privado';
519}
520
521$dueno=$this->get_account_name($data['owner'],'gecos');
522
523
524$participantesreunion="";
525                        $overlapped_event = $this->bo->read_entry2($data['id'],True);
526                       
527                //      echo "rrrr".$overlapped_event."lllll".count($overlapped_event);
528                       
529                         $participantesreunion="";
530                                foreach($overlapped_event['participants'] as $id => $status)
531                                {
532                                        //$conflict = isset($event['participants'][$id]);
533                                        for ($i = 0; $i < count($partes); $i++) {
534                                                //echo $partes[$i];
535                                                if($partes[$i]==$id)
536                                                $participantesreunion .= '<li>'.$GLOBALS['phpgw']->common->grab_owner_name($id)."</li>";
537                                               
538                                        }
539                                       
540                                               
541                                }
542
543echo "<tr><td>".$name."</td><td>".$descripcion."</td><td>".$dueno."<td>".$participantesreunion."</td><td> ".$GLOBALS['phpgw']->common->show_hour($this->bo->maketime($data['start']))."-".$GLOBALS['phpgw']->common->show_hour($this->bo->maketime($data['end']))."</td></tr>";
544
545
546
547
548                        }
549                        }else{         
550                                echo $nohay;
551                        }       
552                        ?>
553
554               
555                </table>
556        </td>
557        </tr>
558        </table>
559        </body>
560        </html>
561<?php
562       
563                /*      if($matches > 0)
564                        {
565                //              $p->parse('rows','search_list_footer',True);
566                        }*/
567
568                //      $p->pparse('out','search');
569                }
570
571
572function get_type($account_id)
573                {
574                        $allValues = array();
575                        /* jakjr: using justthese with ldap_search */
576                        $sri = @ldap_search($this->ds, $this->user_context, '(&(uidnumber=' . (int)$account_id . ')(phpgwaccounttype=u))', array("phpgwaccounttype"));
577                        if(!$sri)
578                                return False;
579                        $allValues = ldap_get_entries($this->ds, $sri);
580
581                        if ($allValues[0]['phpgwaccounttype'][0])
582                        {
583                                return $allValues[0]['phpgwaccounttype'][0];
584                        }
585
586                        $allValues = array();
587                        /* jakjr: using justthese with ldap_search */
588                        $sri = @ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwaccounttype=g))', array("phpgwaccounttype"));
589                        if(!$sri)
590                                return False;
591                        $allValues = ldap_get_entries($this->ds, $sri);
592
593                        if ($allValues[0]['phpgwaccounttype'][0])
594                        {
595                                return $allValues[0]['phpgwaccounttype'][0];
596                        }
597                        return False;
598                }
599
600               
601               
602
603function get_account_name($account_id,$valor)
604                {
605                        $this->user_context  = $GLOBALS['phpgw_info']['server']['ldap_context'];
606                        $this->group_context = $GLOBALS['phpgw_info']['server']['ldap_group_context'];
607                        $acct_type = $this->get_type($account_id);
608                        $this->ds = $GLOBALS['phpgw']->common->ldapConnect();
609                        if(!$this->ds)
610                                $this->ds = $GLOBALS['phpgw']->common->ldapConnect();
611                        /* jakjr: using justthese with ldap_search */
612                        //$justthese = array("cn","uid","givenname","sn","gecos");
613
614                        /* search the dn for the given uid */
615
616$justthese = array("uidnumber",  "cn",  "mail","gecos","dn");
617                        //      $sri = @ldap_search($this->ds, "ou=usuarios,ou=cnti,dc=gob,dc=ve", ("(&(sn=*)(mail=*@*)(structuralObjectClass=inetOrgPerson)(deliveryMode=virtual))"), $justthese);
618
619                        if(($acct_type == 'g') && $this->group_context)
620                        {
621                                $sri = @ldap_search($this->ds, $this->group_context, '(gidnumber=' . (int)$account_id . ')', $justthese);
622                        }
623                        else
624                        {
625                                $sri = @ldap_search($this->ds, $this->user_context, '(uidnumber=' . (int)$account_id . ')', $justthese);
626                        }
627
628//echo $this->ds.",". $this->user_context.",". '(uidnumber=' . (int)$account_id . ')'.",". $justthese;
629                        if(!$sri)
630                                return False;
631                        $allValues = ldap_get_entries($this->ds, $sri);
632$retorna="";
633                        if($acct_type =='g')
634                        {
635                                if($valor=='gecos') {
636                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['gecos'][0],'utf-8');
637                                }
638                                if($valor=='uidnumber') {
639                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['uidnumber'][0],'utf-8');
640                                }
641                                if($valor=='cn') {
642                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8');
643                                }
644
645                                if($valor=='mail') {
646                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['mail'][0],'utf-8');
647                                }
648                                if($valor=='dn') {
649                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['dn'][0],'utf-8');
650                                }
651                               
652                        }
653                        else
654                        {
655                                if($valor=='gecos') {
656                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['gecos'][0],'utf-8');
657                                }
658                                if($valor=='uidnumber') {
659                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['uidnumber'][0],'utf-8');
660                                }
661                                if($valor=='cn') {
662                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8');
663                                }
664
665                                if($valor=='mail') {
666                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['mail'][0],'utf-8');
667                                }
668                                if($valor=='dn') {
669                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['dn'][0],'utf-8');
670                                }
671                               
672
673
674
675                        }
676                        return $retorna;
677                }
678               
679               
680}
681
682?>
Note: See TracBrowser for help on using the repository browser.