source: trunk/contactcenter/inc/class.ui_api.inc.php @ 1494

Revision 1494, 17.7 KB checked in by amuller, 15 years ago (diff)

Ticket #504 - O maximo possivel em colocar Css para cima e javascript para baixo

  • 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  *  - Jonas Goes <jqhcb@users.sourceforge.net>                               *
8  *  sponsored by Thyamad - http://www.thyamad.com                            *
9  * ------------------------------------------------------------------------- *
10  *  This program is free software; you can redistribute it and/or modify it  *
11  *  under the terms of the GNU General Public License as published by the    *
12  *  Free Software Foundation; either version 2 of the License, or (at your   *
13  *  option) any later version.                                               *
14  \***************************************************************************/
15
16        /*
17         * This is the Main ContactCenter API for other eGroupWare applications
18         *
19         */
20 
21        class ui_api
22        {
23                var $commons;
24                var $commons_loaded = false;
25               
26                function ui_api()
27                {
28                        $template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
29
30                        $template->set_file(array('api' => 'api_common.tpl'));
31                        /* Style Sheets */
32                        $template->set_var('cc_css', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/styles/cc_api.css');
33                        $template->set_var('cc_dtree_css', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/js/dftree/dftree.css');
34
35                        $template->set_var('cc_email_id_type', $preferences['personCardEmail']);
36                       
37                       
38                        /* Messages */
39                        $template->set_var('cc_msg_err_invalid_catalog',lang('Unavailable or empty Catalog'));
40                        $template->set_var('cc_msg_err_contacting_server',lang('Couldn\'t contact server or server response is invalid. Contact Admin.'));
41                        $template->set_var('cc_msg_err_timeout',lang('Operation Timed Out.'));
42                        $template->set_var('cc_msg_err_serialize_data_unknown',lang('Data to be serialized is of unknown type!'));
43                        /* End Messages */
44
45                        if ($preferences['displayConnector'])
46                        {
47                                $template->set_var('cc_connector_visible', 'true');
48                        }
49                        else
50                        {
51                                $template->set_var('cc_connector_visible', 'false');
52                        }
53                        $template->set_var('cc_loading_1', lang('Contacting Server...'));
54                        $template->set_var('cc_loading_2', lang('Server Contacted. Waiting for response...'));
55                        $template->set_var('cc_loading_3', lang('Processing Information...'));
56                        $template->set_var('cc_loading_image', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/templates/default/images/loading_back.png');
57                        $template->set_var('cc_server_root', $GLOBALS['phpgw_info']['server']['webserver_url']);
58                        $template->set_var('cc_phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images');
59
60                        /* JS Files */
61                        $template->set_var('cc_js_aux', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/ccAux.js');
62                        $template->set_var('cc_js_connector', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/connector.js');
63                        $template->set_var('cc_js_wz_dragdrop', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/js/wz_dragdrop/wz_dragdrop.js');
64                        $template->set_var('cc_js_dtree', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/js/dftree/dftree.js');
65                        $template->set_var('cc_js_dtabs', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/js/dTabs/dTabs.js');
66                        $template->set_var('cc_js_djswin', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/js/dJSWin/dJSWin.js');
67                        $template->set_var('cc_js_catalog_tree', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_tree.js');
68                       
69                        $template->parse('out','api');
70
71                        $this->commons = $template->get_var('out');
72                        $this->commons_loaded = false;
73                        $preferences = ExecMethod('contactcenter.ui_preferences.get_preferences');
74                        if (!is_array($preferences))
75                        {
76                                $preferences['personCardEmail'] = 1;
77                                //$preferences['personCardPhone'] = 2;
78                        }
79                }
80               
81                /* DEPRECTED! Use get_email_win() instead */
82                function ui_get_email_win()
83                {
84                        return $this->get_email_win();
85                }
86
87                function get_email_win()
88                {
89                        //$search = $this->ui_get_search_win();
90                       
91                        $template_dir = PHPGW_SERVER_ROOT . '/contactcenter/templates/default/';
92                        $template = CreateObject('phpgwapi.Template', $template_dir);
93
94                        $template->set_file(array('email_win' => 'email_win.tpl'));
95                       
96                        if (!$this->commons_loaded)
97                        {
98                                $template->set_var('cc_api', $this->commons);
99                                $this->commons_loaded = true;
100                        }
101                        else
102                        {
103                                $template->set_var('cc_api', '');
104                        }
105                       
106                        //$template->set_var('cc_search_win', $search);
107                        $template->set_var('cc_js_search', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_search.js');
108                       
109                        $template->set_var('cc_email_id_type', $search);
110                       
111                        $template->set_var('cc_email_win_title',lang('Contact Center').' - '.lang('Catalog Entries Emails'));
112                        $template->set_var('cc_email_status',lang('Status').':');
113                        $template->set_var('cc_email_search_text',lang('Search').'...');
114                       
115                        $template->set_var('cc_choose_catalogue',lang('Choose a catalogue').'...');
116                        $template->set_var('cc_choose_ordinance',lang('Choose a ordinance').'...');
117                       
118                        $template->set_var('cc_btn_to_add',lang('To').' >>');
119                        $template->set_var('cc_btn_to_del','<< '.lang('To'));
120                        $template->set_var('cc_btn_cc_add',lang('Cc').' >>');
121                        $template->set_var('cc_btn_cc_del','<< '.lang('Cc'));
122                        $template->set_var('cc_btn_cco_add',lang('Bcc').' >>');
123                        $template->set_var('cc_btn_cco_del','<< '.lang('Bcc'));
124                        $template->set_var('cc_btn_new',lang('New').'...');
125                        $template->set_var('cc_btn_details',lang('Details').'...');
126                        $template->set_var('cc_btn_update',lang('Update'));
127                        $template->set_var('cc_btn_ok',lang('Ok'));
128                        $template->set_var('cc_btn_cancel',lang('Cancel'));
129                       
130                        $template->set_var('cc_label_to',lang('To').':');
131                        $template->set_var('cc_label_cc',lang('Cc').':');
132                        $template->set_var('cc_label_cco',lang('Bcc').':');
133                        $template->set_var('cc_label_entries',lang('Entries').':');
134                        $template->set_var('cc_label_catalogues',lang('Catalogues').':');
135                        $template->set_var('cc_label_catalogue_type',lang('Type Of Catalogue').':');
136                        $template->set_var('cc_label_ordinance_type',lang('Type Of Ordinace').':');
137                       
138                        $template->set_var('phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images');
139                       
140                        $template->set_var('cc_js_email_win', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_email_win.js');
141                       
142                        $template->parse('out','email_win');
143
144                        return $template->get_var('out');
145                }
146
147                function ui_get_search_win()
148                {
149                        return $this->get_search_win();
150                }
151
152                function get_search_win()
153                {
154                        $template_dir = PHPGW_SERVER_ROOT . '/contactcenter/templates/default/';
155                        $template = CreateObject('phpgwapi.Template',$template_dir);
156
157                        $template->set_file(array('search' => 'search_win.tpl'));
158                       
159                        if (!$this->commons_loaded)
160                        {
161                                $template->set_var('cc_api', $this->commons);
162                                $this->commons_loaded = true;
163                        }
164                        else
165                        {
166                                $template->set_var('cc_api', '');
167                        }
168                       
169                        $template->set_var('cc_search_title',lang('Contact Center - Search for Catalog Entries'));
170                        $template->set_var('cc_search_minimize',lang('Minimize'));
171                        $template->set_var('cc_search_close',lang('Close'));
172                        $template->set_var('cc_search_catalogues',lang('Catalogues'));
173                        $template->set_var('cc_search_for',lang('Search for...'));
174                        $template->set_var('cc_search_recursive',lang('Recursive Search?'));
175                        $template->set_var('cc_search_go',lang('Go'));
176                        $template->set_var('cc_search_cancel',lang('Cancel'));
177                       
178                        $template->set_var('cc_js_search_win', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_search_win.js');
179                       
180                        $template->set_var('phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images');
181                       
182                        $template->parse('out','search');
183
184                        return $template->get_var('out');
185                }
186
187                function get_search_obj()
188                {
189                        return "\n".'<script type="text/javascript" src="'.$GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_search.js'.'"></script>'."\n";
190                }
191
192                function ui_get_full_add()
193                {
194                        return $this->get_full_add();
195                }
196
197                function get_full_add()
198                {
199                        $template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
200
201                        $template->set_file(array('full_add' => 'full_add.tpl'));
202                       
203                        if (!$this->commons_loaded)
204                        {
205                                $template->set_var('cc_api', $this->commons);
206                                $this->commons_loaded = true;
207                        }
208                        else
209                        {
210                                $template->set_var('cc_api', '');
211                        }
212                       
213                        $template->set_var('cc_contact_title',lang('Contact Center').' - '.lang('Contacts'));
214
215                        /* Messages */
216                        $template->set_var('cc_msg_err_empty_field',lang('field is empty'));
217                        $template->set_var('cc_msg_type_state',lang('Type new state here').'...');
218                        $template->set_var('cc_msg_type_city',lang('Type new city here').'...');
219                        /* End Messages */
220                       
221                        /* Contact */
222                        $template->set_var('cc_contact_save',lang('Save'));
223                        $template->set_var('cc_contact_cancel',lang('Cancel'));
224                        $template->set_var('cc_contact_reset',lang('Reset'));
225
226                        $template->set_var('cc_contact_personal',lang('Personal'));
227                        $template->set_var('cc_contact_addrs',lang('Addresses'));
228                        $template->set_var('cc_contact_conns',lang('Connections'));
229                        $template->set_var('emails_telephones', lang("E-Mails and Telephones"));
230                        $template->set_var('cc_default', lang("Default"));
231
232                        /* End Contact */
233                       
234                        /* Contact - Personal Data */
235                        $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
236               
237                        $j = 0;
238                        for ($i = 0; $i < 5; $i+=2)
239                        {
240                                switch($dateformat{$i})
241                                {
242                                        case 'Y':
243                                                $date[$j]['size'] = 4;
244                                                $date[$j]['name'] = lang('Year');
245                                                break;
246
247                                        case 'm':
248                                        case 'M':
249                                                $date[$j]['size'] = 2;
250                                                $date[$j]['name'] = lang('Month');
251                                                break;
252
253                                        case 'd':
254                                                $date[$j]['size'] = 2;
255                                                $date[$j]['name'] = lang('Day');
256                                }
257                                $j++;
258                        }
259                       
260                        $template->set_var('cc_pd_birth_size_0', "{$date[0]['size']}");
261                        $template->set_var('cc_pd_birth_size_1', "{$date[1]['size']}");
262                        $template->set_var('cc_pd_birth_size_2', "{$date[2]['size']}");
263                       
264                        $template->set_var('cc_pd_birthdate_0', "{$date[0]['name']}");
265                        $template->set_var('cc_pd_birthdate_1', "{$date[1]['name']}");
266                        $template->set_var('cc_pd_birthdate_2', "{$date[2]['name']}");
267
268                        $template->set_var('cc_pd_select_photo_b', lang('Browse').'...');
269                        $template->set_var('cc_form_photo_src', 'photo_form.html');
270                       
271                        $template->set_var('cc_pd_select_photo',lang('Select Photo'));
272                        $template->set_var('cc_pd_alias',lang('Alias'));
273                        $template->set_var('cc_pd_given_names',lang('Given Names'));
274                        $template->set_var('cc_pd_family_names',lang('Family Names'));
275                        $template->set_var('cc_pd_full_name',lang('Full Name'));
276                        $template->set_var('cc_pd_birthdate',lang('Birthdate'));
277                        $template->set_var('cc_pd_gpg_finger_print',lang('GPG Finger Print'));
278                        $template->set_var('cc_pd_suffix',lang('Suffix'));
279                        $template->set_var('cc_pd_choose_suffix',lang('Choose Suffix...'));
280                        $template->set_var('cc_pd_prefix',lang('Prefix'));
281                        $template->set_var('cc_pd_choose_prefix',lang('Choose Prefix...'));
282                        $template->set_var('cc_pd_notes',lang('Notes'));
283                        $template->set_var('cc_pd_sex',lang('Sex'));
284                        $template->set_var('cc_pd_choose_sex',lang('Choose Sex ...'));
285                        $template->set_var('cc_pd_male',lang('Male'));
286                        $template->set_var('cc_pd_female',lang('Female'));
287                        /* End Contact - Personal Data */
288                       
289                        /* Contact - Addresses */
290                        $template->set_var('cc_addr_types',lang('Type of Address'));
291                        $template->set_var('cc_addr_choose_types',lang('Choose Type of Address').'...');
292                        $template->set_var('cc_addr_countries',lang('Country'));
293                        $template->set_var('cc_addr_choose_countries',lang('Choose Country').'...');
294                        $template->set_var('cc_addr_states',lang('State'));
295                        $template->set_var('cc_addr_states_new',lang('New State').'...');
296                        $template->set_var('cc_addr_states_nostate',lang('No State'));
297                        $template->set_var('cc_addr_choose_states',lang('Choose State').'...');
298                        $template->set_var('cc_addr_cities',lang('City'));
299                        $template->set_var('cc_addr_cities_new',lang('New City').'...');
300                        $template->set_var('cc_addr_choose_cities',lang('Choose City').'...');
301                        $template->set_var('cc_addr_1',lang('Address 1'));
302                        $template->set_var('cc_addr_2',lang('Address 2'));
303                        $template->set_var('cc_addr_complement',lang('Complement'));
304                        $template->set_var('cc_addr_other',lang('Address Other'));
305                        $template->set_var('cc_addr_postal_code',lang('Postal Code'));
306                        $template->set_var('cc_addr_po_box',lang('PO Box'));
307                        $template->set_var('cc_addr_is_default',lang('Is Default?'));
308                        $template->set_var('cc_addr_yes',lang('Yes'));
309                        $template->set_var('cc_addr_no',lang('No'));
310                        $template->set_var('cc_available',lang('Available'));
311                        /* End Contact - Addresses */
312                       
313                       
314                        /* Contact - Connections */
315                        $template->set_var('cc_conn_type',lang('Type of Connection'));
316                        $template->set_var('cc_conn_name',lang('Connection Name'));
317                        $template->set_var('cc_conn_value',lang('Connection Value'));
318                       
319                        $template->set_var('cc_new_same_type',lang('New from the same Type').'...');
320                       
321                        $template->set_var('cc_conn_type_none',lang('Choose Type of Connection').'...');
322                        /* End Contact - Connections */
323
324                        $template->set_var('email', lang("E-Mail"));
325                        $template->set_var('telephone', lang("Telephone"));
326                        $template->set_var('choose_email_telephone', lang("Choose 'E-Mail' or 'Telephone'"));
327
328                        $template->parse('out_full', 'full_add');
329
330                        return $template->get_var('out_full');
331                }
332
333                function get_quick_add_plugin()
334                {
335                        $template_dir = PHPGW_SERVER_ROOT . '/contactcenter/templates/default/';
336                        $template = CreateObject('phpgwapi.Template',$template_dir);
337
338                        $template->set_file(array('quickAdd' => 'quickAddPlugin.tpl'));
339                       
340                        if (!$this->commons_loaded)
341                        {
342                                $template->set_var('cc_api', $this->commons);
343                                $this->commons_loaded = true;
344                        }
345                        else
346                        {
347                                $template->set_var('cc_api', '');
348                        }
349                       
350                        $template->set_var('ccQAPluginFile', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/ccQuickAdd-plugin.js');
351
352                        /* Fields Insertion */
353
354                        // TODO: get this from preferences
355                        $nFields = 5;
356                        $fields = array(
357                                lang('Alias'),
358                                lang('Given Names'),
359                                lang('Family Names'),
360                                lang('Phone'),
361                                lang('Email')
362                        );
363                       
364                        $template->set_var('ccQAnFields', $nFields);
365                       
366                        $fieldsHTML = '';
367                        $fieldsTop = 10;
368                        $fieldsSpace = 30;
369                        for ($i = 0; $i < $nFields; $i++)
370                        {
371                                $fieldsHTML .= '<span id="ccQuickAddT'.$i.'" style="position: absolute; top: '.($fieldsTop+$i*$fieldsSpace).'px; left: 5px; width: 100px; text-align: right; border: 0px solid #999;">'.$fields[$i].':</span>'."\n";
372                                if ($i == 0){
373                                        $fieldsHTML .= '<input id="ccQuickAddI'.$i.'" type="text" value="" maxlength="30" style="position: absolute; top: '.($fieldsTop+$i*$fieldsSpace).'px; left: 110px; width: 135px;">'."\n";
374                                }
375                                else if ($i == 4){
376                                        $fieldsHTML .= '<input id="ccQuickAddI'.$i.'" type="text" value="" maxlength="100" style="position: absolute; top: '.($fieldsTop+$i*$fieldsSpace).'px; left: 110px; width: 135px;">'."\n";
377                                }
378                                else {
379                                        $fieldsHTML .= '<input id="ccQuickAddI'.$i.'" type="text" value="" maxlength="50" style="position: absolute; top: '.($fieldsTop+$i*$fieldsSpace).'px; left: 110px; width: 135px;">'."\n";
380                                }
381                        }
382
383                        $template->set_var('ccQAFields', $fieldsHTML);
384                        $template->set_var('ccQAWinHeight', ($i+1)*$fieldsSpace+$fieldsTop);
385                        $template->set_var('ccQAFunctionsTop', ($fieldsTop+$i*$fieldsSpace).'px');
386                       
387                        /* Images Dir */
388                        $template->set_var('ccQACardImgRoot', $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/templates/default/images/');
389                       
390                        /* Texts */
391                        $template->set_var('ccQATitle', lang('Contact Center').' - '.lang('Quick Add'));
392                        $template->set_var('ccQASave', lang('Save'));
393                        $template->set_var('ccQAClear', lang('Reset'));
394                        $template->set_var('ccQACancel', lang('Cancel'));
395                       
396                        $template->parse('out_QA', 'quickAdd');
397
398                        return $template->get_var('out_QA');
399                }
400               
401                function get_add_group()
402                {
403                        $template_dir = PHPGW_SERVER_ROOT . '/contactcenter/templates/default/';
404                        $template = CreateObject('phpgwapi.Template',$template_dir);
405
406                        $template->set_file(array('addGroup' => 'addGroup.tpl'));
407                       
408                        if (!$this->commons_loaded)
409                        {
410                                $template->set_var('cc_api', $this->commons);
411                                $this->commons_loaded = true;
412                        }
413                        else
414                        {
415                               
416                                $template->set_var('cc_api', '');
417                        }
418                       
419                        $template->set_var('ccAGFile', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/ccAddGroup.js');                 
420                        $template->set_var('ccAGWinHeightIE', '285');                   
421                        $template->set_var('ccAGWinHeightMO', '335');
422                       
423                        /* Images Dir */
424                        $template->set_var('ccAGCardImgRoot', $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/templates/default/images/');
425                       
426                        /* Texts */
427                        $template->set_var('ccAGTitle', lang('Contact Center').' - '.lang('Group Add'));
428                        $template->set_var('ccAGSave', lang('Save'));
429                        $template->set_var('ccAGClear', lang('Reset'));
430                        $template->set_var('ccAGCancel', lang('Cancel'));
431                        $title = '<input type="text" id="title" name="title" value="'.$group['title'].'" size="50" maxlength="50"/>';                   
432                               
433                        $template->set_var('title', $title);                                                                                           
434                        // set content and label variables.
435                        $template->set_var(array(
436                                                'msg_text'      => lang($status),                                               
437                                                'txt_title'     => lang('Contact Group List'),                                         
438                                                'txt_cancel'=> lang('cancel'),
439                                                'txt_add'=> lang('Add'),                                               
440                                                'txt_rem'=> lang('Remove'),
441                                                'txt_personal_contacts' => lang('Personal Contacts'),
442                                                'txt_contacts_in_list' => lang("Participants"),
443                                                'txt_name'      => lang('Full Name')));
444                                               
445                        $template->parse('out_AG', 'addGroup');
446                       
447                        return $template->get_var('out_AG');
448                }
449        }
450?>
Note: See TracBrowser for help on using the repository browser.