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