Changeset 4498
- Timestamp:
- 05/24/11 17:58:15 (13 years ago)
- Location:
- sandbox/2.2.0.2/contactcenter
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.2.0.2/contactcenter/inc/class.bo_group.inc.php
r1280 r4498 59 59 } 60 60 61 /*! 62 * @function get_groups_by_user 63 * @abstract Busca todos os grupos cadastrados de um usuário. 64 * @author Luiz Carlos Viana Melo - Prognus 65 * @param (integer) $id_user O ID do usuário. 66 * @return Retorna uma estrutura contendo: 67 * array( 68 * array( 69 * id_group => O ID do grupo; 70 * title => O nome do grupo; 71 * short_name => O nome abreviado do grupo. 72 * ) 73 * ) 74 */ 75 function get_groups_by_user($id_user = false) 76 { 77 return $this->so->select_owner_groups($id_user); 78 } 79 80 /*! 81 * @function get_contact_groups 82 * @abstract Busca todos os grupos a qual o contato pertence. 83 * @author Luiz Carlos Viana Melo - Prognus 84 * @param (integer) $id_contact O ID do contato. 85 * @return Retorna uma estrutura contendo: 86 * array( 87 * array( 88 * id_contact => O ID do contato; 89 * id_connection => O ID da conexão de associação; 90 * id_group => O ID do grupo; 91 * title => O nome do grupo; 92 * short_name => O nome abreviado do grupo. 93 * ) 94 * ) 95 */ 96 function get_contact_groups ($id_contact) 97 { 98 return $this->so->select_contact_groups($id_contact); 99 } 100 101 /*! 102 * @function add_contacts_in_group 103 * @abstract Adiciona novos contatos em um determinado grupo. 104 * @author Luiz Carlos Viana Melo - Prognus 105 * @param (integer) $id_group O ID do grupo onde serão adicionados os contatos. 106 * @param (array) $contacts_conns Os IDs das conexões dos contatos que serão 107 * associados ao grupo. 108 * @return Retorna true caso for adicionado com sucesso. 109 */ 110 function add_contacts_in_group($id_group, $contacts_conns) 111 { 112 //essa função recebe uma lista de ID de conexões que serão adicionadas no grupo. 113 return $this->so->insertContactsByGroup($id_group, $contacts_conns); 114 } 115 116 /*! 117 * @function remove_contacts_from_group 118 * @abstract Remove contatos de um grupo. 119 * @author Luiz Carlos Viana Melo - Prognus 120 * @param (integer) $id_group O ID do grupo de onde serão removidos os contatos. 121 * @param (array) $contact_conns Os ID das conexões dos contatos que serão 122 * removidos do grupo. 123 * @return Retorna True caso for removidos com sucesso. 124 */ 125 function remove_contacts_from_group($id_group, $contacts_conns) 126 { 127 return $this->so->deleteContactsByGroup($id_group, $contacts_conns); 128 } 61 129 62 130 } -
sandbox/2.2.0.2/contactcenter/inc/class.bo_people_catalog.inc.php
r4477 r4498 518 518 { 519 519 $contact = CreateObject('contactcenter.so_contact', $id_contact); 520 $connections = $contact->get_connections($extra); 521 520 $connections = $contact->get_connections(); 521 $getDummy = false; 522 if ($extra && $extra === 'defaultwdummy') 523 { 524 $getDummy = true; 525 $extra = 'default'; 526 } 527 522 528 $count = 1; 523 529 foreach($connections as $id => $type) … … 552 558 553 559 return $return; 560 } 561 562 /* 563 * @function update_contact_groups 564 * @abstract Atualiza os grupos onde o contato está inserido. 565 * @author Luiz Carlos Viana Melo - Prognus 566 * @param (integer) $id_contact O ID do contato. 567 * @param (array) $groups Os grupos onde o contato será inserido/removido. O 568 * formato dos grupos será: 569 * array( 570 * 'added' => array( 571 * id_group => array ( 572 * 'id_group' => O ID do grupo. 573 * 'title' => O título do grupo. 574 * ) 575 * ) 576 * 'removed' => mesmo formato do added. 577 * ) 578 */ 579 function update_contact_groups($id_contact, $groups, $old_connections = false) 580 { 581 $connections = $this->get_connections($id_contact, 'defaultwdummy'); 582 $default_connection = false; 583 foreach ($connections as $connection) 584 { 585 if (!$default_connection) 586 { 587 $default_connection = $connection; 588 } 589 if ($connection['id_type'] === 1) 590 { 591 $default_connection = $connection; 592 } 593 if($default_connection['id_type'] === 1) 594 { 595 break; 596 } 597 598 } 599 600 $altered = false; 601 602 if ($default_connection) 603 { 604 $bo_group = CreateObject('contactcenter.bo_group'); 605 $old_groups = $groups['previous_selected']; 606 if ($old_connections) 607 $bo_group->update_contact_groups($default_connection['id_connection'], $old_connections, $old_groups); 608 $added_groups = $groups['added']; 609 $removed_groups = $groups['removed']; 610 611 foreach ($added_groups as $group) 612 { 613 $altered = true; 614 $c = array(); 615 $c[] = $default_connection['id_connection']; 616 $bo_group->add_contacts_in_group($group['id_group'], $c); 617 } 618 619 foreach ($removed_groups as $group) 620 { 621 $altered = true; 622 $c = array(); 623 $c[] = $default_connection['id_connection']; 624 $bo_group->remove_contacts_from_group($group['id_group'], $c); 625 } 626 } 627 628 if ($altered) 629 { 630 $contact = CreateObject('contactcenter.so_contact', $id_contact); 631 $contact->set_field("last_status", 'U'); 632 $contact->set_field("last_update",time()."000"); 633 return $contact->commit(); 634 } 554 635 } 555 636 -
sandbox/2.2.0.2/contactcenter/inc/class.so_group.inc.php
r4477 r4498 104 104 return True; 105 105 } 106 107 /*! 108 * @function select_owner_groups 109 * @abstract Busca todos os grupos do usuário atual. 110 * @author Luiz Carlos Viana Melo - Prognus 111 * @param (integer) $id_owner O ID do usuário. 112 * @return Retorna uma estrutura contendo: 113 * array( 114 * array( 115 * id_group => O ID do grupo; 116 * title => O nome do grupo; 117 * short_name => O nome abreviado do grupo. 118 * ) 119 * ) 120 */ 121 function select_owner_groups($id_owner = false) 122 { 123 $query = 'SELECT id_group, title, short_name FROM phpgw_cc_groups '; 124 if ($id_owner) 125 $query .= 'WHERE owner = ' . $id_owner. ' ORDER BY title;'; 126 else 127 $query .= 'WHERE owner = ' . $this->owner . ' ORDER BY title;'; 128 129 if (!$this->db->query($query)) 130 { 131 exit ('Query failed! File: '.__FILE__.' on line'.__LINE__); 132 } 133 134 $return = false; 135 136 while($this->db->next_record()) 137 { 138 $return[] = $this->db->row(); 139 } 140 141 return $return; 142 } 143 144 /*! 145 * @function select_contact_groups 146 * @abstract Seleciona os grupos do contato. 147 * @author Luiz Carlos Viana Melo - Prognus 148 * @param (integer) $id_contact O ID do contato. 149 * @return Retorna uma estrutura contendo: 150 * array( 151 * array( 152 * id_contact => O ID do contato; 153 * id_group => O ID do grupo; 154 * title => O nome do grupo; 155 * short_name => O nome abreviado do grupo. 156 * ) 157 * ) 158 */ 159 function select_contact_groups($id_contact) 160 { 161 $query = 'SELECT Contato.id_contact, ContatoGprs.id_connection, Grupos.id_group, Grupos.title, ' . 162 'Grupos.short_name FROM phpgw_cc_contact_conns Contato, ' . 163 'phpgw_cc_connections Conexao, phpgw_cc_contact_grps ContatoGprs, ' . 164 'phpgw_cc_groups Grupos WHERE Contato.id_contact = ' . $id_contact . 165 ' AND Contato.id_connection = Conexao.id_connection AND ' . 166 'Conexao.id_connection = ContatoGprs.id_connection AND ' . 167 'ContatoGprs.id_group = Grupos.id_group ORDER BY title'; 168 169 if (!$this->db->query($query)) 170 { 171 exit ('Query failed! File: '.__FILE__.' on line'.__LINE__); 172 } 173 174 $return = false; 175 176 while($this->db->next_record()) 177 { 178 $return[] = $this->db->row(); 179 } 180 181 return $return; 182 } 106 183 107 184 function deleteContactFromGroups($id) … … 402 479 "phpgw_cc_contact_conns B, phpgw_cc_connections C,phpgw_cc_contact_grps D,phpgw_cc_groups E where ". 403 480 "A.id_contact = B.id_contact and B.id_connection = C.id_connection ". 404 " and B.id_typeof_contact_connection = 1and ".481 " and ". 405 482 "A.id_owner =".$this->owner." and ". 406 483 "D.id_group = E.id_group and ". … … 445 522 'phpgw_cc_contact_conns B, phpgw_cc_connections C,phpgw_cc_contact_grps D where '. 446 523 'A.id_contact = B.id_contact and B.id_connection = C.id_connection '. 447 ' and B.id_typeof_contact_connection = 1and '.524 ' and '. 448 525 //'A.id_owner ='.$this->owner.' and D.id_connection = C.id_connection and D.id_group = '.$id_group. 449 526 ' D.id_connection = C.id_connection and D.id_group = '.$id_group. //If I have the group ID, why ask about owner? -
sandbox/2.2.0.2/contactcenter/inc/class.ui_api.inc.php
r4196 r4498 233 233 $template->set_var('cc_contact_corporative',lang('Corporative')); 234 234 $template->set_var('cc_contact_conns',lang('Connections')); 235 $template->set_var('cc_contact_grps', lang('Groups')); 235 236 $template->set_var('emails_telephones', lang("E-Mails and Telephones")); 236 237 $template->set_var('cc_default', lang("Default")); … … 331 332 /* End Contact - Connections */ 332 333 333 334 /* Contact - Groups */ 335 $template->set_var('cc_grps_available', lang('Groups available')); 336 $template->set_var('cc_grps_selected', lang('Selected groups')); 337 $template->set_var('txt_add', lang('Add')); 338 $template->set_var('txt_rem', lang('Remove')); 339 /* End Contact - Groups */ 334 340 335 341 /* Corporate - contact */ -
sandbox/2.2.0.2/contactcenter/inc/class.ui_data.inc.php
r4483 r4498 1803 1803 1804 1804 /* Relations */ 1805 1805 1806 /* Groups */ 1807 /* 1808 * Criado uma estrutura no data que conterá os grupos do 1809 * contato. O formato é: 1810 * data['groups'] = array( 1811 * 'id_group' => array( 1812 * 'id_group', 'title', 'short_name' 1813 * ) 1814 * ); 1815 */ 1816 $boGroup = CreateObject('contactcenter.bo_group'); 1817 $groups = $boGroup->get_contact_groups($id); 1818 1819 $i = 0; 1820 $data['groups'] = array(); 1821 foreach($groups as $group) 1822 { 1823 $idGroup = $group['id_group']; 1824 $data['groups'][$idGroup] = array( 1825 'title' => $group['title'], 1826 'id_group' => $idGroup, 1827 'short_name' => $group['short_name'] 1828 ); 1829 $i++; 1830 } 1831 1806 1832 echo serialize($data); 1807 1833 } … … 1822 1848 $predata[] = $boPeopleCatalog -> get_all_countries(); 1823 1849 $predata[] = $boPeopleCatalog -> get_all_connections_types(); 1850 $boGroup = CreateObject('contactcenter.bo_group'); 1851 $predata[] = $boGroup->get_groups_by_user(); 1824 1852 //$predata[] = $this->bo->catalog->get_all_relations_types(); 1825 1853 … … 2444 2472 /* Does nothing... */ 2445 2473 break; 2474 case 'groups': 2475 $groups = $data['groups']; 2476 unset($data['groups']); 2477 break; 2446 2478 2447 2479 default: … … 2478 2510 'status' => 'fail' 2479 2511 ); 2512 } 2513 else 2514 { 2515 $this->bo->catalog->update_contact_groups($id, $groups); 2480 2516 } 2481 2517 -
sandbox/2.2.0.2/contactcenter/js/cc.js
r4305 r4498 74 74 /* Connections Variables */ 75 75 var CC_conn_last_selected = 0; 76 77 /* Grupos inicialmente selecionados */ 78 var CC_initial_selected_grps = new Array(); 76 79 77 80 /***********************************************\ … … 344 347 345 348 /* Populate Connection Types */ 346 i = 1; 349 /* 350 * Código não funcional com o expresso. 351 */ 352 /*i = 1; 347 353 for (j in data[4]) 348 354 { 349 355 Element('cc_conn_type').options[i] = new Option(data[4][j], j); 350 356 i++; 351 } 352 357 }*/ 358 353 359 /* Populate Relations Types */ 360 /* 361 * Código conflitante com a modificação de seleção de grupos durante 362 * a criação de um novo contato. Também foi verificado que este código não 363 * é funcional. 364 */ 365 /* 354 366 i = 0; 355 367 for (j in data[5]) … … 357 369 Element('cc_rels_type').options[i] = new Option(data[5][j], j); 358 370 i++; 371 }*/ 372 373 /* Populate available groups */ 374 i = 0; 375 var grupos = data[5]; 376 for (var grupo in grupos) 377 { 378 Element('id_grps_available').options[i] = new Option(grupos[grupo]['title'], grupos[grupo]['id_group']); 379 i++; 359 380 } 360 381 … … 364 385 365 386 Connector.newRequest('populateFullAddConst', CC_url+'get_contact_full_add_const', 'GET', handler); 387 } 388 389 /* 390 * Função que faz a seleção do grupo. 391 * Autor: Luiz Carlos Viana Melo - Prognus 392 */ 393 function selectGroup() 394 { 395 grps_avail = Element('id_grps_available'); 396 grps_selec = Element('id_grps_selected'); 397 398 for (i = 0; i < grps_avail.length; i++) 399 { 400 if (grps_avail.options[i].selected) { 401 isSelected = false; 402 403 for(var j = 0;j < grps_selec.options.length; j++) { 404 if(grps_selec.options[j].value === grps_avail.options[i].value){ 405 isSelected = true; 406 break; 407 } 408 } 409 410 if(!isSelected){ 411 412 option = document.createElement('option'); 413 option.value = grps_avail.options[i].value; 414 option.text = grps_avail.options[i].text; 415 option.selected = false; 416 grps_selec.options[grps_selec.options.length] = option; 417 418 } 419 420 } 421 } 422 423 for (j =0; j < grps_avail.options.length; j++) 424 grps_avail.options[j].selected = false; 425 } 426 427 /* 428 * Função que remove um grupo selecionado. 429 * Autor: Luiz Carlos Viana Melo - Prognus 430 */ 431 function deselectGroup() 432 { 433 grps_selec = Element('id_grps_selected'); 434 435 for(var i = 0;i < grps_selec.options.length; i++) 436 if(grps_selec.options[i].selected) 437 grps_selec.options[i--] = null; 366 438 } 367 439 … … 384 456 Element('cc_full_add_contact_id').value = data['cc_full_add_contact_id']; 385 457 populatePersonalData(data['personal']); 458 populateContactGroups(data['groups']); 386 459 //populateRelations(data['relations']); 387 460 }; 388 461 Connector.newRequest('populateFullEdit', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_full_data&id=' + id + "&catalog="+catalog, 'GET', handler); 462 } 463 464 /* 465 * Função que preenche a lista de grupos a qual o contato pertence. 466 * Autor: Luiz Carlos Viana Melo - Prognus 467 */ 468 function populateContactGroups(groupsData) 469 { 470 groups_selected = Element('id_grps_selected'); 471 var i = 0; 472 CC_initial_selected_grps = new Array(); 473 for (var group in groupsData) 474 { 475 var id_group = groupsData[group]['id_group']; 476 option = document.createElement('option'); 477 option.value = id_group; 478 option.text = groupsData[group]['title']; 479 option.selected = false; 480 groups_selected.options[i++] = option; 481 CC_initial_selected_grps[id_group] = new Array(); 482 CC_initial_selected_grps[id_group]['id_group'] = id_group; 483 CC_initial_selected_grps[id_group]['title'] = groupsData[group]['title']; 484 CC_initial_selected_grps[id_group]['short_name'] = groupsData[group]['short_name']; 485 } 389 486 } 390 487 … … 441 538 function resetFullAdd() 442 539 { 540 /* Groups */ 541 gprs_selected = Element('id_grps_selected'); 542 for (j =0; j < gprs_selected.options.length; j++) { 543 gprs_selected.options[j].selected = false; 544 gprs_selected.options[j--] = null; 545 } 443 546 /* Clear information container */ 444 547 CC_contact_full_info = new Array(); … … 706 809 } 707 810 811 data['groups'] = getAddedRemovedGroups(); 812 708 813 var serial = serialize(data); 709 814 return 'data=' + escape(serialize(data)); 815 } 816 817 /* 818 * Função que retorna os grupos que foram anteriormente selecionados, adicionados ou removidos pelo 819 * usuário. O formato retornado é um array contendo: 820 * ['added'] { 821 * [id_group] { 822 * 'id_group' => o ID do grupo 823 * 'title' => o título do grupo 824 * } 825 * }, 826 * ['removed'] { 827 * [id_group] { 828 * 'id_group' => o ID do grupo 829 * 'title' => o título do grupo 830 * } 831 * } 832 * Autor: Luiz Carlos Viana Melo - Prognus 833 */ 834 function getAddedRemovedGroups() 835 { 836 var selected_groups = getSelectedGroups(); 837 var added_groups = diffContactIDArray(selected_groups, CC_initial_selected_grps); 838 var removed_groups = diffContactIDArray(CC_initial_selected_grps, selected_groups); 839 var groups = new Array(); 840 groups['added'] = added_groups; 841 groups['removed'] = removed_groups; 842 return groups; 843 } 844 845 /* 846 * Função que retorna os grupos que foram selecionados pelo usuário. O formato retornado é: 847 * [id_group] { 848 * 'id_group' => o ID do grupo 849 * 'title' => o título do grupo 850 * } 851 * Autor: Luiz Carlos Viana Melo - Prognus 852 */ 853 function getSelectedGroups() 854 { 855 var gprs_selected = Element('id_grps_selected'); 856 var data = new Array(); 857 for(i = 0; i < gprs_selected.options.length; i++) 858 { 859 var id_group = gprs_selected.options[i].value; 860 data[id_group] = new Array(); 861 data[id_group]['id_group'] = id_group; 862 data[id_group]['title'] = gprs_selected.options[i].text; 863 } 864 return data; 865 } 866 867 /* 868 * Função que retorna a diferença entre 2 arrays com ID dos contatos. 869 * Autor: Luiz Carlos Viana Melo - Prognus 870 */ 871 function diffContactIDArray(array1, array2) 872 { 873 var diff = new Array(); 874 for (var group in array1) 875 { 876 if (!array2[group]) 877 diff.push(array1[group]); 878 } 879 return diff; 710 880 } 711 881 -
sandbox/2.2.0.2/contactcenter/setup/phpgw_es-es.lang
r4477 r4498 99 99 GPG Finger Print contactcenter es-es Firma GPG 100 100 Group Add common es-es Añadir Grupo 101 Groups available contactcenter es-es Grupos disponibles 102 Selected groups contactcenter es-es Grupos seleccionados 101 103 Home contactcenter es-es Casa 102 104 Import contactcenter es-es Importar -
sandbox/2.2.0.2/contactcenter/templates/default/full_add.tpl
r1676 r4498 13 13 <input id="cc_contact_personal" type="hidden" value="{cc_contact_personal}"> 14 14 <input id="cc_contact_addrs" type="hidden" value="{cc_contact_addrs}"> 15 <input id="cc_contact_grps" type="hidden" value="{cc_contact_grps}"> 15 16 <input id="cc_contact_conns" type="hidden" value="{emails_telephones}"> 16 17 <input id="cc_pd_full_name" name="{cc_pd_full_name}" type="hidden"> … … 161 162 <div style="z-index:10000;position: absolute;display:none; top: 170px; left: 78px;" id="div_cc_conn_is_default"> {cc_default} <select id="cc_email_default" name="cc_email_default" disabled style="display:none"></select><select id="cc_phone_default" name="cc_phone_default" disabled style="display:none"></select></div> 162 163 </div> 164 165 <!-- _GROUPS --> 166 <div id="cc_contact_groups_tab" class="row_off div_cc_contact_tab" style="position: absolute; visibility: hidden;height:247px;width:498px"> 167 <table border="0" cellpadding="0" cellspacing="0" align="center" width="100%"> 168 <tr> 169 <td align="right"> 170 <table border="0" cellpadding="0" cellspacing="0"> 171 <tr height="30" class="th"> 172 <td align="center">{cc_grps_available}</td> 173 </tr> 174 <tr height="30" class="th"> 175 <td align="right"><select id="id_grps_available" multiple name="grps_available[]" style="width:200px" size="10"></select></td> 176 </tr> 177 </table> 178 </td> 179 <td id="buttons" width="95" align="center"> 180 <button type="button" onClick="javascript:selectGroup()"><img src="../phpgwapi/templates/celepar/images/add.png" style="vertical-align: middle;" > {txt_add}</button> 181 <br><br> 182 <button type="button" onClick="javascript:deselectGroup()"><img src="../phpgwapi/templates/celepar/images/rem.png" style="vertical-align: middle;" > {txt_rem}</button> 183 </td> 184 <td align="left"> 185 <table border="0" cellpadding="0" cellspacing="0"> 186 <tr height="30" class="th"> 187 <td align="center">{cc_grps_selected}</td> 188 </tr> 189 <tr height="30" class="th"> 190 <td align="left"><select id="id_grps_selected" multiple name="grps_selected[]" style="width:200px" size="10"></select></td> 191 </tr> 192 </table> 193 </td> 194 </tr> 195 </table> 196 </div> 197 163 198 <!-- _BOTTOM BUTTONS --> 164 199 <div align="center" id="cc_contact_tab_buttons" style="position: absolute; visibility: hidden; top: 250px; left: 0px; width: 498px; height: 64px; border: 0px solid black"> … … 227 262 'name': Element('cc_contact_addrs').value, 228 263 'selectedClass': 'tab_box_active', 229 'unselectedClass': 'tab_box'}); 264 'unselectedClass': 'tab_box'}); 265 tabs.addTab({'id': 'cc_contact_groups_tab', 266 'name': Element('cc_contact_grps').value, 267 'selectedClass': 'tab_box_active', 268 'unselectedClass': 'tab_box'}); 230 269 231 270 fullAddWin = new dJSWin({'id': 'cc_full_add_window', … … 238 277 'title_text_color': 'white', 239 278 'button_x_img': Element('cc_phpgw_img_dir').value+'/winclose.gif', 240 'include_contents': new Array('cc_contact_tab_0', 'cc_contact_tab_1', 'cc_contact_tab_2','cc_contact_ tab_buttons'),279 'include_contents': new Array('cc_contact_tab_0', 'cc_contact_tab_1', 'cc_contact_tab_2','cc_contact_groups_tab','cc_contact_tab_buttons'), 241 280 'border': true}); 242 281
Note: See TracChangeset
for help on using the changeset viewer.