source: branches/2.2/contactcenter/inc/class.ui_preferences.inc.php @ 1600

Revision 1600, 5.8 KB checked in by rafaelraymundo, 14 years ago (diff)

Ticket #619 - Incluidos campos configuraveis (matricula/celular/setor) para o contactcenter

  • 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                                /*
144                                $GLOBALS['phpgw']->preferences->add('contactcenter', 'personCardEmail', $_POST['personCardEmail'], 'forced');
145                                $GLOBALS['phpgw']->preferences->add('contactcenter', 'personCardPhone', $_POST['personCardPhone'], 'forced');
146                                */
147                               
148                                $GLOBALS['phpgw']->preferences->add('contactcenter', 'displayConnectorDefault', '1');
149
150                                if($_POST['displayConnector'])
151                                {
152                                        $GLOBALS['phpgw']->preferences->add('contactcenter', 'displayConnector', '1');
153                                }
154                                else
155                                {
156                                        $GLOBALS['phpgw']->preferences->add('contactcenter', 'displayConnector', '0');
157                                }
158                               
159                                if($_POST['empNum'])
160                                {
161                                        $GLOBALS['phpgw']->preferences->add('contactcenter', 'empNum', '1');
162                                }
163                                else
164                                {
165                                        $GLOBALS['phpgw']->preferences->add('contactcenter', 'empNum', '0');
166                                }
167                               
168                                if($_POST['cell'])
169                                {
170                                        $GLOBALS['phpgw']->preferences->add('contactcenter', 'cell', '1');
171                                }
172                                else
173                                {
174                                        $GLOBALS['phpgw']->preferences->add('contactcenter', 'cell', '0');
175                                }
176                               
177                                if($_POST['department'])
178                                {
179                                        $GLOBALS['phpgw']->preferences->add('contactcenter', 'department', '1');
180                                }
181                                else
182                                {
183                                        $GLOBALS['phpgw']->preferences->add('contactcenter', 'department', '0');
184                                }
185                               
186                                $GLOBALS['phpgw']->preferences->save_repository();
187                        }
188
189                        header('Location: '.$GLOBALS['phpgw']->link('/preferences/index.php'));
190                }
191
192                function get_preferences()
193                {
194                        $prefs = $GLOBALS['phpgw']->preferences->read();
195
196                        if (!$prefs['contactcenter']['displayConnectorDefault'] and !$prefs['contactcenter']['displayConnector'])
197                        {
198                                $prefs['contactcenter']['displayConnector'] = true;
199                        }
200                       
201                        $prefs['contactcenter']['personCardEmail'] = 1;
202                        $prefs['contactcenter']['personCardPhone'] = 2;
203                       
204                        return $prefs['contactcenter'];
205                }
206        }
207?>
Note: See TracBrowser for help on using the repository browser.