Ignore:
Timestamp:
12/16/10 14:59:34 (13 years ago)
Author:
eduardoalex
Message:

Ticket #1412 - adição do novo layout na tela de contatos.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/mobile/inc/class.ui_mobilecc.inc.php

    r3573 r3595  
    66                var $page_info = array ( 
    77                                'actual_catalog' => false, 
    8                                 'is_external_catalog' => false 
     8                                'actual_letter' => null, 
     9                                'actual_max_contacts' => null, 
     10                                'request_from' => null 
    911                        ); 
    1012                 
    1113                var $public_functions = array( 
    12                         'contacts_list' => true, 
     14                        'index' => true, 
     15                        'change_max_results' => true, 
     16                        'change_catalog' => true, 
     17                        'delete_contacts' => true, 
     18                        'change_letter' => true, 
     19                        'choose_contact' => true, 
     20                        'init_cc' => true 
    1321                ); 
     22                var $template; 
    1423                 
    1524                /** 
     
    1827                 */ 
    1928                public function ui_mobilecc() { 
    20                         $this->nextmatchs       = CreateObject('phpgwapi.nextmatchs'); 
    21                 } 
    22                  
    23                 /** 
    24                  * Inicia um BO de catálogo do módulo de contactcenter. 
     29                        $this->template = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']); 
     30                        $this->bo = CreateObject('mobile.bo_mobilecc'); 
     31                        $page_info = $GLOBALS['phpgw']->session->appsession('mobilecc.page_info','mobile'); 
     32                         
     33                        if($page_info) { 
     34                                $this->page_info = $page_info; 
     35                        } 
     36                        else { 
     37                                $this->set_page_info_to_default(); 
     38                        } 
     39                         
     40                        //if() 
     41 
     42                } 
     43                 
     44                private function set_page_info_to_default() { //Valores default para iniciar o módulo de contatos 
     45                        $this->page_info['actual_catalog'] = 'bo_people_catalog'; 
     46                        $this->page_info['actual_letter'] = 'a'; 
     47                        $this->page_info['actual_max_contacts'] = 10; 
     48                        $this->page_info['request_from'] = null; 
     49                } 
     50                 
     51                private function save_session() { 
     52                        $GLOBALS['phpgw']->session->appsession('mobilecc.page_info','mobile',$this->page_info); 
     53                } 
     54                 
     55                public function index($params) { 
     56                        $GLOBALS['phpgw_info']['mobiletemplate']->set_error_msg($params["error_message"]); 
     57                        $GLOBALS['phpgw_info']['mobiletemplate']->set_success_msg($params["success_message"]); 
     58                        $this->contacts_list(); 
     59                } 
     60                 
     61                public function change_max_results($params) { 
     62                        $this->page_info['actual_max_contacts'] = $params['results']; 
     63                        $this->contacts_list(); 
     64                        $this->save_session(); 
     65                } 
     66                 
     67                public function change_letter($params) { 
     68                        $this->page_info['actual_letter'] = $params['letter']; 
     69                        $this->page_info['actual_max_contacts'] = 10; 
     70                        $this->contacts_list(); 
     71                        $this->save_session(); 
     72                } 
     73                 
     74                public function change_catalog($params) { 
     75 
     76                        $this->page_info['actual_catalog'] = $params['catalog']; 
     77                        $this->page_info['actual_max_contacts'] = 10; 
     78                        $this->page_info['actual_letter'] = 'a'; 
     79                         
     80                        $this->contacts_list(); 
     81                         
     82                        $this->save_session(); 
     83                } 
     84                 
     85                /** 
     86                 * Função de inicio do módulo para escolha de um contato para outro módulo. 
     87                 *  
    2588                 * @return  
    26                  * @param $catalog String com o catálogo 
    27                  */ 
    28                 private function set_catalog($catalog) { 
    29                         if(strpos($catalog,'bo_global_ldap_catalog')===false) //Ldap? 
    30                                 $this->bo= CreateObject("contactcenter.".$catalog); 
    31                         else { 
    32                                 $exploded = explode("#",$catalog); 
    33                                 $this->bo= CreateObject("contactcenter.bo_global_ldap_catalog",$exploded[1],$exploded[2],$exploded[3]); 
    34                                 if($exploded[3]==1) 
    35                                         $this->page_info['is_external_catalog'] = true; 
    36                                 else { 
    37                                         $this->page_info['is_external_catalog'] = false; 
    38                                 } 
    39                                          
    40                         } 
    41                         $this->page_info['actual_catalog'] = $catalog; 
    42                 } 
    43                  
    44                 /** 
    45                  * Busca um nome a partir do catálogo. Se nenhum for informado previamente, 
    46                  * retorna um array vazio. 
    47                  *  
    48                  * Caso o catálogo atual seja grupos, a busca será por títulos, caso seja 
    49                  * contatos pessoais, será por names_ordered, se for contato no ldap, será 
    50                  * por cn. 
    51                  *  
    52                  * @return array, com os ids relativos a busca 
    53                  * @param $name string com o nome à ser buscado. 
    54                  */ 
    55                 public function find($name) { 
    56                         if(!$this->page_info["actual_catalog"]) 
    57                                 return array(); 
    58                          
    59                         if($this->page_info['actual_catalog']=="bo_group_manager") { //parametros de busca para grupos 
    60                                 $id = 'group.id_group'; 
    61                                 $what = array('group.title',$id); 
    62                                 $search = "group.title"; 
    63                         } 
    64                         else { //parametros de busca para pessoas 
    65                                 $id = 'contact.id_contact'; 
    66                                 $search = "contact.names_ordered"; 
    67                                 $what = array('contact.names_ordered',$id); 
    68                         } 
    69                          
    70                         if ((strpos($this->page_info["actual_catalog"],'bo_global_ldap_catalog')!==false) && 
    71                                         (!$this->page_info['is_external_catalog'])) { //Ldap do expresso, leva em conta alguns atributos do expresso 
    72  
    73                                 array_push($what,'contact.object_class', 
    74                                                 'contact.account_visible', 
    75                                                 'contact.account_status' 
    76                                                 ); 
    77                                  
    78                                 $rules = array( 
    79                                                         0 => array( 
    80                                                                 'field' => 'contact.object_class', 
    81                                                                 'type'  => '=', 
    82                                                                 'value' => 'phpgwAccount' 
    83                                                         ), 
    84                                                         1 => array( 
    85                                                                 'field' => 'contact.account_status', 
    86                                                                 'type'  => 'iLIKE', 
    87                                                                 'value' => '%' 
    88                                                         ), 
    89                                                         2 => array( 
    90                                                                 'field' => 'contact.account_visible', 
    91                                                                 'type'  => '!=', 
    92                                                                 'value' => '-1' 
    93                                                         ), 
    94                                                         3 => array( 
    95                                                                 'field' => 'contact.object_class', 
    96                                                                 'type'  => '=', 
    97                                                                 'value' => 'inetOrgPerson' 
    98                                                         ) 
    99                                                 ); 
    100                         } 
    101                         else{ 
    102                                 $rules = array(); 
    103                         } 
    104  
    105                          
    106                          
    107                         if ($name != '') { //String em branco, não preciso adicionar essa regra 
    108                                 array_push($rules,array( 
    109                                                                 'field' => $search, 
    110                                                                 'type'  => 'iLIKE', 
    111                                                                 'value' => '%'.$name.'%' 
    112                                                         ));              
    113                         } 
    114                                                                                                                  
    115                         $ids = $this->bo->find($what,$rules); 
    116  
    117                         if(is_array($ids)) foreach($ids as $id_r) { //Quero apenas os ids, como valores nas posições do array 
    118                                 $retorno[] = $id_r[substr($id,strpos($id,".")+1)]; 
    119                         } 
    120                          
    121                         return $retorno; 
     89                 * @param $params Object 
     90                 */ 
     91                public function choose_contact($params) { 
     92                        $this->set_page_info_to_default(); 
     93                        $this->page_info['request_from'] = $params['request_from']; //Para escolher contato vindo de outro modulo, mudo apenas o request_from 
     94                        $this->contacts_list(); 
     95                        $this->save_session(); 
     96                } 
     97                 
     98                /** 
     99                 * Função de inicio do módulo de cc 
     100                 *  
     101                 * @return  
     102                 * @param $params Object 
     103                 */ 
     104                public function init_cc($params) { 
     105                        $this->set_page_info_to_default(); 
     106                        $this->contacts_list(); 
     107                        $this->save_session(); 
    122108                } 
    123109                 
     
    129115                 */ 
    130116                 
    131                 function contacts_list($from_calendar=false) { 
    132  
    133                         $entries = array(); 
    134                         $actual_page = 0; 
    135  
    136                         if(isset($_POST['name']) && strlen($_POST['name'])<4) //Busca apenas para nomes com mais de 4 palavras 
    137                                 $ids = false; 
    138                         else { 
    139                                 /////////////// Pego os ids referente a consulta, se a mesma foi feita 
    140                                 if(isset($_POST['name'])) { 
    141                                         $this->set_catalog($_POST['catalog']); 
    142                                         $ids = $this->find($_POST['name']); 
    143                                         if(is_array($ids)) { 
    144                                                 $actual_page = 1; 
    145                                                 $_SESSION["mobile_search_ids"] = $ids; 
    146                                                 $_SESSION["mobile_search_catalog"] = $_POST['catalog']; 
    147                                                 $ids = array_slice($ids,0,10); //Apenas a primeira página 
    148                                         } 
     117                function contacts_list() { 
     118                         
     119                        $this->template->set_file( 
     120                                Array( 
     121                                        'contacts_list' => 'cc_main.tpl' 
     122                                ) 
     123                        ); 
     124                        $this->template->set_block("contacts_list","catalog_row"); 
     125                        $this->template->set_block("contacts_list","main_body"); 
     126                        $this->template->set_block("contacts_list","pagging_block"); 
     127 
     128                        //Langs gerais da página 
     129                        $this->template->set_var("lang_back",lang("back")); 
     130                        $this->template->set_var("lang_more",lang("more")); 
     131                        $this->template->set_var("lang_contacts",ucfirst(lang("contacts"))); 
     132                        $this->template->set_var("actual_catalog",$this->page_info["actual_catalog"]); 
     133                        $this->template->set_var("next_max_results",$this->page_info["actual_max_contacts"]+10); 
     134                         
     135                        //Combo de catálogos 
     136                        $catalogs = $this->bo->get_all_catalogs(); 
     137                        foreach($catalogs as $catalog) { 
     138                                $this->template->set_var("catalog_value",$catalog["catalog"]); 
     139                                $this->template->set_var("catalog_name",$catalog["label"]); 
     140                                if($this->page_info['actual_catalog']==$catalog['catalog']) 
     141                                        $this->template->set_var("selected","selected"); 
     142                                else 
     143                                        $this->template->set_var("selected"," "); 
     144                                $this->template->fp("catalogs","catalog_row",true); 
     145                        } 
     146                        $this->bo->set_catalog($this->page_info["actual_catalog"]); 
     147                        $contacts = $this->bo->search($this->page_info["actual_letter"]."%", 
     148                                                                                        $this->page_info["actual_max_contacts"]); 
     149                                 
     150                         
     151                        //Letras da paginação 
     152                        $max_letters = 5; 
     153                        if ( in_array($this->page_info['actual_letter'], 
     154                                                  range("a","c"))){ //Letras de A à C iniciam sempre com A               
     155         
     156                                $this->template->set_var('show_back','none'); 
     157                                $this->template->set_var('show_next','inline'); 
     158                                $first_letter = "a"; 
     159                                $this->template->set_var('href_next',"index.php?menuaction=mobile.". 
     160                                                                                 "ui_mobilecc.change_letter&letter=f"); 
     161                        } 
     162                        else if ( in_array($this->page_info['actual_letter'], 
     163                                                  range("x","z"))) { //Letras de X à Z terminam sempre no Z 
     164                                $this->template->set_var('show_back','inline'); 
     165                                $this->template->set_var('show_next','none'); 
     166                                $first_letter = "v"; 
     167                                $this->template->set_var('href_back',"index.php?menuaction=mobile.". 
     168                                                                                 "ui_mobilecc.change_letter&letter=u"); 
    149169                                } 
    150                                 else if(isset($_GET['page'])) {  
    151                                         $this->set_catalog($_SESSION["mobile_search_catalog"]); 
    152                                         $ids = array_slice($_SESSION["mobile_search_ids"],($_GET['page']-1)*10,10); //Página solicitada 
    153                                         $actual_page = $_GET['page']; 
    154                                 } 
    155                                 else  
    156                                         $ids = false; 
    157                         } 
    158  
    159                         ///////////// Pego os dados dos ids da página em questão. 
    160                         if(!is_array($ids) || count($_SESSION["mobile_search_ids"])>100 || (isset($_POST["name"]) && strlen($_POST['name'])<4)) {  
    161                                 $entries = array(); 
    162                         } 
    163                         else { //Só pego os dados completos caso haja resultado na busca 
    164                                 if($this->page_info['actual_catalog']!="bo_group_manager") { //Se não for grupo, tenho que ordenar as connections 
    165  
    166                                     $display = "none"; 
    167                                     if(isset($GLOBALS['phpgw_info']['user']['preferences']['contactcenter']['cell']) && $GLOBALS['phpgw_info']['user']['preferences']['contactcenter']['cell'] == 1) 
    168                                     { 
    169                                         $_SESSION['phpgw_info']['user']['preferences']['contactcenter']['cellShow'] = true; 
    170                                         $display = "inline"; 
    171                                         $entries = $this->bo->get_multiple_entries($ids,array("names_ordered"=>true,"uidnumber"=>true,"id_contact"=>true,"companies"=>true,"connections"=>true)); 
    172                                     }else { 
    173                                         $entries = $this->bo->get_multiple_entries($ids,array("names_ordered"=>true,"uidnumber"=>true,"id_contact"=>true,"connections"=>true)); 
    174                                     } 
    175                                         /** 
    176                                          * As entradas vindas de get_multiple_entries não vem com as connections 
    177                                          * ordenadas. Abaixo eu ordeno o array connections de cada entrada para ter 
    178                                          * sempre na frente os valores defaults, primeiro o default de email, depois 
    179                                          * o de telefone. 
    180                                          */ 
    181                                         foreach($entries as &$valor) { 
    182                                                 /* Sempre iniciar os arrays, pois pode interferir na  
    183                                                  * ordenação atual se tiverem valores antigos desnecessários  
    184                                                  * causando erro de tamanhos inconsistentes */ 
    185                                                 $default = array();  
    186                                                 $type = array(); 
     170                        else { //Letras do meio 
     171                                $this->template->set_var('show_back','inline'); 
     172                                $this->template->set_var('show_next','inline'); 
     173                                 
     174                                $first_letter = chr(ord($this->page_info["actual_letter"])-3);//Inicio 3 letras antes 
     175                                $last_letter = chr(ord($first_letter)+($max_letters+1));//A ultima é a máxima quantidade de letras mais 1 do next_letter 
     176                                 
     177                                $this->template->set_var('href_back',"index.php?menuaction=mobile.". 
     178                                                                                 "ui_mobilecc.change_letter&letter=".$first_letter); 
     179                                $this->template->set_var('href_next',"index.php?menuaction=mobile.". 
     180                                                                                 "ui_mobilecc.change_letter&letter=".$last_letter); 
     181                                $first_letter++; 
     182                        } 
     183                         
     184                        for($i=1;$i<=$max_letters;$i++) { //Roda as letras 
     185                                        $this->template->set_var("href","index.php?menuaction=mobile.". 
     186                                                                                        "ui_mobilecc.change_letter&letter=".$first_letter); 
     187                                        $this->template->set_var("letter",strtoupper($first_letter)); 
     188                                        if($first_letter===$this->page_info["actual_letter"]) 
     189                                                $this->template->set_var("class_button","letter-contact-selected"); 
     190                                        else 
     191                                                $this->template->set_var("class_button","btn_off"); 
     192                                        $this->template->set_var("letter",strtoupper($first_letter)); 
     193                                        $this->template->fp("pagging_letters","pagging_block",true); 
     194                                        $first_letter++; 
     195                        } 
     196                         
     197 
     198                        if($contacts['has_more']) 
     199                                $this->template->set_var("show_more","block"); 
     200                        else 
     201                                $this->template->set_var("show_more","none"); 
     202                        unset($contacts['has_more']); 
    187203                                                 
    188                                                 foreach($valor['connections'] as $key => $value) { 
    189                                                         $default[$key] = $value['connection_is_default']; 
    190                                                         $type[$key] = $value['id_type']; 
    191                                                 } 
    192                                                 array_multisort($default, SORT_DESC, $type, SORT_ASC, $valor['connections']); 
    193                                         }//Fim da ordenação 
    194                                 } 
    195                                 else { 
    196                                         $entries = $this->bo->get_multiple_entries($ids,array("id_group"=>true,"title"=>true,"short_name"=>true)); 
    197                                 } 
    198  
    199                         } 
    200                          
    201                         ///////////////// Monto os dados gerais da página no template. 
    202                         $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); 
    203                          
    204                         if(!$from_calendar) 
    205                                 $p->set_file(Array('entries' => 'cc_main.tpl')); 
    206                         else if($from_calendar =='mobilecalendar') 
    207                                 $p->set_file(Array('entries' => 'add_participants.tpl')); 
    208                         else     
    209                                 $p->set_file(Array('entries' => 'add_recipients.tpl')); 
    210                                  
    211                         $p->set_block('entries','body'); 
    212                         $p->set_block('entries','people_header'); 
    213                         $p->set_block('entries','group_header'); 
    214                         $p->set_block('entries','row'); 
    215                         $p->set_block('entries','row_group'); 
    216                         $p->set_block('entries','row_empty'); 
    217                         $p->set_block('entries','option'); 
    218                         $p->set_block('entries','page'); 
    219                         $p->set_block('entries','page_no_link'); 
    220                         $p->set_block('entries','row_addeds'); 
    221                          
    222                          
    223                         $texts = array( 
    224                                 'lang_name' => lang("Name"), 
    225                                 'lang_catalog' => lang("Catalog"), 
    226                                 'lang_search' => lang("Search") 
    227                                 ); 
    228                         $p->set_var($texts); 
    229  
    230                         $p->set_var('lang_already_addeds:',lang('already_addeds:')); 
    231  
    232                         if($from_calendar == 'mobilecalendar') 
    233                                 $p->set_var('lang_continue_scheduling',lang('continue scheduling')); 
    234                         else if($from_calendar == 'mobilemail'){ 
    235                                 $p->set_var('lang_continue',lang('continue')); 
    236                         } 
    237  
    238                         /////////// Preenche o combo de catálogos 
    239                          
    240                         $bo_cc = CreateObject("contactcenter.bo_contactcenter"); 
    241                         $branchs = $bo_cc->get_catalog_tree(); 
    242                          
    243                         if(!$from_calendar || $from_calendar == 'mobilemail') { 
    244                                 foreach($branchs as $branch) { //Pego apenas a estrutura dos ramos vindos do banco, pois as do ldap estão confusas e com dados aparentemente inconsistentes. 
    245                                         if($branch['class']!="bo_global_ldap_catalog" && $branch['class']!="bo_catalog_group_catalog") { 
    246                                                 $p->set_var(array('option_value'=>$branch['class'],'option_text'=>$branch['name'])); 
    247          
    248                                                 if($this->page_info['actual_catalog']==$branch['class']) 
    249                                                         $p->set_var('selected','selected'); 
    250                                                 else 
    251                                                         $p->set_var('selected',''); 
    252                                                 $p->parse('options','option',True); 
    253                                         } 
    254                                                  
    255                                 } 
    256                         } 
    257                          
    258                         /////////// Preenche o combo, com dados do ldap 
    259                         $bo_ldap_manager = CreateObject("contactcenter.bo_ldap_manager"); 
    260                         $branchs = $bo_ldap_manager->get_all_ldap_sources(); 
    261                          
    262                         foreach($branchs as $id=>$branch) { //Ldaps expresso 
    263                                 $p->set_var(array('option_value'=>"bo_global_ldap_catalog#". 
    264                                                 $id."#". 
    265                                                 $branch['dn']."#". 
    266                                                 0, 
    267                                                 'option_text'=>$branch['name'])); //No value eu passo também o id, o contexto e se é externo, quando é um ldap 
    268  
    269                                 if($this->page_info['actual_catalog']=="bo_global_ldap_catalog#".$id."#".$branch['dn']."#". 0) 
    270                                         $p->set_var('selected','selected'); 
    271                                 else 
    272                                         $p->set_var('selected',''); 
    273                                 $p->parse('options','option',True);      
    274                         } 
    275                          
    276                         if(!$from_calendar  || $from_calendar == 'mobilemail') { 
    277                                 $branchs = $bo_ldap_manager->get_external_ldap_sources(); 
    278                                 if(is_array($branchs)) foreach($branchs as $id=>$branch) { //Ldaps externos 
    279                                         $p->set_var(array('option_value'=>"bo_global_ldap_catalog#". 
    280                                                         $id."#". 
    281                                                         $branch['dn']."#". 
    282                                                         1, 
    283                                                         'option_text'=>$branch['name'])); //No value eu passo também o id, o contexto e se é externo, quando é um ldap 
    284          
    285                                         if($this->page_info['actual_catalog']=="bo_global_ldap_catalog#".$id."#".$branch['dn']."#". 1) 
    286                                                 $p->set_var('selected','selected'); 
    287                                         else 
    288                                                 $p->set_var('selected',''); 
    289                                         $p->parse('options','option',True);      
    290                                 } 
    291                         } 
    292  
    293                         /////////// Monta o resultado da pesquisa 
    294                         $p->set_var('th_theme',$GLOBALS['phpgw_info']['theme']['th_bg']); 
    295                                                  
    296                         if(empty($entries) && isset($_POST["name"]) && count($_SESSION["mobile_search_ids"])<=100 && strlen($_POST['name'])>=4) { //Se foi feita a busca e não teve resultados... 
    297                                 $p->set_var('message',lang('No matches found')); 
    298                                 $p->parse('rows','row_empty',True); 
    299                         } 
    300                         else if(count($_SESSION["mobile_search_ids"])>100) { //Muitos resultados... 
    301                                 $p->set_var('message',lang('too many results')); 
    302                                 $p->parse('rows','row_empty',True);                      
    303                         } 
    304                         else if(isset($_POST["name"]) && strlen($_POST['name'])<4) { //Muitos resultados... 
    305                                 $p->set_var('message',lang('the search argument must have at least 4 digits')); 
    306                                 $p->parse('rows','row_empty',True);                      
    307                         } 
    308                         else if((isset($_POST["name"])) || (isset($_GET["page"]))){ //Renderizar... 
    309                                  
    310                                 /////////// Preenche o cabeçalho da consulta 
    311                                 if($this->page_info['actual_catalog']!="bo_group_manager") { 
    312                                         $p->set_var( 
    313                                                         array('lang_people_name'        => lang("Name"), 
    314                                                                 'lang_phone'            => lang("Phone"), 
    315                                                                 'lang_mobile'           => "Celular", //lang("Mobile"), 
    316                                                                 'display'               => $display, 
    317                                                                 'lang_mail'             => lang("Email"))); 
    318                                         $p->parse('header','people_header',True); 
    319                                 } 
    320                                 else { 
    321                                         $p->set_var( 
    322                                                         array('lang_group_name' => lang("Name"), 
    323                                                                 'lang_title' => lang("Title") 
    324                                                                 )); 
    325                                         $p->parse('header','group_header',True); 
    326                                 } 
    327                                  
    328                                 /////////// Preencho as linhas do resultado 
    329                                 foreach($entries as $id => $entry) { 
    330                                         $this->nextmatchs->template_alternate_row_color($p); 
    331                                         if(($this->page_info['actual_catalog']!="bo_group_manager") && 
    332                                                          (strpos($this->page_info['actual_catalog'],'bo_global_ldap_catalog')===false)){ //People 
    333                                                 $var = array( 
    334                                                                 'row_nome'      => $entry['names_ordered'], 
    335                                                                 'row_mobile'    => $entry['companies']['company1']['celPhone'] 
    336                                                         ); 
    337                                                 $conn1 = array_shift($entry['connections']); 
    338                                                 if(($conn1==NULL)||($conn1['connection_is_default']!=1)) { 
    339                                                         $var['row_telefone'] = '&nbsp;'; 
    340                                                         $var['row_email'] = '&nbsp;'; 
    341                                                 } 
    342                                                 else if($conn1['id_type']==1) { 
    343                                                         $var['row_email'] = $conn1['connection_value']; 
    344                                                         $conn2=array_shift($entry['connections']); 
    345                                                         if(($conn2==NULL)||($conn2['connection_is_default']!=1)) 
    346                                                                 $var['row_telefone'] = '&nbsp'; 
    347                                                         else 
    348                                                                 $var['row_telefone'] = $conn2['connection_value']; 
    349                                                 } 
    350                                                 else if($conn1['id_type']==2) { 
    351                                                         $var['row_email'] = '&nbsp;'; 
    352                                                         $var['row_telefone'] = $conn1['connection_value']; 
    353                                                 } 
    354                                                 $var['form_action'] = "index.php?menuaction=mobile.ui_mobilemail.new_msg"; 
    355                                                 $p->set_var($var); 
    356                                                 $p->parse('rows','row',True); 
    357                                         } 
    358                                         else if($this->page_info['actual_catalog']=="bo_group_manager"){ //Grupos 
    359                                                 $var = array( 
    360                                                                 'row_group_name'=>$entry['short_name'], 
    361                                                                 'row_title' => $entry['title'] 
    362                                                                 ); 
    363                                                  
    364                                                 $p->set_var($var); 
    365                                                 $p->parse('rows','row_group',True); 
    366                                         } 
    367                                         else { //Ldap 
    368                                                 $var = array('row_nome'=>$entry['names_ordered'][0],'row_mobile'=> $entry['companies']['company1']['celPhone']); 
    369                                                 $conn1 = array_shift($entry['connections']); 
    370                                                 if(($conn1==NULL)) { 
    371                                                         $var['row_telefone'] = '&nbsp;'; 
    372                                                         $var['row_email'] = '&nbsp;'; 
    373                                                 } 
    374                                                 else if($conn1['id_type']==1) { 
    375                                                         $var['row_email'] = $conn1['connection_value']; 
    376                                                         $conn2=array_shift($entry['connections']); 
    377                                                         if($conn2==NULL) 
    378                                                                 $var['row_telefone'] = '&nbsp'; 
    379                                                         else 
    380                                                                 $var['row_telefone'] = $conn2['connection_value']; 
    381                                                 } 
    382                                                 else if($conn1['id_type']==2) { 
    383                                                         $var['row_email'] = '&nbsp;'; 
    384                                                         $var['row_telefone'] = $conn1['connection_value']; 
    385                                                 } 
    386                                                 if(!$from_calendar) 
    387                                                         $var['form_action'] = "index.php?menuaction=mobile.ui_mobilemail.new_msg"; 
    388                                                 else if($from_calendar == 'mobilecalendar'){ 
    389                                                         $var['id_contact'] = $entry['uidnumber'][0].'U'; 
    390                                                         $var['form_action'] = "index.php?menuaction=mobile.ui_mobilecalendar.add_participant"; 
    391                                                 }else{ 
    392                                                         $var['id_contact'] = $entry['uidnumber'][0].'U'; 
    393                                                         $var['form_action'] = "index.php?menuaction=mobile.ui_mobilemail.add_recipient"; 
    394                                                 } 
    395                                                 $var['lang_select'] = lang("select"); 
    396                                                 $p->set_var($var); 
    397                                                 $p->parse('rows','row',True); 
    398                                         } 
    399                                 } 
    400                         } 
    401                          
    402                         if($from_calendar == 'mobilemail') { 
    403                                 $p->set_var('lang_choose_the_recipients',lang("choose the recipients")); 
    404                                 $participants = $_SESSION['mobile_mail']; 
    405                                 reset($participants); 
    406                                 while (($participant = current($participants))!==false) { 
    407                                         $p->set_var('row_contact_name',$participant); 
    408                                         if(next($participants)!==false) 
    409                                                 $p->set_var('row_separate',','); 
    410                                         else 
    411                                                 $p->set_var('row_separate','.'); 
    412                                         $p->parse('rows_addeds','row_addeds',True); 
    413                                 } 
    414                         }else if($from_calendar == 'mobilecalendar'){ 
    415                                 $p->set_var('lang_choose_the_participants',lang("choose the participants")); 
    416                                 $participants = $_SESSION['mobile_calendar']; 
    417                                 reset($participants); 
    418                                 while (($participant = current($participants))!==false) { 
    419                                         $p->set_var('row_contact_name',$participant); 
    420                                         if(next($participants)!==false) 
    421                                                 $p->set_var('row_separate',','); 
    422                                         else 
    423                                                 $p->set_var('row_separate','.'); 
    424                                         $p->parse('rows_addeds','row_addeds',True); 
    425                                 }                                
    426                         } 
    427                          
    428                         ////////////////// Monto a paginação 
    429                         if(!empty($entries) && count($_SESSION["mobile_search_ids"])<=100) { 
    430                                 $num_pages = count($_SESSION["mobile_search_ids"])/10; 
    431                                  
    432                                 if((count($_SESSION["mobile_search_ids"])%10!=0) || ($num_pages<1)) 
    433                                         $num_pages++; 
    434                                 if($actual_page!=0) { 
    435                                         for($i=1;$i<=$num_pages;$i++) { 
    436                                                 $p->set_var('num_page',$i); 
    437                                                 $p->set_var('display_page',$i); 
    438                                                 if($i!=$actual_page) 
    439                                                         $p->parse('pages','page',True); 
    440                                                 else 
    441                                                         $p->parse('pages','page_no_link',True); 
    442                                         } 
    443                                 } 
    444                                  
    445                                 if($actual_page>1) { 
    446                                         $p->set_var('num_page',$actual_page-1); 
    447                                         $p->set_var('display_page','<'); 
    448                                         $p->parse('back','page',True); 
    449                                 } 
    450                                  
    451                                 if(($actual_page!=floor($num_pages)) && (floor($num_pages)>1) && ($actual_page!=0)) { 
    452                                         $p->set_var('num_page',$actual_page+1); 
    453                                         $p->set_var('display_page','>'); 
    454                                         $p->parse('next','page',True); 
    455                                 }        
    456                         }                        
    457                          
    458                         //$p->pfp('out','body'); 
    459                         $GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out','body')); 
    460                 } 
    461                  
    462                 static function print_contacts($contacts) { 
     204                        $this->template->set_var("contacts",$this->print_contacts($contacts,true,$this->page_info['request_from'])); 
     205                         
     206 
     207                        $GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out','main_body')); 
     208                } 
     209                 
     210                /** 
     211                 * Remove os contatos selecionados 
     212                 *  
     213                 * @return  
     214                 * @param $contacts Object 
     215                 * @param $show_checkbox Object[optional] 
     216                 */ 
     217                 
     218                function delete_contacts($params) { 
     219                        $this->bo->set_catalog($params['catalog']); 
     220                        $status = $this->bo->remove_multiple_entries($params['contacts']); 
     221                         
     222                        $type = $this->page_info['actual_catalog']==='bo_people_catalog'?"contacts":"groups"; 
     223                         
     224                        if($status['success']) 
     225                                header("Location: index.php?menuaction=mobile.ui_mobilecc.index&success_message=".lang("selected $type were removed successfully")); 
     226                        else 
     227                                header("Location: index.php?menuaction=mobile.ui_mobilecc.index&error_message=".lang("one or more $type couldnt be removed")); 
     228                } 
     229                 
     230                static function print_contacts($contacts,$show_checkbox=false,$request_from = null) { 
    463231                        $functions = CreateObject('mobile.common_functions'); 
    464232                        $p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']); 
     
    470238                        $p->set_block('cc_t', 'rows_contacts'); 
    471239                        $p->set_block('cc_t', 'row_contacts'); 
     240                        $p->set_block('cc_t', 'row_groups'); 
    472241                        $p->set_block('cc_t', 'no_contacts'); 
    473                          
     242 
    474243                        $bg = "par"; 
    475244                        if(!empty($contacts)) { 
    476245                                foreach($contacts as $id => $contact) { 
    477246                                         
    478                                         $p->set_var('bg',$bg=="par"?$bg="reset-dt":$bg="par");                                                   
    479                                         $p->set_var('lang_tel',lang("tel")); 
    480                                         $p->set_var('show_tel',$contact["connections"]["connection2"]["connection_value"]!=null?"inline":"none"); 
    481                                         $p->set_var('lang_see_details',strtoupper(lang("see details"))); 
    482                                         $p->set_var('contact_name',$functions->strach_string(is_array($contact["names_ordered"])? 
    483                                                                         $contact["names_ordered"][0]:$contact["names_ordered"],20)); 
    484                                         $p->set_var('email', 
    485                                                                 $functions->strach_string( 
    486                                                                         ($contact["connections"]["connection1"]["connection_value"]!=null &&  
    487                                                                         $contact["connections"]["connection1"]["id_type"]==="1")? 
    488                                                                                 $contact["connections"]["connection1"]["connection_value"]:"&nbsp;",20)); 
    489                                         $p->set_var('tel',$functions->strach_string($contact["connections"]["connection1"]["id_type"]==="2"? 
    490                                                                                 $contact["connections"]["connection1"]["connection_value"]: 
    491                                                                                 $contact["connections"]["connection2"]["connection_value"],19)); 
     247                                        $p->set_var('show_check',$show_checkbox?"inline":"none"); 
     248                                        $p->set_var('bg',$bg=="par"?$bg="reset-dt":$bg="par"); 
     249                                                                                 
     250                                        if($contact["catalog"]!=="bo_group_manager") {  //Contatos               
     251                                                $id=$contact["catalog"]==="bo_people_catalog"?$contact["id_contact"]:$contact['uidnumber'][0]; 
    492252                                                 
    493                                         $p->fp('rows','row_contacts',True); 
     253                                                $mail = $contact["connections"]["connection1"]["connection_value"];//Preciso o mail depois 
     254                                                $cn = is_array($contact["names_ordered"])? 
     255                                                                                $contact["names_ordered"][0]:$contact["names_ordered"]; 
     256                                                if(($contact["connections"]["connection1"]["connection_value"]==null ||  
     257                                                                                $contact["connections"]["connection1"]["id_type"]!=="1") 
     258                                                                                && isset($request_from)) //Se vier de outro módulo e não possuir e-mail, não mostre. 
     259                                                        continue; 
     260 
     261                                                $p->set_var('contact_id',$id);           
     262                                                $p->set_var('lang_tel',lang("tel")); 
     263                                                $p->set_var('show_tel',$contact["connections"]["connection2"]["connection_value"]!=null?"inline":"none"); 
     264                                                $p->set_var('contact_name',$functions->strach_string($cn,17)); 
     265                                                $p->set_var('email', 
     266                                                                        $functions->strach_string( 
     267                                                                                ($contact["connections"]["connection1"]["connection_value"]!=null &&  
     268                                                                                $contact["connections"]["connection1"]["id_type"]==="1")? 
     269                                                                                        $contact["connections"]["connection1"]["connection_value"]:"&nbsp;",20)); 
     270                                                $p->set_var('tel',$functions->strach_string($contact["connections"]["connection1"]["id_type"]==="2"? 
     271                                                                                        $contact["connections"]["connection1"]["connection_value"]: 
     272                                                                                        $contact["connections"]["connection2"]["connection_value"],19)); 
     273                                                         
     274                                                $p->fp('rows','row_contacts',True); 
     275                                        } 
     276                                        else { //Grupos 
     277                                                $id=$contact["id_group"]; 
     278                                                $mail = $cn = $contact["title"]; 
     279                                                $p->set_var('group_id',$contact["id_group"]); 
     280                                                $p->set_var('group_name',$contact["title"]); 
     281                                                $p->fp('rows','row_groups',True); 
     282                                        } 
     283                                         
     284                                        if($request_from==null) { 
     285                                                $p->set_var('lang_see_details',strtoupper(lang("see details"))); 
     286                                                $p->set_var('href_details',"ui_mobilecc.contact_view&id=$id&catalog=".$contact["catalog"]); 
     287                                        } 
     288                                        else { 
     289                                                $p->set_var('lang_see_details',strtoupper(lang("select"))); 
     290                                                $p->set_var('href_details','ui_mobilemail.add_recipient&mail=$mail&cn=$cn'); 
     291                                        } 
    494292                                } 
     293                                 
    495294                        } 
    496295                        else { 
Note: See TracChangeset for help on using the changeset viewer.