source: contrib/resources/inc/class.uiresources.inc.php @ 3524

Revision 3524, 44.0 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  * 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 uiresources
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                'index' => True,               
28                'view' => True,
29                'edit' => True,
30                'update'=> True,                               
31                'delete' => True,
32                'close'       => True,
33                'import_mail' => True,
34                'search' => True,
35                'search2' => True,
36                'header' => True,
37                'footer' => True                       
38                );
39
40
41        var $prefs;
42        /**
43         * instance of the bo-class
44         *
45         * @var boresources
46         */
47        var $bo;
48        /**
49         * reference to instance of the link-class of bo
50         *
51         * @var bolink
52         */
53        var $link;
54        /**
55         * instance of the etemplate class
56         *
57         * @var etemplate
58         */
59        var $tmpl;
60        /**
61         * reference to the html object of etemplate
62         *
63         * @var html
64         */
65        var $html;
66        /**
67         * allowed units and hours per day, can be overwritten by the projectmanager configuration, default all units, 8h
68         *
69         * @var string
70         */
71        var $duration_format = ',';     // comma is necessary!
72       
73        var $icons = array(
74                'type' => array(
75                        'task'      => 'task.png',      'task_alt'      => 'Task',
76                        'phone'     => 'phone.gpng',     'phone_alt'     => 'Phonecall',
77                        'note'      => 'note.png',      'note_alt'      => 'Note',
78                        'confirm'   => 'confirm.png',   'confirm_alt'   => 'Confirmation',
79                        'reject'    => 'reject.png',    'reject_alt'    => 'Reject',
80                        'email'     => 'email.png',     'email_alt'     => 'Email' ),
81                'action' => array(
82                        'new'       => 'new.png',       'new_alt'       => 'Add Sub',
83                        'view'      => 'view.png',      'view_alt'      => 'View Subs',
84                        'parent'    => 'parent.png',    'parent_alt'    => 'View other Subs',
85                        'edit'      => 'edit.png',      'edit_alt'      => 'Edit',
86                        'addfile'   => 'addfile.png',   'addfile_alt'   => 'Add a file',
87                        'delete'    => 'delete.png',    'delete_alt'    => 'Delete',
88                        'close'     => 'done.png',      'close_alt'     => 'Close' ),
89                'status' => array(
90                        'billed'    => 'billed.png',    'billed_alt'    => 'billed',
91                        'done'      => 'done.png',      'done_alt'      => 'done',
92                        'will-call' => 'will-call.png', 'will-call_alt' => 'will-call',
93                        'call'      => 'call.png',      'call_alt'      => 'call',
94                        'ongoing'   => 'ongoing.png',   'ongoing_alt'   => 'ongoing',
95                        'offer'     => 'offer.png',     'offer_alt'     => 'offer' )
96        );
97        var $filters = array(
98                'none'                     => 'no Filter',
99                'done'                     => 'done',
100                'responsible'              => 'responsible',
101                'responsible-open-today'   => 'responsible open',
102                'responsible-open-overdue' => 'responsible overdue',
103                'responsible-upcoming'     => 'responsible upcoming',
104                'delegated'                => 'delegated',
105                'delegated-open-today'     => 'delegated open',
106                'delegated-open-overdue'   => 'delegated overdue',
107                'delegated-upcoming'       => 'delegated upcomming',
108                'own'                      => 'own',
109                'own-open-today'           => 'own open',
110                'own-open-overdue'         => 'own overdue',
111                'own-upcoming'             => 'own upcoming',
112                'open-today'               => 'open',
113                'open-overdue'             => 'overdue',
114                'upcoming'                 => 'upcoming',
115        );
116        var $messages = array(
117                'edit'    => 'resources - Edit',
118                'add'     => 'resources - New',
119                'add_sub' => 'resources - New Subproject',
120                'sp'      => '- Subprojects from',
121                're'      => 'Re:'
122        );
123
124
125var $optionldap;
126
127        /**
128         * Constructor
129         *
130         * @return uiresources
131         */
132
133
134
135                function uiresources()
136                {
137
138
139
140
141                       
142 
143//print_r($GLOBALS);
144
145                        $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs');
146                        $this->bo = CreateObject('resources.boresources',1);
147                        $this->cat = &$this->bo->cat;
148                        //echo "pwnre".$this->bo->owner."  ".$this->bo->today."  ".$this->bo->evento;
149                        $this->dbb = CreateObject('class.DBAccess',1);
150                        $this->cat = &$this->bo->cat;
151
152
153                        $this->resources = &$this->bo->resources;
154
155                        $this->project = &$this->bo->project;
156
157$this->tarea = &$this->bo->tarea;
158
159                        print_debug('BO Owner',$this->bo->owner);
160
161                        $this->template = $GLOBALS['phpgw']->template;
162                        $this->template_dir = $GLOBALS['phpgw']->common->get_tpl_dir('resources');
163
164                        $this->cat_id   = $this->bo->cat_id;
165
166                        $this->link_tpl = CreateObject('phpgwapi.Template',$this->template_dir);
167                        $this->link_tpl->set_unknowns('remove');
168                        $this->link_tpl->set_file(
169                                Array(
170                                        'link_picture'  => 'link_pict.tpl'
171                                )
172                        );
173                        $this->link_tpl->set_block('link_picture','link_pict','link_pict');
174                        $this->link_tpl->set_block('link_picture','pict','pict');
175                        $this->link_tpl->set_block('link_picture','link_open','link_open');
176                        $this->link_tpl->set_block('link_picture','link_close','link_close');
177                        $this->link_tpl->set_block('link_picture','link_text','link_text');
178
179
180
181$this->ds = $GLOBALS['phpgw']->common->ldapConnect();
182                        if(!$this->ds)
183                                $this->ds = $GLOBALS['phpgw']->common->ldapConnect();
184                        if(!@is_object($GLOBALS['phpgw']->translation))
185                        {
186                                $GLOBALS['phpgw']->translation = CreateObject('phpgwapi.translation');
187                        }
188                        $this->user_context  = $GLOBALS['phpgw_info']['server']['ldap_context'];
189                        $this->group_context = $GLOBALS['phpgw_info']['server']['ldap_group_context'];
190               
191/*************************************************/
192
193                        $this->always_app_header = $this->bo->prefs['common']['template_set'] == 'idots';
194
195                        //print_debug('UI',$this->_debug_sqsof());
196
197                        if (!is_object($GLOBALS['phpgw']->html))
198                        {
199                                $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html');
200                        }
201                        $this->html = &$GLOBALS['phpgw']->html;
202                }
203
204                /* Public functions */
205
206               
207
208                function index($params='')
209
210                {
211
212                        if (!$params)
213                        {
214                                foreach(array('date','year','month','day') as $field)
215                                {
216                                        if (isset($_GET[$field]))
217                                        {
218                                                $params[$field] = $_REQUEST[$field];
219                                        }
220                                }
221                        }
222//$todos = $this->get_todos($todo_label);
223
224                        $GLOBALS['phpgw']->redirect($this->page('search',$params));
225                       
226                }
227
228
229               
230function page($_page='',$params='')
231                {
232                        if($_page == '')
233                        {
234                                $page_ = explode('.',$this->bo->prefs['resources']['defaultresources']);
235                                $_page = $page_[0];
236
237                                if ($_page=='planner_cat' || $_page=='planner_user')
238                                {
239                                        $_page = 'month';
240                                }
241                                elseif ($_page=='index' || ($_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year' && $_page != 'planner'))
242                                {
243                                        $_page = 'month';
244                                        $GLOBALS['phpgw']->preferences->add('resources','defaultresources','month');
245                                        $GLOBALS['phpgw']->preferences->save_repository();
246                                }
247                        }
248                        if($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home' ||
249                                strstr($GLOBALS['phpgw_info']['flags']['currentapp'],'mail'))   // email, felamimail, ...
250                        {
251                                $page_app = 'resources';
252                        }
253                        else
254                        {
255                                $page_app = $GLOBALS['phpgw_info']['flags']['currentapp'];
256                        }
257                        if (is_array($params))
258                        {
259                                $params['menuaction'] = $page_app.'.ui'.$page_app.'.'.$_page;
260                        }
261                        else
262                        {
263                                $params = 'menuaction='.$page_app.'.ui'.$page_app.'.'.$_page.$params;
264                        }
265                        return $GLOBALS['phpgw']->link('/index.php',$params);
266                }
267
268
269
270// NDEE: printer-friendly
271function printer_friendly($body,$app_header='')
272                {
273                        $_SESSION['resources']['category'] = $this->cat->formated_list('select','all',$this->bo->cat_id,'True');
274$_SESSION['resources']['resources'] = $this->resources->formated_list('select','all',$this->bo->resources_id,'True');
275                        if((!isset($GLOBALS['phpgw_info']['server']['deny_user_granres_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_granres_access']) && count($this->bo->grants) > 0)
276                                $_SESSION['resources']['cals'] = $this->bo->list_cals();
277
278                       
279                                unset($GLOBALS['phpgw_info']['flags']['noheader']);
280                                unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
281                                unset($GLOBALS['phpgw_info']['flags']['noappheader']);
282                                unset($GLOBALS['phpgw_info']['flags']['noappfooter']);
283                                if ($app_header && $this->always_app_header)
284                                {
285                                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['resources']['title'].' - '.$app_header;
286                                }
287                               
288                                $GLOBALS['phpgw']->common->phpgw_header();
289                               
290                        return $new_body;
291                }
292
293
294
295
296
297function normalizeminutes(&$minutes)
298                {
299                        $hour = 0;
300                        $min = (int)$minutes;
301                        if($min >= 60)
302                        {
303                                $hour += $min / 60;
304                                $min %= 60;
305                        }
306                        settype($minutes,'integer');
307                        $minutes = $min;
308                        return $hour;
309                }
310
311                function header()
312                {
313                        $cols = 8;
314                        if($this->bo->check_perms(PHPGW_ACL_PRIVATE) == True)
315                        {
316                                $cols++;
317                        }
318
319                        $tpl = $GLOBALS['phpgw']->template;
320                        $tpl->set_unknowns('remove');
321
322                        if (!file_exists($file = $this->template_dir.'/header.inc.php'))
323                        {
324                                $file = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/resources/templates/default/header.inc.php';
325                        }
326
327                        include($file);
328                        $refer = explode('.',$GLOBALS['HTTP_GET_VARS']['menuaction']);
329                        if($refer[2] != 'view') {
330                        $header = $tpl->fp('out','head');
331                        unset($tpl);
332                        echo $header;
333                }
334                        unset($tpl);
335                }
336
337                function footer()
338                {
339                        $menuaction = $_GET['menuaction'];
340                        list(,,$method) = explode('.',$menuaction);
341
342                        if (@$this->bo->printer_friendly)
343                        {
344                                return;
345                        }
346
347                        $p = $GLOBALS['phpgw']->template;
348
349                        $p->set_file(
350                                Array(
351                                        'footer'        => 'footer.tpl',
352                                        'form_button'   => 'form_button_script.tpl'
353                                )
354                        );
355                        $p->set_block('footer','footer_table','footer_table');
356                        $p->set_block('footer','footer_row','footer_row');
357                        $p->set_block('footer','blank_row','blank_row');
358                        $p->set_block('footer','num_dias','num_dias');
359
360                        $m = $this->bo->month;
361                        $y = $this->bo->year;
362
363                        $hoje = date('Ymd',$GLOBALS['phpgw']->datetime->gmtnow);
364                        $mes_hoje = (int)substr($hoje,4,2);
365                        $mes_footer = (int)substr($_POST['date'],4,2);
366                        if($_GET['sday'])
367                        {
368                                if($_GET['month'] == $mes_hoje)
369                                {
370                                        $day = $this->bo->day;
371                                }
372                                else
373                                {
374                                        $day = $_GET['sday'];
375                                }
376                        }
377                        else
378                        {
379                                $day = $this->bo->day;
380                                $dia_ini = $day;
381                        }
382                        if($mes_footer == $mes_hoje)
383                        {
384                                $dia_ini = (int)substr($hoje,6,2);
385                                $day = $dia_ini;
386                        }
387                       
388                        /********************************************************************************************/
389
390                }
391
392               
393
394
395
396
397/****************************************************************************************/
398
399
400function edit($cd=0,$readsess=0)
401                {
402
403                        $this->today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime);
404
405
406
407
408                        if(!$this->bo->check_perms(PHPGW_ACL_ADD))
409                        {
410                                $this->index();
411                        }
412                       
413                        if($readsess)
414                        {
415
416                                $event = $this->bo->restore_from_appsession;
417                                if(!$event['owner'])
418                                {
419                                        $this->bo->add_attribute('owner',$this->bo->owner);
420                                }
421                                $can_edit = True;
422                        }
423                        else
424                        {
425
426
427                                $this->bo->event_init();
428                                $this->bo->add_attribute('id',0);
429
430                                $can_edit = True;
431                                $participants = (string)(get_var('participants',array('GET'),FALSE));
432                                $starthour = (int)(get_var('hour',array('GET'),$this->bo->prefs['resources']['workdaystarts']));
433                                $startmin  = (int)(get_var('minute',array('GET'),0));
434                                $endmin    = $startmin + (int)$this->bo->prefs['resources']['defaultlength'];
435                                $endhour   = $starthour + $this->bo->normalizeminutes($endmin);
436                               
437                                $subject        = (string)(get_var('title',array('GET'),0));
438                                if ($subject != '0')
439                                {
440                                        $description    = (string)(get_var('description',array('GET'),0));
441                                        $description1   = (string)(get_var('description1',array('GET'),0));
442                                        $location       = (string)(get_var('location',array('GET'),0));
443                                }
444                                else
445                                        unset($subject);
446                               
447                                $this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$starthour,$startmin,0);
448                                $this->bo->set_end($this->bo->year,$this->bo->month,$this->bo->day,$endhour,$endmin,0);
449
450
451                                if(@$this->bo->prefs['resources']['default_private'])
452                                {
453                                        $this->bo->set_class(False);
454                                }
455                                else
456                                {
457                                        $this->bo->set_class(True);
458                                }
459                               
460                                $event = $this->bo->restore_from_appsession;
461                               
462                        }
463if(isset($_REQUEST['error'])){
464$cd=$_REQUEST['error'];
465}
466                        $this->edit_form(
467                                Array(
468                                        'event' => $event,
469                                        'cd' => $cd,
470                                        'plain' => $_GET['plain']
471                                )
472                        );
473                        $GLOBALS['phpgw']->common->phpgw_footer();
474                }
475
476
477function edit_form($param)
478                {
479
480
481if(isset($_REQUEST['id'])){
482                        $event=$this->select($_REQUEST['id']);
483}else{
484$event=$this->select_init();
485}
486
487                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
488
489
490                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
491                       
492       
493$justthese = array("uidnumber", "gidnumber", "uid", "cn", "givenname", "sn", "mail","telephonenumber","gecos","dn");
494                                $sri = @ldap_search($this->ds, "ou=usuarios,ou=cnti,dc=gob,dc=ve", ("(&(sn=*)(mail=*@*)(structuralObjectClass=inetOrgPerson)(deliveryMode=virtual))"), $justthese);
495               
496
497if(!$sri)
498                                return null;
499                        $allValues = ldap_get_entries($this->ds, $sri);
500
501
502
503$ttt=count($allValues);
504
505for($i=0;$i<$ttt;$i++){
506
507                                                        if(isset($allValues[$i]['mail'][0]))
508                                {
509                                                                $option = '    <option  value="' . $allValues[$i]['uidnumber'][0] . '" >'.$allValues[$i]['gecos'][0].'</option>'."\n";
510                                                                $optionldap .= $option;
511                                                                $option2 = '    <option  value="' . $allValues[$i]['uidnumber'][0] . '" >'.$allValues[$i]['gecos'][0].'</option>'."\n";
512                                                                $optionldap2 .= $option2;
513}
514
515
516
517
518}
519
520
521
522
523
524                        if(!is_array($param))
525                        {
526                                $this->index();
527                        }
528                       
529                        if(isset($param['event']))
530                        {
531                                $event = $param['event'];
532                        }
533                       
534                        $hourformat = substr($this->bo->users_timeformat,0,1);
535                       
536                        $jscal = CreateObject('phpgwapi.jscalendar');   // before phpgw_header() !!!
537                       
538                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
539                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
540                        $GLOBALS['phpgw_info']['flags']['noappheader'] = True;
541                        $GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
542                        $GLOBALS['phpgw_info']['flags']['app_header'] = $event['id'] ? lang('Editing event') : lang('Adding resources');
543                        if ($param['plain'] != "True"){
544                                $GLOBALS['phpgw']->common->phpgw_header();
545                        }
546                        else{
547                                $GLOBALS['phpgw_info']['theme']['row_on'] = "F8F8F8";
548                                $GLOBALS['phpgw_info']['theme']['row_off'] = "F8F8F8";
549                        }
550
551                        $p = &$GLOBALS['phpgw']->template;
552                        $p->set_file(
553                                Array(
554                                        'edit'          => 'edit.tpl',
555                                        'form_button'   => 'form_button_script.tpl'
556                                )
557                        );
558                        $p->set_block('edit','edit_entry','edit_entry');
559                        $p->set_block('edit','list','list');
560                        $p->set_block('edit','hr','hr');
561
562                        $vars = Array(
563                                'font'                  => $this->theme['font'],
564                                'bg_color'              => $this->theme['bg_text'],
565                                'action_url'            => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'resources.uiresources.update')),
566                                'accounres_link'                => $GLOBALS['phpgw']->link('/index.php','menuaction=resources.uiresources.accounres_popup'),
567                                'common_hidden' => '<input type="hidden" name="resources[id]" value="'.$event['id'].'">'."\n"
568                                        . '<input type="hidden" name="resources[owner]" value="'.$event['owner'].'">'."\n"
569                                        . (@isset($GLOBALS['phpgw_info']['server']['deny_user_granres_access']) && $GLOBALS['phpgw_info']['server']['deny_user_granres_access']?
570                                        '<input type="hidden" name="participants[]" value="'.$this->bo->owner.'">'."\n":''),
571                                'errormsg'              => ($param['cd']?$GLOBALS['phpgw']->common->check_code($param['cd']):'')
572                        );
573                       
574                        $p->set_var($vars);
575
576// res_type
577        //echo $event['type'];         
578
579
580// Display Categories
581                        if(strpos($event['category'],','))
582                        {
583                                $temp_cats = explode(',',$event['category']);
584                                @reset($temp_cats);
585                                while(list($key,$value) = each($temp_cats))
586                                {
587                                        $check_cats[] = (int)$value;
588                                }
589                        }
590                        elseif($event['category'])
591                        {
592                                $check_cats[] = (int)$event['category'];
593                        }
594                        else
595                        {
596                                $check_cats[] = 0;
597                        }
598                        $var['category'] = Array(
599                                'field' => lang('Category'),
600                                'data'  => '<select name="resources[category]" onchange="javascript:updateTitleField(this)" >'.$this->cat->formated_list('select','all',$check_cats,True).'</select>'
601                        );
602       
603
604
605
606
607// nombre
608                        $var['name'] = Array(
609                                'field' => lang('name'),
610                                'data'  => '<input type="text" name="resources[name]" maxlength="255" value="'.$event['name'].'">'
611                        );
612
613
614// location
615                        $var['location'] = Array(
616                                'field' => lang('location'),
617                                'data'  => '<input type="text" name="resources[location]" maxlength="255" value="'.$event['location'].'">'
618                        );
619
620
621//cantidad
622                        $var['cantidad'] = Array(
623                                'field' => lang('quantity'),
624                                'data'  => '<input type="text" name="resources[cantidad]" maxlength="255" value="'.$event['cantidad'].'">'
625                        );
626
627
628
629
630// Full Description
631                        $var['description'] = Array(
632                                'field' => lang('Description'),
633                                'data'  => '<textarea name="resources[description]" rows="5" cols="40" wrap="virtual" maxlength="2048">'.$event['descripcion'].'</textarea>'
634                        );
635
636
637
638
639//responsable
640                        if(!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access'])
641                        {
642                               
643                                       
644                                                $str2 = utf8_decode($optionldap2);
645                                               
646                                                $var['administrador'] = array
647                                                (
648                                                        'field' => lang('Responsable'),                                                 
649                                                        'data'  => "
650                                                                        <select id='user_list' name='resources[administrador]' style='width: 220px' ><option value=0>seleccione</option>".$str2."</select>                                                                             
651                                                                                       
652                                                                       
653                                                                        "
654                                                );
655                                                                       
656                                               
657                                               
658                                               
659                                               
660                                }
661
662//email
663                        $var['email'] = Array(
664                                'field' => lang('email'),
665                                'data'  => '<input type="text" name="resources[email]" maxlength="255" value="'.$event['email'].'">'
666                        );
667
668
669$valorfechainicio=$this->bo->time2array($event['fechainicio'],$alarm = 0);
670$start=$valorfechainicio['mday']."/".$valorfechainicio['month']."/".$valorfechainicio['year'];
671                        $var['startdate'] = Array(
672                                'field' => lang('Start Date'),
673
674                                'data' => $jscal->input('start[str]',$start)
675                        );
676
677
678//                      $this->output_template_array($p,'row','list',Array('data' => '<script src="simple_show_hide.js" type="text/javascript"></script>'));
679
680                        if (!isset($this->fields))
681                        {
682                                $this->custom_fields = CreateObject('resources.bocustom_fields');
683                                $this->fields = &$this->custom_fields->fields;
684                                $this->stock_fields = &$this->custom_fields->stock_fields;
685                        }
686                //      $this->output_template_array($p,'row','list',$var['access']);
687                        unset($var['access']);
688
689                        $preserved = False;
690                        foreach($this->fields as $field => $data)
691                        {
692
693                                if (!$data['disabled'])
694                                {
695
696
697                                        if (isset($var[$field]))
698                                        {
699
700
701                                                switch($field)
702                                                {
703                                                        case 'startdate':
704                                                                $this->output_template_array($p,'row','list',$var['startdate']);
705                                                                $this->output_template_array($p,'row','list',$var['starttime']);
706                                                                break;
707                                                        case 'enddate':
708                                                                $this->output_template_array($p,'row','list',$var['enddate']);
709                                                                $this->output_template_array($p,'row','list',$var['endtime']);
710                                                                break;
711                                                        case 'recure_type':
712                                                                $p->set_var('tr_color',$this->theme['th_bg']);
713                                                                $p->set_var('hr_text','<center id="rpt_label"><b>'.lang('Repeating Event Information').'</b></center>');
714                                                                $p->parse('row','hr',True);
715                                                                $this->output_template_array($p,'row','list',$var['recure_type']);
716                                                                $this->output_template_array($p,'row','list',$var['recure_enddate']);
717                                                                $this->output_template_array($p,'row','list',$var['recure_day']);
718                                                                $this->output_template_array($p,'row','list',$var['recure_interval']);
719                                                                break;
720                                                        default:
721                                                                $this->output_template_array($p,'row','list',$var[$field]);
722
723                                                }
724                                        }
725                                        elseif (!isset($this->stock_fields[$field]))    // Custom field
726                                        {
727
728
729                                                $lang = lang($name = substr($field,1));
730                                                $size = 'SIZE='.($data['shown'] ? $data['shown'] : ($data['length'] ? $data['length'] : 30)).
731                                                        ' MAXLENGTH='.($data['length'] ? $data['length'] : 255);
732                                                $v = array(
733                                                        'field' => $lang == $name.'*' ? $name : $lang,
734                                                        'data'  => '<input name="cal['.htmlspecialchars($field).']" '.$size.' value="'.$event['#'.$name].'">'
735                                                );
736                                                if ($data['title'])
737                                                {
738                                                        $v['tr_color'] = $this->theme['th_bg'];
739                                                }
740                                                if (!$data['length'] && $data['title'])
741                                                {
742                                                        $p->set_var('tr_color',$this->theme['th_bg']);
743                                                        $p->set_var('hr_text','<center><b>'.$v['field'].'</b></center>');
744                                                        $p->parse('row','hr',True);
745                                                }
746                                                else
747                                                {
748                                                        $this->output_template_array($p,'row','list',$v);
749                                                }
750                                        }
751                                }
752                                else    // preserve disabled fields
753                                {
754
755
756                                        switch ($field)
757                                        {
758                                                case 'owner':
759                                                        $preserved[$field] = $event['id'] ? $event['participants'][$event['owner']] : 'A';
760                                                        break;
761                                                case 'recure_type':
762                                                        foreach(array('recur_type','recur_enddate','recur_data','recur_interval') as $field)
763                                                        {
764                                                                $preserved[$field] = $event[$field];
765                                                        }
766                                                        break;
767                                                case 'startdate':
768                                                case 'enddate':
769                                                        $field = substr($field,0,-4);
770                                                default:
771                                                        $preserved[$field] = $event[$field];
772                                        }
773                                }
774                        }
775                        unset($var);
776                        if (is_array($preserved))
777                        {
778                                //echo "preserving<pre>"; print_r($preserved); echo "</pre>\n";
779                                $p->set_var('common_hidden',$p->get_var('common_hidden').'<input type="hidden" name="preserved" value="'.htmlspecialchars(serialize($preserved)).'">'."\n");
780                        }
781                        $p->set_var('submit_button',lang('Save'));
782
783                        $delete_button = $cancel_button = '';
784                        if ($event['id'] > 0)
785                        {
786                                $var = Array(
787                                        'action_url_button'     => $this->page('delete','&cal_id='.$event['id']),
788                                        'action_text_button'    => lang('Delete'),
789                                        'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"",
790                                        'action_extra_field'    => '',
791                                        'button_id'     =>      'delete_button'
792                                );
793                                $p->set_var($var);
794                                $delete_button = $p->fp('out','form_button');
795                        }
796                        $p->set_var('delete_button',$delete_button);
797                        $p->set_var('alert_msg',lang('Required field (category) is empty'));
798
799                        if ($this->bo->return_to)
800                        {
801                                $var = Array(
802                                        'action_url_button'     => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to),
803                                        'action_text_button'    => lang('Cancel'),
804                                        'action_confirm_button' => '',
805                                        'action_extra_field'    => '',
806                                        'button_id'     =>      'cancel_button'
807                                );
808                                $p->set_var($var);
809                                $cancel_button = $p->fp('out','form_button');
810                        }
811                        $p->set_var('cancel_button',$cancel_button);
812                        $p->pparse('out','edit_entry');
813                }
814
815        function output_template_array(&$p,$row,$list,$var)
816                {
817                        if (!isset($var['hidden_vars']))
818                        {
819                                $var['hidden_vars'] = '';
820                        }
821                        if (!isset($var['tr_color']))
822                        {
823                                $var['tr_color'] = $GLOBALS['phpgw']->nextmatchs->alternate_row_color();
824                        }
825                        $p->set_var($var);
826                        $p->parse($row,$list,True);
827                }
828
829
830function get_organizations($context, $selected='', $recursive = false)
831                {
832                        $s = CreateObject('phpgwapi.sector_search_ldap');
833                                               
834                        return ($recursive ?
835                                $s->get_organizations($context, $selected, false ,true) :
836                                $s->get_sectors($selected, false, false));
837                }       
838       
839
840
841
842/**********************************************/
843
844
845function _debug_sqsof()
846                {
847                        $data = array(
848                                'filter'     => $this->bo->filter,
849                                'cat_id'     => $this->bo->cat_id,
850                                'owner'      => $this->bo->owner,
851                                'year'       => $this->bo->year,
852                                'month'      => $this->bo->month,
853                                'day'        => $this->bo->day,
854                                'sortby'     => $this->bo->sortby,
855                                'num_months' => $this->bo->num_months
856                        );
857                        Return _debug_array($data,False);
858                }
859
860
861
862
863/***********************************/
864
865
866
867
868function search()
869                {
870
871//print_r($_REQUEST);
872//echo "kkkkkkkkkkk".$_REQUEST['errormsg'];
873
874
875                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
876                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
877                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['resources']['title'].' - '.lang('Search Results');
878                        $GLOBALS['phpgw']->common->phpgw_header();
879
880                        $error = '';
881
882                        $matches = 0;
883
884                //$event = $this->bo->read_entry($res_id);     
885$event = $this->get_event_ids($adicional);
886
887
888                        //$event_ids = $this->bo->search_keywords($_POST['keywords']);
889
890                       
891                        $matches = count($event);
892
893//echo "matches" . $matches;
894
895                        if ($matches == 1)
896                        {
897                                $quantity = lang('1 match found').'.';
898                        }
899                        elseif ($matches > 0)
900                        {
901                                $quantity = lang('%1 matches found',$matches).'.';
902                        }
903                        else
904                        {
905                                echo lang('no matches found');
906                                return;
907                        }
908
909                        $p = $GLOBALS['phpgw']->template;
910                        $p->set_file(
911                                Array(
912                                        'search_form'   => 'search.tpl'
913                                )
914                        );
915                        $p->set_block('search_form','search','search');
916                        $p->set_block('search_form','search_list_header','search_list_header');
917                        $p->set_block('search_form','search_list','search_list');
918                        $p->set_block('search_form','search_list_footer','search_list_footer');
919
920
921$script='';
922
923               
924
925                        if($matches > 0)
926                        {
927                                $p->parse('rows','search_list_header',True);
928                        }
929
930//if($info){
931                        foreach($event  as $id => $data)
932                        {
933
934
935                                $datetime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
936
937
938
939
940                                $info = array(
941                                        'tr_color'      => $GLOBALS['phpgw']->nextmatchs->alternate_row_color(),
942                                        'date'          => $GLOBALS['phpgw']->common->show_date($datetime),
943'id'    => $data['id'],
944                                        'name'         => $data['name'],
945                                        'description'         => $data['short_description'],
946                                        'category'         => $data['cat_name'],
947                                        'picture_src' => $data['picture_src'],
948                                        'administrador'=>$data['administrador'],
949                                        'email'=>$data['email'],
950                                        'owner'=>$data['owner'],
951
952
953
954'accionmodificar'       =>'index.php?menuaction=resources.uiresources.edit&id='. $data['id'],
955'accionlistar'  =>'index.php?menuaction=resources.uiresources.search2&id='.  $data['name'],
956'accionborrar'  =>'index.php?menuaction=resources.uiresources.delete&id='. $data['id'],
957'accionreservar'        =>'index.php?menuaction=calendar.uicalendar.add&location='. $data['name']
958                                );
959
960
961
962//'accionagregar'       =>'index.php?menuaction=resources.uiresources.edit&parent='. $data['id']
963$p->set_var($info);
964                                $p->set_var($data);
965                                $p->parse('rows','search_list',True);
966                        }
967//      }
968                        if($matches > 0)
969                        {
970                                $p->parse('rows','search_list_footer',True);
971                        }
972
973                        $p->pparse('out','search');
974                }
975
976
977function get_event_ids($search)
978                {
979//echo "tamannn".count($search)."  ".$search[0];
980
981$from ="";
982//if (isset($_REQUEST['id'])){
983
984        //              $from = ' and t1.res_id='.$_REQUEST['id'];
985        //              }
986
987                        $sql = 'select t1.*,t2.cat_name from   phpgw_resources t1 ,phpgw_categories t2 where t1.cat_id=t2.cat_id '
988                                        . $from;
989                                        //.$search;
990                                        //. 'WHERE (phpgw_cal_user.res_id = phpgw_cal.res_id) '
991                                        //. $where . $extra;
992
993
994//echo "FULL SQL : ".$sql."<br>\n";
995
996
997                        if($this->debug)
998                        {
999                                echo "FULL SQL : ".$sql."<br>\n";
1000                        }
1001
1002 //$resultado=pg_query($this->bo->connect(),$sql) or die("Error al mostrar");
1003
1004
1005$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
1006while( $GLOBALS['phpgw']->db->next_record() )
1007                        {
1008                        //     
1009
1010$valorfechaini=$this->bo->time2array($GLOBALS['phpgw']->db->f('res_start'),$alarm = 0);
1011$ini=$valorfechaini['mday']."/".$valorfechaini['month']."/".$valorfechaini['year'];
1012
1013$valorfechaend=$this->bo->time2array($GLOBALS['phpgw']->db->f('res_end'),$alarm = 0);
1014$end=$valorfechaend['mday']."/".$valorfechaend['month']."/".$valorfechaend['year'];
1015
1016$valorfechaend2=$this->bo->time2array($GLOBALS['phpgw']->db->f('res_modified'),$alarm = 0);
1017$end2=$valorfechaend2['mday']."/".$valorfechaend2['month']."/".$valorfechaend2['year'];
1018
1019$imagen2="";
1020if($GLOBALS['phpgw']->db->f('picture_src')!=""){
1021$imagen2="<img src='".$GLOBALS['phpgw_info']['server']['webserver_url']."/resources/templates/default/images/resource_icons/".$GLOBALS['phpgw']->db->f('picture_src')."'>";
1022}
1023
1024
1025
1026$retval[] =  array(
1027
1028'id'    => $GLOBALS['phpgw']->db->f('res_id'),
1029                                        'name'         => $GLOBALS['phpgw']->db->f('name'),
1030                                        'description'         => $GLOBALS['phpgw']->db->f('short_description'),
1031                                        'category'         => $GLOBALS['phpgw']->db->f('cat_name'),
1032                                        'picture_src' => $imagen2,
1033                                        'administrador'=>$GLOBALS['phpgw']->db->f('administrador'),
1034                                        'location'=>$GLOBALS['phpgw']->db->f('location'),
1035                                        'email'=>$GLOBALS['phpgw']->db->f('email'),
1036                                        'owner'=>$GLOBALS['phpgw']->db->f('owner')
1037
1038                                       
1039                                );
1040
1041
1042                        }
1043               
1044
1045
1046                       
1047                        return $retval;
1048                }
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060function update()
1061                {
1062
1063
1064
1065#  $vars = get_defined_vars(); 
1066#   print_r($vars);
1067/*foreach($_POST as $k=>$v){
1068$$k=$v;
1069echo $$k."<br>";
1070}
1071foreach($_POST as $nombre_campo => $valor){
1072   $asignacion = "\$" . $nombre_campo . "='" . $valor . "';";
1073   echo $asignacion."<br>";
1074} */
1075
1076
1077
1078
1079
1080
1081
1082unset($GLOBALS['phpgw_info']['flags']['noheader']);
1083                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
1084                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['resources']['title'].' - '.lang('Search Results');
1085                        $GLOBALS['phpgw']->common->phpgw_header();
1086
1087                        $error = '';
1088
1089                        $matches = 0;
1090
1091
1092
1093
1094
1095list($dia,$mes,$ano)=split("/",$_POST['start']['str']);
1096
1097        $starttime = $this->bo->maketime2($_POST['start']['hour'],$_POST['start']['min'],0,$dia,$mes,$ano,$_POST['start']['ampm']) - $GLOBALS['phpgw']->datetime->tz_offset;
1098//echo $starttime;
1099
1100list($dia2,$mes2,$ano2)=split("/",$_POST['end']['str']);
1101
1102        $endtime = $this->bo->maketime2($_POST['end']['hour'],$_POST['end']['min'],0,$dia2,$mes2,$ano2,$_POST['end']['ampm']) - $GLOBALS['phpgw']->datetime->tz_offset;
1103//echo "gggg".$_POST['end2']['month'];
1104if($_POST['end2']['str']['month']>0){
1105list($dia3,$mes3,$ano3)=split("/",$_POST['end2']['str']);
1106        $endtime2 = $this->bo->maketime2($_POST['end2']['hour'],$_POST['end2']['min'],0,$dia3,$mes3,$ano3,$_POST['end2']['ampm']) - $GLOBALS['phpgw']->datetime->tz_offset;
1107}else{
1108$endtime2=0;
1109}
1110 
1111                        //$starttime = $this->bo->maketime2($starthora,$startmin,0,$startfecha) - $GLOBALS['phpgw']->datetime->tz_offset;
1112//echo "kkkk3".$_POST['exec']['accesso'];
1113if($_REQUEST['resources']['parent']==""){
1114$parent=0;
1115
1116}else{
1117$parent=$_REQUEST['resources']['parent'];
1118
1119}
1120$resources=Array(
1121name=>$_POST['resources']['name'],
1122descripction=>$_POST['resources']['description']
1123);
1124$valores="&name=".$_POST['resources']['name']."&description=".$_POST['resources']['description']."&category=".$_POST['resources']['category']."&cantidad=".$_POST['resources']['cantidad']."&email=".$_POST['resources']['email']."&administrador=".$_POST['resources']['administrador']."&location=".$_POST['resources']['location']."";
1125
1126//$GLOBALS['phpgw']->redirect($this->page($valores,''));
1127if($_POST['resources']['name']==""){
1128$GLOBALS['phpgw']->redirect($this->page('edit&error=44'.$valores,''));
1129}
1130if($_POST['resources']['location']==""){
1131$GLOBALS['phpgw']->redirect($this->page('edit&error=45'.$valores,''));
1132}
1133if($_POST['resources']['cantidad']==""){
1134$GLOBALS['phpgw']->redirect($this->page('edit&error=46'.$valores,''));
1135}
1136if($_POST['resources']['email']==""){
1137$GLOBALS['phpgw']->redirect($this->page('edit&error=47'.$valores,''));
1138}
1139if($_POST['resources']['description']==""){
1140$GLOBALS['phpgw']->redirect($this->page('edit&error=48'.$valores,''));
1141}
1142
1143/*ExecMethod('resources.uiresources.edit',                      Array(
1144                                                        'cd'            => 13,
1145                                                        'readsess'      => 1
1146                                                )
1147                                        );*/
1148
1149//$parms['errormsg']=$GLOBALS['phpgw']->common->check_code(13);
1150//echo $GLOBALS['phpgw']->common->check_code(13);
1151//ExecMethod('resources.uiresources.index',$parms);
1152//      $GLOBALS['phpgw']->common->phpgw_exit();
1153
1154                //      $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset;
1155if(isset($_POST['resources']['id'])&&$_POST['resources']['id']>0){
1156                        $sql = "update  phpgw_resources set  name='".$_POST['resources']['name']."',short_description='".$_POST['resources']['description']."',cat_id=".$_POST['resources']['category'].",quantity=".$_POST['resources']['cantidad'].",location='".$_POST['resources']['location']."',picture_src='".$_POST['resources']['picture_src']."',  administrador='". $this->get_account_name($_POST['resources']['administrador'],'gecos')."',email='".$_POST['resources']['email']."',owner=".$_POST['resources']['owner']."  where res_id='".$_POST['resources']['id']."'";
1157}else{
1158                        $sql = "insert into  phpgw_resources (name,short_description,cat_id,quantity,location,picture_src,  administrador,email,owner)
1159values ('".$_POST['resources']['name']."','".$_POST['resources']['description']."',".$_POST['resources']['category'].",".$_POST['resources']['cantidad'].",'". $this->get_account_name($_POST['resources']['administrador'],'gecos')."','".$_POST['resources']['picture_src']."','".$_POST['resources']['administrador']."','".$_POST['resources']['email']."',".$_POST['resources']['owner'].")";
1160
1161
1162
1163 
1164}
1165
1166$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);   
1167$GLOBALS['phpgw']->redirect($this->page('edit&error=14',''));
1168
1169
1170return "";
1171                }
1172
1173
1174
1175
1176function get_account_name($account_id,$valor)
1177                {
1178                        $acct_type = $this->get_type($account_id);
1179
1180                        /* jakjr: using justthese with ldap_search */
1181                        //$justthese = array("cn","uid","givenname","sn","gecos");
1182
1183                        /* search the dn for the given uid */
1184
1185$justthese = array("uidnumber",  "cn",  "mail","gecos","dn");
1186                        //      $sri = @ldap_search($this->ds, "ou=usuarios,ou=cnti,dc=gob,dc=ve", ("(&(sn=*)(mail=*@*)(structuralObjectClass=inetOrgPerson)(deliveryMode=virtual))"), $justthese);
1187
1188                        if(($acct_type == 'g') && $this->group_context)
1189                        {
1190                                $sri = @ldap_search($this->ds, $this->group_context, '(gidnumber=' . (int)$account_id . ')', $justthese);
1191                        }
1192                        else
1193                        {
1194                                $sri = @ldap_search($this->ds, $this->user_context, '(uidnumber=' . (int)$account_id . ')', $justthese);
1195                        }
1196
1197//echo $this->ds.",". $this->user_context.",". '(uidnumber=' . (int)$account_id . ')'.",". $justthese;
1198                        if(!$sri)
1199                                return False;
1200                        $allValues = ldap_get_entries($this->ds, $sri);
1201$retorna="";
1202                        if($acct_type =='g')
1203                        {
1204                                if($valor=='gecos') {
1205                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['gecos'][0],'utf-8');
1206                                }
1207                                if($valor=='uidnumber') {
1208                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['uidnumber'][0],'utf-8');
1209                                }
1210                                if($valor=='cn') {
1211                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8');
1212                                }
1213
1214                                if($valor=='mail') {
1215                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['mail'][0],'utf-8');
1216                                }
1217                                if($valor=='dn') {
1218                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['dn'][0],'utf-8');
1219                                }
1220                               
1221                        }
1222                        else
1223                        {
1224                                if($valor=='gecos') {
1225                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['gecos'][0],'utf-8');
1226                                }
1227                                if($valor=='uidnumber') {
1228                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['uidnumber'][0],'utf-8');
1229                                }
1230                                if($valor=='cn') {
1231                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8');
1232                                }
1233
1234                                if($valor=='mail') {
1235                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['mail'][0],'utf-8');
1236                                }
1237                                if($valor=='dn') {
1238                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['dn'][0],'utf-8');
1239                                }
1240                               
1241
1242
1243
1244                        }
1245                        return $retorna;
1246                }
1247
1248
1249
1250
1251
1252function get_type($account_id)
1253                {
1254                        $allValues = array();
1255                        /* jakjr: using justthese with ldap_search */
1256                        $sri = @ldap_search($this->ds, $this->user_context, '(&(uidnumber=' . (int)$account_id . ')(phpgwaccounttype=u))', array("phpgwaccounttype"));
1257                        if(!$sri)
1258                                return False;
1259                        $allValues = ldap_get_entries($this->ds, $sri);
1260
1261                        if ($allValues[0]['phpgwaccounttype'][0])
1262                        {
1263                                return $allValues[0]['phpgwaccounttype'][0];
1264                        }
1265
1266                        $allValues = array();
1267                        /* jakjr: using justthese with ldap_search */
1268                        $sri = @ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwaccounttype=g))', array("phpgwaccounttype"));
1269                        if(!$sri)
1270                                return False;
1271                        $allValues = ldap_get_entries($this->ds, $sri);
1272
1273                        if ($allValues[0]['phpgwaccounttype'][0])
1274                        {
1275                                return $allValues[0]['phpgwaccounttype'][0];
1276                        }
1277                        return False;
1278                }
1279
1280
1281
1282
1283
1284
1285
1286function select($id)
1287                {
1288
1289
1290                        $sql = "select * from   phpgw_resources where res_id='".$id."'";
1291
1292$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);   
1293
1294if( $GLOBALS['phpgw']->db->next_record() )
1295                        {
1296
1297
1298
1299
1300$retval =  array(
1301                                        'id'    => $GLOBALS['phpgw']->db->f('res_id'),
1302                                        'name'         => $GLOBALS['phpgw']->db->f('name'),
1303                                        'descripcion'         => $GLOBALS['phpgw']->db->f('short_description'),
1304                                        'category'         => $GLOBALS['phpgw']->db->f('cat_id'),
1305                                        'picture_src' => $GLOBALS['phpgw']->db->f('picture_src'),
1306                                        'administrador'=>$GLOBALS['phpgw']->db->f('administrador'),
1307                                        'email'=>$GLOBALS['phpgw']->db->f('email'),
1308                                        'location'=>$GLOBALS['phpgw']->db->f('location'),
1309                                        'cantidad'=>$GLOBALS['phpgw']->db->f('quantity'),
1310                                        'owner'=>$GLOBALS['phpgw']->db->f('owner')
1311                                );
1312
1313                        }
1314               
1315//echo "iddd".$id."  56666 ".$retval['id'];
1316
1317
1318return $retval;
1319               
1320                }
1321
1322
1323function select_init()
1324                {
1325
1326$id=0;
1327if(isset($_REQUEST['resources[id]'])){
1328$id=$_REQUEST['resources[id]'];
1329}
1330
1331$name="";
1332if(isset($_REQUEST['name'])){
1333$name=$_REQUEST['name'];
1334}
1335
1336
1337$description="";
1338if(isset($_REQUEST['description'])){
1339$description=$_REQUEST['description'];
1340}
1341
1342$catgory=0;
1343if(isset($_REQUEST['category'])){
1344$category=$_REQUEST['category'];
1345}
1346$administrador="";
1347if(isset($_REQUEST['administrador'])){
1348$administrador=$_REQUEST['administrador'];
1349}
1350$email="";
1351if(isset($_REQUEST['email'])){
1352$email=$_REQUEST['email'];
1353}
1354$cantidad=0;
1355if(isset($_REQUEST['cantidad'])){
1356$cantidad=$_REQUEST['cantidad'];
1357}
1358
1359$location="";
1360if(isset($_REQUEST['location'])){
1361$location=$_REQUEST['location'];
1362}
1363                       
1364$retval =  array(
1365
1366                                        'id'    => $id,
1367                                        'name'         => $name,
1368                                        'descripcion'         => $description,
1369                                        'category'         => $category,
1370                                        'picture_src' => 'generic.png',
1371                                        'administrador'=>$administrador,
1372                                        'location'=>$location,
1373                                        'email'=>$email,
1374                                        'cantidad'=>$cantidad,
1375                                        'owner'=>$this->bo->owner
1376
1377
1378                                       
1379                                );
1380
1381
1382
1383
1384
1385
1386                       
1387
1388
1389return $retval;
1390               
1391                }
1392
1393
1394function delete()
1395                {
1396
1397
1398
1399#  $vars = get_defined_vars(); 
1400#   print_r($vars);
1401/*foreach($_POST as $k=>$v){
1402$$k=$v;
1403echo $$k."<br>";
1404}
1405foreach($_POST as $nombre_campo => $valor){
1406   $asignacion = "\$" . $nombre_campo . "='" . $valor . "';";
1407   echo $asignacion."<br>";
1408} */
1409
1410
1411
1412
1413unset($GLOBALS['phpgw_info']['flags']['noheader']);
1414                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
1415                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['infolog']['title'].' - '.lang('Search Results');
1416                        $GLOBALS['phpgw']->common->phpgw_header();
1417
1418                        $error = '';
1419
1420                        $matches = 0;
1421
1422
1423
1424
1425                //      $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset;
1426
1427                        $sql = "delete from  phpgw_resources   where res_id='".$_GET['id']."'";
1428
1429
1430$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);   
1431
1432$params['errormsg'] = '';
1433$GLOBALS['phpgw']->redirect($this->page('search',$params));
1434return "";
1435                }
1436
1437
1438 function translate($key,$vars=false, $not_found='*' )
1439          {
1440            if ($this->async)
1441              return $GLOBALS['phpgw']->translation->translate_async($key, $vars);
1442            return lang($key, $vars);
1443          }
1444
1445function maketime($time)
1446                {
1447                        return mktime(intval($time['hour']),intval($time['min']),intval($time['sec']),intval($time['month']),intval($time['mday']),intval($time['year']));
1448                }
1449
1450function search2()
1451                {
1452
1453//print_r($_REQUEST);
1454
1455                        $jscal = CreateObject('phpgwapi.jscalendar');   // before phpgw_header() !!!
1456
1457                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
1458                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
1459                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['resources']['title'].' - '.lang('Search Results');
1460                        $GLOBALS['phpgw']->common->phpgw_header();
1461
1462                        $error = '';
1463
1464
1465
1466                        $matches = 0;
1467
1468//echo "aaaaa".$GLOBALS['phpgw']->common->show_date(1288884600);
1469
1470//echo "aaaaa".$GLOBALS['phpgw']->common->show_date(1288886400);
1471if (isset($_REQUEST['fecha'])){
1472list($dia,$mes,$ano)=split("/",$_REQUEST['fecha']);
1473
1474        $starttime = $this->bo->maketime2(0,0,0,$dia,$mes,$ano,'am') - $GLOBALS['phpgw']->datetime->tz_offset;
1475///echo $starttime;
1476$starttime2 = $this->bo->maketime2(23,59,59,$dia,$mes,$ano,'pm') - $GLOBALS['phpgw']->datetime->tz_offset;
1477///echo $starttime2;
1478}
1479                //$event = $this->bo->read_entry($res_id);     
1480$event = $this->get_event_ids2($_REQUEST['id'],$starttime,$starttime2);
1481
1482
1483                        //$event_ids = $this->bo->search_keywords($_POST['keywords']);
1484
1485                       
1486                        $matches = count($event);
1487
1488//echo "matches" . $matches;
1489
1490                        if ($matches == 1)
1491                        {
1492                                $quantity = lang('1 match found').'.';
1493                        }
1494                        elseif ($matches > 0)
1495                        {
1496                                $quantity = lang('%1 matches found',$matches).'.';
1497                        }
1498                        else
1499                        {
1500                                echo lang('no matches found');
1501                                return;
1502                        }
1503
1504                        $p = $GLOBALS['phpgw']->template;
1505                        $p->set_file(
1506                                Array(
1507                                        'search_form'   => 'search2.tpl'
1508                                )
1509                        );
1510                        $p->set_block('search_form','search','search');
1511                        $p->set_block('search_form','search_list_header','search_list_header');
1512                        $p->set_block('search_form','search_list','search_list');
1513                        $p->set_block('search_form','search_list_footer','search_list_footer');
1514
1515
1516$script='';
1517
1518               
1519
1520                        if($matches > 0)
1521                        {
1522                                $p->parse('rows','search_list_header',True);
1523                        }
1524
1525//if($info){
1526                        foreach($event  as $id => $data)
1527                        {
1528
1529
1530                                $datetime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
1531
1532
1533
1534
1535                                $info = array(
1536                                        'tr_color'      => $GLOBALS['phpgw']->nextmatchs->alternate_row_color(),
1537                                        'date'          => $GLOBALS['phpgw']->common->show_date($datetime),
1538'id'    => $data['id'],
1539                                        'name'         => $data['name'],
1540                                        'description'         => $data['short_description'],
1541                                        'location'         =>$data['namelocation'],
1542                               
1543                                        'owner'=>$this->get_account_name($data['owner'],'gecos'),
1544                                        'fecha'=>$data['fech'],
1545                                        'priority'=>$data['priority'],
1546                                        'ispublic'=>$data['ispublic'],
1547
1548'accionmodificar'       =>'index.php?menuaction=resources.uiresources.edit&id='. $data['id'],
1549'accionlistar'  =>'index.php?menuaction=resources.uiresources.search2&id='. $data['id'],
1550'accionborrar'  =>$data['id'],
1551'accionreservar'        =>'index.php?menuaction=calendar.uicalendar.add&location='. $data['id']
1552                                );
1553
1554
1555
1556//'accionagregar'       =>'index.php?menuaction=resources.uiresources.edit&parent='. $data['id']
1557$p->set_var($info);
1558                                $p->set_var($data);
1559                                $p->parse('rows','search_list',True);
1560                        }
1561//      }
1562                        if($matches > 0)
1563                        {
1564                                $p->parse('rows','search_list_footer',True);
1565                        }
1566
1567                        $p->pparse('out','search');
1568                }
1569
1570
1571
1572
1573function get_event_ids2($idd,$starttime,$starttime2)
1574                {
1575////echo "tamannn".count($search)."  ".$search[0];
1576
1577$from ="";
1578if (isset($idd)){
1579
1580                        $from = ' and t1.location=\''.$idd.'\' ';
1581                        }
1582
1583if (isset($starttime)){
1584if (isset($starttime2)){
1585
1586                        $from =$from .' and t1.datetime>=\''.$starttime.'\' and t1.datetime<=\''.$starttime2.'\' ';
1587}
1588                        }
1589
1590                        $sql = 'select t1.cal_id ,t1.owner,t1.groups,t1.datetime,t1.edatetime,
1591t1.priority ,t1.cal_type, t1.is_public ,
1592t1.title,t1.description,t1.location ,
1593t2.list_descripcion as publico,t3.list_descripcion as priority ,t4.name as namelocation from   phpgw_cal  t1, phpgw_listas t2, phpgw_listas t3 ,phpgw_resources t4
1594where t1.is_public =t2.list_id and t2.list_name=\'visibility\'
1595and t1.priority=t3.list_id and t3.list_name=\'priority\'
1596and t1.location=t4.name '
1597                                        . $from. "order by t1.datetime desc ";
1598                                        //.$search;
1599                                        //. 'WHERE (phpgw_cal_user.res_id = phpgw_cal.res_id) '
1600                                        //. $where . $extra;
1601
1602
1603
1604
1605
1606                        if($this->debug)
1607                        {
1608                                echo "FULL SQL : ".$sql."<br>\n";
1609                        }
1610
1611 //$resultado=pg_query($this->bo->connect(),$sql) or die("Error al mostrar");
1612
1613
1614$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
1615while( $GLOBALS['phpgw']->db->next_record() )
1616                        {
1617                        //     
1618
1619//$valorfechaini=$this->bo->time2array($GLOBALS['phpgw']->db->f('datetime'),$alarm = 0);
1620//$ini=$valorfechaini['mday']."/".$valorfechaini['month']."/".$valorfechaini['year'];
1621$ini=$GLOBALS['phpgw']->common->show_date($GLOBALS['phpgw']->db->f('datetime'))."-".$GLOBALS['phpgw']->common->show_date($GLOBALS['phpgw']->db->f('edatetime'));
1622
1623
1624
1625$retval[] =  array(
1626
1627'id'    => $GLOBALS['phpgw']->db->f('cat_id'),
1628                                        'name'         => $GLOBALS['phpgw']->db->f('title'),
1629                                        'description'         => $GLOBALS['phpgw']->db->f('description'),                                       
1630                                        'location'=>$GLOBALS['phpgw']->db->f('namelocation'),
1631                                        'groups'=>$GLOBALS['phpgw']->db->f('groups'),
1632                                        'owner'=>$this->get_account_name($GLOBALS['phpgw']->db->f('owner'),'gecos'),
1633                                        'fecha'=>$ini,
1634                                        'priority'=>$GLOBALS['phpgw']->db->f('priority'),
1635                                        'ispublic'=>$GLOBALS['phpgw']->db->f('publico')
1636
1637                                       
1638                                );
1639
1640
1641                        }
1642               
1643
1644
1645                       
1646                        return $retval;
1647                }
1648
1649
1650
1651}
1652
1653?>
Note: See TracBrowser for help on using the repository browser.