source: branches/2.2.0.1/contactcenter/inc/class.ui_preferences.inc.php @ 3707

Revision 3707, 5.7 KB checked in by eduardoalex, 13 years ago (diff)

Ticket #1499 - Contactcenter - Ajuste em salvar Preferencias de Visualizacao de Cartoes.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2  /***************************************************************************\
3  * eGroupWare - Contacts Center                                              *
4  * http://www.egroupware.org                                                 *
5  * Written by:                                                               *
6  *  - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net>         *
7  *  sponsored by Thyamad - http://www.thyamad.com
8  * ------------------------------------------------------------------------- *
9  *  This program is free software; you can redistribute it and/or modify it  *
10  *  under the terms of the GNU General Public License as published by the    *
11  *  Free Software Foundation; either version 2 of the License, or (at your   *
12  *  option) any later version.                                               *
13  \***************************************************************************/
14
15
16        class ui_preferences
17        {
18                var $public_functions = array(
19                        'index'           => true,
20                        'set_preferences' => true,
21                );
22               
23                function index()
24                {
25                        $GLOBALS['phpgw_info']['flags']['app_header'] = lang('ContactCenter').' - '.lang('Preferences');
26                        $GLOBALS['phpgw']->common->phpgw_header();
27                        echo parse_navbar();
28
29                        $GLOBALS['phpgw']->template->set_file(array('pref' => 'preferences.tpl'));
30
31                        /* Get Saved Preferences */
32                        $actual = $this->get_preferences();
33                       
34                        /* Get the catalog options */
35                        $pCatalog = CreateObject('contactcenter.bo_people_catalog');
36                        $types = $pCatalog->get_all_connections_types();
37                       
38                        if (is_array($types))
39                        {
40                                $options_email = '';
41                                foreach($types as $id => $name)
42                                {
43                                        $options_email .= '<option value="'.$id.'"';
44                                       
45                                        if ($actual['personCardEmail'] == $id)
46                                        {
47                                                $options_email .= ' selected ';
48                                        }
49                               
50                                        $options_email .= '>'.$name."</option>\n";
51                                }
52                       
53                                $options_phone = '';
54                                foreach($types as $id => $name)
55                                {
56                                        $options_phone .= '<option value="'.$id.'"';
57                                       
58                                        if ($actual['personCardPhone'] == $id)
59                                        {
60                                                $options_phone .= ' selected ';
61                                        }
62                               
63                                        $options_phone .= '>'.$name."</option>\n";
64                                }
65                        }
66                        else
67                        {
68                                $options_email = '';
69                                $options_phone = '';
70                        }
71                       
72                        if ($actual['displayConnector'] or !$actual['displayConnectorDefault'])
73                        {
74                                $GLOBALS['phpgw']->template->set_var('displayConnector', 'checked');
75                        }
76                        else
77                        {
78                                $GLOBALS['phpgw']->template->set_var('displayConnector', '');
79                        }
80                       
81                        if ($actual['empNum'])
82                        {
83                                $GLOBALS['phpgw']->template->set_var('empNum', 'checked');
84                        }
85                        else
86                        {
87                                $GLOBALS['phpgw']->template->set_var('empNum', '');
88                        }
89
90                        if ($actual['cell'])
91                        {
92                                $GLOBALS['phpgw']->template->set_var('cell', 'checked');
93                        }
94                        else
95                        {
96                                $GLOBALS['phpgw']->template->set_var('cell', '');
97                        }
98
99                        if ($actual['department'])
100                        {
101                                $GLOBALS['phpgw']->template->set_var('department', 'checked');
102                        }
103                        else
104                        {
105                                $GLOBALS['phpgw']->template->set_var('department', '');
106                        }
107
108                        $GLOBALS['phpgw']->template->set_var('personCardEmail', $options_email);
109                        $GLOBALS['phpgw']->template->set_var('personCardPhone', $options_phone);
110
111                        /* Translate the fields */
112                        $this->translate('pref');
113
114                        $GLOBALS['phpgw']->template->set_var('form_action', $GLOBALS['phpgw']->link('/index.php', 'menuaction=contactcenter.ui_preferences.set_preferences'));
115
116                        $GLOBALS['phpgw']->template->pparse('out', 'pref');
117                }
118               
119                function translate($handle)
120                {
121                        $vars = $GLOBALS['phpgw']->template->get_undefined($handle);
122                        foreach($vars as $name => $value)
123                        {
124                                if (ereg('^lang_', $name) !== false)
125                                {
126                                        $GLOBALS['phpgw']->template->set_var($name, lang(str_replace('_',' ',substr($name, 5))));
127                                }
128                        }
129                }
130               
131                function set_preferences()
132                {
133                        if ($_POST['save'])
134                        {
135                                $GLOBALS['phpgw']->preferences->read();
136                               
137                                $GLOBALS['phpgw']->preferences->delete('contactcenter', 'personCardEmail');
138                                $GLOBALS['phpgw']->preferences->delete('contactcenter', 'personCardPhone');
139
140                                $GLOBALS['phpgw']->preferences->delete('contactcenter', 'displayConnector');
141                                $GLOBALS['phpgw']->preferences->delete('contactcenter', 'displayConnectorDefault');
142                               
143                                $GLOBALS['phpgw']->preferences->add('contactcenter', 'personCardEmail', $_POST['personCardEmail']);
144                                $GLOBALS['phpgw']->preferences->add('contactcenter', 'personCardPhone', $_POST['personCardPhone']);
145                               
146                                $GLOBALS['phpgw']->preferences->add('contactcenter', 'displayConnectorDefault', '1');
147
148                                if($_POST['displayConnector'])
149                                {
150                                        $GLOBALS['phpgw']->preferences->add('contactcenter', 'displayConnector', '1');
151                                }
152                                else
153                                {
154                                        $GLOBALS['phpgw']->preferences->add('contactcenter', 'displayConnector', '0');
155                                }
156                               
157                                if($_POST['empNum'])
158                                {
159                                        $GLOBALS['phpgw']->preferences->add('contactcenter', 'empNum', '1');
160                                }
161                                else
162                                {
163                                        $GLOBALS['phpgw']->preferences->add('contactcenter', 'empNum', '0');
164                                }
165                               
166                                if($_POST['cell'])
167                                {
168                                        $GLOBALS['phpgw']->preferences->add('contactcenter', 'cell', '1');
169                                }
170                                else
171                                {
172                                        $GLOBALS['phpgw']->preferences->add('contactcenter', 'cell', '0');
173                                }
174                               
175                                if($_POST['department'])
176                                {
177                                        $GLOBALS['phpgw']->preferences->add('contactcenter', 'department', '1');
178                                }
179                                else
180                                {
181                                        $GLOBALS['phpgw']->preferences->add('contactcenter', 'department', '0');
182                                }
183
184                                $GLOBALS['phpgw']->preferences->save_repository();
185                        }
186
187                        header('Location: '.$GLOBALS['phpgw']->link('/preferences/index.php'));
188                }
189
190                function get_preferences()
191                {
192                        $prefs = $GLOBALS['phpgw']->preferences->read();
193
194                        if (!$prefs['contactcenter']['displayConnectorDefault'] and !$prefs['contactcenter']['displayConnector'])
195                        {
196                                $prefs['contactcenter']['displayConnector'] = true;
197                        }
198                       
199                        return $prefs['contactcenter'];
200                }
201        }
202?>
Note: See TracBrowser for help on using the repository browser.