debug("get_user_array query: $query"); $result = $db->query($query, true, "Error filling in user array: "); if ($add_blank==true){ // Add in a blank row $temp_result[''] = ''; } // Get the id and the name. while($row = $db->fetchByAssoc($result)) { $temp_result[$row['id']] = $row['user_name']; } $user_array = &$temp_result; } return $user_array; } function clean($string, $maxLength) { $string = substr($string, 0, $maxLength); return escapeshellcmd($string); } /** * Copy the specified request variable to the member variable of the specified object. * Do no copy if the member variable is already set. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function safe_map($request_var, & $focus, $always_copy = false) { safe_map_named($request_var, $focus, $request_var, $always_copy); } /** * Copy the specified request variable to the member variable of the specified object. * Do no copy if the member variable is already set. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function safe_map_named($request_var, & $focus, $member_var, $always_copy) { global $log; if (isset($_REQUEST[$request_var]) && ($always_copy || is_null($focus->$member_var))) { $log->debug("safe map named called assigning '{$_REQUEST[$request_var]}' to $member_var"); $focus->$member_var = $_REQUEST[$request_var]; } } /** This function retrieves an application language file and returns the array of strings included in the $app_list_strings var. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. * If you are using the current language, do not call this function unless you are loading it for the first time */ function return_app_list_strings_language($language) { global $app_list_strings, $default_language, $log, $translation_string_prefix; $temp_app_list_strings = $app_list_strings; $language_used = $language; @include("include/language/$language.lang.php"); if(!isset($app_list_strings)) { $log->warn("Unable to find the application language file for language: ".$language); require("include/language/$default_language.lang.php"); $language_used = $default_language; } if(!isset($app_list_strings)) { $log->fatal("Unable to load the application language file for the selected language($language) or the default language($default_language)"); return null; } $return_value = $app_list_strings; $app_list_strings = $temp_app_list_strings; return $return_value; } /** This function retrieves an application language file and returns the array of strings included. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. * If you are using the current language, do not call this function unless you are loading it for the first time */ function return_application_language($language) { global $app_strings, $default_language, $log, $translation_string_prefix; $temp_app_strings = $app_strings; $language_used = $language; @include("include/language/$language.lang.php"); if(!isset($app_strings)) { $log->warn("Unable to find the application language file for language: ".$language); require("include/language/$default_language.lang.php"); $language_used = $default_language; } if(!isset($app_strings)) { $log->fatal("Unable to load the application language file for the selected language($language) or the default language($default_language)"); return null; } // If we are in debug mode for translating, turn on the prefix now! if($translation_string_prefix) { foreach($app_strings as $entry_key=>$entry_value) { $app_strings[$entry_key] = $language_used.' '.$entry_value; } } $return_value = $app_strings; $app_strings = $temp_app_strings; return $return_value; } /** This function retrieves a module's language file and returns the array of strings included. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. * If you are in the current module, do not call this function unless you are loading it for the first time */ function return_module_language($language, $module) { global $mod_strings, $default_language, $log, $currentModule, $translation_string_prefix; if($currentModule == $module && isset($mod_strings) && $mod_strings != null) { // We should have already loaded the array. return the current one. //$log->fatal("module strings already loaded for language: ".$language." and module: ".$module); return $mod_strings; } $temp_mod_strings = $mod_strings; $language_used = $language; @include("modules/$module/language/$language.lang.php"); if(!isset($mod_strings)) { $log->warn("Unable to find the module language file for language: ".$language." and module: ".$module); require("modules/$module/language/$default_language.lang.php"); $language_used = $default_language; } if(!isset($mod_strings)) { $log->fatal("Unable to load the module($module) language file for the selected language($language) or the default language($default_language)"); return null; } // If we are in debug mode for translating, turn on the prefix now! if($translation_string_prefix) { foreach($mod_strings as $entry_key=>$entry_value) { $mod_strings[$entry_key] = $language_used.' '.$entry_value; } } $return_value = $mod_strings; $mod_strings = $temp_mod_strings; return $return_value; } /** This function retrieves an application language file and returns the array of strings included in the $mod_list_strings var. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. * If you are using the current language, do not call this function unless you are loading it for the first time */ function return_mod_list_strings_language($language,$module) { global $mod_list_strings, $default_language, $log, $currentModule,$translation_string_prefix; $language_used = $language; $temp_mod_list_strings = $mod_list_strings; if($currentModule == $module && isset($mod_list_strings) && $mod_list_strings != null) { return $mod_list_strings; } @include("modules/$module/language/$language.lang.php"); if(!isset($mod_list_strings)) { $log->fatal("Unable to load the application list language file for the selected language($language) or the default language($default_language)"); return null; } $return_value = $mod_list_strings; $mod_list_strings = $temp_mod_list_strings; return $return_value; } /** This function retrieves a theme's language file and returns the array of strings included. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function return_theme_language($language, $theme) { global $mod_strings, $default_language, $log, $currentModule, $translation_string_prefix; $language_used = $language; @include("themes/$theme/language/$current_language.lang.php"); if(!isset($theme_strings)) { $log->warn("Unable to find the theme file for language: ".$language." and theme: ".$theme); require("themes/$theme/language/$default_language.lang.php"); $language_used = $default_language; } if(!isset($theme_strings)) { $log->fatal("Unable to load the theme($theme) language file for the selected language($language) or the default language($default_language)"); return null; } // If we are in debug mode for translating, turn on the prefix now! if($translation_string_prefix) { foreach($theme_strings as $entry_key=>$entry_value) { $theme_strings[$entry_key] = $language_used.' '.$entry_value; } } return $theme_strings; } /** If the session variable is defined and is not equal to "" then return it. Otherwise, return the default value. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function return_session_value_or_default($varname, $default) { if(isset($_SESSION[$varname]) && $_SESSION[$varname] != "") { return $_SESSION[$varname]; } return $default; } /** * Creates an array of where restrictions. These are used to construct a where SQL statement on the query * It looks for the variable in the $_REQUEST array. If it is set and is not "" it will create a where clause out of it. * @param &$where_clauses - The array to append the clause to * @param $variable_name - The name of the variable to look for an add to the where clause if found * @param $SQL_name - [Optional] If specified, this is the SQL column name that is used. If not specified, the $variable_name is used as the SQL_name. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function append_where_clause(&$where_clauses, $variable_name, $SQL_name = null) { if($SQL_name == null) { $SQL_name = $variable_name; } if(isset($_REQUEST[$variable_name]) && $_REQUEST[$variable_name] != "") { array_push($where_clauses, "$SQL_name like '$_REQUEST[$variable_name]%'"); } } /** * Generate the appropriate SQL based on the where clauses. * @param $where_clauses - An Array of individual where clauses stored as strings * @returns string where_clause - The final SQL where clause to be executed. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function generate_where_statement($where_clauses) { global $log; $where = ""; foreach($where_clauses as $clause) { if($where != "") $where .= " and "; $where .= $clause; } $log->info("Here is the where clause for the list view: $where"); return $where; } /** * A temporary method of generating GUIDs of the correct format for our DB. * @return String contianing a GUID in the format: aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee * * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function create_guid() { $microTime = microtime(); list($a_dec, $a_sec) = explode(" ", $microTime); $dec_hex = sprintf("%x", $a_dec* 1000000); $sec_hex = sprintf("%x", $a_sec); ensure_length($dec_hex, 5); ensure_length($sec_hex, 6); $guid = ""; $guid .= $dec_hex; $guid .= create_guid_section(3); $guid .= '-'; $guid .= create_guid_section(4); $guid .= '-'; $guid .= create_guid_section(4); $guid .= '-'; $guid .= create_guid_section(4); $guid .= '-'; $guid .= $sec_hex; $guid .= create_guid_section(6); return $guid; } function create_guid_section($characters) { $return = ""; for($i=0; $i<$characters; $i++) { $return .= sprintf("%x", rand(0,15)); } return $return; } function ensure_length(&$string, $length) { $strlen = strlen($string); if($strlen < $length) { $string = str_pad($string,$length,"0"); } else if($strlen > $length) { $string = substr($string, 0, $length); } } function microtime_diff($a, $b) { list($a_dec, $a_sec) = explode(" ", $a); list($b_dec, $b_sec) = explode(" ", $b); return $b_sec - $a_sec + $b_dec - $a_dec; } /** * Check if user id belongs to a system admin. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function is_admin($user) { if ($user->is_admin == 'on') return true; else return false; } /** * Return the display name for a theme if it exists. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function get_theme_display($theme) { global $theme_name, $theme_description; $temp_theme_name = $theme_name; $temp_theme_description = $theme_description; if (is_file("./themes/$theme/config.php")) { @include("./themes/$theme/config.php"); $return_theme_value = $theme_name; } else { $return_theme_value = $theme; } $theme_name = $temp_theme_name; $theme_description = $temp_theme_description; return $return_theme_value; } /** * Return an array of directory names. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function get_themes() { if ($dir = @opendir("./themes")) { while (($file = readdir($dir)) !== false) { if ($file != ".." && $file != "." && $file != "CVS" && $file != "Attic" && $file != "akodarkgem" && $file != "bushtree" && $file != "coolblue" && $file != "Amazon" && $file != "busthree") { if(is_dir("./themes/".$file)) { if(!($file[0] == '.')) { // set the initial theme name to the filename $name = $file; // if there is a configuration class, load that. if(is_file("./themes/$file/config.php")) { require_once("./themes/$file/config.php"); $name = $theme_name; } if(is_file("./themes/$file/header.php")) { $filelist[$file] = $name; } } } } } closedir($dir); } ksort($filelist); return $filelist; } /** * THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED; USE get_select_options_with_id() * Create HTML to display select options in a dropdown list. To be used inside * of a select statement in a form. * param $option_list - the array of strings to that contains the option list * param $selected - the string which contains the default value * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function get_select_options (&$option_list, $selected, $advsearch='false') { return get_select_options_with_id(&$option_list, $selected, $advsearch); } /** * Create HTML to display select options in a dropdown list. To be used inside * of a select statement in a form. This method expects the option list to have keys and values. The keys are the ids. The values are the display strings. * param $option_list - the array of strings to that contains the option list * param $selected - the string which contains the default value * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function get_select_options_with_id (&$option_list, $selected_key, $advsearch='false') { return get_select_options_with_id_separate_key($option_list, $option_list, $selected_key, $advsearch); } /** * Create HTML to display select options in a dropdown list. To be used inside * of a select statement in a form. This method expects the option list to have keys and values. The keys are the ids. The values are the display strings. * param $label_list - the array of strings to that contains the option list * param $key_list - the array of strings to that contains the values list * param $selected - the string which contains the default value * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function get_select_options_with_id_separate_key (&$label_list, &$key_list, $selected_key, $advsearch='false') { global $app_strings; if($advsearch=='true') $select_options = "\n"; else $select_options = ""; //for setting null selection values to human readable --None-- $pattern = "/'0?'>".$app_strings['LBL_NONE']."<"; if (!is_array($selected_key)) $selected_key = array($selected_key); //create the type dropdown domain and set the selected value if $opp value already exists foreach ($key_list as $option_key=>$option_value) { $selected_string = ''; // the system is evaluating $selected_key == 0 || '' to true. Be very careful when changing this. Test all cases. // The reported bug was only happening with one of the users in the drop down. It was being replaced by none. if (($option_key != '' && $selected_key == $option_key) || ($selected_key == '' && $option_key == '') || (in_array($option_key, $selected_key))) { $selected_string = 'selected '; } $html_value = $option_key; $select_options .= "\n"; } $select_options = preg_replace($pattern, $replacement, $select_options); return $select_options; } /** * Create javascript to clear values of all elements in a form. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function get_clear_form_js () { $the_script = << EOQ; return $the_script; } /** * Create javascript to set the cursor focus to specific field in a form * when the screen is rendered. The field name is currently hardcoded into the * the function. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function get_set_focus_js () { //TODO Clint 5/20 - Make this function more generic so that it can take in the target form and field names as variables $the_script = << EOQ; return $the_script; } /** * Very cool algorithm for sorting multi-dimensional arrays. Found at http://us2.php.net/manual/en/function.array-multisort.php * Syntax: $new_array = array_csort($array [, 'col1' [, SORT_FLAG [, SORT_FLAG]]]...); * Explanation: $array is the array you want to sort, 'col1' is the name of the column * you want to sort, SORT_FLAGS are : SORT_ASC, SORT_DESC, SORT_REGULAR, SORT_NUMERIC, SORT_STRING * you can repeat the 'col',FLAG,FLAG, as often you want, the highest prioritiy is given to * the first - so the array is sorted by the last given column first, then the one before ... * Example: $array = array_csort($array,'town','age',SORT_DESC,'name'); * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function array_csort() { $args = func_get_args(); $marray = array_shift($args); $i = 0; $msortline = "return(array_multisort("; foreach ($args as $arg) { $i++; if (is_string($arg)) { foreach ($marray as $row) { $sortarr[$i][] = $row[$arg]; } } else { $sortarr[$i] = $arg; } $msortline .= "\$sortarr[".$i."],"; } $msortline .= "\$marray));"; eval($msortline); return $marray; } /** * Converts localized date format string to jscalendar format * Example: $array = array_csort($array,'town','age',SORT_DESC,'name'); * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function parse_calendardate($local_format) { /* temporarily disabled until international date formats are fixed preg_match("/\(?([^-]{1})[^-]*-([^-]{1})[^-]*-([^-]{1})[^-]*\)/", $local_format, $matches); if (isset($matches[1]) && isset($matches[2]) && isset($matches[3])) { $calendar_format = "%" . $matches[1] . "-%" . $matches[2] . "-%" . $matches[3]; return str_replace(array("y", "�, "a", "j"), array("Y", "Y", "Y", "d"), $calendar_format); } else { return "%Y-%m-%d"; } */ global $current_user; if($current_user->date_format == 'dd-mm-yyyy') { $dt_popup_fmt = "%d-%m-%Y"; } elseif($current_user->date_format == 'mm-dd-yyyy') { $dt_popup_fmt = "%m-%d-%Y"; } elseif($current_user->date_format == 'yyyy-mm-dd') { $dt_popup_fmt = "%Y-%m-%d"; } return $dt_popup_fmt; //return "%Y-%m-%d"; } function set_default_config(&$defaults) { foreach ($defaults as $name=>$value) { if ( ! isset($GLOBALS[$name]) ) { $GLOBALS[$name] = $value; } } } $toHtml = array( '"' => '"', '<' => '<', '>' => '>', '& ' => '& ', "'" => ''', ); function to_html($string, $encode=true){ global $toHtml; if($encode && is_string($string)){//$string = htmlentities($string, ENT_QUOTES); $string = str_replace(array_keys($toHtml), array_values($toHtml), $string); } return $string; } function from_html($string, $encode=true){ global $toHtml; //if($encode && is_string($string))$string = html_entity_decode($string, ENT_QUOTES); if($encode && is_string($string)){ $string = str_replace(array_values($toHtml), array_keys($toHtml), $string); } return $string; } function get_group_options() { global $adb; $sql = "select name from groups"; $result = $adb->query($sql); return $result; } function get_assigned_user_or_group_name($id,$module) { global $adb; //it might so happen that an entity is assigned to a group but at that time the group has no members. even in this case, the query should return a valid value and not just blank if($module == 'Leads') { //$sql = "select (case when (user_name is null) then (users2group.groupname) else (user_name) end) as name from leads left join users on users.id= assigned_user_id left join users2group on users2group.groupname=leads.assigned_user_id where leads.id='" .$id ."'"; //$sql = "select (case when (user_name is null) then (groups.name) else (user_name) end) as name from leads left join users on users.id= assigned_user_id left join groups on groups.name=leads.assigned_user_id where leads.id='" .$id ."'"; $sql="select (case when (user_name is null) then (leadgrouprelation.groupname) else (user_name) end) as name from leads left join users on users.id= assigned_user_id left join leadgrouprelation on leadgrouprelation.leadid=leads.id where leads.deleted=0 and leads.id='". $id ."'"; } else if($module == 'Tasks') { $sql="select (case when (user_name is null) then (taskgrouprelation.groupname) else (user_name) end) as name from tasks left join users on users.id= assigned_user_id left join taskgrouprelation on taskgrouprelation.taskid=tasks.id where tasks.deleted=0 and tasks.id='". $id ."'"; //$sql = "select (case when (user_name is null) then (groups.name) else (user_name) end) as name from tasks left join users on users.id= assigned_user_id left join groups on groups.name=tasks.assigned_user_id where tasks.id='" .$id ."'"; } else if($module == 'Calls') { $sql="select (case when (user_name is null) then (callgrouprelation.groupname) else (user_name) end) as name from calls left join users on users.id= assigned_user_id left join callgrouprelation on callgrouprelation.callid=calls.id where calls.deleted=0 and calls.id='". $id ."'"; // $sql = "select (case when (user_name is null) then (groups.name) else (user_name) end) as name from calls left join users on users.id= assigned_user_id left join groups on groups.name=calls.assigned_user_id where calls.id='" .$id ."'"; } $result = $adb->query($sql); $tempval = $adb->fetch_row($result); return $tempval[0]; } function getTabname($tabid) { global $vtlog; $vtlog->logthis("tab id is ".$tabid,'info'); global $adb; $sql = "select tablabel from tab where tabid='".$tabid."'"; $result = $adb->query($sql); $tabname= $adb->query_result($result,0,"tablabel"); return $tabname; } function getTabid($module) { global $vtlog; $vtlog->logthis("module is ".$module,'info'); global $adb; $sql = "select tabid from tab where name='".$module."'"; $result = $adb->query($sql); $tabid= $adb->query_result($result,0,"tabid"); return $tabid; } function getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields,$generatedtype) { global $adb; global $theme; global $mod_strings; global $app_strings; global $current_user; $value = $col_fields[$fieldname]; $custfld = ''; if($generatedtype == 2) $mod_strings[$fieldlabel] = $fieldlabel; if($uitype == 5 || $uitype == 6 || $uitype ==23) { global $vtlog; $vtlog->logthis("uitype is ".$uitype,'info'); if($value=='') { if($fieldname != 'birthday') $disp_value=getNewDisplayDate(); } else { $disp_value = getDisplayDate($value); } $custfld .= ''; if($uitype == 6 || $uitype == 23) $custfld .= '*'; $custfld .= $mod_strings[$fieldlabel].':'; $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']); $custfld .= ' '; if($uitype == 6) { if($col_fields['time_start']!='') { $curr_time = $col_fields['time_start']; } else { $curr_time = date('H:i'); } $custfld .= '  '; } if($uitype == 5 || $uitype == 23) $custfld .= '
('.$current_user->date_format.')'; else $custfld .= '
('.$current_user->date_format.' '.$app_strings['YEAR_MONTH_DATE'].')'; $custfld .= ''; } elseif($uitype == 15 || $uitype == 16) { #$vtlog->logthis("uitype selected is ".$uitype,'info'); $custfld .= ''; if($uitype == 16) $custfld .= '*'; $custfld .= $mod_strings[$fieldlabel].':'; //$pick_query="select * from ".$fieldname." order by sortorderid"; $pick_query="select * from ".$fieldname; $pickListResult = $adb->query($pick_query); $noofpickrows = $adb->num_rows($pickListResult); $custfld .= ''; } elseif($uitype == 21 || $uitype == 24) { $custfld .= ''; if($uitype == 24) { $custfld .= '*'; } $custfld .= $mod_strings[$fieldlabel].':'; $custfld .= ''; } elseif($uitype == 22) { $custfld .= '* '.$mod_strings[$fieldlabel].':'; $custfld .= ''; } elseif($uitype == 52 || $uitype == 77) { $custfld .= ''.$mod_strings[$fieldlabel].':'; global $current_user; if($value != '') { $assigned_user_id = $value; } else { $assigned_user_id = $current_user->id; } if($uitype == 52) { $combo_lbl_name = 'assigned_user_id'; } elseif($uitype == 77) { $combo_lbl_name = 'assigned_user_id1'; } $users_combo = get_select_options_with_id(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id); $custfld .= ''; } elseif($uitype == 53) { $custfld .= ''.$mod_strings[$fieldlabel].':'; $result = get_group_options(); $nameArray = $adb->fetch_array($result); global $current_user; if($value != '' && $value != 0) { $assigned_user_id = $value; $user_checked = "checked"; $team_checked = ''; $user_style='display:block'; $team_style='display:none'; } else { if($value=='0') { $record = $col_fields["record_id"]; $module = $col_fields["record_module"]; $selected_groupname = getGroupName($record, $module); $user_checked = ''; $team_checked = 'checked'; $user_style='display:none'; $team_style='display:block'; } else { $assigned_user_id = $current_user->id; $user_checked = "checked"; $team_checked = ''; $user_style='display:block'; $team_style='display:none'; } } $users_combo = get_select_options_with_id(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id); $GROUP_SELECT_OPTION = ''.$app_strings['LBL_USER'].''.$app_strings['LBL_TEAM'].'
'; $GROUP_SELECT_OPTION .=''; $custfld .= $GROUP_SELECT_OPTION; } elseif($uitype == 51 || $uitype == 50 || $uitype == 73) { if($_REQUEST['convertmode'] != 'update_quote_val' && $_REQUEST['convertmode'] != 'update_so_val') { if(isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') $value = $_REQUEST['account_id']; } if($value != '') { $account_name = getAccountName($value); } $custfld .= ''; if($uitype==50 || $uitype==73) $custfld .= '*'; $custfld .= $mod_strings[$fieldlabel].':'; if($uitype == 73) { $custfld .= ' '; } else { $custfld .= ' '; } } elseif($uitype == 54) { $custfld .= ''.$mod_strings[$fieldlabel].':'; $pick_query="select * from groups"; $pickListResult = $adb->query($pick_query); $noofpickrows = $adb->num_rows($pickListResult); $custfld .= ''; for($j = 0; $j < $noofpickrows; $j++) { $pickListValue=$adb->query_result($pickListResult,$j,"salutationtype"); if($salt_value == $pickListValue) { $chk_val = "selected"; } else { $chk_val = ''; } $custfld .= ''; } $custfld .= ''; } elseif($uitype == 59) { if($_REQUEST['module'] == 'HelpDesk') { if(isset($_REQUEST['product_id']) & $_REQUEST['product_id'] != '') $value = $_REQUEST['product_id']; } elseif(isset($_REQUEST['parent_id']) & $_REQUEST['parent_id'] != '') $value = $_REQUEST['parent_id']; if($value != '') { $product_name = getProductName($value); } $custfld .= ''; $custfld .= $mod_strings[$fieldlabel].':'; $custfld .= ' '; } elseif($uitype == 63) { $custfld .= ''.$mod_strings[$fieldlabel].':'; if($value=='') $value=1; $custfld .= ' '; $pick_query="select * from duration_minutes order by sortorderid"; $pickListResult = $adb->query($pick_query); $noofpickrows = $adb->num_rows($pickListResult); $salt_value = $col_fields["duration_minutes"]; $custfld .= ''; $custfld .= $app_strings['LBL_HOUR_AND_MINUTE'].''; } elseif($uitype == 64) { $custfld .= ''; $custfld .= $mod_strings[$fieldlabel].':'; $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']); $custfld .= '   '.$mod_strings["LBL_NONE"].'
'.$mod_strings["DATE_FORMAT"].''; $custfld .= ''; } elseif($uitype == 56) { $custfld .= ''.$mod_strings[$fieldlabel].':'; if($value == 1) { $custfld .=''; } else { $custfld .=''; } } elseif($uitype == 57) { //if(isset($_REQUEST['contact_id']) && $_REQUEST['contact_id'] != '') // $value = $_REQUEST['contact_id']; if($value != '') { $contact_name = getContactName($value); } elseif(isset($_REQUEST['contact_id']) && $_REQUEST['contact_id'] != '') { if($_REQUEST['module'] == 'Contacts' && $fieldname = 'contact_id') { $contact_name = ''; } else { $value = $_REQUEST['contact_id']; $contact_name = getContactName($value); } } //Checking for contacts duplicate $custfld .= ''.$mod_strings[$fieldlabel].''; $custfld .= ' '; } elseif($uitype == 61 || $uitype == 69) { global $current_user; if($value != '') { $assigned_user_id = $value; } else { $assigned_user_id = $current_user->id; } if($value!='') $filename=' [ '.$value. ' ]'; $custfld .= ''.$mod_strings[$fieldlabel].''; $custfld .=''.$filename.''; } elseif($uitype == 62) { if(isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') $value = $_REQUEST['parent_id']; if($value != '') { $parent_module = getSalesEntityType($value); if($parent_module == "Leads") { $sql = "select * from leaddetails where leadid=".$value; $result = $adb->query($sql); $first_name = $adb->query_result($result,0,"firstname"); $last_name = $adb->query_result($result,0,"lastname"); $parent_name = $first_name.' '.$last_name; $lead_selected = "selected"; } elseif($parent_module == "Accounts") { $sql = "select * from account where accountid=".$value; $result = $adb->query($sql); $parent_name = $adb->query_result($result,0,"accountname"); $account_selected = "selected"; } elseif($parent_module == "Potentials") { $sql = "select * from potential where potentialid=".$value; $result = $adb->query($sql); $parent_name = $adb->query_result($result,0,"potentialname"); $contact_selected = "selected"; } elseif($parent_module == "Products") { $sql = "select * from products where productid=".$value; $result = $adb->query($sql); $parent_name= $adb->query_result($result,0,"productname"); $product_selected = "selected"; } elseif($parent_module == "Orders") { $sql = "select * from purchaseorder where purchaseorderid=".$value; $result = $adb->query($sql); $parent_name= $adb->query_result($result,0,"subject"); $porder_selected = "selected"; } elseif($parent_module == "SalesOrder") { $sql = "select * from salesorder where salesorderid=".$value; $result = $adb->query($sql); $parent_name= $adb->query_result($result,0,"subject"); $sorder_selected = "selected"; } elseif($parent_module == "Invoice") { $sql = "select * from invoice where invoiceid=".$value; $result = $adb->query($sql); $parent_name= $adb->query_result($result,0,"subject"); $invoice_selected = "selected"; } } $custfld .= ''; $custfld .= ' '; } elseif($uitype == 66) { if(isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') $value = $_REQUEST['parent_id']; // Check for activity type if task orders to be added in select option $act_mode = $_REQUEST['activity_mode']; if($value != '') { $parent_module = getSalesEntityType($value); if($parent_module == "Leads") { $sql = "select * from leaddetails where leadid=".$value; $result = $adb->query($sql); $first_name = $adb->query_result($result,0,"firstname"); $last_name = $adb->query_result($result,0,"lastname"); $parent_name = $first_name.' '.$last_name; $lead_selected = "selected"; } elseif($parent_module == "Accounts") { $sql = "select * from account where accountid=".$value; $result = $adb->query($sql); $parent_name = $adb->query_result($result,0,"accountname"); $account_selected = "selected"; } elseif($parent_module == "Potentials") { $sql = "select * from potential where potentialid=".$value; $result = $adb->query($sql); $parent_name = $adb->query_result($result,0,"potentialname"); $contact_selected = "selected"; } elseif($parent_module == "Quotes") { $sql = "select * from quotes where quoteid=".$value; $result = $adb->query($sql); $parent_name = $adb->query_result($result,0,"subject"); $quote_selected = "selected"; } elseif($act_mode == "Task") { if($parent_module == "Orders") { $sql = "select * from purchaseorder where purchaseorderid=".$value; $result = $adb->query($sql); $parent_name = $adb->query_result($result,0,"subject"); $purchase_selected = "selected"; } if($parent_module == "SalesOrder") { $sql = "select * from salesorder where salesorderid=".$value; $result = $adb->query($sql); $parent_name = $adb->query_result($result,0,"subject"); $sales_selected = "selected"; } if($parent_module == "Invoice") { $sql = "select * from invoice where invoiceid=".$value; $result = $adb->query($sql); $parent_name = $adb->query_result($result,0,"subject"); $invoice_selected = "selected"; } } } $custfld .= ''; $custfld .= ' '; } elseif($uitype == 67) { if(isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') $value = $_REQUEST['parent_id']; if($value != '') { $parent_module = getSalesEntityType($value); if($parent_module == "Leads") { $sql = "select * from leaddetails where leadid=".$value; $result = $adb->query($sql); $first_name = $adb->query_result($result,0,"firstname"); $last_name = $adb->query_result($result,0,"lastname"); $parent_name = $first_name.' '.$last_name; $lead_selected = "selected"; } elseif($parent_module == "Contacts") { $sql = "select * from contactdetails where contactid=".$value; $result = $adb->query($sql); $first_name = $adb->query_result($result,0,"firstname"); $last_name = $adb->query_result($result,0,"lastname"); $parent_name = $first_name.' '.$last_name; $contact_selected = "selected"; } } $custfld .= ' '; } elseif($uitype == 68) { if(isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') $value = $_REQUEST['parent_id']; if($value != '') { $parent_module = getSalesEntityType($value); if($parent_module == "Contacts") { $sql = "select * from contactdetails where contactid=".$value; $result = $adb->query($sql); $first_name = $adb->query_result($result,0,"firstname"); $last_name = $adb->query_result($result,0,"lastname"); $parent_name = $first_name.' '.$last_name; $contact_selected = "selected"; } elseif($parent_module == "Accounts") { $sql = "select * from account where accountid=".$value; $result = $adb->query($sql); $parent_name = $adb->query_result($result,0,"accountname"); $account_selected = "selected"; } } $custfld .= ' '; } elseif($uitype == 65) { $custfld .= ''; $custfld .= ' '; } elseif($uitype == 71 || $uitype == 72) { $custfld .= ''; if($uitype == 72) { $custfld .= '*'; } $disp_currency = getDisplayCurrency(); $custfld .= $mod_strings[$fieldlabel].': ('.$disp_currency.')'; $custfld .= ''; } elseif($uitype == 75 || $uitype ==81) { if($value != '') { $vendor_name = getVendorName($value); } elseif(isset($_REQUEST['vendor_id']) && $_REQUEST['vendor_id'] != '') { $value = $_REQUEST['vendor_id']; $vendor_name = getVendorName($value); } $custfld .= ''; $pop_type = 'specific'; if($uitype == 81) { $custfld .= '*'; $pop_type = 'specific_vendor_address'; } $custfld .= $mod_strings[$fieldlabel].''; $custfld .= ' '; } elseif($uitype == 76) { if($value != '') { $potential_name = getPotentialName($value); } elseif(isset($_REQUEST['potential_id']) && $_REQUEST['potential_id'] != '') { $value = $_REQUEST['potental_id']; $potential_name = getPotentialName($value); } $custfld .= ''.$mod_strings[$fieldlabel].''; $custfld .= ' '; } elseif($uitype == 78) { if($value != '') { $quote_name = getQuoteName($value); } elseif(isset($_REQUEST['quote_id']) && $_REQUEST['quote_id'] != '') { $value = $_REQUEST['quote_id']; $potential_name = getQuoteName($value); } $custfld .= ''.$mod_strings[$fieldlabel].''; $custfld .= ' '; } elseif($uitype == 79) { if($value != '') { $purchaseorder_name = getPoName($value); } elseif(isset($_REQUEST['purchaseorder_id']) && $_REQUEST['purchaseorder_id'] != '') { $value = $_REQUEST['purchaseorder_id']; $purchaseorder_name = getPoName($value); } $custfld .= ''.$mod_strings[$fieldlabel].''; $custfld .= ' '; } elseif($uitype == 80) { if($value != '') { $salesorder_name = getSoName($value); } elseif(isset($_REQUEST['salesorder_id']) && $_REQUEST['salesorder_id'] != '') { $value = $_REQUEST['salesorder_id']; $salesorder_name = getSoName($value); } $custfld .= ''.$mod_strings[$fieldlabel].''; $custfld .= ' '; } elseif($uitype == 30) { $rem_days = 0; $rem_hrs = 0; $rem_min = 0; if($value!='') $SET_REM = "CHECKED"; $rem_days = floor($col_fields[$fieldname]/(24*60)); $rem_hrs = floor(($col_fields[$fieldname]-$rem_days*24*60)/60); $rem_min = ($col_fields[$fieldname]-$rem_days*24*60)%60; $custfld .= ''.$mod_strings[$fieldlabel].':'; $custfld .= '  '.$mod_strings['LBL_YES'].'  '.$mod_strings['LBL_NO'].' '; $day_options = getReminderSelectOption(0,31,'remdays',$rem_days); $hr_options = getReminderSelectOption(0,23,'remhrs',$rem_hrs); $min_options = getReminderSelectOption(1,59,'remmin',$rem_min); $custfld .= '  '.$day_options.'  '.$mod_strings['LBL_DAYS'].'  '.$hr_options.' '.$mod_strings['LBL_HOURS'].'  '.$min_options.' '.$mod_strings['LBL_MINUTES'].'  '.$mod_strings['LBL_BEFORE_EVENT'].''; $SET_REM = ''; } else { $custfld .= ''; //Added condition to set the subject if click Reply All from web mail if($_REQUEST['module'] == 'Emails' && $_REQUEST['mg_subject'] != '') { $value = $_REQUEST['mg_subject']; } if($uitype == 2) $custfld .= '*'; $custfld .= $mod_strings[$fieldlabel].':'; $custfld .= ''; } return $custfld; } function getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields,$generatedtype) { global $adb; global $mod_strings; global $app_strings; global $current_user; $custfld = ''; $value =''; if($generatedtype == 2) $mod_strings[$fieldlabel] = $fieldlabel; if($col_fields[$fieldname]=='--None--') $col_fields[$fieldname]=''; if($uitype == 13) { $custfld .= ''.$mod_strings[$fieldlabel].':'; $custfld .= ''.$col_fields[$fieldname].''; } elseif($uitype == 17) { $custfld .= ''.$mod_strings[$fieldlabel].':'; $custfld .= ''.$col_fields[$fieldname].''; } elseif($uitype == 19 || $uitype == 20 || $uitype == 21 || $uitype == 22 || $uitype == 24) { $col_fields[$fieldname]=nl2br($col_fields[$fieldname]); $custfld .= ''.$mod_strings[$fieldlabel].':'; $custfld .= ''.$col_fields[$fieldname].''; } elseif($uitype == 51 || $uitype == 50 || $uitype == 73) { $account_id = $col_fields[$fieldname]; if($account_id != '') { $account_name = getAccountName($account_id); } //Account Name View $custfld .= ''.$mod_strings[$fieldlabel].':'; $custfld .= ''.$account_name.''; } elseif($uitype == 52 || $uitype == 77) { $custfld .= ''.$mod_strings[$fieldlabel].':'; $user_id = $col_fields[$fieldname]; $user_name = getUserName($user_id); if(is_admin($current_user)) { $custfld .= ''.$user_name.''; } else { $custfld .= ''.$user_name.''; } } elseif($uitype == 53) { $user_id = $col_fields[$fieldname]; if($user_id != 0) { $custfld .= ''.$mod_strings[$fieldlabel].$app_strings['LBL_USER'].' :'; $user_name = getUserName($user_id); if(is_admin($current_user)) { $custfld .= ''.$user_name.''; } else { $custfld .= ''.$user_name.''; } } elseif($user_id == 0) { $custfld .= ''.$mod_strings[$fieldlabel].$app_strings['LBL_GROUP'].' :'; $id = $col_fields["record_id"]; $module = $col_fields["record_module"]; $groupname = getGroupName($id, $module); if(is_admin($current_user)) { $custfld .= ''.$groupname.''; } else { $custfld .= ''.$groupname.''; } } } elseif($uitype == 55) { $custfld .= ''.$mod_strings[$fieldlabel].':'; $value = $col_fields[$fieldname]; $sal_value = $col_fields["salutationtype"]; if($sal_value == '--None--') { $sal_value=''; } $custfld .= ''.$sal_value.' '.$value.''; } elseif($uitype == 56) { $custfld .= ''.$mod_strings[$fieldlabel].':'; $value = $col_fields[$fieldname]; if($value == 1) { $display_val = 'yes'; } else { $display_val = ''; } $custfld .= ''.$display_val.''; } elseif($uitype == 57) { $custfld .= ''.$mod_strings[$fieldlabel].':'; $contact_id = $col_fields[$fieldname]; if($contact_id != '') { $contact_name = getContactName($contact_id); } $custfld .= ''.$contact_name.''; } elseif($uitype == 59) { $product_id = $col_fields[$fieldname]; if($product_id != '') { $product_name = getProductName($product_id); } //Account Name View $custfld .= ''.$mod_strings[$fieldlabel].':'; $custfld .= ''.$product_name.''; } elseif($uitype == 61) { global $adb; $attachmentid=$adb->query_result($adb->query("select * from seattachmentsrel where crmid = ".$col_fields['record_id']),0,'attachmentsid'); if($col_fields[$fieldname] == '' && $attachmentid != '') { $attachquery = "select * from attachments where attachmentsid=".$attachmentid; $col_fields[$fieldname] = $adb->query_result($adb->query($attachquery),0,'name'); } $custfldval = ''.$col_fields[$fieldname].''; $custfld .= ''.$mod_strings[$fieldlabel].':'; $custfld .= ''.$custfldval.''; } elseif($uitype == 69) { $custfld .= ''.$mod_strings[$fieldlabel].':'; if($col_fields[$fieldname] != '') { $imgpath = "test/product/".$col_fields[$fieldname]; $custfld .= ''; } else { $custfld .= ''; } } elseif($uitype == 62) { $value = $col_fields[$fieldname]; if($value != '') { $parent_module = getSalesEntityType($value); if($parent_module == "Leads") { $custfld .= ''.$app_strings['LBL_LEAD_NAME'].':'; $sql = "select * from leaddetails where leadid=".$value; $result = $adb->query($sql); $first_name = $adb->query_result($result,0,"firstname"); $last_name = $adb->query_result($result,0,"lastname"); $custfld .= ''.$first_name.' '.$last_name.''; } elseif($parent_module == "Accounts") { $custfld .= ''.$app_strings['LBL_ACCOUNT_NAME'].':'; $sql = "select * from account where accountid=".$value; $result = $adb->query($sql); $account_name = $adb->query_result($result,0,"accountname"); $custfld .= ''.$account_name.''; } elseif($parent_module == "Potentials") { $custfld .= ''.$app_strings['LBL_POTENTIAL_NAME'].':'; $sql = "select * from potential where potentialid=".$value; $result = $adb->query($sql); $potentialname = $adb->query_result($result,0,"potentialname"); $custfld .= ''.$potentialname.''; } elseif($parent_module == "Products") { $custfld .= ''.$app_strings['LBL_PRODUCT_NAME'].':'; $sql = "select * from products where productid=".$value; $result = $adb->query($sql); $productname= $adb->query_result($result,0,"productname"); $custfld .= ''.$productname.''; } elseif($parent_module == "Orders") { $custfld .= ''.$app_strings['LBL_PORDER_NAME'].':'; $sql = "select * from purchaseorder where purchaseorderid=".$value; $result = $adb->query($sql); $pordername= $adb->query_result($result,0,"subject"); $custfld .= ''.$pordername.''; } elseif($parent_module == "SalesOrder") { $custfld .= ''.$app_strings['LBL_SORDER_NAME'].':'; $sql = "select * from salesorder where salesorderid=".$value; $result = $adb->query($sql); $sordername= $adb->query_result($result,0,"subject"); $custfld .= ''.$sordername.''; } elseif($parent_module == "Invoice") { $custfld .= ''.$app_strings['LBL_INVOICE_NAME'].':'; $sql = "select * from invoice where invoiceid=".$value; $result = $adb->query($sql); $invoicename= $adb->query_result($result,0,"subject"); $custfld .= ''.$invoicename.''; } } else { $custfld .= ''.$mod_strings[$fieldlabel].':'; $custfld .= ''.$value.''; } } elseif($uitype == 66) { $value = $col_fields[$fieldname]; if($value != '') { $parent_module = getSalesEntityType($value); if($parent_module == "Leads") { $custfld .= ''.$app_strings['LBL_LEAD_NAME'].':'; $sql = "select * from leaddetails where leadid=".$value; $result = $adb->query($sql); $first_name = $adb->query_result($result,0,"firstname"); $last_name = $adb->query_result($result,0,"lastname"); $custfld .= ''.$first_name.' '.$last_name.''; } elseif($parent_module == "Accounts") { $custfld .= ''.$app_strings['LBL_ACCOUNT_NAME'].':'; $sql = "select * from account where accountid=".$value; $result = $adb->query($sql); $account_name = $adb->query_result($result,0,"accountname"); $custfld .= ''.$account_name.''; } elseif($parent_module == "Potentials") { $custfld .= ''.$app_strings['LBL_POTENTIAL_NAME'].':'; $sql = "select * from potential where potentialid=".$value; $result = $adb->query($sql); $potentialname = $adb->query_result($result,0,"potentialname"); $custfld .= ''.$potentialname.''; } elseif($parent_module == "Quotes") { $custfld .= ''.$app_strings['LBL_QUOTE_NAME'].':'; $sql = "select * from quotes where quoteid=".$value; $result = $adb->query($sql); $quotename = $adb->query_result($result,0,"subject"); $custfld .= ''.$quotename.''; } elseif($parent_module == "Orders") { $custfld .= ''.$app_strings['LBL_PORDER_NAME'].':'; $sql = "select * from purchaseorder where purchaseorderid=".$value; $result = $adb->query($sql); $pordername = $adb->query_result($result,0,"subject"); $custfld .= ''.$pordername.''; } elseif($parent_module == "SalesOrder") { $custfld .= ''.$app_strings['LBL_SORDER_NAME'].':'; $sql = "select * from salesorder where salesorderid=".$value; $result = $adb->query($sql); $sordername = $adb->query_result($result,0,"subject"); $custfld .= ''.$sordername.''; } elseif($parent_module == "Invoice") { $custfld .= ''.$app_strings['LBL_INVOICE_NAME'].':'; $sql = "select * from invoice where invoiceid=".$value; $result = $adb->query($sql); $invoicename = $adb->query_result($result,0,"subject"); $custfld .= ''.$invoicename.''; } } else { $custfld .= ''.$mod_strings[$fieldlabel].':'; $custfld .= ''.$value.''; } } elseif($uitype == 67) { $value = $col_fields[$fieldname]; if($value != '') { $parent_module = getSalesEntityType($value); if($parent_module == "Leads") { $custfld .= ''.$app_strings['LBL_LEAD_NAME'].':'; $sql = "select * from leaddetails where leadid=".$value; $result = $adb->query($sql); $first_name = $adb->query_result($result,0,"firstname"); $last_name = $adb->query_result($result,0,"lastname"); $custfld .= ''.$first_name.' '.$last_name.''; } elseif($parent_module == "Contacts") { $custfld .= ''.$app_strings['LBL_CONTACT_NAME'].':'; $sql = "select * from contactdetails where contactid=".$value; $result = $adb->query($sql); $first_name = $adb->query_result($result,0,"firstname"); $last_name = $adb->query_result($result,0,"lastname"); $custfld .= ''.$first_name.' '.$last_name.''; } } else { $custfld .= ''.$mod_strings[$fieldlabel].':'; $custfld .= ''.$value.''; } } elseif($uitype == 68) { $value = $col_fields[$fieldname]; if($value != '') { $parent_module = getSalesEntityType($value); if($parent_module == "Contacts") { $custfld .= ''.$app_strings['LBL_CONTACT_NAME'].':'; $sql = "select * from contactdetails where contactid=".$value; $result = $adb->query($sql); $first_name = $adb->query_result($result,0,"firstname"); $last_name = $adb->query_result($result,0,"lastname"); $custfld .= ''.$first_name.' '.$last_name.''; } elseif($parent_module == "Accounts") { $custfld .= ''.$app_strings['LBL_ACCOUNT_NAME'].':'; $sql = "select * from account where accountid=".$value; $result = $adb->query($sql); $account_name = $adb->query_result($result,0,"accountname"); $custfld .= ''.$account_name.''; } } else { $custfld .= ''.$mod_strings[$fieldlabel].':'; $custfld .= ''.$value.''; } } elseif($uitype==63) { $custfld .= ''.$mod_strings[$fieldlabel].':'; $custfld .= ''.$col_fields[$fieldname].'h  '.$col_fields['duration_minutes'].'m'; } elseif($uitype == 6) { $custfld .= ''.$mod_strings[$fieldlabel].':'; if($col_fields[$fieldname]=='0') $col_fields[$fieldname]=''; if($col_fields['time_start']!='') { $start_time = $col_fields['time_start']; } if($col_fields[$fieldname] == '0000-00-00') { $displ_date = ''; } else { $displ_date = getDisplayDate($col_fields[$fieldname]); } $custfld .= ''.$displ_date.' '.$start_time.''; } elseif($uitype == 5 || $uitype == 23 || $uitype == 70) { $custfld .= ''.$mod_strings[$fieldlabel].':'; $cur_date_val = $col_fields[$fieldname]; if($cur_date_val == '0000-00-00') { $display_val = ''; } else { $display_val = getDisplayDate($cur_date_val); } $custfld .= ''.$display_val.''; } elseif($uitype == 71 || $uitype == 72) { $custfld .= ''.$mod_strings[$fieldlabel].':'; $display_val = ''; if($col_fields[$fieldname] != '' && $col_fields[$fieldname] != 0) { $curr_symbol = getCurrencySymbol(); $display_val = $curr_symbol.' '.$col_fields[$fieldname]; } $custfld .= ''.$display_val.''; } elseif($uitype == 75 || $uitype == 81) { $custfld .= ''.$mod_strings[$fieldlabel].':'; $vendor_id = $col_fields[$fieldname]; if($vendor_id != '') { $vendor_name = getVendorName($vendor_id); } $custfld .= ''.$vendor_name.''; } elseif($uitype == 76) { $custfld .= ''.$mod_strings[$fieldlabel].':'; $potential_id = $col_fields[$fieldname]; if($potential_id != '') { $potential_name = getPotentialName($potential_id); } $custfld .= ''.$potential_name.''; } elseif($uitype == 78) { $custfld .= ''.$mod_strings[$fieldlabel].':'; $quote_id = $col_fields[$fieldname]; if($quote_id != '') { $quote_name = getQuoteName($quote_id); } $custfld .= ''.$quote_name.''; } elseif($uitype == 79) { $custfld .= ''.$mod_strings[$fieldlabel].':'; $purchaseorder_id = $col_fields[$fieldname]; if($purchaseorder_id != '') { $purchaseorder_name = getPoName($purchaseorder_id); } $custfld .= ''.$purchaseorder_name.''; } elseif($uitype == 80) { $custfld .= ''.$mod_strings[$fieldlabel].':'; $salesorder_id = $col_fields[$fieldname]; if($salesorder_id != '') { $salesorder_name = getSoName($salesorder_id); } $custfld .= ''.$salesorder_name.''; } elseif($uitype == 30) { $rem_days = 0; $rem_hrs = 0; $rem_min = 0; $reminder_str =""; $rem_days = floor($col_fields[$fieldname]/(24*60)); $rem_hrs = floor(($col_fields[$fieldname]-$rem_days*24*60)/60); $rem_min = ($col_fields[$fieldname]-$rem_days*24*60)%60; $custfld .= ''.$mod_strings[$fieldlabel].':'; if($col_fields[$fieldname]) { $reminder_str= $rem_days.' '.$mod_strings['LBL_DAYS'].' '.$rem_hrs.' '.$mod_strings['LBL_HOURS'].' '.$rem_min.' '.$mod_strings['LBL_MINUTES'].'  '.$mod_strings['LBL_BEFORE_EVENT']; } $custfld .= ' '.$reminder_str.''; } else { $custfld .= ''.$mod_strings[$fieldlabel].':'; if($col_fields[$fieldname]=='0') $col_fields[$fieldname]=''; $custfld .= ''.$col_fields[$fieldname].''; } return $custfld; } function getSalesEntityType($crmid) { global $vtlog; $vtlog->logthis("in getSalesEntityType ".$crmid,'info'); global $adb; $sql = "select * from crmentity where crmid=".$crmid; $result = $adb->query($sql); $parent_module = $adb->query_result($result,0,"setype"); return $parent_module; } function getAccountName($account_id) { global $vtlog; $vtlog->logthis("in getAccountName ".$account_id,'info'); global $adb; if($account_id != '') { $sql = "select accountname from account where accountid=".$account_id; $result = $adb->query($sql); $accountname = $adb->query_result($result,0,"accountname"); } return $accountname; } function getProductName($product_id) { global $vtlog; $vtlog->logthis("in getproductname ".$product_id,'info'); global $adb; $sql = "select productname from products where productid=".$product_id; $result = $adb->query($sql); $productname = $adb->query_result($result,0,"productname"); return $productname; } function getPotentialName($potential_id) { global $vtlog; $vtlog->logthis("in getPotentialName ".$potential_id,'info'); global $adb; $sql = "select potentialname from potential where potentialid=".$potential_id; $result = $adb->query($sql); $potentialname = $adb->query_result($result,0,"potentialname"); return $potentialname; } function getContactName($contact_id) { global $vtlog; $vtlog->logthis("in getContactName ".$contact_id,'info'); global $adb; $sql = "select * from contactdetails where contactid=".$contact_id; $result = $adb->query($sql); $firstname = $adb->query_result($result,0,"firstname"); $lastname = $adb->query_result($result,0,"lastname"); $contact_name = $firstname.' '.$lastname; return $contact_name; } function getVendorName($vendor_id) { global $vtlog; $vtlog->logthis("in getVendorName ".$vendor_id,'info'); global $adb; $sql = "select * from vendor where vendorid=".$vendor_id; $result = $adb->query($sql); $vendor_name = $adb->query_result($result,0,"vendorname"); return $vendor_name; } function getQuoteName($quote_id) { global $vtlog; $vtlog->logthis("in getQuoteName ".$quote_id,'info'); global $adb; $sql = "select * from quotes where quoteid=".$quote_id; $result = $adb->query($sql); $quote_name = $adb->query_result($result,0,"subject"); return $quote_name; } function getPriceBookName($pricebookid) { global $vtlog; $vtlog->logthis("in getPriceBookName ".$pricebookid,'info'); global $adb; $sql = "select * from pricebook where pricebookid=".$pricebookid; $result = $adb->query($sql); $pricebook_name = $adb->query_result($result,0,"bookname"); return $pricebook_name; } function getPoName($po_id) { global $vtlog; $vtlog->logthis("in getPoName ".$po_id,'info'); global $adb; $sql = "select * from purchaseorder where purchaseorderid=".$po_id; $result = $adb->query($sql); $po_name = $adb->query_result($result,0,"subject"); return $po_name; } function getSoName($so_id) { global $vtlog; $vtlog->logthis("in getSoName ".$so_id,'info'); global $adb; $sql = "select * from salesorder where salesorderid=".$so_id; $result = $adb->query($sql); $so_name = $adb->query_result($result,0,"subject"); return $so_name; } function getGroupName($id, $module) { global $vtlog; $vtlog->logthis("in getGroupName ".$id.' module is '.$module,'info'); global $adb; if($module == 'Leads') { $sql = "select * from leadgrouprelation where leadid=".$id; } elseif($module == 'HelpDesk') { $sql = "select * from ticketgrouprelation where ticketid=".$id; } elseif($module = 'Calls') { $sql = "select * from activitygrouprelation where activityid=".$id; } elseif($module = 'Tasks') { $sql = "select * from taskgrouprelation where taskid=".$id; } $result = $adb->query($sql); $groupname = $adb->query_result($result,0,"groupname"); return $groupname; } function getColumnFields($module) { global $vtlog; $vtlog->logthis("in getColumnFields ".$module,'info'); global $adb; $column_fld = Array(); $tabid = getTabid($module); $sql = "select * from field where tabid=".$tabid; $result = $adb->query($sql); $noofrows = $adb->num_rows($result); for($i=0; $i<$noofrows; $i++) { $fieldname = $adb->query_result($result,$i,"fieldname"); $column_fld[$fieldname] = ''; } return $column_fld; } function getUserName($userid) { global $vtlog; $vtlog->logthis("in getUserName ".$userid,'info'); global $adb; if($userid != '') { $sql = "select user_name from users where id=".$userid; $result = $adb->query($sql); $user_name = $adb->query_result($result,0,"user_name"); } return $user_name; } function getUserEmail($userid) { global $vtlog; $vtlog->logthis("in getUserEmail ".$userid,'info'); global $adb; if($userid != '') { $sql = "select email1 from users where id=".$userid; $result = $adb->query($sql); $email = $adb->query_result($result,0,"email1"); } return $email; } //outlook security function getUserId_Ol($username) { global $vtlog; $vtlog->logthis("in getUserId_Ol ".$username,'info'); global $adb; $sql = "select id from users where user_name='".$username."'"; $result = $adb->query($sql); $num_rows = $adb->num_rows($result); if($num_rows > 0) { $user_id = $adb->query_result($result,0,"id"); } else { $user_id = 0; } return $user_id; } //outlook security function getNavigationValues($start, $noofrows, $list_max_entries_per_page) { $navigation_array = Array(); require_once('config.php'); //Setting the start to end counter $starttoendvaluecounter = $list_max_entries_per_page - 1; //Setting the ending value if($noofrows > $list_max_entries_per_page) { $end = $start + $starttoendvaluecounter; if($end > $noofrows) { $end = $noofrows; } $startvalue = 1; $remainder = $noofrows % $list_max_entries_per_page; if($remainder > 0) { $endval = $noofrows - $remainder + 1; } elseif($remainder == 0) { $endval = $noofrows - $starttoendvaluecounter; } } else { $end = $noofrows; } //Setting the next and previous value if(isset($start) && $start != '') { $tempnextstartvalue = $start + $list_max_entries_per_page; if($tempnextstartvalue <= $noofrows) { $nextstartvalue = $tempnextstartvalue; } $tempprevvalue = $_REQUEST['start'] - $list_max_entries_per_page; if($tempprevvalue > 0) { $prevstartvalue = $tempprevvalue; } } else { if($noofrows > $list_max_entries_per_page) { $nextstartvalue = $list_max_entries_per_page + 1; } } $navigation_array['start'] = $start; $navigation_array['end'] = $endval; $navigation_array['prev'] = $prevstartvalue; $navigation_array['next'] = $nextstartvalue; $navigation_array['end_val'] = $end; return $navigation_array; } function getURLstring($focus) { $qry = ""; foreach($focus->column_fields as $fldname=>$val) { if(isset($_REQUEST[$fldname]) && $_REQUEST[$fldname] != '') { if($qry == '') $qry = "&".$fldname."=".$_REQUEST[$fldname]; else $qry .="&".$fldname."=".$_REQUEST[$fldname]; } } if(isset($_REQUEST['current_user_only']) && $_REQUEST['current_user_only'] !='') { $qry .="¤t_user_only=".$_REQUEST['current_user_only']; } if(isset($_REQUEST['advanced']) && $_REQUEST['advanced'] =='true') { $qry .="&advanced=true"; } if($qry !='') { $qry .="&query=true"; } return $qry; } function getListViewHeader($focus, $module,$sort_qry='',$sorder='',$order_by='',$relatedlist='',$oCv='') { global $adb; global $theme; global $app_strings; global $mod_strings; //Seggregating between module and smodule if(isset($_REQUEST['smodule']) && $_REQUEST['smodule'] == 'VENDOR') { $smodule = 'Vendor'; } elseif(isset($_REQUEST['smodule']) && $_REQUEST['smodule'] == 'PRICEBOOK') { $smodule = 'PriceBook'; } else { $smodule = $module; } $arrow=''; $qry = getURLstring($focus); $theme_path="themes/".$theme."/"; $image_path=$theme_path."images/"; $list_header = ''; $list_header .= ''; if($relatedlist == '') { $list_header .=''; $list_header .= ''; } //Get the tabid of the module //require_once('modules/Users/UserInfoUtil.php') $tabid = getTabid($smodule); global $profile_id; if($profile_id == '') { global $current_user; $profile_id = fetchUserProfileId($current_user->id); } //added for customview 27/5 if($oCv) { if(isset($oCv->list_fields)) { $focus->list_fields = $oCv->list_fields; } } //modified for customview 27/5 - $app_strings change to $mod_strings foreach($focus->list_fields as $name=>$tableinfo) { //$fieldname = $focus->list_fields_name[$name]; //commented for customview 27/5 //added for customview 27/5 if($oCv) { if(isset($oCv->list_fields_name)) { $fieldname = $oCv->list_fields_name[$name]; }else { $fieldname = $focus->list_fields_name[$name]; } }else { $fieldname = $focus->list_fields_name[$name]; } //Getting the Entries from Profile2 field table $query = "select profile2field.* from field inner join profile2field on field.fieldid=profile2field.fieldid where profile2field.tabid=".$tabid." and profile2field.profileid=".$profile_id." and field.fieldname='".$fieldname."'"; $result = $adb->query($query); //Getting the Entries from def_org_field table $query1 = "select def_org_field.* from field inner join def_org_field on field.fieldid=def_org_field.fieldid where def_org_field.tabid=".$tabid." and field.fieldname='".$fieldname."'"; $result_def = $adb->query($query1); if($adb->query_result($result,0,"visible") == 0 && $adb->query_result($result_def,0,"visible") == 0) { if(isset($focus->sortby_fields) && $focus->sortby_fields !='') { foreach($focus->list_fields[$name] as $tab=>$col) { if(in_array($col,$focus->sortby_fields)) { if($order_by == $col) { if($sorder == 'ASC') { $sorder = "DESC"; $arrow = ""; } else { $sorder = 'ASC'; $arrow = ""; } } if($relatedlist !='') { if($app_strings[$name]) { $name = $app_strings[$name]; } else { $name = $mod_strings[$name]; } } else { if($app_strings[$name]) { $lbl_name = $app_strings[$name]; } else { $lbl_name = $mod_strings[$name]; } $name = "".$lbl_name." ".$arrow.""; $arrow = ''; } } else { if($app_strings[$name]) { $name = $app_strings[$name]; } elseif($mod_strings[$name]) { $name = $mod_strings[$name]; } } } } //Added condition to hide the close column in Related Lists if($name == 'Close' && $relatedlist != '') { $list_header .= ''; } else { $list_header .= ''.$name.''; $list_header .=''; } } } $list_header .=''.$app_strings['LBL_EDIT'].' | '.$app_strings['LBL_DELETE'].''; $list_header .= ''; $list_header .= ''; return $list_header; } function getSearchListViewHeader($focus, $module,$sort_qry='',$sorder='',$order_by='') { global $adb; global $theme; global $app_strings; global $mod_strings; $arrow=''; //$theme = $focus->current_theme; $theme_path="themes/".$theme."/"; $image_path=$theme_path."images/"; $list_header = ''; $list_header .= ''; foreach($focus->search_fields as $name=>$tableinfo) { $fieldname = $focus->search_fields_name[$name]; global $profile_id; $tabid = getTabid($module); $query = "select profile2field.* from field inner join profile2field on field.fieldid=profile2field.fieldid where profile2field.tabid=".$tabid." and profile2field.profileid=".$profile_id." and field.fieldname='".$fieldname."'"; $result = $adb->query($query); //Getting the Entries from def_org_field table $query1 = "select def_org_field.* from field inner join def_org_field on field.fieldid=def_org_field.fieldid where def_org_field.tabid=".$tabid." and field.fieldname='".$fieldname."'"; $result_def = $adb->query($query1); if($adb->query_result($result,0,"visible") == 0 && $adb->query_result($result_def,0,"visible") == 0) { if(isset($focus->sortby_fields) && $focus->sortby_fields !='') { foreach($focus->search_fields[$name] as $tab=>$col) { if(in_array($col,$focus->sortby_fields)) { if($order_by == $col) { if($sorder == 'ASC') { $sorder = "DESC"; $arrow = ""; } else { $sorder = 'ASC'; $arrow = ""; } } $name = "".$app_strings[$name]." ".$arrow.""; $arrow = ''; } else $name = $app_strings[$name]; } } $list_header .= ''.$name.''; $list_header .=''; } } $list_header .= ''; return $list_header; } function getRelatedToEntity($module,$list_result,$rset) { global $adb; $seid = $adb->query_result($list_result,$rset,"relatedto"); if(isset($seid) && $seid != '') { $parent_module = $parent_module = getSalesEntityType($seid); if($parent_module == 'Accounts') { $parent_query = "SELECT accountname FROM account WHERE accountid=".$seid; $parent_result = $adb->query($parent_query); $parent_name = $adb->query_result($parent_result,0,"accountname"); } if($parent_module == 'Leads') { $parent_query = "SELECT firstname,lastname FROM leaddetails WHERE leadid=".$seid; $parent_result = $adb->query($parent_query); $parent_name = $adb->query_result($parent_result,0,"firstname") ." " .$adb->query_result($parent_result,0,"lastname"); } if($parent_module == 'Potentials') { $parent_query = "SELECT potentialname FROM potential WHERE potentialid=".$seid; $parent_result = $adb->query($parent_query); $parent_name = $adb->query_result($parent_result,0,"potentialname"); } if($parent_module == 'Products') { $parent_query = "SELECT productname FROM products WHERE productid=".$seid; $parent_result = $adb->query($parent_query); $parent_name = $adb->query_result($parent_result,0,"productname"); } if($parent_module == 'Orders') { $parent_query = "SELECT subject FROM purchaseorder WHERE purchaseorderid=".$seid; $parent_result = $adb->query($parent_query); $parent_name = $adb->query_result($parent_result,0,"subject"); } if($parent_module == 'SalesOrder') { $parent_query = "SELECT subject FROM salesorder WHERE salesorderid=".$seid; $parent_result = $adb->query($parent_query); $parent_name = $adb->query_result($parent_result,0,"subject"); } if($parent_module == 'Invoice') { $parent_query = "SELECT subject FROM invoice WHERE invoiceid=".$seid; $parent_result = $adb->query($parent_query); $parent_name = $adb->query_result($parent_result,0,"subject"); } $parent_value = "".$parent_name.""; } else { $parent_value = ''; } return $parent_value; } function getRelatedTo($module,$list_result,$rset) { global $adb; if($module == "Notes") { $notesid = $adb->query_result($list_result,$rset,"notesid"); $action = "DetailView"; $evt_query="select senotesrel.crmid,crmentity.setype from senotesrel, crmentity where senotesrel.notesid ='".$notesid."' and senotesrel.crmid = crmentity.crmid"; }else if($module == "Products") { $productid = $adb->query_result($list_result,$rset,"productid"); $action = "DetailView"; $evt_query="select seproductsrel.crmid,crmentity.setype from seproductsrel, crmentity where seproductsrel.productid ='".$productid."' and seproductsrel.crmid = crmentity.crmid"; }else { $activity_id = $adb->query_result($list_result,$rset,"activityid"); $action = "DetailView"; $evt_query="select seactivityrel.crmid,crmentity.setype from seactivityrel, crmentity where seactivityrel.activityid='".$activity_id."' and seactivityrel.crmid = crmentity.crmid"; if($module == 'HelpDesk') { $activity_id = $adb->query_result($list_result,$rset,"parent_id"); if($activity_id != '') $evt_query = "select * from crmentity where crmid=".$activity_id; } } $evt_result = $adb->query($evt_query); $parent_module = $adb->query_result($evt_result,0,'setype'); $parent_id = $adb->query_result($evt_result,0,'crmid'); if($module == 'HelpDesk' && ($parent_module == 'Accounts' || $parent_module == 'Contacts')) { global $theme; $module_icon = ' '; } if($parent_module == 'Accounts') { $parent_query = "SELECT accountname FROM account WHERE accountid=".$parent_id; $parent_result = $adb->query($parent_query); $parent_name = $adb->query_result($parent_result,0,"accountname"); } if($parent_module == 'Leads') { $parent_query = "SELECT firstname,lastname FROM leaddetails WHERE leadid=".$parent_id; $parent_result = $adb->query($parent_query); $parent_name = $adb->query_result($parent_result,0,"firstname") ." " .$adb->query_result($parent_result,0,"lastname"); } if($parent_module == 'Potentials') { $parent_query = "SELECT potentialname FROM potential WHERE potentialid=".$parent_id; $parent_result = $adb->query($parent_query); $parent_name = $adb->query_result($parent_result,0,"potentialname"); } if($parent_module == 'Products') { $parent_query = "SELECT productname FROM products WHERE productid=".$parent_id; $parent_result = $adb->query($parent_query); $parent_name = $adb->query_result($parent_result,0,"productname"); } if($parent_module == 'Quotes') { $parent_query = "SELECT subject FROM quotes WHERE quoteid=".$parent_id; $parent_result = $adb->query($parent_query); $parent_name = $adb->query_result($parent_result,0,"subject"); } if($parent_module == 'Orders') { $parent_query = "SELECT subject FROM purchaseorder WHERE purchaseorderid=".$parent_id; $parent_result = $adb->query($parent_query); $parent_name = $adb->query_result($parent_result,0,"subject"); } if($parent_module == 'Invoice') { $parent_query = "SELECT subject FROM invoice WHERE invoiceid=".$parent_id; $parent_result = $adb->query($parent_query); $parent_name = $adb->query_result($parent_result,0,"subject"); } if($parent_module == 'SalesOrder') { $parent_query = "SELECT subject FROM salesorder WHERE salesorderid=".$parent_id; $parent_result = $adb->query($parent_query); $parent_name = $adb->query_result($parent_result,0,"subject"); $action = "SalesOrderDetailView"; } if($parent_module == 'Contacts' && ($module == 'Emails' || $module == 'HelpDesk')) { $parent_query = "SELECT firstname,lastname FROM contactdetails WHERE contactid=".$parent_id; $parent_result = $adb->query($parent_query); $parent_name = $adb->query_result($parent_result,0,"firstname") ." " .$adb->query_result($parent_result,0,"lastname"); } $parent_value = $module_icon."".$parent_name.""; return $parent_value; } //parameter added for customview $oCv 27/5 function getListViewEntries($focus, $module,$list_result,$navigation_array,$relatedlist='',$returnset='',$edit_action='EditView',$del_action='Delete',$oCv='') { global $adb; global $app_strings; $noofrows = $adb->num_rows($list_result); $list_header = ''; global $theme; $evt_status; $theme_path="themes/".$theme."/"; $image_path=$theme_path."images/"; //getting the fieldtable entries from database $tabid = getTabid($module); //added for customview 27/5 if($oCv) { if(isset($oCv->list_fields)) { $focus->list_fields = $oCv->list_fields; } } for ($i=$navigation_array['start']; $i<=$navigation_array['end_val']; $i++) { if (($i%2)==0) $list_header .= ''; else $list_header .= ''; //Getting the entityid $entity_id = $adb->query_result($list_result,$i-1,"crmid"); $owner_id = $adb->query_result($list_result,$i-1,"smownerid"); if($relatedlist == '') { $list_header .= ''; $list_header .= ''; } $list_header .= ''; foreach($focus->list_fields as $name=>$tableinfo) { $fieldname = $focus->list_fields_name[$name]; //added for customview 27/5 if($oCv) { if(isset($oCv->list_fields_name)) { $fieldname = $oCv->list_fields_name[$name]; } } global $profile_id; $query = "select profile2field.* from field inner join profile2field on field.fieldid=profile2field.fieldid where profile2field.tabid=".$tabid." and profile2field.profileid=".$profile_id." and field.fieldname='".$fieldname."'"; $result = $adb->query($query); //Getting the Entries from def_org_field table $query1 = "select def_org_field.* from field inner join def_org_field on field.fieldid=def_org_field.fieldid where def_org_field.tabid=".$tabid." and field.fieldname='".$fieldname."'"; $result_def = $adb->query($query1); if($adb->query_result($result,0,"visible") == 0 && $adb->query_result($result_def,0,"visible") == 0) { if($fieldname == '') { $table_name = ''; $column_name = ''; foreach($tableinfo as $tablename=>$colname) { $table_name=$tablename; $column_name = $colname; } $value = $adb->query_result($list_result,$i-1,$colname); } else { if(($module == 'Activities' || $module == 'Tasks' || $module == 'Meetings' || $module == 'Emails' || $module == 'HelpDesk' || $module == 'Invoice') && (($name=='Related to') || ($name=='Contact Name') || ($name=='Close'))) { $status = $adb->query_result($list_result,$i-1,"status"); if($status == '') $status = $adb->query_result($list_result,$i-1,"eventstatus"); if ($name=='Related to') $value=getRelatedTo($module,$list_result,$i-1); if($name=='Contact Name') { $first_name = $adb->query_result($list_result,$i-1,"firstname"); $last_name = $adb->query_result($list_result,$i-1,"lastname"); $contact_id = $adb->query_result($list_result,$i-1,"contactid"); $contact_name = ""; $value=""; if($first_name != 'NULL') $contact_name .= $first_name; if($last_name != 'NULL') $contact_name .= " ".$last_name; if(($contact_name != "") && ($contact_id !='NULL')) $value = "".$contact_name.""; } if ($name == 'Close') { if($status =='Deferred' || $status == 'Completed' || $status == 'Held' || $status == '') { $value=""; } else { $activityid = $adb->query_result($list_result,$i-1,"activityid"); $activitytype = $adb->query_result($list_result,$i-1,"activitytype"); if($activitytype=='Task') $evt_status='&status=Completed'; else $evt_status='&eventstatus=Held'; if(isPermitted("Activities",1,$activityid) == 'yes') { $value = "X"; } else { $value = ""; } } } } elseif($module == "Products" && $name == "Related to") { $value=getRelatedTo($module,$list_result,$i-1); } elseif($module == 'Notes' && $name=='Related to') { $value=getRelatedTo($module,$list_result,$i-1); } elseif($name=='Account Name') { //modified for customview 27/5 if($module == 'Accounts') { $account_id = $adb->query_result($list_result,$i-1,"crmid"); $account_name = getAccountName($account_id); $value = ''.$account_name.''; }else { $account_id = $adb->query_result($list_result,$i-1,"accountid"); $account_name = getAccountName($account_id); $value = ''.$account_name.''; } } elseif(($module == 'PriceBook' || $module == 'Quotes' || $module == 'Orders' || $module == 'Faq') && $name == 'Product Name') { if($module == 'Faq') $product_id = $adb->query_result($list_result,$i-1,"product_id"); else $product_id = $adb->query_result($list_result,$i-1,"productid"); if($product_id != '') $product_name = getProductName($product_id); else $product_name = ''; $value = ''.$product_name.''; } elseif($module == 'Quotes' && $name == 'Potential Name') { $potential_id = $adb->query_result($list_result,$i-1,"potentialid"); $potential_name = getPotentialName($potential_id); $value = ''.$potential_name.''; } elseif($owner_id == 0 && $name == 'Assigned To') { $value = getGroupName($entity_id, $module); } else { $query = "select * from field where tabid=".$tabid." and fieldname='".$fieldname."'"; $field_result = $adb->query($query); $list_result_count = $i-1; $value = getValue($field_result,$list_result,$fieldname,$focus,$module,$entity_id,$list_result_count,"list","",$returnset); } } //Added condition to hide the close symbol in Related Lists // if($relatedlist != '' && $value == "X") if($name == 'Close' && $relatedlist != '') { $list_header .= ''; } else { $list_header .= ''.$value.''; $list_header .=''; } if($fieldname=='filename') { $filename = $adb->query_result($list_result,$list_result_count,$fieldname); } } } if($returnset=='') $returnset = '&return_module='.$module.'&return_action=index'; if($module == 'Activities') { $actvity_type = $adb->query_result($list_result,$list_result_count,'activitytype'); if($actvity_type == 'Task') $returnset .= '&activity_mode=Task'; else $returnset .= '&activity_mode=Events'; } $list_header .= ''; $mod_dir=getModuleDirName($module); if(isPermitted($module,1,$entity_id) == 'yes') { $list_header .=''.$app_strings['LNK_EDIT'].' | '; } if(isPermitted($module,2,$entity_id) == 'yes') { $del_param = 'index.php?action='.$del_action.'&module='.$mod_dir.'&record='.$entity_id.$returnset; $list_header .= ''.$app_strings['LNK_DELETE'].''; } $list_header .= ''; $list_header .= ''; $list_header .= ''; } $list_header .= ''; return $list_header; } function getSearchListViewEntries($focus, $module,$list_result,$navigation_array) { global $adb; $noofrows = $adb->num_rows($list_result); $list_header = ''; global $theme; //$theme = $focus->current_theme; $theme_path="themes/".$theme."/"; $image_path=$theme_path."images/"; //getting the fieldtable entries from database $tabid = getTabid($module); for ($i=$navigation_array['start']; $i<=$navigation_array['end_val']; $i++) { if (($i%2)==0) $list_header .= ''; else $list_header .= ''; //Getting the entityid $entity_id = $adb->query_result($list_result,$i-1,"crmid"); $list_header .= ''; foreach($focus->search_fields as $name=>$tableinfo) { $fieldname = $focus->search_fields_name[$name]; global $profile_id; $query = "select profile2field.* from field inner join profile2field on field.fieldid=profile2field.fieldid where profile2field.tabid=".$tabid." and profile2field.profileid=".$profile_id." and field.fieldname='".$fieldname."'"; $result = $adb->query($query); //Getting the Entries from def_org_field table $query1 = "select def_org_field.* from field inner join def_org_field on field.fieldid=def_org_field.fieldid where def_org_field.tabid=".$tabid." and field.fieldname='".$fieldname."'"; $result_def = $adb->query($query1); if($adb->query_result($result,0,"visible") == 0 && $adb->query_result($result_def,0,"visible") == 0) { if($fieldname == '') { $table_name = ''; $column_name = ''; foreach($tableinfo as $tablename=>$colname) { $table_name=$tablename; $column_name = $colname; } $value = $adb->query_result($list_result,$i-1,$colname); } else { if(($module == 'Calls' || $module == 'Tasks' || $module == 'Meetings' || $module == 'Emails') && (($name=='Related to') || ($name=='Contact Name'))) { if ($name=='Related to') $value=getRelatedTo($module,$list_result,$i-1); if($name=='Contact Name') { $first_name = $adb->query_result($list_result,$i-1,"firstname"); $last_name = $adb->query_result($list_result,$i-1,"lastname"); $contact_id = $adb->query_result($list_result,$i-1,"contactid"); $contact_name = ""; $value=""; if($first_name != 'NULL') $contact_name .= $first_name; if($last_name != 'NULL') $contact_name .= " ".$last_name; if(($contact_name != "") && ($contact_id !='NULL')) $value = "".$contact_name.""; } } elseif(($module == 'Faq' || $module == 'Notes') && $name=='Related to') { $value=getRelatedToEntity($module,$list_result,$i-1); } elseif($name=='Account Name' && ($module == 'Potentials' || $module == 'SalesOrder' || $module == 'Quotes')) { $account_id = $adb->query_result($list_result,$i-1,"accountid"); $account_name = getAccountName($account_id); $value = $account_name; } elseif($name=='Quote Name' && $module == 'SalesOrder') { $quote_id = $adb->query_result($list_result,$i-1,"quoteid"); $quotename = getQuoteName($quote_id); $value = $quotename; } else { $query = "select * from field where tabid=".$tabid." and fieldname='".$fieldname."'"; $field_result = $adb->query($query); $list_result_count = $i-1; $value = getValue($field_result,$list_result,$fieldname,$focus,$module,$entity_id,$list_result_count,"search",$focus->popup_type); } } $list_header .= ''.$value.''; $list_header .=''; } } $list_header .= ''; } $list_header .= ''; return $list_header; } function getValue($field_result, $list_result,$fieldname,$focus,$module,$entity_id,$list_result_count,$mode,$popuptype,$returnset='') { global $adb; $uitype = $adb->query_result($field_result,0,"uitype"); $colname = $adb->query_result($field_result,0,"columnname"); $temp_val = $adb->query_result($list_result,$list_result_count,$colname); if(strlen($temp_val) > 40) { $temp_val = substr($temp_val,0,40).'...'; } if($uitype == 52 || $uitype == 53 || $uitype == 77) { $user_name = getUserName($temp_val); $value = $user_name; } elseif($uitype == 5 || $uitype == 6 || $uitype == 23 || $uitype == 70) { if($temp_val != '' && $temp_val != '0000-00-00') { $value = getDisplayDate($temp_val); } elseif($temp_val == '0000-00-00') { $value = ''; } else { $value = $temp_val; } } elseif($uitype == 71 || $uitype == 72) { if($temp_val != '' && $temp_val != 0) { $symbol = getCurrencySymbol(); $value = $symbol.' '.$temp_val; } else { $value = ''; } } elseif($uitype == 17) { $value = ''.$temp_val.''; } elseif($uitype == 13) { $value = ''.$temp_val.''; } elseif($uitype == 56) { if($temp_val == 1) { $value = 'yes'; } else { $value = ''; } } elseif($uitype == 57) { global $adb; if($temp_val != '') { $sql="select * from contactdetails where contactid=".$temp_val; $result=$adb->query($sql); $firstname=$adb->query_result($result,0,"firstname"); $lastname=$adb->query_result($result,0,"lastname"); $name=$lastname.' '.$firstname; $value= ''.$name.''; } else $value=''; } elseif($uitype == 61) { global $adb; $attachmentid=$adb->query_result($adb->query("select * from seattachmentsrel where crmid = ".$entity_id),0,'attachmentsid'); $value = ''.$temp_val.''; } elseif($uitype == 62) { global $adb; $parentid = $adb->query_result($list_result,$list_result_count,"parent_id"); $parenttype = $adb->query_result($list_result,$list_result_count,"parent_type"); if($parenttype == "Leads") { $tablename = "leaddetails"; $fieldname = "lastname"; $idname="leadid"; } if($parenttype == "Accounts") { $tablename = "account"; $fieldname = "accountname"; $idname="accountid"; } if($parenttype == "Products") { $tablename = "products"; $fieldname = "productname"; $idname="productid"; } if($parenttype == "HelpDesk") { $tablename = "troubletickets"; $fieldname = "title"; $idname="crmid"; } if($parenttype == "Products") { $tablename = "products"; $fieldname = "productname"; $idname="productid"; } if($parenttype == "Invoice") { $tablename = "invoice"; $fieldname = "subject"; $idname="invoiceid"; } if($parentid != '') { $sql="select * from ".$tablename." where ".$idname." = ".$parentid; //echo '
query : .. '.$sql; $fieldvalue=$adb->query_result($adb->query($sql),0,$fieldname); //echo '

val : '.$fieldvalue; $value=''.$fieldvalue.''; } else $value=''; } elseif($uitype == 66) { global $adb; $parentid = $adb->query_result($list_result,$list_result_count,"parent_id"); $parenttype = $adb->query_result($list_result,$list_result_count,"parent_type"); if($parenttype == "Leads") { $tablename = "leaddetails"; $fieldname = "lastname"; $idname="leadid"; } if($parenttype == "Accounts") { $tablename = "account"; $fieldname = "accountname"; $idname="accountid"; } if($parenttype == "HelpDesk") { $tablename = "troubletickets"; $fieldname = "title"; $idname="crmid"; } if($parentid != '') { $sql="select * from ".$tablename." where ".$idname." = ".$parentid; //echo '
query : .. '.$sql; $fieldvalue=$adb->query_result($adb->query($sql),0,$fieldname); //echo '

val : '.$fieldvalue; $value=''.$fieldvalue.''; } else $value=''; } elseif($uitype == 67) { global $adb; $parentid = $adb->query_result($list_result,$list_result_count,"parent_id"); $parenttype = $adb->query_result($list_result,$list_result_count,"parent_type"); if($parenttype == "Leads") { $tablename = "leaddetails"; $fieldname = "lastname"; $idname="leadid"; } if($parenttype == "Contacts") { $tablename = "contactdetails"; $fieldname = "contactname"; $idname="contactid"; } if($parentid != '') { $sql="select * from ".$tablename." where ".$idname." = ".$parentid; //echo '
query : .. '.$sql; $fieldvalue=$adb->query_result($adb->query($sql),0,$fieldname); //echo '

val : '.$fieldvalue; $value=''.$fieldvalue.''; } else $value=''; } elseif($uitype == 68) { global $adb; $parentid = $adb->query_result($list_result,$list_result_count,"parent_id"); $parenttype = $adb->query_result($list_result,$list_result_count,"parent_type"); if($parenttype == '' && $parentid != '') $parenttype = getSalesEntityType($parentid); if($parenttype == "Contacts") { $tablename = "contactdetails"; $fieldname = "contactname"; $idname="contactid"; } if($parenttype == "Accounts") { $tablename = "account"; $fieldname = "accountname"; $idname="accountid"; } if($parentid != '') { $sql="select * from ".$tablename." where ".$idname." = ".$parentid; //echo '
query : .. '.$sql; $fieldvalue=$adb->query_result($adb->query($sql),0,$fieldname); //echo '

val : '.$fieldvalue; $value=''.$fieldvalue.''; } else $value=''; } elseif($uitype == 78) { global $adb; if($temp_val != '') { $quote_name = getQuoteName($temp_val); $value= ''.$quote_name.''; } else $value=''; } elseif($uitype == 79) { global $adb; if($temp_val != '') { $purchaseorder_name = getPoName($temp_val); $value= ''.$purchaseorder_name.''; } else $value=''; } elseif($uitype == 80) { global $adb; if($temp_val != '') { $salesorder_name = getSoName($temp_val); $value= ''.$salesorder_name.''; } else $value=''; } elseif($uitype == 75 || $uitype == 81) { global $adb; if($temp_val != '') { $vendor_name = getVendorName($temp_val); $value= ''.$vendor_name.''; } else $value=''; } else { if($fieldname == $focus->list_link_field) { if($mode == "search") { if($popuptype == "specific") { // Added for get the first name of contact in Popup window if($colname == "lastname" && $module == 'Contacts') { $firstname=$adb->query_result($list_result,$list_result_count,'firstname'); $temp_val =$firstname.' '.$temp_val; } $temp_val = str_replace("'",'\"',$temp_val); $value = ''.$temp_val.''; } elseif($popuptype == "detailview") { if($colname == "lastname" && $module == 'Contacts') $firstname=$adb->query_result($list_result,$list_result_count,'firstname'); $temp_val =$firstname.' '.$temp_val; $focus->record_id = $_REQUEST['recordid']; $value = 'record_id.'"); window.close()\'>'.$temp_val.''; } elseif($popuptype == "formname_specific") { $value = ''.$temp_val.''; } elseif($popuptype == "inventory_prod") { $row_id = $_REQUEST['curr_row']; $unitprice=$adb->query_result($list_result,$list_result_count,'unit_price'); $qty_stock=$adb->query_result($list_result,$list_result_count,'qtyinstock'); $value = ''.$temp_val.''; } elseif($popuptype == "inventory_prod_po") { $row_id = $_REQUEST['curr_row']; $unitprice=$adb->query_result($list_result,$list_result_count,'unit_price'); //$qty_stock=$adb->query_result($list_result,$list_result_count,'qtyinstock'); $value = ''.$temp_val.''; } elseif($popuptype == "inventory_pb") { $prod_id = $_REQUEST['productid']; $flname = $_REQUEST['fldname']; $listprice=getListPrice($prod_id,$entity_id); $value = ''.$temp_val.''; } elseif($popuptype == "specific_account_address") { require_once('modules/Accounts/Account.php'); $acct_focus = new Account(); $acct_focus->retrieve_entity_info($entity_id,"Accounts"); $value = 'column_fields['bill_street'].'", "'.$acct_focus->column_fields['ship_street'].'", "'.$acct_focus->column_fields['bill_city'].'", "'.$acct_focus->column_fields['ship_city'].'", "'.$acct_focus->column_fields['bill_state'].'", "'.$acct_focus->column_fields['ship_state'].'", "'.$acct_focus->column_fields['bill_code'].'", "'.$acct_focus->column_fields['ship_code'].'", "'.$acct_focus->column_fields['bill_country'].'", "'.$acct_focus->column_fields['ship_country'].'"); window.close()\'>'.$temp_val.''; } elseif($popuptype == "specific_vendor_address") { require_once('modules/Products/Vendor.php'); $acct_focus = new Vendor(); $acct_focus->retrieve_entity_info($entity_id,"Vendor"); $value = 'column_fields['treet'].'", "'.$acct_focus->column_fields['city'].'", "'.$acct_focus->column_fields['state'].'", "'.$acct_focus->column_fields['postalcode'].'", "'.$acct_focus->column_fields['country'].'"); window.close()\'>'.$temp_val.''; } else { if($colname == "lastname") $firstname=$adb->query_result($list_result,$list_result_count,'firstname'); $temp_val =$firstname.' '.$temp_val; $temp_val = str_replace("'",'\"',$temp_val); $value = ''.$temp_val.''; } } else { if(($module == "Leads" && $colname == "lastname") || ($module == "Contacts" && $colname == "lastname")) { if($colname == "lastname") $firstname=$adb->query_result($list_result,$list_result_count,'firstname'); $temp_val =$firstname.' '.$temp_val; $value = ''.$temp_val.''; } elseif($module == "Activities") { $actvity_type = $adb->query_result($list_result,$list_result_count,'activitytype'); if($actvity_type == "Task") { $value = ''.$temp_val.''; } else { $value = ''.$temp_val.''; } } elseif($module == "Vendor") { $value = ''.$temp_val.''; } elseif($module == "PriceBook") { $value = ''.$temp_val.''; } elseif($module == "SalesOrder") { $value = ''.$temp_val.''; } else { $value = ''.$temp_val.''; } } } else { $value = $temp_val; } } // $value .= $returnset; return $value; } function getListQuery($module,$where='') { if($module == "HelpDesk") { $query = "select crmentity.crmid,troubletickets.title,troubletickets.status,troubletickets.priority,crmentity.smownerid, contactdetails.contactid, troubletickets.parent_id, contactdetails.firstname, contactdetails.lastname, account.accountid, account.accountname, ticketcf.* from troubletickets inner join ticketcf on ticketcf.ticketid = troubletickets.ticketid inner join crmentity on crmentity.crmid=troubletickets.ticketid left join contactdetails on troubletickets.parent_id=contactdetails.contactid left join account on account.accountid=troubletickets.parent_id left join users on crmentity.smownerid=users.id and troubletickets.ticketid = ticketcf.ticketid where crmentity.deleted=0"; //$query = "select crmentity.crmid,troubletickets.title,troubletickets.status,troubletickets.priority,crmentity.smownerid, contactdetails.firstname, contactdetails.lastname, ticketcf.* from troubletickets inner join crmentity on crmentity.crmid=troubletickets.ticketid inner join ticketcf on ticketcf.ticketid = troubletickets.ticketid left join contactdetails on troubletickets.contact_id=contactdetails.contactid left join users on crmentity.smownerid=users.id where crmentity.deleted=0"; } if($module == "Accounts") { //$query = "select crmentity.crmid, account.accountname,accountbillads.city,account.website,account.phone,crmentity.smownerid, accountscf.* from account, accountbillads, accountshipads, accountscf inner join crmentity on crmentity.crmid=account.accountid and account.accountid=accountbillads.accountaddressid and account.accountid = accountscf.accountid and account.accountid=accountshipads.accountaddressid where crmentity.deleted=0"; $query = "select crmentity.crmid, account.accountname,accountbillads.city,account.website,account.phone,crmentity.smownerid, accountscf.* from account inner join crmentity on crmentity.crmid=account.accountid inner join accountbillads on account.accountid=accountbillads.accountaddressid inner join accountshipads on account.accountid=accountshipads.accountaddressid inner join accountscf on account.accountid = accountscf.accountid where crmentity.deleted=0"; } if ($module == "Potentials") { //$query = "select crmentity.crmid, crmentity.smownerid,account.accountname, potential.*, potentialscf.* from potential , account, potentialscf inner join crmentity on crmentity.crmid=potential.potentialid and potential.accountid = account.accountid and potentialscf.potentialid = potential.potentialid where crmentity.deleted=0 ".$where; $query = "select crmentity.crmid, crmentity.smownerid,account.accountname, potential.accountid,potential.potentialname,potential.sales_stage,potential.amount,potential.currency,potential.closingdate,potential.typeofrevenue, potentialscf.* from potential inner join crmentity on crmentity.crmid=potential.potentialid inner join account on potential.accountid = account.accountid inner join potentialscf on potentialscf.potentialid = potential.potentialid where crmentity.deleted=0 ".$where; } if($module == "Leads") { //$query = "select crmentity.crmid, leaddetails.firstname, leaddetails.lastname, leaddetails.company, leadaddress.phone, leadsubdetails.website, leaddetails.email, crmentity.smownerid, leadscf.* from leaddetails, leadaddress, leadsubdetails, leadscf inner join crmentity on crmentity.crmid=leaddetails.leadid and leaddetails.leadid=leadaddressid and leaddetails.leadid = leadscf.leadid and leadaddress.leadaddressid=leadsubdetails.leadsubscriptionid where crmentity.deleted=0 and leaddetails.converted=0"; $query = "select crmentity.crmid, leaddetails.firstname, leaddetails.lastname, leaddetails.company, leadaddress.phone, leadsubdetails.website, leaddetails.email, crmentity.smownerid, leadscf.* from leaddetails inner join crmentity on crmentity.crmid=leaddetails.leadid inner join leadsubdetails on leadsubdetails.leadsubscriptionid=leaddetails.leadid inner join leadaddress on leadaddress.leadaddressid=leadsubdetails.leadsubscriptionid inner join leadscf on leaddetails.leadid = leadscf.leadid where crmentity.deleted=0 and leaddetails.converted=0"; } if($module == "Products") { $query = "select crmentity.crmid, products.*, productcf.* from products inner join crmentity on crmentity.crmid=products.productid left join productcf on products.productid = productcf.productid left join seproductsrel on seproductsrel.productid = products.productid where crmentity.deleted=0"; } if($module == "Notes") { $query="select crmentity.crmid, notes.title, notes.contact_id, notes.filename, crmentity.modifiedtime,senotesrel.crmid as relatedto, contactdetails.firstname, contactdetails.lastname, notes.* from notes inner join crmentity on crmentity.crmid=notes.notesid left join senotesrel on senotesrel.notesid=notes.notesid left join contactdetails on contactdetails.contactid = notes.contact_id where crmentity.deleted=0"; } if($module == "Calls") { $query = "select crmentity.crmid, crmentity.smownerid, seactivityrel.activityid, calls.* from calls inner join crmentity on crmentity.crmid = calls.callid left join seactivityrel on seactivityrel.activityid = calls.callid where crmentity.deleted=0"; } if($module == "Contacts") { $query = "select crmentity.crmid, crmentity.smownerid, contactdetails.*, contactaddress.*, contactsubdetails.*, contactscf.*, account.accountname from contactdetails, contactaddress, contactsubdetails, contactscf inner join crmentity on crmentity.crmid=contactdetails.contactid and contactdetails.contactid=contactaddress.contactaddressid and contactdetails.contactid = contactscf.contactid and contactaddress.contactaddressid=contactsubdetails.contactsubscriptionid left join account on account.accountid = contactdetails.accountid where crmentity.deleted=0"; //$query = "select crmentity.crmid, crmentity.smownerid, contactdetails.*, contactaddress.*, contactsubdetails.*, contactscf.*, account.accountname from contactdetails, contactaddress, contactsubdetails, contactscf,crmentity,account where crmentity.crmid=contactdetails.contactid and contactdetails.contactid=contactaddress.contactaddressid and contactdetails.contactid = contactscf.contactid and contactaddress.contactaddressid=contactsubdetails.contactsubscriptionid and account.accountid = contactdetails.accountid and crmentity.deleted=0"; } if($module == "Meetings") { $query = "select crmentity.crmid,crmentity.smownerid, meetings.*, activity.subject, activity.activityid, contactdetails.lastname, contactdetails.firstname, contactdetails.contactid from meetings inner join crmentity on crmentity.crmid=meetings.meetingid inner join activity on activity.activityid= crmentity.crmid left join cntactivityrel on cntactivityrel.activityid= activity.activityid left join contactdetails on contactdetails.contactid= cntactivityrel.contactid WHERE crmentity.deleted=0"; } if($module == "Activities") { $query = " select crmentity.crmid,crmentity.smownerid,crmentity.setype, activity.*, contactdetails.lastname, contactdetails.firstname, contactdetails.contactid, account.accountid, account.accountname, recurringevents.recurringtype from activity inner join crmentity on crmentity.crmid=activity.activityid left join cntactivityrel on cntactivityrel.activityid= activity.activityid left join contactdetails on contactdetails.contactid= cntactivityrel.contactid left join seactivityrel on seactivityrel.activityid = activity.activityid left outer join account on account.accountid = contactdetails.accountid left outer join recurringevents on recurringevents.activityid=activity.activityid WHERE crmentity.deleted=0 and (activity.activitytype = 'Meeting' or activity.activitytype='Call' or activity.activitytype='Task') ".$where ; //included by Jaguar } if($module == "Emails") { //$query = "select crmentity.crmid,crmentity.smownerid, emails.emailid, emails.filename, activity.subject, activity.activityid, contactdetails.lastname, contactdetails.firstname, contactdetails.contactid , activity.date_start from emails inner join crmentity on crmentity.crmid=emails.emailid inner join activity on activity.activityid = crmentity.crmid left join cntactivityrel on cntactivityrel.activityid= activity.activityid left join contactdetails on contactdetails.contactid= cntactivityrel.contactid WHERE crmentity.deleted=0"; $query = "select crmentity.crmid,crmentity.smownerid, emails.emailid, emails.filename, activity.subject, activity.activityid, contactdetails.lastname, contactdetails.firstname, contactdetails.contactid , activity.date_start from emails inner join crmentity on crmentity.crmid=emails.emailid inner join activity on activity.activityid = crmentity.crmid left join seactivityrel on seactivityrel.activityid = activity.activityid left join contactdetails on contactdetails.contactid=seactivityrel.crmid left join cntactivityrel on cntactivityrel.activityid= activity.activityid and cntactivityrel.contactid=cntactivityrel.contactid WHERE crmentity.deleted=0"; } if($module == "Faq") { $query = "select crmentity.crmid, faq.*, crmentity.createdtime, crmentity.modifiedtime from faq inner join crmentity on crmentity.crmid=faq.id left join products on faq.product_id=products.productid where crmentity.deleted=0"; } if($module == "Vendor") { $query = "select crmentity.crmid, vendor.* from vendor inner join crmentity on crmentity.crmid=vendor.vendorid where crmentity.deleted=0"; } if($module == "PriceBook") { $query = "select crmentity.crmid, pricebook.* from pricebook inner join crmentity on crmentity.crmid=pricebook.pricebookid where crmentity.deleted=0"; } if($module == "Quotes") { $query = "select crmentity.*, quotes.*, quotesbillads.*, quotesshipads.*,potential.potentialname,account.accountname from quotes inner join crmentity on crmentity.crmid=quotes.quoteid inner join quotesbillads on quotes.quoteid=quotesbillads.quotebilladdressid inner join quotesshipads on quotes.quoteid=quotesshipads.quoteshipaddressid left outer join account on account.accountid=quotes.accountid left outer join potential on potential.potentialid=quotes.potentialid where crmentity.deleted=0".$where; } if($module == "Orders") { $query = "select crmentity.*, purchaseorder.*, pobillads.*, poshipads.*,vendor.vendorname from purchaseorder inner join crmentity on crmentity.crmid=purchaseorder.purchaseorderid left outer join vendor on purchaseorder.vendorid=vendor.vendorid inner join pobillads on purchaseorder.purchaseorderid=pobillads.pobilladdressid inner join poshipads on purchaseorder.purchaseorderid=poshipads.poshipaddressid where crmentity.deleted=0"; } if($module == "SalesOrder") { $query = "select crmentity.*, salesorder.*, sobillads.*, soshipads.*,quotes.subject as quotename, account.accountname from salesorder inner join crmentity on crmentity.crmid=salesorder.salesorderid inner join sobillads on salesorder.salesorderid=sobillads.sobilladdressid inner join soshipads on salesorder.salesorderid=soshipads.soshipaddressid left outer join quotes on quotes.quoteid=salesorder.quoteid left outer join account on account.accountid=salesorder.accountid where crmentity.deleted=0".$where; } if($module == "Invoice") { $query = "select crmentity.*, invoice.*, invoicebillads.*, invoiceshipads.*,salesorder.subject as salessubject from invoice inner join crmentity on crmentity.crmid=invoice.invoiceid inner join invoicebillads on invoice.invoiceid=invoicebillads.invoicebilladdressid inner join invoiceshipads on invoice.invoiceid=invoiceshipads.invoiceshipaddressid left outer join salesorder on salesorder.salesorderid=invoice.salesorderid where crmentity.deleted=0".$where; } //Appending the Security parameters by DON global $others_permission_id; global $current_user; if($others_permission_id == 3 && $module != 'Notes' && $module != 'Products' && $module != 'Faq' && $module!= 'Vendor' && $module != 'PriceBook') { $query .= " and crmentity.smownerid in(".$current_user->id .",0)"; } return $query; } function getActionid($action) { global $vtlog; $vtlog->logthis("get Actionid ".$action,'info'); $actionid = ''; if($action == 'Save') { $actionid= 0; } else if($action == 'EditView') { $actionid= 1; } else if($action == 'Delete') { $actionid= 2; } else if($action == 'index') { $actionid= 3; } else if($action == 'DetailView') { $actionid= 4; } else if($action == 'Import') { $actionid= 5; } else if($action == 'Export') { $actionid= 6; } else if($action == 'BusinessCard') { $actionid= 7; } else if($action == 'Merge') { $actionid= 8; } else if($action == 'VendorEditView') { $actionid= 1; } else if($action == 'VendorDetailView') { $actionid= 4; } else if($action == 'SaveVendor') { $actionid= 0; } else if($action == 'DeleteVendor') { $actionid= 1; } else if($action == 'PriceBookEditView') { $actionid= 1; } else if($action == 'PriceBookDetailView') { $actionid= 4; } else if($action == 'SavePriceBook') { $actionid= 0; } else if($action == 'DeletePriceBook') { $actionid= 1; } else if($action == 'SalesOrderEditView') { $actionid= 1; } else if($action == 'SalesOrderDetailView') { $actionid= 4; } else if($action == 'SaveSalesOrder') { $actionid= 0; } else if($action == 'DeleteSalesOrder') { $actionid= 1; } $vtlog->logthis("action id selected is ".$actionid ,'info'); return $actionid; } function getActionname($actionid) { global $vtlog; $vtlog->logthis("getActionName ".$actionid ,'info'); $actionname = ''; if($actionid == 0) { $actionname= 'Save'; } else if($actionid == 1) { $actionname= 'EditView'; } else if($actionid == 2) { $actionname= 'Delete'; } else if($actionid == 3) { $actionname= 'index'; } else if($actionid == 4) { $actionname= 'DetailView'; } else if($actionid == 5) { $actionname= 'Import'; } else if($actionid == 6) { $actionname= 'Export'; } else if($actionid == 7) { $actionname= 'BusinessCard'; } else if($actionid == 8) { $actionname= 'Merge'; } return $actionname; } function getUserId($record) { global $vtlog; $vtlog->logthis("in getUserId ".$record,'info'); global $adb; $user_id=$adb->query_result($adb->query("select * from crmentity where crmid = ".$record),0,'smownerid'); return $user_id; } function insertProfile2field($profileid) { global $vtlog; $vtlog->logthis("in insertProfile2field ".$profileid,'info'); global $adb; $adb->database->SetFetchMode(ADODB_FETCH_ASSOC); $fld_result = $adb->query("select * from field where generatedtype=1 and displaytype in (1,2)"); $num_rows = $adb->num_rows($fld_result); for($i=0; $i<$num_rows; $i++) { $tab_id = $adb->query_result($fld_result,$i,'tabid'); $field_id = $adb->query_result($fld_result,$i,'fieldid'); $adb->query("insert into profile2field values (".$profileid.",".$tab_id.",".$field_id.",0,1)"); } } function insert_def_org_field() { global $adb; $adb->database->SetFetchMode(ADODB_FETCH_ASSOC); $fld_result = $adb->query("select * from field where generatedtype=1 and displaytype in (1,2)"); $num_rows = $adb->num_rows($fld_result); for($i=0; $i<$num_rows; $i++) { $tab_id = $adb->query_result($fld_result,$i,'tabid'); $field_id = $adb->query_result($fld_result,$i,'fieldid'); $adb->query("insert into def_org_field values (".$tab_id.",".$field_id.",0,1)"); } } function getProfile2FieldList($fld_module, $profileid) { global $vtlog; $vtlog->logthis("in getProfile2FieldList ".$fld_module. ' profile id is '.$profileid,'info'); global $adb; $tabid = getTabid($fld_module); $query = "select profile2field.visible,field.* from profile2field inner join field on field.fieldid=profile2field.fieldid where profile2field.profileid=".$profileid." and profile2field.tabid=".$tabid; $result = $adb->query($query); return $result; } function getDefOrgFieldList($fld_module) { global $vtlog; $vtlog->logthis("in getDefOrgFieldList ".$fld_module,'info'); global $adb; $tabid = getTabid($fld_module); $query = "select def_org_field.visible,field.* from def_org_field inner join field on field.fieldid=def_org_field.fieldid where def_org_field.tabid=".$tabid; $result = $adb->query($query); return $result; } function getQuickCreate($tabid,$actionid) { $QuickCreateForm= 'true'; $profile_id = $_SESSION['authenticated_user_profileid']; $tab_per_Data = getAllTabsPermission($profile_id); $permissionData = $_SESSION['action_permission_set']; if($tab_per_Data[$tabid] !=0) { $QuickCreateForm= 'false'; } if($permissionData[$tabid][1] !=0) { $QuickCreateForm= 'false'; } return $QuickCreateForm; } function ChangeStatus($status,$activityid,$activity_mode='') { global $vtlog; $vtlog->logthis("in ChangeStatus ".$status. ' activityid is '.$activityid,'info'); global $adb; if ($activity_mode == 'Task') { $query = "Update activity set status='".$status."' where activityid = ".$activityid; } elseif ($activity_mode == 'Events') { $query = "Update activity set eventstatus='".$status."' where activityid = ".$activityid; } $adb->query($query); } //parameter $viewid added for customview 27/5 function AlphabeticalSearch($module,$action,$fieldname,$query,$type,$popuptype='',$recordid='',$return_module='',$append_url='',$viewid='') { if($type=='advanced') $flag='&advanced=true'; if($popuptype != '') $popuptypevalue = "&popuptype=".$popuptype; if($recordid != '') $returnvalue = '&recordid='.$recordid; if($return_module != '') $returnvalue .= '&return_module='.$return_module; for($var='A',$i =1;$i<=26;$i++,$var++) $list .= ''.$var.''; return $list; } function getDisplayDate($cur_date_val) { global $current_user; $dat_fmt = $current_user->date_format; if($dat_fmt == '') { $dat_fmt = 'dd-mm-yyyy'; } //echo $dat_fmt; //echo '
'.$cur_date_val.'
'; $date_value = explode(' ',$cur_date_val); list($y,$m,$d) = split('-',$date_value[0]); //echo $y.'----'.$m.'------'.$d; if($dat_fmt == 'dd-mm-yyyy') { //echo '
inside 1'; $display_date = $d.'-'.$m.'-'.$y; } elseif($dat_fmt == 'mm-dd-yyyy') { //echo '
inside 2'; $display_date = $m.'-'.$d.'-'.$y; } elseif($dat_fmt == 'yyyy-mm-dd') { //echo '
inside 3'; $display_date = $y.'-'.$m.'-'.$d; } if($date_value[1] != '') { $display_date = $display_date.' '.$date_value[1]; } return $display_date; } function getNewDisplayDate() { global $vtlog; $vtlog->logthis("in getNewDisplayDate ",'info'); global $current_user; $dat_fmt = $current_user->date_format; if($dat_fmt == '') { $dat_fmt = 'dd-mm-yyyy'; } //echo $dat_fmt; //echo '
'; $display_date=''; if($dat_fmt == 'dd-mm-yyyy') { $display_date = date('d-m-Y'); } elseif($dat_fmt == 'mm-dd-yyyy') { $display_date = date('m-d-Y'); } elseif($dat_fmt == 'yyyy-mm-dd') { $display_date = date('Y-m-d'); } //echo $display_date; return $display_date; } function getDBInsertDateValue($value) { global $current_user; $dat_fmt = $current_user->date_format; if($dat_fmt == '') { $dat_fmt = 'dd-mm-yyyy'; } //echo $dat_fmt; //echo '
'; $insert_date=''; if($dat_fmt == 'dd-mm-yyyy') { list($d,$m,$y) = split('-',$value); } elseif($dat_fmt == 'mm-dd-yyyy') { list($m,$d,$y) = split('-',$value); } elseif($dat_fmt == 'yyyy-mm-dd') { list($y,$m,$d) = split('-',$value); } //echo $display_date; $insert_date=$y.'-'.$m.'-'.$d; return $insert_date; } function getDisplayCurrency() { global $adb; $sql1 = "select * from currency_info"; $result = $adb->query($sql1); $curr_name = $adb->query_result($result,0,"currency_name"); $curr_symbol = $adb->query_result($result,0,"currency_symbol"); $disp_curr = $curr_name.' : '.$curr_symbol; return $disp_curr; } function getCurrencySymbol() { global $adb; $sql1 = "select * from currency_info"; $result = $adb->query($sql1); $curr_symbol = $adb->query_result($result,0,"currency_symbol"); return $curr_symbol; } function getRelatedLists($module,$focus) { global $adb; global $profile_id; $mod_dir_name=getModuleDirName($module); $tab_per_Data = getAllTabsPermission($profile_id); $permissionData = $_SESSION['action_permission_set']; $inc_file = 'modules/'.$mod_dir_name.'/RenderRelatedListUI.php'; include($inc_file); $cur_tab_id = getTabid($module); $sql1 = "select * from relatedlists where tabid=".$cur_tab_id; $result = $adb->query($sql1); $num_row = $adb->num_rows($result); for($i=0; $i<$num_row; $i++) { $rel_tab_id = $adb->query_result($result,$i,"related_tabid"); $funtion_name = $adb->query_result($result,$i,"name"); if($rel_tab_id != 0) { if($tab_per_Data[$rel_tab_id] == 0) { if($permissionData[$rel_tab_id][3] == 0) { $focus_list = & $focus->$funtion_name($focus->id); } } } else { $focus_list = & $focus->$funtion_name($focus->id); } } } function getModuleDirName($module) { if($module == 'Vendor' || $module == 'PriceBook') { $dir_name = 'Products'; } elseif($module == 'SalesOrder') { $dir_name = 'Orders'; } else { $dir_name = $module; } return $dir_name; } function getReminderSelectOption($start,$end,$fldname,$selvalue='') { global $mod_strings; global $app_strings; $def_sel =""; $OPTION_FLD = ""; return $OPTION_FLD; } function getAssociatedProducts($module,$focus,$seid='') { global $adb; $output = ''; global $theme; $theme_path="themes/".$theme."/"; $image_path=$theme_path."images/"; if($module == 'Quotes') { $query="select products.productname,products.unit_price,products.qtyinstock,quotesproductrel.* from quotesproductrel inner join products on products.productid=quotesproductrel.productid where quoteid=".$focus->id; } elseif($module == 'Orders') { $query="select products.productname,products.unit_price,products.qtyinstock,poproductrel.* from poproductrel inner join products on products.productid=poproductrel.productid where purchaseorderid=".$focus->id; } elseif($module == 'SalesOrder') { $query="select products.productname,products.unit_price,products.qtyinstock,soproductrel.* from soproductrel inner join products on products.productid=soproductrel.productid where salesorderid=".$focus->id; } elseif($module == 'Invoice') { $query="select products.productname,products.unit_price,products.qtyinstock,invoiceproductrel.* from invoiceproductrel inner join products on products.productid=invoiceproductrel.productid where invoiceid=".$focus->id; } elseif($module == 'Potentials') { $query="select products.productname,products.unit_price,products.qtyinstock,seproductsrel.* from products inner join seproductsrel on seproductsrel.productid=products.productid where crmid=".$seid; } elseif($module == 'Products') { $query="select products.productid,products.productname,products.unit_price,products.qtyinstock,crmentity.* from products inner join crmentity on crmentity.crmid=products.productid where crmentity.deleted=0 and productid=".$seid; } $result = $adb->query($query); $num_rows=$adb->num_rows($result); for($i=1;$i<=$num_rows;$i++) { $productname=$adb->query_result($result,$i-1,'productname'); $unitprice=$adb->query_result($result,$i-1,'unit_price'); $qtyinstock=$adb->query_result($result,$i-1,'qtyinstock'); $productid=$adb->query_result($result,$i-1,'productid'); $qty=$adb->query_result($result,$i-1,'quantity'); $listprice=$adb->query_result($result,$i-1,'listprice'); if($listprice == '') $listprice = $unitprice; if($qty =='') $qty = 1; $total = $qty*$listprice; $product_id_var = 'hdnProductId'.$i; $status_var = 'hdnRowStatus'.$i; $qty_var = 'txtQty'.$i; $list_price_var = 'txtListPrice'.$i; $total_var = 'total'.$i; if($num_rows%2 == 0) { $row_class = "evenListRow"; } else { $row_class = "oddListRow"; } $output .= ''; $output .= ' '; $output .= ''; if($module != 'Orders' && $focus->object_name != 'Order') { $output .= '
'.$qtyinstock.'
 '; $output .= ''; } $output .= ''; $output .=''; $output .= '
'.$unitprice.'
 '; $output .= ''; $output .= ' '; $output .= ''; $output .= '
'.$total.'
'; $output .= ''; if($i != 1) { $output .= 'Del'; } else { $output .= ''; } $output .= ''; $output .= ''; $output .= ''; $output .= ''; } return $output; } function getNoOfAssocProducts($module,$focus,$seid='') { global $adb; $output = ''; if($module == 'Quotes') { $query="select products.productname,products.unit_price,quotesproductrel.* from quotesproductrel inner join products on products.productid=quotesproductrel.productid where quoteid=".$focus->id; } elseif($module == 'Orders') { $query="select products.productname,products.unit_price,poproductrel.* from poproductrel inner join products on products.productid=poproductrel.productid where purchaseorderid=".$focus->id; } elseif($module == 'SalesOrder') { $query="select products.productname,products.unit_price,soproductrel.* from soproductrel inner join products on products.productid=soproductrel.productid where salesorderid=".$focus->id; } elseif($module == 'Invoice') { $query="select products.productname,products.unit_price,invoiceproductrel.* from invoiceproductrel inner join products on products.productid=invoiceproductrel.productid where invoiceid=".$focus->id; } elseif($module == 'Potentials') { $query="select products.productname,products.unit_price,seproductsrel.* from products inner join seproductsrel on seproductsrel.productid=products.productid where crmid=".$seid; } elseif($module == 'Products') { $query="select products.productname,products.unit_price, crmentity.* from products inner join crmentity on crmentity.crmid=products.productid where crmentity.deleted=0 and productid=".$seid; } $result = $adb->query($query); $num_rows=$adb->num_rows($result); return $num_rows; } function getListPrice($productid,$pbid) { global $vtlog; $vtlog->logthis("in getListPrice productid ".$productid,'info'); global $adb; $query = "select listprice from pricebookproductrel where pricebookid=".$pbid." and productid=".$productid; $result = $adb->query($query); $lp = $adb->query_result($result,0,'listprice'); return $lp; } function getDetailAssociatedProducts($module,$focus) { global $adb; global $theme; global $vtlog; $theme_path="themes/".$theme."/"; $image_path=$theme_path."images/"; $vtlog->logthis("in getDetailAssociatedProducts. Module is ".$module,'debug'); $output = ''; $output .= '
Product Details
'; $output .= ''; $output .= ''; $output .= ''; $output .= ''; if($module != 'Orders') { $output .= ''; $output .= ''; } $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; //$output .='
ProductQty In StockQtyUnit PriceList Price
Total
'; //$output .= ''; if($module == 'Quotes') { $query="select products.productname,products.unit_price,products.qtyinstock,quotesproductrel.* from quotesproductrel inner join products on products.productid=quotesproductrel.productid where quoteid=".$focus->id; } elseif($module == 'Orders') { $query="select products.productname,products.unit_price,products.qtyinstock,poproductrel.* from poproductrel inner join products on products.productid=poproductrel.productid where purchaseorderid=".$focus->id; } elseif($module == 'SalesOrder') { $query="select products.productname,products.unit_price,products.qtyinstock,soproductrel.* from soproductrel inner join products on products.productid=soproductrel.productid where salesorderid=".$focus->id; } elseif($module == 'Invoice') { $query="select products.productname,products.unit_price,products.qtyinstock,invoiceproductrel.* from invoiceproductrel inner join products on products.productid=invoiceproductrel.productid where invoiceid=".$focus->id; } $result = $adb->query($query); $num_rows=$adb->num_rows($result); for($i=1;$i<=$num_rows;$i++) { $productname=$adb->query_result($result,$i-1,'productname'); $unitprice=$adb->query_result($result,$i-1,'unit_price'); $productid=$adb->query_result($result,$i-1,'productid'); $qtyinstock=$adb->query_result($result,$i-1,'qtyinstock'); $qty=$adb->query_result($result,$i-1,'quantity'); $listprice=$adb->query_result($result,$i-1,'listprice'); $total = $qty*$listprice; if($i%2 == 0) { $row_class = "evenListRow"; } else { $row_class = "oddListRow"; } $output .= ''; $output .= ''; $output .= ''; if($module != 'Orders') { $output .= ''; $output .= ''; } $output .= ''; $output .=''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; /* if (($i%2)==0) $output .= ''; else $output .= ''; $output .= ''; */ } $output .= '
ProductQuantityUnit PriceList PriceTotal
'.$productname.''.$qtyinstock.''.$qty.''.$unitprice.''.$listprice.'
'.$total.'
'.$productname.''.$qty.''.$unitprice.''.$listprice.''.$total.'
'; $output .= '
'; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= '
Sub Total:
 '.$focus->column_fields['hdnSubTotal'].'
 
Tax:
 '.$focus->column_fields['txtTax'].'
 
Adjustment:
 '.$focus->column_fields['txtAdjustment'].'
 
Grand Total:
 '.$focus->column_fields['hdnGrandTotal'].'
'; /* $output .= 'Sub Total:'.$focus->column_fields['hdnSubTotal'].''; $output .= 'Tax:'.$focus->column_fields['txtTax'].''; $output .= 'Adjustment:'.$focus->column_fields['txtAdjustment'].''; $output .= 'Total:'.$focus->column_fields['hdnGrandTotal'].''; //$output .= ''; */ return $output; } function getConvertQuoteToSoObject($focus,$quote_focus,$quoteid) { global $vtlog; $vtlog->logthis("in getConvertQuoteToSoObject ".$quoteid,'info'); $focus->column_fields['quote_id'] = $quoteid; $focus->column_fields['subject'] = $quote_focus->column_fields['subject']; $focus->column_fields['contact_id'] = $quote_focus->column_fields['contact_id']; $focus->column_fields['potential_id'] = $quote_focus->column_fields['potential_id']; $focus->column_fields['account_id'] = $quote_focus->column_fields['account_id']; $focus->column_fields['carrier'] = $quote_focus->column_fields['carrier']; $focus->column_fields['bill_street'] = $quote_focus->column_fields['bill_street']; $focus->column_fields['ship_street'] = $quote_focus->column_fields['ship_street']; $focus->column_fields['bill_city'] = $quote_focus->column_fields['bill_city']; $focus->column_fields['ship_city'] = $quote_focus->column_fields['ship_city']; $focus->column_fields['bill_state'] = $quote_focus->column_fields['bill_state']; $focus->column_fields['ship_state'] = $quote_focus->column_fields['ship_state']; $focus->column_fields['bill_code'] = $quote_focus->column_fields['bill_code']; $focus->column_fields['ship_code'] = $quote_focus->column_fields['ship_code']; $focus->column_fields['bill_country'] = $quote_focus->column_fields['bill_country']; $focus->column_fields['ship_country'] = $quote_focus->column_fields['ship_country']; $focus->column_fields['description'] = $quote_focus->column_fields['description']; $focus->column_fields['terms_conditions'] = $quote_focus->column_fields['terms_conditions']; return $focus; } function getConvertQuoteToInvoice($focus,$quote_focus,$quoteid) { global $vtlog; $vtlog->logthis("in getConvertQuoteToInvoice ".$quoteid,'info'); $focus->column_fields['subject'] = $quote_focus->column_fields['subject']; $focus->column_fields['account_id'] = $quote_focus->column_fields['account_id']; $focus->column_fields['bill_street'] = $quote_focus->column_fields['bill_street']; $focus->column_fields['ship_street'] = $quote_focus->column_fields['ship_street']; $focus->column_fields['bill_city'] = $quote_focus->column_fields['bill_city']; $focus->column_fields['ship_city'] = $quote_focus->column_fields['ship_city']; $focus->column_fields['bill_state'] = $quote_focus->column_fields['bill_state']; $focus->column_fields['ship_state'] = $quote_focus->column_fields['ship_state']; $focus->column_fields['bill_code'] = $quote_focus->column_fields['bill_code']; $focus->column_fields['ship_code'] = $quote_focus->column_fields['ship_code']; $focus->column_fields['bill_country'] = $quote_focus->column_fields['bill_country']; $focus->column_fields['ship_country'] = $quote_focus->column_fields['ship_country']; $focus->column_fields['description'] = $quote_focus->column_fields['description']; $focus->column_fields['terms_conditions'] = $quote_focus->column_fields['terms_conditions']; return $focus; } function getConvertSoToInvoice($focus,$so_focus,$soid) { global $vtlog; $vtlog->logthis("in getConvertSoToInvoice ".$soid,'info'); $focus->column_fields['salesorder_id'] = $soid; $focus->column_fields['subject'] = $so_focus->column_fields['subject']; $focus->column_fields['customerno'] = $so_focus->column_fields['customerno']; $focus->column_fields['duedate'] = $so_focus->column_fields['duedate']; $focus->column_fields['account_id'] = $so_focus->column_fields['account_id']; $focus->column_fields['exciseduty'] = $so_focus->column_fields['exciseduty']; $focus->column_fields['salescommission'] = $so_focus->column_fields['salescommission']; $focus->column_fields['purchaseorder'] = $so_focus->column_fields['purchaseorder']; $focus->column_fields['bill_street'] = $so_focus->column_fields['bill_street']; $focus->column_fields['ship_street'] = $so_focus->column_fields['ship_street']; $focus->column_fields['bill_city'] = $so_focus->column_fields['bill_city']; $focus->column_fields['ship_city'] = $so_focus->column_fields['ship_city']; $focus->column_fields['bill_state'] = $so_focus->column_fields['bill_state']; $focus->column_fields['ship_state'] = $so_focus->column_fields['ship_state']; $focus->column_fields['bill_code'] = $so_focus->column_fields['bill_code']; $focus->column_fields['ship_code'] = $so_focus->column_fields['ship_code']; $focus->column_fields['bill_country'] = $so_focus->column_fields['bill_country']; $focus->column_fields['ship_country'] = $so_focus->column_fields['ship_country']; $focus->column_fields['description'] = $so_focus->column_fields['description']; $focus->column_fields['terms_conditions'] = $so_focus->column_fields['terms_conditions']; return $focus; } function upload_product_image_file($mode,$id) { global $root_directory; global $vtlog; $vtlog->logthis("Inside upload_product_image_file. The id is ".$id,'debug'); $uploaddir = $root_directory ."/test/product/"; $file_path_name = $_FILES['imagename']['name']; $file_name = basename($file_path_name); $file_name = $id.'_'.$file_name; $filetype= $_FILES['imagename']['type']; $filesize = $_FILES['imagename']['size']; $ret_array = Array(); if($filesize > 0) { if(move_uploaded_file($_FILES["imagename"]["tmp_name"],$uploaddir.$file_name)) { $upload_status = "yes"; $ret_array["status"] = $upload_status; $ret_array["file_name"] = $file_name; } else { $errorCode = $_FILES['imagename']['error']; $upload_status = "no"; $ret_array["status"] = $upload_status; $ret_array["errorcode"] = $errorCode; } } else { $upload_status = "no"; $ret_array["status"] = $upload_status; } return $ret_array; } function getProductImageName($id) { global $adb; global $vtlog; $query = "select imagename from products where productid=".$id; $result = $adb->query($query); $image_name = $adb->query_result($result,0,"imagename"); $vtlog->logthis("Inside getProductImageName. The image_name is ".$image_name,'debug'); return $image_name; } function updateSubTotal($module,$tablename,$colname,$colname1,$entid_fld,$entid,$prod_total) { global $adb; //getting the subtotal $query = "select ".$colname.",".$colname1." from ".$tablename." where ".$entid_fld."=".$entid; $result1 = $adb->query($query); $subtot = $adb->query_result($result1,0,$colname); $subtot_upd = $subtot - $prod_total; $gdtot = $adb->query_result($result1,0,$colname1); $gdtot_upd = $gdtot - $prod_total; //updating the subtotal $sub_query = "update ".$tablename." set ".$colname."=".$subtot_upd.",".$colname1."=".$gdtot_upd." where ".$entid_fld."=".$entid; $adb->query($sub_query); } function getInventoryTotal($return_module,$id) { global $adb; if($return_module == "Potentials") { $query ="select products.productname,products.unit_price,products.qtyinstock,seproductsrel.* from products inner join seproductsrel on seproductsrel.productid=products.productid where crmid=".$id; } elseif($return_module == "Products") { $query="select products.productid,products.productname,products.unit_price,products.qtyinstock,crmentity.* from products inner join crmentity on crmentity.crmid=products.productid where crmentity.deleted=0 and productid=".$id; } $result = $adb->query($query); $num_rows=$adb->num_rows($result); $total=0; for($i=1;$i<=$num_rows;$i++) { $unitprice=$adb->query_result($result,$i-1,'unit_price'); $qty=$adb->query_result($result,$i-1,'quantity'); $listprice=$adb->query_result($result,$i-1,'listprice'); if($listprice == '') $listprice = $unitprice; if($qty =='') $qty = 1; $total = $total+($qty*$listprice); } return $total; } ?>