source: trunk/expressoAdmin1_2/js/jscode/institutional_accounts.js @ 5133

Revision 5133, 7.3 KB checked in by wmerlotto, 12 years ago (diff)

Ticket #2305 - Enviando alteracoes, desenvolvidas internamente na Prognus, do modulo ExpressoAdmin.

Line 
1countFiles = 1;
2
3function create_institutional_accounts()
4{
5        select_owners = Element('ea_select_owners');
6        for(var i = 0;i < select_owners.options.length; i++)
7                select_owners.options[i].selected = true;       
8        cExecuteForm ("$this.ldap_functions.create_institutional_accounts", document.forms['institutional_accounts_form'], handler_create_institutional_accounts);
9}
10
11function handler_create_institutional_accounts(data_return)
12{
13        handler_create_institutional_accounts2(data_return);
14        return;
15}
16
17function handler_create_institutional_accounts2(data_return)
18{
19        if (!data_return.status)
20        {
21                write_msg(data_return.msg, 'error');
22        }
23        else
24        {
25                close_lightbox();
26                write_msg(get_lang('Institutional account successful created') + '.', 'normal');
27        }
28        return;
29}
30
31function set_onload()
32{
33        sinc_combos_org(Element('ea_combo_org').value);
34}
35
36
37function search_organization(key, element)
38{
39        var organizations = Element(element);
40        var RegExp_org = new RegExp("\\b"+key, "i");
41       
42        for(i = 0; i < organizations.length; i++)
43        {
44                if (RegExp_org.test(organizations[i].text))
45                {
46                        organizations[i].selected = true;
47                        return;
48                }
49        }
50}
51
52function sinc_combos_org(context)
53{
54        combo_org_available_users = Element('ea_combo_org_available_users');
55
56        for (i=0; i<combo_org_available_users.length; i++)
57        {
58                if (combo_org_available_users.options[i].value == context)
59                {
60                        combo_org_available_users.options[i].selected = true;
61                        break;
62                }
63        }
64}
65
66// var finderTimeout = '';
67// optionFinderTimeout
68function optionFinderTimeout(obj, event)
69{
70
71    if( event && event.keyCode !== 13 )
72        return( true );
73//      clearTimeout(finderTimeout);
74//      var oWait = Element("ea_span_searching");
75//      oWait.innerHTML = get_lang('searching') + '...';
76//      finderTimeout = setTimeout("optionFinder('"+obj.id+"')",500);
77    optionFinder( obj.id );
78       
79    return( false );
80}
81function optionFinder(id) {
82//     var sentence = Element( id ).value;
83//
84//     var url = '$this.ldap_functions.get_available_users&context=' + Element('ea_combo_org').value + '&sentence=' + sentence;
85//
86//     var fillHandler = function( fill ){
87//
88//          return fillContentSelect( fill, 'ea_select_available_users' );
89//
90//      }
91//
92//     userFinder( sentence, fillHandler, url, 'ea_span_searching' );
93
94    optionFind( id, 'ea_select_available_users', '$this.ldap_functions.get_available_users',
95                    'ea_combo_org_available_users', 'ea_span_searching' );
96}                       
97
98function add_user()
99{
100        select_available_users = Element('ea_select_available_users');
101        select_owners = Element('ea_select_owners');
102
103        var count_available_users = select_available_users.length;
104//      var count_owners = select_owners.options.length;
105        var new_options = '';
106
107        for (i = 0 ; i < count_available_users ; i++)
108        {
109                if (select_available_users.options[i].selected)
110                {
111                        if(document.all)
112                        {
113                                if ( (select_owners.innerHTML.indexOf('value='+select_available_users.options[i].value)) == '-1' )
114                                {
115                                        new_options +=  "<option value="
116                                                                + select_available_users.options[i].value
117                                                                + ">"
118                                                                + select_available_users.options[i].text
119                                                                + "</options>";
120                                }
121                        }
122                        else
123                        {
124                                if ( (select_owners.innerHTML.indexOf('value="'+select_available_users.options[i].value+'"')) == '-1' )
125                                {
126                                        new_options +=  "<option value="
127                                                                + select_available_users.options[i].value
128                                                                + ">"
129                                                                + select_available_users.options[i].text
130                                                                + "</options>";
131                                }
132                        }
133                }
134        }
135
136        if (new_options != '')
137        {
138                select_owners.innerHTML = '&nbsp;' + new_options + select_owners.innerHTML;
139                select_owners.outerHTML = select_owners.outerHTML;
140                document.getElementById('ea_input_searchUser').value = "";
141        }
142}
143
144function remove_user()
145{
146        select_owners = Element('ea_select_owners');
147        for(var i = 0;i < select_owners.options.length; i++)
148                if(select_owners.options[i].selected)
149                        select_owners.options[i--] = null;
150}
151
152function get_institutional_accounts_timeOut(input, event)
153{
154        Element('institutional_accounts_content').innerHTML = '<table border="0" width="90%"><tr bgcolor="#d3dce3"><td width="30%">'+get_lang("full name")+'</td><td width="30%">'+get_lang("mail")+'</td><td width="5%" align="center">'+get_lang("remove")+'</td></tr></table>';
155       
156        if (event.keyCode === 13)
157        {
158            get_institutional_accounts( input );
159        }
160}
161
162function get_institutional_accounts(input)
163{
164        var handler_get_institutional_accounts = function(data)
165        {
166                if (data.status == 'true')
167                {
168                        var table = '<table border="0" width="90%"><tr bgcolor="#d3dce3"><td width="30%">'+get_lang("full name")+'</td><td width="30%">'+get_lang("mail")+'</td><td width="5%" align="center">'+get_lang("delete")+'</td></tr>'+data.trs+'</table>';
169                        Element('institutional_accounts_content').innerHTML = table;
170                }
171                else
172                        write_msg(data.msg, 'error');
173        }
174        cExecute ('$this.ldap_functions.get_institutional_accounts&input='+input, handler_get_institutional_accounts);
175}
176
177function edit_institutional_account(uid)
178{
179        var handle_edit_institutional_account = function(data)
180        {
181                if (data.status == 'true')
182                {
183                        modal('institutional_accounts_modal','save');
184                       
185                        var combo_org = Element('ea_combo_org');
186                        for (i=0; i<combo_org.length; i++)
187                        {
188                                if (combo_org.options[i].value == data.user_context)
189                                {
190                                        combo_org.options[i].selected = true;
191                                        break;
192                                }
193                        }
194                       
195                        // anchor
196                        Element('anchor').value = "uid=" + uid + ',' + data.user_context;
197                       
198                        if (data.accountStatus != 'active')
199                                Element('accountStatus').checked = false;
200                               
201                        if (data.phpgwAccountVisible == '-1')
202                                Element('phpgwAccountVisible').checked = true;
203                       
204                        Element('cn').value = data.cn;
205                        Element('mail').value = data.mail;
206                        Element('desc').value = data.description;
207                        Element('ea_select_owners').innerHTML = data.owners;
208
209                        sinc_combos_org(data.user_context);
210                }
211                else
212                        write_msg(data.msg, 'error');
213        }
214        cExecute ('$this.ldap_functions.get_institutional_account_data&uid='+uid, handle_edit_institutional_account);
215}
216
217function save_institutional_accounts()
218{
219        if (is_ie){
220                var i = 0;
221                while (document.forms(i).name != "institutional_accounts_form"){i++}
222                form = document.forms(i);
223        }
224        else
225                form = document.forms["institutional_accounts_form"];
226       
227        select_owners = Element('ea_select_owners');
228        for(var i = 0;i < select_owners.options.length; i++)
229                select_owners.options[i].selected = true;       
230        cExecuteForm ("$this.ldap_functions.save_institutional_accounts", form, handler_save_institutional_accounts);
231}
232
233function handler_save_institutional_accounts(data_return)
234{
235        handler_save_institutional_accounts2(data_return);
236        return;
237}
238function handler_save_institutional_accounts2(data_return)
239{
240        if (!data_return.status)
241        {
242                write_msg(data_return.msg, 'error');
243        }
244        else
245        {
246                get_institutional_accounts(Element('ea_institutional_account_search').value);
247                close_lightbox();
248                write_msg(get_lang('Institutional account successful saved') + '.', 'normal');
249        }
250        return;
251}
252
253function delete_institutional_accounts(uid)
254{
255        if (!confirm(get_lang('Are you sure that you want to delete this institutional account') + "?"))
256                return;
257       
258        var handle_delete_institutional_account = function(data_return)
259        {
260                if (!data_return.status)
261                {
262                        write_msg(data_return.msg, 'error');
263                }
264                else
265                {
266                        write_msg(get_lang('Institutional account successful deleted') + '.', 'normal');
267                        get_institutional_accounts(Element('ea_institutional_account_search').value);
268                }
269                return;
270        }
271        cExecute ('$this.ldap_functions.delete_institutional_account_data&uid='+uid, handle_delete_institutional_account);
272}
Note: See TracBrowser for help on using the repository browser.