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 | $preferences = ExecMethod('contactcenter.ui_preferences.get_preferences'); |
---|
29 | |
---|
30 | if (!is_array($preferences)) |
---|
31 | { |
---|
32 | $preferences['personCardEmail'] = 1; |
---|
33 | } |
---|
34 | $template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
35 | |
---|
36 | $template->set_file(array('api' => 'api_common.tpl')); |
---|
37 | /* Style Sheets */ |
---|
38 | $template->set_var('cc_css', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/styles/cc_api.css'); |
---|
39 | $template->set_var('cc_dtree_css', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/js/dftree/dftree.css'); |
---|
40 | |
---|
41 | $template->set_var('cc_email_id_type', $preferences['personCardEmail']); |
---|
42 | |
---|
43 | |
---|
44 | /* Messages */ |
---|
45 | $template->set_var('cc_msg_err_invalid_catalog',lang('Unavailable or empty Catalog')); |
---|
46 | $template->set_var('cc_msg_err_contacting_server',lang('Couldn\'t contact server or server response is invalid. Contact Admin.')); |
---|
47 | $template->set_var('cc_msg_err_timeout',lang('Operation Timed Out.')); |
---|
48 | $template->set_var('cc_msg_err_serialize_data_unknown',lang('Data to be serialized is of unknown type!')); |
---|
49 | $template->set_var('cc_msg_err_shared',lang('No shared catalog that has permission to add.')); |
---|
50 | /* End Messages */ |
---|
51 | |
---|
52 | if ($preferences['displayConnector']) |
---|
53 | { |
---|
54 | $template->set_var('cc_connector_visible', 'true'); |
---|
55 | } |
---|
56 | else |
---|
57 | { |
---|
58 | $template->set_var('cc_connector_visible', 'false'); |
---|
59 | } |
---|
60 | $template->set_var('cc_loading_1', lang('Contacting Server...')); |
---|
61 | $template->set_var('cc_loading_2', lang('Server Contacted. Waiting for response...')); |
---|
62 | $template->set_var('cc_loading_3', lang('Processing Information...')); |
---|
63 | $template->set_var('cc_loading_image', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/templates/default/images/loading_back.png'); |
---|
64 | $template->set_var('cc_server_root', $GLOBALS['phpgw_info']['server']['webserver_url']); |
---|
65 | $template->set_var('cc_phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images'); |
---|
66 | |
---|
67 | /* JS Files */ |
---|
68 | $template->set_var('cc_js_aux', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/ccAux.js'); |
---|
69 | $template->set_var('cc_js_connector', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/connector.js'); |
---|
70 | $template->set_var('cc_js_wz_dragdrop', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/js/wz_dragdrop/wz_dragdrop.js'); |
---|
71 | $template->set_var('cc_js_dtree', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/js/dftree/dftree.js'); |
---|
72 | $template->set_var('cc_js_dtabs', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/js/dTabs/dTabs.js'); |
---|
73 | $template->set_var('cc_js_djswin', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/js/dJSWin/dJSWin.js'); |
---|
74 | $template->set_var('cc_js_catalog_tree', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_tree.js'); |
---|
75 | |
---|
76 | $template->parse('out','api'); |
---|
77 | |
---|
78 | $this->commons = $template->get_var('out'); |
---|
79 | $this->commons_loaded = false; |
---|
80 | } |
---|
81 | |
---|
82 | /* DEPRECTED! Use get_email_win() instead */ |
---|
83 | function ui_get_email_win() |
---|
84 | { |
---|
85 | return $this->get_email_win(); |
---|
86 | } |
---|
87 | |
---|
88 | function get_email_win() |
---|
89 | { |
---|
90 | //$search = $this->ui_get_search_win(); |
---|
91 | |
---|
92 | $template_dir = PHPGW_SERVER_ROOT . '/contactcenter/templates/default/'; |
---|
93 | $template = CreateObject('phpgwapi.Template', $template_dir); |
---|
94 | |
---|
95 | $template->set_file(array('email_win' => 'email_win.tpl')); |
---|
96 | |
---|
97 | if (!$this->commons_loaded) |
---|
98 | { |
---|
99 | $template->set_var('cc_api', $this->commons); |
---|
100 | $this->commons_loaded = true; |
---|
101 | } |
---|
102 | else |
---|
103 | { |
---|
104 | $template->set_var('cc_api', ''); |
---|
105 | } |
---|
106 | |
---|
107 | //$template->set_var('cc_search_win', $search); |
---|
108 | $template->set_var('cc_js_search', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_search.js'); |
---|
109 | |
---|
110 | $template->set_var('cc_email_id_type', $search); |
---|
111 | |
---|
112 | $template->set_var('cc_email_win_title',lang('Contact Center').' - '.lang('Catalog Entries Emails')); |
---|
113 | $template->set_var('cc_email_status',lang('Status').':'); |
---|
114 | $template->set_var('cc_email_search_text',lang('Search').'...'); |
---|
115 | |
---|
116 | $template->set_var('cc_choose_catalogue',lang('Choose a catalogue').'...'); |
---|
117 | $template->set_var('cc_choose_ordinance',lang('Choose a ordinance').'...'); |
---|
118 | |
---|
119 | $template->set_var('cc_btn_to_add',lang('To').' >>'); |
---|
120 | $template->set_var('cc_btn_to_del','<< '.lang('To')); |
---|
121 | $template->set_var('cc_btn_cc_add',lang('Cc').' >>'); |
---|
122 | $template->set_var('cc_btn_cc_del','<< '.lang('Cc')); |
---|
123 | $template->set_var('cc_btn_cco_add',lang('Bcc').' >>'); |
---|
124 | $template->set_var('cc_btn_cco_del','<< '.lang('Bcc')); |
---|
125 | $template->set_var('cc_btn_new',lang('New').'...'); |
---|
126 | $template->set_var('cc_btn_details',lang('Details').'...'); |
---|
127 | $template->set_var('cc_btn_update',lang('Update')); |
---|
128 | $template->set_var('cc_btn_ok',lang('Ok')); |
---|
129 | $template->set_var('cc_btn_cancel',lang('Cancel')); |
---|
130 | |
---|
131 | $template->set_var('cc_label_to',lang('To').':'); |
---|
132 | $template->set_var('cc_label_cc',lang('Cc').':'); |
---|
133 | $template->set_var('cc_label_cco',lang('Bcc').':'); |
---|
134 | $template->set_var('cc_label_entries',lang('Entries').':'); |
---|
135 | $template->set_var('cc_label_catalogues',lang('Catalogues').':'); |
---|
136 | $template->set_var('cc_label_catalogue_type',lang('Type Of Catalogue').':'); |
---|
137 | $template->set_var('cc_label_ordinance_type',lang('Type Of Ordinace').':'); |
---|
138 | |
---|
139 | $template->set_var('phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images'); |
---|
140 | |
---|
141 | $template->set_var('cc_js_email_win', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_email_win.js'); |
---|
142 | |
---|
143 | $template->parse('out','email_win'); |
---|
144 | |
---|
145 | return $template->get_var('out'); |
---|
146 | } |
---|
147 | |
---|
148 | function ui_get_search_win() |
---|
149 | { |
---|
150 | return $this->get_search_win(); |
---|
151 | } |
---|
152 | |
---|
153 | function get_search_win() |
---|
154 | { |
---|
155 | $template_dir = PHPGW_SERVER_ROOT . '/contactcenter/templates/default/'; |
---|
156 | $template = CreateObject('phpgwapi.Template',$template_dir); |
---|
157 | |
---|
158 | $template->set_file(array('search' => 'search_win.tpl')); |
---|
159 | |
---|
160 | if (!$this->commons_loaded) |
---|
161 | { |
---|
162 | $template->set_var('cc_api', $this->commons); |
---|
163 | $this->commons_loaded = true; |
---|
164 | } |
---|
165 | else |
---|
166 | { |
---|
167 | $template->set_var('cc_api', ''); |
---|
168 | } |
---|
169 | |
---|
170 | $template->set_var('cc_search_title',lang('Contact Center - Search for Catalog Entries')); |
---|
171 | $template->set_var('cc_search_minimize',lang('Minimize')); |
---|
172 | $template->set_var('cc_search_close',lang('Close')); |
---|
173 | $template->set_var('cc_search_catalogues',lang('Catalogues')); |
---|
174 | $template->set_var('cc_search_for',lang('Search for...')); |
---|
175 | $template->set_var('cc_search_recursive',lang('Recursive Search?')); |
---|
176 | $template->set_var('cc_search_go',lang('Go')); |
---|
177 | $template->set_var('cc_search_cancel',lang('Cancel')); |
---|
178 | |
---|
179 | $template->set_var('cc_js_search_win', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_search_win.js'); |
---|
180 | |
---|
181 | $template->set_var('phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images'); |
---|
182 | |
---|
183 | $template->parse('out','search'); |
---|
184 | |
---|
185 | return $template->get_var('out'); |
---|
186 | } |
---|
187 | |
---|
188 | function get_contact_details() |
---|
189 | { |
---|
190 | $template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
191 | $template->set_file(array('details' => 'contact_details.tpl')); |
---|
192 | |
---|
193 | if (!$this->commons_loaded) |
---|
194 | { |
---|
195 | $template->set_var('cc_api', $this->commons); |
---|
196 | $this->commons_loaded = true; |
---|
197 | } |
---|
198 | else |
---|
199 | { |
---|
200 | $template->set_var('cc_api', ''); |
---|
201 | } |
---|
202 | |
---|
203 | //$template->set_var('ccContactDetails.js', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/ccContactDetails.js'); |
---|
204 | $template->set_var('cc_contact_details_title',lang("Contact's details")); |
---|
205 | $template->set_var('cc_contact_details_close',lang("Close")); |
---|
206 | $template->set_var('cc_contact_details_no_fields',lang("The extra details are not configured.")); |
---|
207 | $template->set_var('cc_contact_details_attr_name',lang("Attribute name")); |
---|
208 | $template->set_var('cc_contact_details_attr_value',lang("Value")); |
---|
209 | $template->parse('out','details'); |
---|
210 | return $template->get_var('out'); |
---|
211 | } |
---|
212 | |
---|
213 | function get_search_obj() |
---|
214 | { |
---|
215 | return "\n".'<script type="text/javascript" src="'.$GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_search.js'.'"></script>'."\n"; |
---|
216 | } |
---|
217 | |
---|
218 | function ui_get_full_add() |
---|
219 | { |
---|
220 | return $this->get_full_add(); |
---|
221 | } |
---|
222 | |
---|
223 | function get_full_add() |
---|
224 | { |
---|
225 | $template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
226 | if($GLOBALS['phpgw_info']['server']['personal_contact_type']=='True'){ |
---|
227 | $template->set_file(array('full_add' => 'corporative_full_add.tpl')); |
---|
228 | $template->set_var('cc_contact_type','advanced'); |
---|
229 | }else{ |
---|
230 | $template->set_file(array('full_add' => 'full_add.tpl')); |
---|
231 | $template->set_var('cc_contact_type','default'); |
---|
232 | } |
---|
233 | if (!$this->commons_loaded) |
---|
234 | { |
---|
235 | $template->set_var('cc_api', $this->commons); |
---|
236 | $this->commons_loaded = true; |
---|
237 | } |
---|
238 | else |
---|
239 | { |
---|
240 | $template->set_var('cc_api', ''); |
---|
241 | } |
---|
242 | |
---|
243 | $template->set_var('cc_contact_title',lang('Contact Center').' - '.lang('Contacts')); |
---|
244 | |
---|
245 | /* Messages */ |
---|
246 | $template->set_var('cc_msg_err_empty_field',lang('field is empty')); |
---|
247 | $template->set_var('cc_msg_type_state',lang('Type new state here').'...'); |
---|
248 | $template->set_var('cc_msg_type_city',lang('Type new city here').'...'); |
---|
249 | /* End Messages */ |
---|
250 | |
---|
251 | /* Contact */ |
---|
252 | $template->set_var('cc_contact_save',lang('Save')); |
---|
253 | $template->set_var('cc_contact_cancel',lang('Cancel')); |
---|
254 | $template->set_var('cc_contact_reset',lang('Reset')); |
---|
255 | |
---|
256 | $template->set_var('cc_contact_personal',lang('Personal')); |
---|
257 | $template->set_var('cc_contact_addrs',lang('Addresses')); |
---|
258 | $template->set_var('cc_contact_corporative',lang('Corporative')); |
---|
259 | $template->set_var('cc_contact_conns',lang('Connections')); |
---|
260 | $template->set_var('cc_contact_grps', lang('Groups')); |
---|
261 | $template->set_var('emails_telephones', lang("E-Mails and Telephones")); |
---|
262 | $template->set_var('cc_default', lang("Default")); |
---|
263 | |
---|
264 | $template->set_var('cc_contact_shared',lang('Add to catalog')); |
---|
265 | $template->set_var('cc_contact_shared_types',lang('Choose in wich catalog you would like to add...')); |
---|
266 | |
---|
267 | /* End Contact */ |
---|
268 | |
---|
269 | /* Contact - Personal Data */ |
---|
270 | $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; |
---|
271 | |
---|
272 | $j = 0; |
---|
273 | for ($i = 0; $i < 5; $i+=2) |
---|
274 | { |
---|
275 | switch($dateformat{$i}) |
---|
276 | { |
---|
277 | case 'Y': |
---|
278 | $date[$j]['size'] = 4; |
---|
279 | $date[$j]['name'] = lang('Year'); |
---|
280 | break; |
---|
281 | |
---|
282 | case 'm': |
---|
283 | case 'M': |
---|
284 | $date[$j]['size'] = 2; |
---|
285 | $date[$j]['name'] = lang('Month'); |
---|
286 | break; |
---|
287 | |
---|
288 | case 'd': |
---|
289 | $date[$j]['size'] = 2; |
---|
290 | $date[$j]['name'] = lang('Day'); |
---|
291 | } |
---|
292 | $j++; |
---|
293 | } |
---|
294 | |
---|
295 | $template->set_var('cc_pd_birth_size_0', "{$date[0]['size']}"); |
---|
296 | $template->set_var('cc_pd_birth_size_1', "{$date[1]['size']}"); |
---|
297 | $template->set_var('cc_pd_birth_size_2', "{$date[2]['size']}"); |
---|
298 | |
---|
299 | $template->set_var('cc_pd_birthdate_0', "{$date[0]['name']}"); |
---|
300 | $template->set_var('cc_pd_birthdate_1', "{$date[1]['name']}"); |
---|
301 | $template->set_var('cc_pd_birthdate_2', "{$date[2]['name']}"); |
---|
302 | |
---|
303 | $template->set_var('cc_pd_select_photo_b', lang('Browse').'...'); |
---|
304 | $template->set_var('cc_form_photo_src', 'photo_form.html'); |
---|
305 | |
---|
306 | $template->set_var('cc_pd_select_photo',lang('Select Photo')); |
---|
307 | $template->set_var('cc_pd_alias',lang('Alias')); |
---|
308 | $template->set_var('cc_pd_given_names',lang('Given Names')); |
---|
309 | $template->set_var('cc_pd_family_names',lang('Family Names')); |
---|
310 | $template->set_var('cc_pd_full_name',lang('Full Name')); |
---|
311 | $template->set_var('cc_pd_birthdate',lang('Birthdate')); |
---|
312 | $template->set_var('cc_pd_gpg_finger_print',lang('GPG Finger Print')); |
---|
313 | $template->set_var('cc_pd_suffix',lang('Suffix')); |
---|
314 | $template->set_var('cc_pd_choose_suffix',lang('Choose Suffix...')); |
---|
315 | $template->set_var('cc_pd_prefix',lang('Prefix')); |
---|
316 | $template->set_var('cc_pd_choose_prefix',lang('Choose Prefix...')); |
---|
317 | $template->set_var('cc_pd_notes',lang('Notes')); |
---|
318 | $template->set_var('cc_pd_sex',lang('Sex')); |
---|
319 | $template->set_var('cc_pd_choose_sex',lang('Choose Sex ...')); |
---|
320 | $template->set_var('cc_pd_male',lang('Male')); |
---|
321 | $template->set_var('cc_pd_female',lang('Female')); |
---|
322 | /* End Contact - Personal Data */ |
---|
323 | |
---|
324 | /* Contact - Addresses */ |
---|
325 | $template->set_var('cc_addr_types',lang('Type of Address')); |
---|
326 | $template->set_var('cc_addr_choose_types',lang('Choose Type of Address').'...'); |
---|
327 | $template->set_var('cc_addr_countries',lang('Country')); |
---|
328 | $template->set_var('cc_addr_choose_countries',lang('Choose Country').'...'); |
---|
329 | $template->set_var('cc_addr_states',lang('State')); |
---|
330 | $template->set_var('cc_addr_states_new',lang('New State').'...'); |
---|
331 | $template->set_var('cc_addr_states_nostate',lang('No State')); |
---|
332 | $template->set_var('cc_addr_choose_states',lang('Choose State').'...'); |
---|
333 | $template->set_var('cc_addr_cities',lang('City')); |
---|
334 | $template->set_var('cc_addr_cities_new',lang('New City').'...'); |
---|
335 | $template->set_var('cc_addr_choose_cities',lang('Choose City').'...'); |
---|
336 | $template->set_var('cc_addr_1',lang('Address 1')); |
---|
337 | $template->set_var('cc_addr_2',lang('Address 2')); |
---|
338 | $template->set_var('cc_addr_complement',lang('Complement')); |
---|
339 | $template->set_var('cc_addr_other',lang('Address Other')); |
---|
340 | $template->set_var('cc_addr_postal_code',lang('Postal Code')); |
---|
341 | $template->set_var('cc_addr_po_box',lang('PO Box')); |
---|
342 | $template->set_var('cc_addr_is_default',lang('Is Default?')); |
---|
343 | $template->set_var('cc_addr_yes',lang('Yes')); |
---|
344 | $template->set_var('cc_addr_no',lang('No')); |
---|
345 | $template->set_var('cc_available',lang('Available')); |
---|
346 | /* End Contact - Addresses */ |
---|
347 | |
---|
348 | |
---|
349 | /* Contact - Connections */ |
---|
350 | $template->set_var('cc_conn_type',lang('Type of Connection')); |
---|
351 | $template->set_var('cc_conn_name',lang('Connection Name')); |
---|
352 | $template->set_var('cc_conn_value',lang('Connection Value')); |
---|
353 | |
---|
354 | $template->set_var('cc_new_same_type',lang('New from the same Type').'...'); |
---|
355 | |
---|
356 | $template->set_var('cc_conn_type_none',lang('Choose Type of Connection').'...'); |
---|
357 | /* End Contact - Connections */ |
---|
358 | |
---|
359 | /* Contact - Groups */ |
---|
360 | $template->set_var('cc_grps_available', lang('Groups available')); |
---|
361 | $template->set_var('cc_grps_selected', lang('Selected groups')); |
---|
362 | $template->set_var('txt_add', lang('Add')); |
---|
363 | $template->set_var('txt_rem', lang('Remove')); |
---|
364 | /* End Contact - Groups */ |
---|
365 | |
---|
366 | /* Corporate - contact */ |
---|
367 | $template->set_var('cc_name_corporate',lang('Corporate')); |
---|
368 | $template->set_var('cc_job_title',lang('Job Title')); |
---|
369 | $template->set_var('cc_department',lang('Department')); |
---|
370 | $template->set_var('cc_web_page',lang('Web Page')); |
---|
371 | |
---|
372 | $template->set_var('email', lang("E-Mail")); |
---|
373 | $template->set_var('telephone', lang("Telephone")); |
---|
374 | $template->set_var('choose_email_telephone', lang("Choose 'E-Mail' or 'Telephone'")); |
---|
375 | |
---|
376 | $template->parse('out_full', 'full_add'); |
---|
377 | |
---|
378 | return $template->get_var('out_full'); |
---|
379 | } |
---|
380 | |
---|
381 | function get_quick_add_plugin() |
---|
382 | { |
---|
383 | $template_dir = PHPGW_SERVER_ROOT . '/contactcenter/templates/default/'; |
---|
384 | $template = CreateObject('phpgwapi.Template',$template_dir); |
---|
385 | |
---|
386 | $template->set_file(array('quickAdd' => 'quickAddPlugin.tpl')); |
---|
387 | |
---|
388 | if (!$this->commons_loaded) |
---|
389 | { |
---|
390 | $template->set_var('cc_api', $this->commons); |
---|
391 | $this->commons_loaded = true; |
---|
392 | } |
---|
393 | else |
---|
394 | { |
---|
395 | $template->set_var('cc_api', ''); |
---|
396 | } |
---|
397 | |
---|
398 | $template->set_var('ccQAPluginFile', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/ccQuickAdd-plugin.js'); |
---|
399 | |
---|
400 | /* Fields Insertion */ |
---|
401 | |
---|
402 | // TODO: get this from preferences |
---|
403 | $nFields = 5; |
---|
404 | $fields = array( |
---|
405 | lang('Alias'), |
---|
406 | lang('Given Names'), |
---|
407 | lang('Family Names'), |
---|
408 | lang('Phone'), |
---|
409 | lang('Email') |
---|
410 | ); |
---|
411 | |
---|
412 | $template->set_var('ccQAnFields', $nFields); |
---|
413 | |
---|
414 | $fieldsHTML = ''; |
---|
415 | $fieldsTop = 10; |
---|
416 | $fieldsSpace = 30; |
---|
417 | for ($i = 0; $i < $nFields; $i++) |
---|
418 | { |
---|
419 | $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"; |
---|
420 | if ($i == 0){ |
---|
421 | $fieldsHTML .= '<input id="ccQuickAddI'.$i.'" type="text" value="" maxlength="30" style="position: absolute; top: '.($fieldsTop+$i*$fieldsSpace).'px; left: 110px; width: 135px;">'."\n"; |
---|
422 | } |
---|
423 | else if ($i == 4){ |
---|
424 | $fieldsHTML .= '<input id="ccQuickAddI'.$i.'" type="text" value="" maxlength="100" style="position: absolute; top: '.($fieldsTop+$i*$fieldsSpace).'px; left: 110px; width: 135px;">'."\n"; |
---|
425 | }else if ($i == 3){ |
---|
426 | $fieldsHTML .= '<input id="ccQuickAddI'.$i.'" type="text" value="" onkeyup="formatPhone(this)" maxlength="30" style="position: absolute; top: '.($fieldsTop+$i*$fieldsSpace).'px; left: 110px; width: 135px;">'."\n"; |
---|
427 | } |
---|
428 | else { |
---|
429 | $fieldsHTML .= '<input id="ccQuickAddI'.$i.'" type="text" value="" maxlength="50" style="position: absolute; top: '.($fieldsTop+$i*$fieldsSpace).'px; left: 110px; width: 135px;">'."\n"; |
---|
430 | } |
---|
431 | } |
---|
432 | |
---|
433 | $template->set_var('ccQAFields', $fieldsHTML); |
---|
434 | $template->set_var('ccQAWinHeight', ($i+1)*$fieldsSpace+$fieldsTop); |
---|
435 | $template->set_var('ccQAFunctionsTop', ($fieldsTop+$i*$fieldsSpace).'px'); |
---|
436 | |
---|
437 | /* Images Dir */ |
---|
438 | $template->set_var('ccQACardImgRoot', $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/templates/default/images/'); |
---|
439 | |
---|
440 | /* Texts */ |
---|
441 | $template->set_var('ccQATitle', lang('Contact Center').' - '.lang('Quick Add')); |
---|
442 | $template->set_var('ccQASave', lang('Save')); |
---|
443 | $template->set_var('ccQAClear', lang('Reset')); |
---|
444 | $template->set_var('ccQACancel', lang('Cancel')); |
---|
445 | |
---|
446 | $template->parse('out_QA', 'quickAdd'); |
---|
447 | |
---|
448 | return $template->get_var('out_QA'); |
---|
449 | } |
---|
450 | |
---|
451 | function parseGroupOption($level, $name, $selected=false){ |
---|
452 | |
---|
453 | $selected = $selected?'selected="selected"':''; |
---|
454 | $optionTemplate = '<option value="{level}" {selected}>{value}</option>'; |
---|
455 | |
---|
456 | $optionTemplate = preg_replace('/\{level\}/', $level, $optionTemplate); |
---|
457 | $optionTemplate = preg_replace('/\{selected\}/', $selected, $optionTemplate); |
---|
458 | $optionTemplate = preg_replace('/\{value\}/', $name, $optionTemplate); |
---|
459 | |
---|
460 | return $optionTemplate; |
---|
461 | |
---|
462 | } |
---|
463 | |
---|
464 | function getCatalogItens($level='0', $parentName=false){ |
---|
465 | $bo = CreateObject('contactcenter.bo_contactcenter'); |
---|
466 | |
---|
467 | $options = ''; |
---|
468 | |
---|
469 | $catalogTree = $bo->get_catalog_tree('0'); |
---|
470 | foreach ($catalogTree as $id => $catalog) |
---|
471 | { |
---|
472 | if ($level.'.'.$id !== '0.1') |
---|
473 | { |
---|
474 | $option = $level.'.'.$id === '0.0'? |
---|
475 | $this->parseGroupOption($level.'.'.$id, $catalog['name'], true): |
---|
476 | $this->parseGroupOption($level.'.'.$id, $catalog['name']); |
---|
477 | $options .= $option; |
---|
478 | } |
---|
479 | } |
---|
480 | return $options; |
---|
481 | } |
---|
482 | |
---|
483 | function get_add_group() |
---|
484 | { |
---|
485 | $template_dir = PHPGW_SERVER_ROOT . '/contactcenter/templates/default/'; |
---|
486 | $template = CreateObject('phpgwapi.Template',$template_dir); |
---|
487 | |
---|
488 | $template->set_file(array('addGroup' => 'addGroup.tpl')); |
---|
489 | |
---|
490 | $catalogOptions = $this->getCatalogItens(); |
---|
491 | |
---|
492 | if (!$this->commons_loaded) |
---|
493 | { |
---|
494 | $template->set_var('cc_api', $this->commons); |
---|
495 | $this->commons_loaded = true; |
---|
496 | } |
---|
497 | else |
---|
498 | { |
---|
499 | |
---|
500 | $template->set_var('cc_api', ''); |
---|
501 | } |
---|
502 | |
---|
503 | $template->set_var('ccAGSourceSelectContent', $catalogOptions); |
---|
504 | $template->set_var('ccAGSearch', lang('Search')); |
---|
505 | |
---|
506 | $template->set_var('ccAGFile', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/ccAddGroup.js'); |
---|
507 | $template->set_var('ccAGWinHeightIE', '340'); |
---|
508 | $template->set_var('ccAGWinHeightMO', '335'); |
---|
509 | |
---|
510 | /* Images Dir */ |
---|
511 | $template->set_var('ccAGCardImgRoot', $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/templates/default/images/'); |
---|
512 | |
---|
513 | /* Texts */ |
---|
514 | $template->set_var('ccAGTitle', lang('Contact Center').' - '.lang('Group Add')); |
---|
515 | $template->set_var('ccAGSave', lang('Save')); |
---|
516 | $template->set_var('ccAGClear', lang('Reset')); |
---|
517 | $template->set_var('ccAGCancel', lang('Cancel')); |
---|
518 | $title = '<input type="text" id="title" name="title" value="'.$group['title'].'" size="50" maxlength="50"/>'; |
---|
519 | |
---|
520 | $template->set_var('title', $title); |
---|
521 | // set content and label variables. |
---|
522 | $template->set_var(array( |
---|
523 | 'msg_text' => lang($status), |
---|
524 | 'txt_title' => lang('Contact Group List'), |
---|
525 | 'txt_cancel'=> lang('cancel'), |
---|
526 | 'txt_add'=> lang('Add'), |
---|
527 | 'txt_rem'=> lang('Remove'), |
---|
528 | 'txt_personal_contacts' => lang('Personal Contacts'), |
---|
529 | 'txt_contacts_in_list' => lang("Participants"), |
---|
530 | 'txt_name' => lang('Full Name'))); |
---|
531 | |
---|
532 | $template->parse('out_AG', 'addGroup'); |
---|
533 | |
---|
534 | return $template->get_var('out_AG'); |
---|
535 | } |
---|
536 | } |
---|
537 | ?> |
---|