Changeset 2107


Ignore:
Timestamp:
03/01/10 17:04:58 (14 years ago)
Author:
pedroerp
Message:

Ticket #935 - Adicionando opção de listagem em ordem alfabética no link 'imprimir'.

Location:
trunk/workflow
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/workflow/inc/class.ui_userinterface.inc.php

    r1227 r2107  
    202202 
    203203                /* pass variables to smarty */ 
    204                 $smarty->assign('areasInfo', $flatAreas); 
     204                $smarty->assign('areasJson', json_encode($flatAreas)); 
    205205                $smarty->assign('javaScripts', $javaScripts); 
    206206                $smarty->assign('css', $css); 
  • trunk/workflow/js/userinterface/orgchartPrint.js

    r795 r2107  
     1/** 
     2* Show / Hide all employees 
     3*/ 
    14function toggleEmployeesVisibility() 
    25{ 
    36        if ($('#employeesVisibility').attr('checked')) 
    4                 $('div.employees').show(); 
     7                $('tr.employees').show(); 
    58        else 
    6                 $('div.employees').hide(); 
    7 } 
    8  
     9                $('tr.employees').hide(); 
     10} 
     11 
     12/** 
     13* Highlight supervisor names? 
     14*/ 
    915function toggleHighlightSupervisor() 
    1016{ 
     
    1521} 
    1622 
     23/** 
     24* Show / Hide orgchart area path visibility 
     25*/ 
    1726function toggleOrgchartPathVisibility() 
    1827{ 
    1928        if ($('#orgchartPathVisibility').attr('checked')) 
    20         { 
    2129                $('span.orgchartPath').css('visibility', 'visible').show(); 
    22         } 
    23         else 
    24         { 
     30        else { 
    2531                if ($('#orgchartPathIndentation').attr('checked')) 
    2632                        $('span.orgchartPath').show().css('visibility', 'hidden'); 
     
    3036} 
    3137 
     38/** 
     39* Group by area or show a single list alphabetically ordered 
     40* For large sets of data this function may be potencially slow 
     41*/ 
     42function toggleGroupByArea() 
     43{ 
     44        /* remove the table and compute it again */ 
     45        $('#employee_table').remove(); 
     46 
     47        if ($('#groupByArea').attr('checked')) 
     48                showGroupedByArea(); 
     49        else 
     50                showUngrouped(); 
     51 
     52        /* updating supervisor highlight and orgchart path visibility */ 
     53        toggleHighlightSupervisor(); 
     54        toggleOrgchartPathVisibility(); 
     55} 
     56 
     57/** 
     58* Centralize the creation of table rows for employees. 
     59* 'showAreaColumn' specifies whether the second column will be shown 
     60*/ 
     61function createEmployeeRow(area_id, user_id, showAreaColumn) 
     62{ 
     63        /* set a special 'class' if the employee is a supervisor one */ 
     64        class_name = 'employee'; 
     65        if (areas[area_id].titular_funcionario_id == areas[area_id].employees[user_id].funcionario_id) 
     66                class_name += 'supervisor'; 
     67 
     68        /* creating the row. */ 
     69        element = $('<tr></tr>') 
     70                                /* name: first column */ 
     71                                .append( 
     72                                                $('<td></td>') 
     73                                                        .append( 
     74                                                                $('<span></span>') 
     75                                                                        .addClass(class_name) 
     76                                                                        .append(areas[area_id].employees[user_id].cn) 
     77                                                        ) 
     78                                                        .css('width', '85%') 
     79                                                ); 
     80 
     81        /* area: second (optional) column */ 
     82        if (showAreaColumn) 
     83                element.append( 
     84                                                $('<td>' + areas[area_id].sigla + '</td>') 
     85                                                        .css('width', '15%') 
     86                                        ); 
     87 
     88        /* telephone: last column */ 
     89        element.append( 
     90                                        $('<td>' + areas[area_id].employees[user_id].telephoneNumber + '</td>') 
     91                                                .css('width', '15%') 
     92                                        ) 
     93                                .addClass('employees'); 
     94 
     95        return element; 
     96} 
     97 
     98/** 
     99* Creating a employee table grouped by area 
     100*/ 
     101function showGroupedByArea() 
     102{ 
     103        var table = $('<table></table>').css('width', '90%').attr('id', 'employee_table'); 
     104        var i, j; 
     105 
     106        /* iterating over areas */ 
     107        for (i=0; i < areas.length; i++) { 
     108 
     109                /* inserting area header */ 
     110                table.append( 
     111                                $('<tr></tr>') 
     112                                .append( 
     113                                        $('<th></th>') 
     114                                                .css('text-align', 'left') 
     115                                                .css('height', '30') 
     116                                                .append( 
     117                                                        $('<span></span>') 
     118                                                                .addClass('orgchartPath') 
     119                                                                .append(areas[i].orgchartPath) 
     120                                                                ) 
     121                                                .append(areas[i].sigla) 
     122                                        ) 
     123                ); 
     124 
     125                /* creating employee rows */ 
     126                for (j=0; j < areas[i].employees.length; j++) 
     127                        table.append(createEmployeeRow(i, j)); 
     128        } 
     129        $('#areas_content').append(table); 
     130} 
     131 
     132/** 
     133* Creating employess ordered alphabetically and ungrouped. In this 
     134* function we implemented a 'merge' of all area's employee arrays. 
     135* 
     136* Be careful if you are going to update this code... =) 
     137*/ 
     138function showUngrouped() 
     139{ 
     140        var table = $('<table></table>').css('width', '90%').attr('id', 'employee_table'); 
     141        var i, less, end; 
     142 
     143        /* creating and reseting indexes */ 
     144        for (i=0; i < areas.length; i++) 
     145                areas[i].index = 0; 
     146 
     147        /* */ 
     148        while (true) { 
     149                less = -1; 
     150                end = true; 
     151 
     152                /* searching the area with smallest employee name */ 
     153                for (i=0; i < areas.length; i++) { 
     154 
     155                        /* if this area have employees left */ 
     156                        if (areas[i].employees.length > areas[i].index) { 
     157 
     158                                /* if it's the first area reached in this iteration */ 
     159                                if (less == -1) 
     160                                        less = i; 
     161 
     162                                /* updating less */ 
     163                                if (areas[i].employees[areas[i].index].cn < areas[less].employees[areas[less].index].cn) 
     164                                        less = i; 
     165 
     166                                /* so, we are not done */ 
     167                                end = false; 
     168                        } 
     169                } 
     170                /* if we are done */ 
     171                if (end) break; 
     172 
     173                /* inserting the row */ 
     174                table.append(createEmployeeRow(less, areas[less].index, true)); 
     175                areas[less].index++; 
     176        } 
     177        $('#areas_content').append(table); 
     178} 
     179 
     180/** 
     181* Print me! 
     182*/ 
    32183function printAction() 
    33184{ 
     
    35186} 
    36187 
     188/** 
     189* Binding events to HTML elements 
     190*/ 
    37191function bindEvents() 
    38192{ 
    39193        $('#employeesVisibility').click(toggleEmployeesVisibility); 
     194        $('#groupByArea').click(toggleGroupByArea); 
    40195        $('#highlightSupervisor').click(toggleHighlightSupervisor); 
    41196        $('#orgchartPathVisibility').click(toggleOrgchartPathVisibility); 
     
    45200function initialSetup() 
    46201{ 
     202        toggleGroupByArea(); 
    47203        toggleEmployeesVisibility(); 
    48204        toggleHighlightSupervisor(); 
     
    50206} 
    51207 
     208/** 
     209* Call setup functions on body onload. 
     210*/ 
    52211function pageLoad() 
    53212{ 
  • trunk/workflow/templates/default/orgchartPrint.tpl

    r795 r2107  
    1010        <label><input type="checkbox" checked id="employeesVisibility" /> Exibir funcionários</label> 
    1111        <br/> 
     12        <label><input type="checkbox" checked id="groupByArea" /> Agrupar por área</label> 
     13        <br/> 
    1214        <label><input type="checkbox" checked id="highlightSupervisor" /> Ressaltar titular</label> 
    1315        <br/> 
     
    1719</div> 
    1820 
     21 
    1922{if !empty($organizationName)} 
    2023<h1 class="organizationName">{$organizationName}</h1> 
    2124{/if} 
    2225 
    23 {foreach from=$areasInfo item=area} 
    24         <div class="area"> 
    25                 <h1><span class="orgchartPath">{$area.orgchartPath}</span>{$area.sigla}</h1> 
    26                 <div class="employees"> 
    27                         <table width="90%"> 
    28                         {foreach from=$area.employees item=employee} 
    29                         <tr> 
    30                         <td width="85%"><span class="employee{if $employee.funcionario_id == $area.titular_funcionario_id}supervisor{/if}">{$employee.cn}</span></td> 
    31                         <td width="15%" align="right">{$employee.telephoneNumber}</td> 
    32                         </tr> 
    33                         {/foreach} 
    34                         </table> 
    35                 </div> 
    36         </div> 
    37 {/foreach} 
     26<div id="areas_content" /> 
     27 
    3828{$footer} 
    3929</body> 
    4030</html> 
     31<script language="javascript"> 
     32var areas = {$areasJson}; 
     33</script> 
Note: See TracChangeset for help on using the changeset viewer.