0){ foreach($_REQUEST['assigned_user_id'] as $au){ $where_clauses[]="contacts.assigned_user_id='".$au."'"; } } if(count($_REQUEST['assigned_user_id_advanced'])>0){ foreach($_REQUEST['assigned_user_id_advanced'] as $au){ $where_clauses[]="contacts.assigned_user_id='".$au."'"; } } if($_REQUEST['account_id']){ $where_clauses[]="contacts.id IN (select contact_id as id from accounts_contacts as ac join accounts acc on acc.id=ac.account_id where acc.id='".$_REQUEST['account_id']."')"; } if($_REQUEST['only_my_items'])$where_clauses[]="contacts.assigned_user_id='".$_SESSION['authenticated_user_id']."'"; /*append_where_clause($where_clauses, "address_postalcode", "contacts.alt_address_postalcode"); append_where_clause($where_clauses, "address_street", "contacts.alt_address_street"); append_where_clause($where_clauses, "address_city", "contacts.alt_address_city"); append_where_clause($where_clauses, "address_country", "contacts.alt_address_country"); append_where_clause($where_clauses, "address_state", "contacts.alt_address_state");*/ //append_where_clause($where_clauses, "assigned_user_advanced", "contacts.assigned_user_id"); $where = generate_where_statement($where_clauses); // echo $where; } return $where; } /** * */ function process_page_dial() { global $system_config; /* * CHECK IF USER WOULD LIKE TO USE PRO VERSION */ if( isset($system_config->settings['system_asterisk_pro']) && $system_config->settings['system_asterisk_pro'] == 1) { $asterisk_popup='include/asterisk/Asterisk_popup.tpl'; $pro='include/asterisk/pro.php'; /* * CHECK THAT ALL NECESSARY FILES FOR PRO VERSION ARE AVAILABLE */ if( file_exists($asterisk_popup) && file_exists($pro) ){ require_once('include/asterisk/pro.php'); proLogic(); } /* * IF ALL FILES ARE NOT THERE THEN DISPLAY WHERE THEY ARE AVAILABLE AT */ else { /* * TRYING TO USE PRO WITHOUT NECESSARY FILES */ echo "

Either the PRO version is not enabled or you are not using the PRO version. For more information you may visit http://www.voicerd.com/products.php
or email VoiceRD ( voicerd@novacoast.com )
"; } } /* * USE THE OPEN SOURCE VERSION */ else{ $this->openSourceLogic(); } } function openSourceLogic() { global $system_config; global $current_user; $display_number = $_REQUEST['number']; //remove anything that is not a number or an asterisk(*) $number = preg_replace ( "/[^\d\*]/", "", $_REQUEST['number'] ); /* * If there is a prefix to be dialed then pre-pend that to the number that will be dialed */ if(!isset($system_config->settings['system_asterisk_prefix']) || $system_config->settings['system_asterisk_prefix'] != "" ) { /* * Grab the prefix number and remove anything that is not a number or an asterisk(*) */ $prefix = $system_config->settings['system_asterisk_prefix']; $prefix = preg_replace ( "/[^\d\*]/", "", $prefix ); /* * Pre-prend the prefix to the dial number and to the display number */ $display_number = $prefix."+".$display_number; $number = $prefix.$number; } /* * If asterisk port was left empty in admin setting then default to 5038 */ if(!isset($system_config->settings['system_asterisk_port']) || $system_config->settings['system_asterisk_port'] == "" ) $system_config->settings['system_asterisk_port'] = "5038"; /* * If asterisk internal context was left empty in admin settings then default to "from-internal" */ if(!isset($system_config->settings['system_asterisk_internal_context']) || $system_config->settings['system_asterisk_internal_context'] == "" ) $system_config->settings['system_asterisk_internal_context'] = "from-internal"; /* * If asterisk external context was left empty in admin settings then default to "from-internal" */ if(!isset($system_config->settings['system_asterisk_external_context']) || $system_config->settings['system_asterisk_external_context'] == "" ) $system_config->settings['system_asterisk_external_context'] = "from-internal"; /* * If asterisk auto pickup is blank default to *3 */ if(!isset($system_config->settings['system_asterisk_auto_pickup']) || $system_config->settings['system_asterisk_auto_pickup'] == "" ) $system_config->settings['system_asterisk_auto_pickup'] = "*3"; /* * if any of the required fields were left empty in admin settings then signal error. */ if( !isset($system_config->settings['system_asterisk_server']) || $system_config->settings['system_asterisk_server'] == "" || !isset($system_config->settings['system_asterisk_username']) || $system_config->settings['system_asterisk_username'] == "" || !isset($system_config->settings['system_asterisk_secret']) || $system_config->settings['system_asterisk_secret'] == "" ) { return "Asterisk Configuration Error."; } /* * If all required fields are filled in then dial */ else { //HTML code $output_html=""; if( isset($system_config->settings['system_asterisk_popup_timer']) && $system_config->settings['system_asterisk_popup_timer'] !="" ) { $output_html.= "settings['system_asterisk_popup_timer']*1000).")\">"; } else { $output_html=""; } $output_html.=<< Dialing...$display_number EOQ; ///If user has auto pickup selected then pre-pend if(isset($current_user->asterisk_auto_pickup) && $current_user->asterisk_auto_pickup == '1'){ $number = $system_config->settings['system_asterisk_auto_pickup'].$number; } //Asterisk DialCode $timeout = 30; $socket = fsockopen( $system_config->settings['system_asterisk_server'],$system_config->settings['system_asterisk_port'], $errno, $errstr, $timeout); if(!$socket){ die("Error Connecting to Asterisk Server"); } fputs($socket, "Action: Login\r\n"); fputs($socket, "UserName: ".$system_config->settings['system_asterisk_username']."\r\n"); fputs($socket, "Secret: ".$system_config->settings['system_asterisk_secret']."\r\n\r\n"); fputs($socket, "Action: Originate\r\n"); //Partially contributed by SugarForge User mikeyb $callerid = $current_user->asterisk_extension; if (strpos($current_user->asterisk_extension, '/') === false) { fputs($socket, "Channel: Local/".$current_user->asterisk_extension."@".$system_config->settings['system_asterisk_internal_context']."\r\n"); } else { fputs($socket, "Channel: ".$current_user->asterisk_extension."\r\n"); } fputs($socket, "Context: ".$system_config->settings['system_asterisk_external_context']."\r\n"); fputs($socket, "Exten: ".$number."\r\n"); fputs($socket, "Priority: 1\r\n"); fputs($socket, "Callerid: ".$current_user->asterisk_extension."\r\n\r\n"); $wrets=fgets($socket,128); echo $output_html; } } ////////END ASTERISK PATCH//////// function process_page() { global $theme; global $mod_strings; global $app_strings; global $currentModule; global $sugar_version, $sugar_config; $output_html = ''; $where = ''; $where = $this->_get_where_clause(); $image_path = 'themes/'.$theme.'/images/'; $formBase = new ContactFormBase(); if(isset($_REQUEST['doAction']) && $_REQUEST['doAction'] == 'save') { $formBase->handleSave('', false, true); } $first_name = empty($_REQUEST['first_name']) ? '' : $_REQUEST['first_name']; $last_name = empty($_REQUEST['last_name']) ? '' : $_REQUEST['last_name']; $account_name = empty($_REQUEST['account_name']) ? '' : $_REQUEST['account_name']; $request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data']; $hide_clear_button = empty($_REQUEST['hide_clear_button']) ? false : true; $lbl_save_button_title = $app_strings['LBL_SAVE_BUTTON_TITLE']; $lbl_save_button_key = $app_strings['LBL_SAVE_BUTTON_KEY']; $lbl_save_button_label = $app_strings['LBL_SAVE_BUTTON_LABEL']; // TODO: cleanup the construction of $addform $formbody = $formBase->getFormBody('','','EmailEditView'); $addform = '
' .str_replace('
', '
 ', $formbody) . '
' . ''; $formSave = << EOQ; $createContact = << EOQ; $addformheader = get_form_header($mod_strings['LNK_NEW_CONTACT'], $formSave, false); $button = "
\n"; //if (!empty($_REQUEST['mode']) && strtoupper($_REQUEST['mode']) == 'MULTISELECT') { $multi_select=true; $button .= "\n"; //} //END:FOR MULTI-SELECT if(!$hide_clear_button) { $button .= "\n"; } $button .= "\n"; //$button.=""; $button .= "
\n"; $first_name = empty($_REQUEST['first_name']) ? '' : $_REQUEST['first_name']; $last_name = empty($_REQUEST['last_name']) ? '' : $_REQUEST['last_name']; $form = new XTemplate('modules/Contacts/Popup_picker.html'); $form->assign('FIRST_NAME', $first_name); $form->assign('LAST_NAME', $last_name); $fields=array("first_name","last_name","address_postalcode","address_street","address_state","address_city","address_country","phone","account_id","account_name","assistant","assigned_user_id"); foreach($fields as $f){ if($_REQUEST[$f])$form->assign(strtoupper($f),$_REQUEST[$f]); else $form->assign(strtoupper($f),$_REQUEST[$f."_advanced"]); } $w=mysql_query("select id,first_name,last_name from users where status='Active' and deleted='0' order by first_name asc, last_name asc"); while($r=mysql_fetch_array($w)){ $atr.='