Changeset 1447 for trunk/calendar


Ignore:
Timestamp:
09/24/09 10:59:52 (15 years ago)
Author:
eduardoalex
Message:

Ticket #599 - Funcionalidade de mapa de disponibilidade.

Location:
trunk/calendar
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/calendar/inc/class.uicalendar.inc.php

    r1126 r1447  
    8484                        'footer' => True, 
    8585                        'css'           => True, 
    86                         'accounts_popup' => True 
     86                        'accounts_popup' => True, 
     87                        'disponibility' => True 
    8788                ); 
    8889 
     
    13261327                } 
    13271328 
     1329                function disponibility($params) { 
     1330                         
     1331                        if(!isset($_SESSION['phpgw_info']['expresso']['expressoAdmin'])) { 
     1332                                $c = CreateObject('phpgwapi.config','expressoAdmin1_2'); 
     1333                                $c->read_repository(); 
     1334                                $current_config = $c->config_data; 
     1335                                 
     1336                                $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); 
     1337                 
     1338                                $_SESSION['phpgw_info']['expresso']['user'] = $GLOBALS['phpgw_info']['user']; 
     1339                                $_SESSION['phpgw_info']['expresso']['server'] = $GLOBALS['phpgw_info']['server']; 
     1340                                $_SESSION['phpgw_info']['expresso']['cc_ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; 
     1341                                $_SESSION['phpgw_info']['expresso']['expressoAdmin'] = $current_config; 
     1342                                $_SESSION['phpgw_info']['expresso']['global_denied_users'] = $GLOBALS['phpgw_info']['server']['global_denied_users']; 
     1343                                $_SESSION['phpgw_info']['expresso']['global_denied_groups'] = $GLOBALS['phpgw_info']['server']['global_denied_groups']; 
     1344                        } 
     1345                        $str_participants = substr($_GET['participants'],0,strlen($_GET['participants'])-1); //remove the last comma 
     1346                        $participants= array(); 
     1347 
     1348                        $participants_splited = explode(",",$str_participants); 
     1349                        foreach($participants_splited as $participant) { 
     1350                                $participant = substr($participant,0,strlen($participant)-1); 
     1351                                $acct_type = $GLOBALS['phpgw']->accounts->get_type((int)$participant); 
     1352                                if($acct_type=='g') { 
     1353                                        $bo_groups = CreateObject('expressoAdmin1_2.group'); 
     1354                                        $users = $bo_groups->get_info($participant); 
     1355                                        foreach($users['memberuid_info'] as $user) { 
     1356                                                if($user['type']==u) 
     1357                                                        $participants[$user['uidnumber']] = 'U'; 
     1358                                        } 
     1359                                } 
     1360                                else { 
     1361                                        $participants[$participant] = 'U'; 
     1362                                } 
     1363                        } 
     1364                         
     1365                        $date = explode("/",$_GET['date']); 
     1366                        $freetime = $GLOBALS['phpgw']->datetime->localdates(mktime(0,0,0,$date[1],$date[0],$date[2]) - $GLOBALS['phpgw']->datetime->tz_offset); 
     1367 
     1368                        echo $this->print_disponibility( 
     1369                                Array( 
     1370                                        'date'          => $freetime, 
     1371                                        'starttime'     => $this->bo->splittime('000000',False), 
     1372                                        'endtime'       => 0, 
     1373                                        'participants'  => $participants 
     1374                                ) 
     1375                        ); 
     1376 
     1377 
     1378                } 
     1379 
     1380                function print_disponibility($param) { 
     1381 
     1382                        $str = "<html><head> 
     1383                        <script type='text/javascript'> 
     1384 
     1385                                var start = null; 
     1386                                var end = null; 
     1387                                function set_time(hour,minute) { 
     1388                                        //alert(start); 
     1389                                        if(start == null) { 
     1390                                                start = new Array(); 
     1391                                                start[0] = hour; 
     1392                                                start[1] = minute; 
     1393                                                paint_interval(start,start,'#0000FF',true); 
     1394                                        } 
     1395                                        else if (end == null) { 
     1396                                                end = new Array(); 
     1397                                                end[0] = hour; 
     1398                                                end[1] = minute; 
     1399                                                if(is_lower(start,end)) 
     1400                                                        paint_interval(start,end,'#0000FF',true); 
     1401                                                else { 
     1402                                                        paint_interval(end,start,'#0000FF',true); 
     1403                                                        temp = start; 
     1404                                                        start = end; 
     1405                                                        end = temp; 
     1406                                                        paint_interval(end,end,'#FFFFFF',false); 
     1407                                                } 
     1408                                                parent.document.getElementById('start_hour').value=start[0]; 
     1409                                                parent.document.getElementById('start_minute').value=start[1];                           
     1410                                                parent.document.getElementById('end_hour').value=end[0]; 
     1411                                                parent.document.getElementById('end_minute').value=end[1]; 
     1412 
     1413                                        } 
     1414                                        else { 
     1415                                                end = null; 
     1416                                                start = new Array(); 
     1417                                                start[0] = hour; 
     1418                                                start[1] = minute; 
     1419                                                repaint(); 
     1420 
     1421                                                paint_interval(start,start,'#0000FF',true); 
     1422                                        } 
     1423                                } 
     1424                                function paint_column(name_array,color,force) { 
     1425                                        name = name_array[0]+'-'+name_array[1]; 
     1426                                        if(navigator.userAgent.toLowerCase().indexOf('msie') == -1) {//firefox 
     1427                                                for(var i in document.getElementsByName(name)) { 
     1428                                                        document.getElementsByName(name)[i].bgColor=color; 
     1429                                                        if(document.getElementsByName(name)[i].nodeType==1) { 
     1430                                                                if(document.getElementsByName(name)[i].innerHTML.indexOf('>-<')==-1 || force==true) 
     1431                                                                        document.getElementsByName(name)[i].bgColor=color; 
     1432                                                                else 
     1433                                                                        document.getElementsByName(name)[i].bgColor='".$this->theme['bg01']."';                                                  
     1434                                                        } 
     1435                                                } 
     1436                                        } 
     1437                                        else {//I.E 
     1438                                                cells = document.getElementsByTagName('td'); 
     1439                                                for(var i=0;i<cells.length;i++) { 
     1440                                                                if(cells.item(i).name==name) { //getElementsByName in I.E is bugged 
     1441                                                                        cells.item(i).bgColor=color; 
     1442                                                                        if(cells.item(i).nodeType==1) { 
     1443                                                                                if(cells.item(i).innerHTML.indexOf('>-<')==-1 || force==true) 
     1444                                                                                        cells.item(i).bgColor=color; 
     1445                                                                                else 
     1446                                                                                        cells.item(i).bgColor='".$this->theme['bg01']."';                                                        
     1447                                                                } 
     1448                                                        } 
     1449                                                } 
     1450                                        } 
     1451                                } 
     1452                                 
     1453                                function repaint() { 
     1454                                        temp_start = new Array(); 
     1455                                        temp_start[0] = 8; 
     1456                                        temp_start[1] = 0; 
     1457                                        temp_end = new Array(); 
     1458                                        temp_end[0] = 19; 
     1459                                        temp_end[1] = 0; 
     1460                                        paint_interval(temp_start,temp_end,'#FFFFFF',false); 
     1461                                } 
     1462                                 
     1463                                //Considera sempre name1 <= name2 
     1464                                function paint_interval(name1,name2,color,force) { 
     1465                                        paint_column(name1,color,force); 
     1466                                        if(name1[0]!=name2[0] || name1[1]!=name2[1]) { 
     1467                                                paint_column(name1,color,force); 
     1468                                                tempHour = name1[0]; 
     1469                                                tempMinute = name1[1]; 
     1470                                                while(tempHour<name2[0]) { 
     1471                                                        if(tempHour==name1[0] && tempMinute!=0) 
     1472                                                                temp_start = tempMinute/30; 
     1473                                                        else 
     1474                                                                temp_start = 0; 
     1475                                                        for(i=temp_start;i<60/30;i++) { 
     1476                                                                temp_column = new Array(); 
     1477                                                                temp_column[0] = tempHour; 
     1478                                                                temp_column[1] = i*30; 
     1479                                                                paint_column(temp_column,color,force); 
     1480                                                        } 
     1481                                                        tempHour++; 
     1482                                                } 
     1483                                                for(i=0;i<name2[1];i+=30) { 
     1484                                                        temp_column = new Array(); 
     1485                                                        temp_column[0] = name2[0]; 
     1486                                                        temp_column[1] = i; 
     1487                                                        paint_column(temp_column,color,force); 
     1488                                                } 
     1489                                        } 
     1490                                } 
     1491                                 
     1492                                function is_lower(array1,array2) { 
     1493                                        if(array1[0]<array2[0]) 
     1494                                                return true; 
     1495                                        else if(array1[0]>array2[0]) 
     1496                                                return false; 
     1497                                        else { 
     1498                                                if(array1[1]<array2[1]) 
     1499                                                        return true; 
     1500                                                else 
     1501                                                        return false; 
     1502                                        } 
     1503                                } 
     1504                        </script></head><body> 
     1505                        "; 
     1506                         
     1507                        $str.= "<table border=\'1\' bgcolor=\"#FFFFFF\" width=\"100%\" height=\"100%\"><tr><td>"; 
     1508 
     1509                         
     1510                        if(!is_array($param)) 
     1511                        { 
     1512                                $this->index(); 
     1513                        } 
     1514 
     1515                        $date = $param['date']; 
     1516                        $starttime = $param['starttime']; 
     1517                        $endtime = $param['endtime']; 
     1518                        $participants = $param['participants']; 
     1519                        foreach($participants as $part => $nul) 
     1520                        { 
     1521                                $participants[$part] = $GLOBALS['phpgw']->common->grab_owner_name($part); 
     1522                                // Much better for processor  :) 
     1523                                $participants_id[]  .= $part; 
     1524                        } 
     1525                        uasort($participants,'strnatcasecmp');  // sort them after their fullname 
     1526 
     1527                        if(!isset($this->bo->prefs['calendar']['interval'])) 
     1528                        { 
     1529                                $this->bo->prefs['calendar']['interval'] = 15; 
     1530                                $GLOBALS['phpgw']->preferences->add('calendar','interval',15); 
     1531                                $GLOBALS['phpgw']->preferences->save_repository(); 
     1532                        } 
     1533                        $increment = $this->bo->prefs['calendar']['interval']; 
     1534                        $interval = (int)(60 / $increment); 
     1535 
     1536                        $pix = $GLOBALS['phpgw']->common->image('calendar','pix'); 
     1537 
     1538                        $str .= '<center>'.lang($GLOBALS['phpgw']->common->show_date($date['raw'],'l')) 
     1539                                . ', '.$this->bo->long_date($date).'<br>' 
     1540                                . '<table width="85%" border="0" cellspacing="0" cellpadding="0" cols="'.((10 * $interval) + 1).'">' 
     1541                                . '<tr><td height="1" colspan="'.((11 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>' 
     1542                                . '<tr><td width="15%"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.lang('Participant').'</font></td>'; 
     1543                        for($i=8;$i<19;$i++) 
     1544                        { 
     1545                                for($j=0;$j<$interval;$j++) 
     1546                                { 
     1547                                        $k = ($j == 0 ? sprintf('%02d',$i).'<br>':'').sprintf('%02d',$j*$increment); 
     1548 
     1549                                        $str .= '<td align="left" bgcolor="'.$this->theme['bg_color'].'" onclick="set_time('.$i.','.($j*$increment).')" style="cursor:hand;cursor:pointer"> 
     1550                                                        <font color="'.$phpgw_info['theme']['bg_text'].'" face="'.$this->theme['font'].'" size="-2">' . $k."&nbsp;</font></td>\n"; 
     1551                                } 
     1552                        } 
     1553                        $str .= '</tr>' 
     1554                                . '<tr><td height="1" colspan="'.((11 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>'; 
     1555                        if(!$endtime) 
     1556                        { 
     1557                                $endtime = $starttime; 
     1558                        } 
     1559                        $owner = $this->bo->owner; 
     1560                        foreach($participants as $part => $fullname) 
     1561                        { 
     1562                                $str .= '<tr align="center">' 
     1563                                        . '<td width="15%" align="left"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.$fullname.'</font></td>'; 
     1564 
     1565                                $this->bo->cached_events = Array(); 
     1566                                $this->bo->so->owner = $part; 
     1567                                $this->bo->so->open_box($part); 
     1568                                $this->bo->store_to_cache( 
     1569                                        Array( 
     1570                                                'syear' => $date['year'], 
     1571                                                'smonth'=> $date['month'], 
     1572                                                'sday'  => $date['day'], 
     1573                                                'eyear' => 0, 
     1574                                                'emonth'=> 0, 
     1575                                                'eday'  => $date['day'] + 1 
     1576                                        ) 
     1577                                ); 
     1578 
     1579                                if(!$this->bo->cached_events[$date['full']]) 
     1580                                { 
     1581                                        for($j=8;$j<19;$j++) 
     1582                                        { 
     1583                                                for($k=0;$k<$interval;$k++) 
     1584                                                { 
     1585//                                                      $helper_name = $k* 
     1586                                                        $str .= '<td name="'.$j.'-'.($k*$increment).'" height="1" align="left" bgcolor="'.$this->theme['bg_color'].'" color="#999999">&nbsp;</td>'; 
     1587                                                } 
     1588                                                $str .= "\n"; 
     1589                                        } 
     1590                                } 
     1591                                else 
     1592                                { 
     1593                                        $time_slice = $this->bo->prepare_matrix($interval,$increment,$part,$date['full']); 
     1594                                        for($h=8;$h<19;$h++) 
     1595                                        { 
     1596                                                $hour = $h * 10000; 
     1597                                                for($m=0;$m<$interval;$m++) 
     1598                                                { 
     1599                                                        $index = ($hour + (($m * $increment) * 100)); 
     1600                                                        switch($time_slice[$index]['marker']) 
     1601                                                        { 
     1602                                                                case '&nbsp': 
     1603                                                                        $time_slice[$index]['color'] = $this->theme['bg_color']; 
     1604                                                                        //$extra = ''; 
     1605                                                                        break; 
     1606                                                                case '-': 
     1607                                                                        $time_slice[$index]['color'] = $this->theme['bg01']; 
     1608                                                                        $link = $this->page('view','&cal_id='.$time_slice[$index]['id'].'&date='.$date['full']); 
     1609                                                                        //$extra =' title="'.$time_slice[$index]['description'].'" onClick="location.href=\''.$link.'\';" style="cursor:pointer; cursor:hand;"'; 
     1610                                                                        break; 
     1611                                                        } 
     1612                                                        $str .= '<td name="'.$h.'-'.($m*$increment).'" bgcolor="'.$time_slice[$index]['color'].'" color="#999999"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.$time_slice[$index]['marker'].'</font></td>'; 
     1613                                                } 
     1614                                                $str .= "\n"; 
     1615                                        } 
     1616                                } 
     1617                                $str .= '</tr>' 
     1618                                        . '<tr><td height="1" colspan="'.((11 * $interval) + 1).'" bgcolor="#999999"><img src="'.$pix.'"></td></tr>'; 
     1619                        } 
     1620                        $this->bo->owner = $owner; 
     1621                        $this->bo->so->owner = $owner; 
     1622                        $this->bo->so->open_box($owner); 
     1623                        $str.= "</table></center> \n </td></tr> 
     1624                        <tr><td onclick=\"parent.document.getElementById('disponibility').style.display='none'\" style='cursor:hand;cursor:pointer' align='center'>Fechar mapa</td></tr> 
     1625                        </table></body>"; 
     1626                        return $str; 
     1627                } 
     1628 
    13281629                function day() 
    13291630                { 
     
    44724773                        $var['starttime'] = Array( 
    44734774                                'field' => lang('Start Time'), 
    4474                                 'data'  => '<input name="start[hour]" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($start,$hourformat).'" maxlength="2">:<input name="start[min]" size="2" value="'.$GLOBALS['phpgw']->common->show_date($start,'i').'" maxlength="2">'."\n".$str 
     4775                                'data'  => '<input name="start[hour]" id="start_hour" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($start,$hourformat).'" maxlength="2">:<input name="start[min]" id="start_minute" size="2" value="'.$GLOBALS['phpgw']->common->show_date($start,'i').'" maxlength="2">'."\n".$str 
    44754776                        ); 
    44764777 
     
    44974798                        $var['endtime'] = Array( 
    44984799                                'field' => lang('End Time'), 
    4499                                 'data'  => '<input name="end[hour]" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($end,$hourformat).'" maxlength="2">:<input name="end[min]" size="2" value="'.$GLOBALS['phpgw']->common->show_date($end,'i').'" maxlength="2">'."\n".$str 
     4800                                'data'  => '<input name="end[hour]" id="end_hour" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($end,$hourformat).'" maxlength="2">:<input name="end[min]" id="end_minute" size="2" value="'.$GLOBALS['phpgw']->common->show_date($end,'i').'" maxlength="2">'."\n".$str 
    45004801                        ); 
    45014802 
     
    45844885                                                                                </tr> 
    45854886                                                                                </table> 
    4586                                                                         <script src='calendar/templates/".$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set']."/js/edit.js' type='text/javascript'></script> 
    45874887                                                                        " 
    45884888                                                ); 
     
    46344934                                                                $var['participants'] = array 
    46354935                                                                ( 
    4636                                                                         'field' => lang('Participants'),                                                         
    4637                                                                         'data'  => '<input type="hidden" id="txt_loading" value="'.lang("Loading").'">' . 
     4936                                                                        'field' => ' 
     4937                                                                        <script src="calendar/templates/'.$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set'].'/js/edit.js" type="text/javascript"></script><div id=\'disponibility\' style=\'display:none;position:absolute\' bgcolor=\'#FFFFFF\'> 
     4938        <iframe src=\'#\' id=\'frame_disponibility\' width=\'500\' marginHeight=\'0\' marginWidth=\'0\'></iframe> 
     4939</div> 
     4940                                                                        '.lang('Participants'),                                                  
     4941                                                                        'data'  => ' 
     4942                                                                                        <font color="#000088"><span onclick=\'show_disponibility()\' style="cursor:hand;cursor:pointer">Mapa de disponibilidade</span></font><br> 
     4943                                                                                        <input type="hidden" id="txt_loading" value="'.lang("Loading").'">' . 
    46384944                                                                                        '<input type="hidden" id="txt_searching" value="'.lang("Searching").'">' . 
    46394945                                                                                        '<input type="hidden" id="txt_users" value="'.lang("Users").'">' .                                                       
  • trunk/calendar/templates/classic/js/edit.js

    r1267 r1447  
    5050                                select_in.options[i--] = null;                                                                                                                                   
    5151        } 
    52                                                                                                                                                                                  
     52        function show_disponibility() { 
     53 
     54                participants = ""; 
     55                combo = document.getElementById('user_list'); 
     56                if(combo.length==0) { 
     57                        alert('set the participants'); 
     58                        return; 
     59                } 
     60                         
     61                for (i=0;i<combo.length;i++) { 
     62                        participants+=combo[i].value+","; 
     63                } 
     64                url = 'index.php?menuaction=calendar.uicalendar.disponibility&participants='+participants+'&date='+document.getElementById('start[str]').value; 
     65                 
     66                //alert(url); 
     67                document.getElementById('frame_disponibility').src = url; 
     68                document.getElementById('disponibility').style.display=''; 
     69                //window.open(url); 
     70        }                                                                                                                                                
    5371        function submitValues(alert_msg){ 
    5472                var typeField = document.getElementById('cal[type]'); 
  • trunk/calendar/templates/default/js/edit.js

    r1268 r1447  
    4343                oWait.innerHTML = '&nbsp;'; 
    4444        }                        
    45                                                                          
     45        function show_disponibility() { 
     46 
     47                participants = ""; 
     48                combo = document.getElementById('user_list'); 
     49                if(combo.length==0) { 
     50                        alert('set the participants'); 
     51                        return; 
     52                } 
     53                         
     54                for (i=0;i<combo.length;i++) { 
     55                        participants+=combo[i].value+","; 
     56                } 
     57                url = 'index.php?menuaction=calendar.uicalendar.disponibility&participants='+participants+'&date='+document.getElementById('start[str]').value; 
     58                 
     59                //alert(url); 
     60                document.getElementById('frame_disponibility').src = url; 
     61                document.getElementById('disponibility').style.display=''; 
     62                //window.open(url); 
     63        }                                        
    4664        function rem() 
    4765        { 
Note: See TracChangeset for help on using the changeset viewer.