Ignore:
Timestamp:
05/12/11 11:52:50 (13 years ago)
Author:
afernandes
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • contrib/Resources/inc/class.uiresources.inc.php

    r3524 r4362  
    3737                'footer' => True                         
    3838                ); 
     39 
     40 
    3941 
    4042 
     
    135137                function uiresources() 
    136138                { 
    137  
    138  
     139                        $localtime = $GLOBALS['phpgw']->datetime->users_localtime; 
     140 
     141                                        $this->year = date('Y',$localtime); 
     142                                        $this->month = date('m',$localtime); 
     143                                        $this->day = date('d',$localtime); 
     144                        $this->today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); 
    139145 
    140146 
     
    954960'accionmodificar'       =>'index.php?menuaction=resources.uiresources.edit&id='. $data['id'], 
    955961'accionlistar'  =>'index.php?menuaction=resources.uiresources.search2&id='.  $data['name'], 
     962                                 
    956963'accionborrar'  =>'index.php?menuaction=resources.uiresources.delete&id='. $data['id'], 
    957964'accionreservar'        =>'index.php?menuaction=calendar.uicalendar.add&location='. $data['name'] 
     
    985992        //              } 
    986993 
    987                         $sql = 'select t1.*,t2.cat_name from   phpgw_resources t1 ,phpgw_categories t2 where t1.cat_id=t2.cat_id ' 
     994                        $sql = "select t1.*,t2.cat_name from   phpgw_resources t1 ,phpgw_categories t2 where t1.cat_id=t2.cat_id and t1.name !='n/a'" 
    988995                                        . $from; 
    989996                                        //.$search; 
     
    14521459 
    14531460//print_r($_REQUEST);  
     1461$this->today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); 
     1462 
     1463 
     1464 
     1465                        $jscal = CreateObject('phpgwapi.jscalendar');   // before phpgw_header() !!! 
     1466 
     1467                        unset($GLOBALS['phpgw_info']['flags']['noheader']); 
     1468                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']); 
     1469                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['resources']['title'].' - '.lang('Search Results'); 
     1470                        $GLOBALS['phpgw']->common->phpgw_header(); 
     1471 
     1472                        $error = ''; 
     1473 
     1474 
     1475 
     1476                        $matches = 0; 
     1477 
     1478//echo "aaaaa".$GLOBALS['phpgw']->common->show_date(1288884600); 
     1479 
     1480//echo "aaaaa".$GLOBALS['phpgw']->common->show_date(1288886400); 
     1481 
     1482if (isset($_REQUEST['fecha'])){ 
     1483list($dia,$mes,$ano)=split("/",$_REQUEST['fecha']); 
     1484if (isset($_REQUEST['fecha2'])){ 
     1485list($dia2,$mes2,$ano2)=split("/",$_REQUEST['fecha2']); 
     1486}else{ 
     1487        list($dia2,$mes2,$ano2)=split("/",$_REQUEST['fecha']); 
     1488         
     1489} 
     1490if(isset($_REQUEST['hora'])){ 
     1491list($horai,$minutoi,$horaf,$minutof)=split(":",$_REQUEST['hora']); 
     1492}else{ 
     1493        $horai=0; 
     1494        $minutoi=0; 
     1495        $horaf=23; 
     1496        $minutof=59; 
     1497} 
     1498        $starttimea = $this->bo->maketime2(0,0,0,$dia,$mes,$ano,'am') - $GLOBALS['phpgw']->datetime->tz_offset; 
     1499 
     1500 
     1501}else{ 
     1502        $localtime = $GLOBALS['phpgw']->datetime->users_localtime; 
     1503        $ano = date('Y',$localtime); 
     1504        $mes = date('m',$localtime); 
     1505        $dia = date('d',$localtime);                                     
     1506        $ano2 = date('Y',$localtime); 
     1507        $mes2 = date('m',$localtime); 
     1508        $dia2 = date('d',$localtime); 
     1509        $horai=0; 
     1510        $minutoi=0; 
     1511        $horaf=23; 
     1512        $minutof=59; 
     1513 
     1514//$starttime = $this->bo->maketime2(0,0,0,$dia,$mes,$ano,'am') - $GLOBALS['phpgw']->datetime->tz_offset; 
     1515///echo $starttime; 
     1516//$starttime2 = $this->bo->maketime2(23,59,59,$dia,$mes,$ano,'pm') - $GLOBALS['phpgw']->datetime->tz_offset; 
     1517///echo $starttime2; 
     1518 
     1519} 
     1520 
     1521 
     1522 
     1523$pm='pm'; 
     1524if($horaf<12){ 
     1525        $pm='am'; 
     1526}else{ 
     1527        $horaf=$horaf-12; 
     1528} 
     1529$am='am'; 
     1530if($horai>11){ 
     1531        $am='pm'; 
     1532        $horai=$horai-12; 
     1533         
     1534} 
     1535 
     1536 
     1537//echo $horai."  <br>  ".$starttimea."<br>".$horaf; 
     1538        $starttime = $this->bo->maketime2($horai,$minutoi,0,$dia,$mes,$ano,$am) - $GLOBALS['phpgw']->datetime->tz_offset; 
     1539//echo "fff".$starttime; 
     1540$starttime2 = $this->bo->maketime2($horaf,$minutof,59,$dia2,$mes2,$ano2,$pm) - $GLOBALS['phpgw']->datetime->tz_offset; 
     1541///echo $starttime2; 
     1542                //$event = $this->bo->read_entry($res_id);       
     1543$location=''; 
     1544if($_GET['id']!=''){ 
     1545$location=$_GET['id'];}else{ 
     1546$location='n/a';} 
     1547 
     1548/*$eventtt=$this->bo->store_to_cache( 
     1549                                Array( 
     1550                                        'syear'  => $ano, 
     1551                                        'smonth' => $mes, 
     1552                                        'sday'   => $dia, 
     1553                                'shour'   => $horai, 
     1554                                'smin'   => $minutoi, 
     1555                                        'eyear'  => $ano, 
     1556                                        'emonth' => $mes, 
     1557                                        'eday'   => $dia, 
     1558                                'fhour'   => $horaf, 
     1559                                'fmin'   => $minutof, 
     1560'location'      =>      $location 
     1561                                ) 
     1562                        );      */ 
     1563                $date_to_eval = sprintf("%04d%02d%02d",$ano,$mes,$dia); 
     1564                 
     1565        //      echo "date _to _eval".$date_to_eval."<br>"; 
     1566//$events = $this->bo->cached_events[$date_to_eval];//(5,23,0,22,10,2010)  
     1567$events=$this->bo->overlap($starttime,$starttime2,Array(),0,0,'False',$location); 
     1568                                print_debug('Date',$date_to_eval); 
     1569                                print_debug('Count',count($events)); 
     1570//echo "llll<br>".'Date'.$date_to_eval; 
     1571//echo "llll<br>".'Count'.count($events); 
     1572if(count($events)>0){ 
     1573                                foreach($events as $event) 
     1574                                { 
     1575                                        if ($this->bo->rejected_no_show($event)) 
     1576                                        { 
     1577                                                continue;       // user does not want to see rejected events 
     1578                                        } 
     1579                                        if ($event['recur_type'])       // calculate start- + end-datetime for recuring events 
     1580                                        { 
     1581                                                $this->bo->set_recur_date($event,$date_to_eval); 
     1582                                        } 
     1583                                        //$events_to_show[] = array( 
     1584                                        //      'starttime' => $this->bo->maketime($event['start']), 
     1585                                        //      'endtime'   => $this->bo->maketime($event['end']), 
     1586                                        //      'content'   => $this->link_to_entry($event,$mes,$dia,$ano) 
     1587                                        //); 
     1588 
     1589                                } 
     1590} 
     1591//echo "eeeevento".count($event)."<br>"; 
     1592                        $date_to_eval = sprintf("%04d%02d%02d",$ano,$mes,$dia); 
     1593 
     1594//$event = $this->get_event_ids2($_REQUEST['id'],$starttime,$starttime2); 
     1595 
     1596 
     1597                        //$event_ids = $this->bo->search_keywords($_POST['keywords']); 
     1598 
     1599                         
     1600                        $matches = count($event); 
     1601 
     1602//echo "matches" . $matches."<br>"; 
     1603 
     1604                        if ($matches == 1) 
     1605                        { 
     1606                                $quantity = lang('1 match found').'.'; 
     1607                        } 
     1608                        elseif ($matches > 0) 
     1609                        { 
     1610                                $quantity = lang('%1 matches found',$matches).'.'; 
     1611                        } 
     1612                        else 
     1613                        { 
     1614                                echo lang('no matches found')." para el ".$dia."/".$mes."/".$ano."  en la sala:".$location; 
     1615                                 
     1616                                //return; 
     1617                        } 
     1618 
     1619                        if ($matches > 0){ 
     1620                        $p = $GLOBALS['phpgw']->template; 
     1621                        $p->set_file( 
     1622                                Array( 
     1623                                        'search_form'   => 'search2.tpl' 
     1624                                ) 
     1625                        ); 
     1626                         
     1627                }else{ 
     1628                        $p = $GLOBALS['phpgw']->template; 
     1629                        $p->set_file( 
     1630                                Array( 
     1631                                        'search_form'   => 'search3.tpl' 
     1632                                ) 
     1633                        ); 
     1634                } 
     1635                $p->set_block('search_form','search','search'); 
     1636                        $p->set_block('search_form','search_list_header','search_list_header'); 
     1637                        $p->set_block('search_form','search_list','search_list'); 
     1638                        $p->set_block('search_form','search_list_footer','search_list_footer'); 
     1639 
     1640$script=''; 
     1641 
     1642                 
     1643 
     1644                        if($matches > 0) 
     1645                        { 
     1646                                $p->parse('rows','search_list_header',True); 
     1647                        } 
     1648 
     1649//if($info){ 
     1650//echo $matches; 
     1651//for($i=0;$i<$matches;$i++) 
     1652                //      { 
     1653//echo "i".$i; 
     1654if(count($events)>0){ 
     1655                        foreach($events  as $id => $data) 
     1656                        { 
     1657 
     1658//echo "<br>dataaaa".$data['title']; 
     1659//echo "<br>".$this->get_account_name($data['owner'],'gecos')."  ".$data['owner']; 
     1660                                $datetime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; 
     1661 
     1662 
     1663 
     1664//echo "ffffffeeecha".$GLOBALS['phpgw']->common->show_date($data[$i]['datetime'])."     ".$data[$i]['start']."  ".$this->bo->maketime($data[$i]['start']); 
     1665//echo $data['location']."  .. ".$data['last_status']."  .. ".$data['is_public']; 
     1666if($data['public']==1){ 
     1667        $descripcion=$data['description']; 
     1668        $name=$data['title']; 
     1669}else{ 
     1670        $descripcion='-'; 
     1671        $name='Privado'; 
     1672} 
     1673$dueno=$this->get_account_name($data['owner'],'gecos'); 
     1674                                $info = array( 
     1675                                        'tr_color'      => $GLOBALS['phpgw']->nextmatchs->alternate_row_color(), 
     1676                                        'date'          => $GLOBALS['phpgw']->common->show_date($datetime), 
     1677'id'    => $data['id'], 
     1678                                        'name'         => $name, 
     1679                                        'description'         => $descripcion, 
     1680                                        'location'         =>$data['location'], 
     1681                                 
     1682                                        'owner'=>$this->get_account_name($data['owner'],'gecos'), 
     1683                                        'fecha'=> $dia."/".$mes."/".$ano." <br>   ".$GLOBALS['phpgw']->common->show_hour($this->bo->maketime($data['start']))."-".$GLOBALS['phpgw']->common->show_hour($this->bo->maketime($data['end'])), 
     1684                                        'priority'=>'', 
     1685                                        'ispublic'=>$data['is_public'], 
     1686 
     1687'accionmodificar'       =>'index.php?menuaction=resources.uiresources.edit&id='. $data['id'], 
     1688'accionlistar'  =>'index.php?menuaction=resources.uiresources.search2&id='. $data['id'], 
     1689'accionborrar'  =>$data['id'], 
     1690'accionreservar'        =>'index.php?menuaction=calendar.uicalendar.add&location='. $data['id'] 
     1691                                ); 
     1692 
     1693 
     1694 
     1695//'accionagregar'       =>'index.php?menuaction=resources.uiresources.edit&parent='. $data['id'] 
     1696$p->set_var($info); 
     1697                                $p->set_var($info); 
     1698                                $p->parse('rows','search_list',True); 
     1699                        } 
     1700//} 
     1701//      } 
     1702} 
     1703                        if($matches > 0) 
     1704                        { 
     1705                                $p->parse('rows','search_list_footer',True); 
     1706                        } 
     1707 
     1708                        $p->pparse('out','search'); 
     1709                } 
     1710 
     1711                 
     1712         
     1713                 
     1714                 
     1715                 
     1716        function search22() 
     1717                { 
     1718 
     1719//print_r($_REQUEST);  
    14541720 
    14551721                        $jscal = CreateObject('phpgwapi.jscalendar');   // before phpgw_header() !!! 
     
    15681834                } 
    15691835 
    1570  
    1571  
    1572  
     1836         
    15731837function get_event_ids2($idd,$starttime,$starttime2) 
    15741838                { 
    1575 ////echo "tamannn".count($search)."  ".$search[0]; 
    1576  
     1839 
     1840 
     1841 
     1842$from =""; 
    15771843$from =""; 
    15781844if (isset($idd)){ 
     
    15821848 
    15831849if (isset($starttime)){ 
     1850 
     1851                        $from =$from .' and t1.datetime>=\''.$starttime.'\''; 
    15841852if (isset($starttime2)){ 
    15851853 
    1586                         $from =$from .' and t1.datetime>=\''.$starttime.'\' and t1.datetime<=\''.$starttime2.'\' '; 
     1854                        $from =$from .' and t1.datetime<=\''.$starttime2.'\' '; 
    15871855} 
    15881856                        } 
     
    16011869 
    16021870 
     1871//echo $sql; 
    16031872 
    16041873 
     
    16381907                                ); 
    16391908 
    1640  
    16411909                        } 
    16421910                 
     
    16461914                        return $retval; 
    16471915                } 
     1916function link_to_entry($event,$month,$day,$year) 
     1917                { 
     1918                        $str = ''; 
     1919                        $is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event); 
     1920                        $viewable = !$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_READ,$event); 
     1921 
     1922                        $starttime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; 
     1923                        $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; 
     1924                        $rawdate = mktime(0,0,0,$month,$day,$year); 
     1925                        $rawdate_offset = $rawdate - $GLOBALS['phpgw']->datetime->tz_offset; 
     1926                        $nextday = mktime(0,0,0,$month,$day + 1,$year) - $GLOBALS['phpgw']->datetime->tz_offset; 
     1927                        if ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') && $starttime == $endtime) 
     1928                        { 
     1929                                $time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); 
     1930                        } 
     1931                        elseif ($starttime <= $rawdate_offset && $endtime >= $nextday - 60) 
     1932                        { 
     1933                                $time = '[ '.lang('All Day').' ]'; 
     1934                        } 
     1935                        elseif ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') || $starttime != $endtime) 
     1936                        { 
     1937                                if($starttime < $rawdate_offset && $event['recur_type'] == MCAL_RECUR_NONE) 
     1938                                { 
     1939                                        $start_time = $GLOBALS['phpgw']->common->show_date($rawdate_offset,$this->bo->users_timeformat); 
     1940                                } 
     1941                                else 
     1942                                { 
     1943                                        $start_time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); 
     1944                                } 
     1945 
     1946                                if($endtime >= ($rawdate_offset + 86400)) 
     1947                                { 
     1948                                        $end_time = $GLOBALS['phpgw']->common->show_date(mktime(23,59,59,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset,$this->bo->users_timeformat); 
     1949                                } 
     1950                                else 
     1951                                { 
     1952                                        $end_time = $GLOBALS['phpgw']->common->show_date($endtime,$this->bo->users_timeformat); 
     1953                                } 
     1954                                $time = $start_time.'-'.$end_time; 
     1955                        } 
     1956                        else 
     1957                        { 
     1958                                $time = ''; 
     1959                        } 
     1960                         
     1961                        $texttitle = $texttime = $textdesc = $textlocation = $textstatus = ''; 
     1962 
     1963                         
     1964                         
     1965                        if(!$is_private) 
     1966                        { 
     1967                                //$text .= $this->bo->display_status($event['users_status']); 
     1968                                 
     1969                                // split text for better display by templates, also see $texttime $texttitle $textdesc $textlocation     
     1970                                $textstatus=$this->bo->display_status($event['users_status']);  
     1971                                 
     1972                        } 
     1973 
     1974                        /* 
     1975                        $text = '<nobr>&nbsp;'.$time.'&nbsp;</nobr> '.$this->bo->get_short_field($event,$is_private,'title').$text. 
     1976                                (!$is_private && $event['description'] ? ': <i>'.$this->bo->get_short_field($event,$is_private,'description').'</i>':''). 
     1977                                $GLOBALS['phpgw']->browser->br; 
     1978                        */ 
     1979                         
     1980                        $texttime=$time; 
     1981                        $texttitle=$this->bo->get_short_field($event,$is_private,'title'); 
     1982                        $textdesc=(!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); 
     1983                        // added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set 
     1984                        $textlocation=$this->bo->get_short_field($event,$is_private,'location'); 
     1985 
     1986                        if ($viewable) 
     1987                        { 
     1988                                $date = sprintf('%04d%02d%02d',$year,$month,$day); 
     1989                                $this->link_tpl->set_var('link_link',$this->page('view','&cal_id='.$event['id'].'&date='.$date)); 
     1990                                $this->link_tpl->set_var('lang_view',lang('View this entry')); 
     1991                                $this->link_tpl->set_var('desc', $textdesc); 
     1992                                $this->link_tpl->set_var('location', $textlocation); 
     1993                                $this->link_tpl->parse('picture','link_open',True); 
     1994                        } 
     1995                        if (!$is_private) 
     1996                        { 
     1997                                if($event['priority'] == 3) 
     1998                                { 
     1999                                        $picture[] = Array( 
     2000                                                'pict'  => $GLOBALS['phpgw']->common->image('calendar','high'), 
     2001                                                'width' => 16, 
     2002                                                'height'=> 16, 
     2003                                                'title' => lang('high priority') 
     2004                                        ); 
     2005                                } 
     2006                                if($event['recur_type'] == MCAL_RECUR_NONE) 
     2007                                { 
     2008                                        $picture[] = Array( 
     2009                                                'pict'  => $GLOBALS['phpgw']->common->image('calendar','circle'), 
     2010                                                'width' => 9, 
     2011                                                'height'=> 9, 
     2012                                                'title' => lang('single event') 
     2013                                        ); 
     2014                                } 
     2015                                else 
     2016                                { 
     2017                                        $picture[] = Array( 
     2018                                                'pict'  => $GLOBALS['phpgw']->common->image('calendar','recur'), 
     2019                                                'width' => 12, 
     2020                                                'height'=> 12, 
     2021                                                'title' => lang('recurring event') 
     2022                                        ); 
     2023                                } 
     2024                        } 
     2025                         
     2026                        if($event['public'] == 0) 
     2027                        { 
     2028                                $picture[] = Array( 
     2029                                        'pict'  => $GLOBALS['phpgw']->common->image('calendar','private'), 
     2030                                        'width' => 13, 
     2031                                        'height'=> 13, 
     2032                                        'title' => lang('private') 
     2033                                ); 
     2034                        } 
     2035                /**     if(@isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private) 
     2036                        { 
     2037                                // if the alarm is to go off the day before the event 
     2038                                // the icon does not show up because of 'alarm_today' 
     2039                                // - TOM 
     2040                                if($this->bo->alarm_today($event,$rawdate_offset,$starttime)) 
     2041                                { 
     2042                                        $picture[] = Array( 
     2043                                                'pict'  => $GLOBALS['phpgw']->common->image('calendar','alarm'), 
     2044                                                'width' => 13, 
     2045                                                'height'=> 13, 
     2046                                                'title' => lang('alarm') 
     2047                                        ); 
     2048                                } 
     2049                        }*/ 
     2050 
     2051                        $description = $this->bo->get_short_field($event,$is_private,'description'); 
     2052                        for($i=0;$i<count($picture);$i++) 
     2053                        { 
     2054                                $var = Array( 
     2055                                        'pic_image' => $picture[$i]['pict'], 
     2056                                        'width'     => $picture[$i]['width'], 
     2057                                        'height'    => $picture[$i]['height'], 
     2058                                        'title'     => $picture[$i]['title'] 
     2059                                ); 
     2060                                $this->output_template_array($this->link_tpl,'picture','pict',$var); 
     2061                        } 
     2062                        if ($texttitle) 
     2063                        { 
     2064                                $var = Array( 
     2065                        //              'text' => $text, 
     2066                                        'time'=> $texttime, 
     2067                                        'title'=> $texttitle, 
     2068                                        'users_status'=>$textstatus, 
     2069                                        'desc'=> $textdesc, 
     2070                                        'location'=> "<br><b>Local:</b> ".$textlocation 
     2071                                ); 
     2072                                $this->output_template_array($this->link_tpl,'picture','link_text',$var); 
     2073                        } 
     2074 
     2075                        if ($viewable) 
     2076                        { 
     2077                                $this->link_tpl->parse('picture','link_close',True); 
     2078                        } 
     2079                        $str = $this->link_tpl->fp('out','link_pict'); 
     2080                        $this->link_tpl->set_var('picture',''); 
     2081                        $this->link_tpl->set_var('out',''); 
     2082//                      unset($p); 
     2083                        return $str; 
     2084                } 
    16482085 
    16492086 
Note: See TracChangeset for help on using the changeset viewer.