예제 #1
0
 /** Constructor which will set the importable_fields as $this->importable_fields[$key]=1 in this object where key is the fieldname in the field table
  */
 function ImportLead()
 {
     parent::Leads();
     $this->log = LoggerManager::getLogger('import_lead');
     $this->db = PearDatabase::getInstance();
     $this->db->println("IMP ImportLead");
     $this->initImportableFields("Leads");
     $this->db->println($this->importable_fields);
 }
예제 #2
0
파일: Leads.php 프로젝트: samxsam/conduct
 public static function assign_agent($first_name, $last_name, $email, $mobile, $message)
 {
     $error_message = array();
     global $database;
     $valid = true;
     if (empty($first_name) || empty($last_name) || empty($email) || empty($mobile) || empty($message)) {
         $error_message[] = "All field are required";
         $valid = false;
     }
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         //validate email
         $error_message[] = "Invalid email format";
         $valid = false;
     }
     if ($valid) {
         // if all fields are filled and email is valid
         $agent_id = self::available_agent();
         if (is_null($agent_id)) {
             $error_message[] = "No agent are currently available, please try again later";
         } else {
             $lead = new Leads();
             $lead->agent_id = $agent_id;
             $lead->first_name = $database->escape_value($first_name);
             $lead->last_name = $database->escape_value($last_name);
             $lead->email = $database->escape_value($email);
             $lead->mobile = $database->escape_value($mobile);
             $lead->message = $database->escape_value($message);
             $lead->created = strftime("%Y-%m-%d %H:%M:%S", time());
             $lead->modified = strftime("%Y-%m-%d %H:%M:%S", time());
             if ($lead->save()) {
                 //saved email both lead and agent
                 if (self::send_email($lead)) {
                     //nothing happen
                 } else {
                     $error_message[] = "Notification emails are failed to send out.  Please contact us ";
                 }
             } else {
                 $error_message[] = "There was an error that prevented the lead from being saved.";
             }
         }
     }
     return $error_message;
 }
예제 #3
0
function SearchContactsByEmail($username, $session, $emailaddress)
{
    if (!validateSession($username, $session)) {
        return null;
    }
    require_once 'modules/Contacts/Contacts.php';
    require_once 'modules/Leads/Leads.php';
    require_once 'modules/Accounts/Accounts.php';
    $seed_contact = new Contacts();
    $output_list = array();
    //To avoid Blind SQL injection we are validating the Email address.
    if (filter_var($emailaddress, FILTER_VALIDATE_EMAIL) == false) {
        return null;
    }
    $response = $seed_contact->get_searchbyemailid($username, $emailaddress);
    $contactList = $response['list'];
    // create a return array of names and email addresses.
    foreach ($contactList as $contact) {
        $output_list[] = array("id" => $contact[contactid], "firstname" => decode_html($contact[firstname]), "lastname" => decode_html($contact[lastname]), "accountname" => decode_html($contact[accountname]), "emailaddress" => decode_html($contact[email]), "category" => "Contact");
    }
    // crm-now added Lead functionality
    $seed_lead = new Leads();
    $response2 = $seed_lead->get_searchbyemailid($username, $emailaddress);
    $leadList = $response2['list'];
    foreach ($leadList as $lead) {
        $output_list[] = array("id" => $lead[leadid], "firstname" => decode_html($lead[firstname]), "lastname" => decode_html($lead[lastname]), "accountname" => decode_html($lead[company]), "emailaddress" => decode_html($lead[email]), "category" => "Lead");
    }
    // crm-now added Accounts functionality
    $acc_lead = new Accounts();
    $response3 = $acc_lead->get_searchbyemailid($username, $emailaddress);
    $accList = $response3['list'];
    foreach ($accList as $acc) {
        $output_list[] = array("id" => $acc['accountid'], "firstname" => decode_html($acc['account_no']), "lastname" => decode_html($acc['accountname']), "accountname" => '', "emailaddress" => decode_html($acc['email1']), "category" => "Account");
    }
    // end crm-now
    //to remove an erroneous compiler warning
    $seed_contact = $seed_contact;
    $seed_lead = $seed_lead;
    $acc_lead = $acc_lead;
    return $output_list;
}
예제 #4
0
/** This function returns the vtiger_field details for a given vtiger_fieldname.
 * Param $uitype - UI type of the vtiger_field
 * Param $fieldname - Form vtiger_field name
 * Param $fieldlabel - Form vtiger_field label name
 * Param $maxlength - maximum length of the vtiger_field
 * Param $col_fields - array contains the vtiger_fieldname and values
 * Param $generatedtype - Field generated type (default is 1)
 * Param $module_name - module name
 * Return type is an array
 */
function getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields, $generatedtype, $module_name, $mode = '', $typeofdata = null)
{
    global $log, $app_strings, $adb, $default_charset, $theme, $mod_strings, $current_user;
    $log->debug("Entering getOutputHtml(" . $uitype . "," . $fieldname . "," . $fieldlabel . "," . $maxlength . "," . print_r($col_fields, true) . "," . $generatedtype . "," . $module_name . ") method ...");
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    $fieldlabel = from_html($fieldlabel);
    $fieldvalue = array();
    $final_arr = array();
    $value = $col_fields[$fieldname];
    $custfld = '';
    $ui_type[] = $uitype;
    $editview_fldname[] = $fieldname;
    // vtlib customization: Related type field
    if ($uitype == '10') {
        global $adb;
        $fldmod_result = $adb->pquery('SELECT relmodule, status FROM vtiger_fieldmodulerel WHERE fieldid=
			(SELECT fieldid FROM vtiger_field, vtiger_tab WHERE vtiger_field.tabid=vtiger_tab.tabid AND fieldname=? AND name=? and vtiger_field.presence in (0,2)) order by sequence', array($fieldname, $module_name));
        $entityTypes = array();
        $parent_id = $value;
        for ($index = 0; $index < $adb->num_rows($fldmod_result); ++$index) {
            $entityTypes[] = $adb->query_result($fldmod_result, $index, 'relmodule');
        }
        if (!empty($value)) {
            if ($adb->num_rows($fldmod_result) == 1) {
                $valueType = $adb->query_result($fldmod_result, 0, 0);
            } else {
                $valueType = getSalesEntityType($value);
            }
            $displayValueArray = getEntityName($valueType, $value);
            if (!empty($displayValueArray)) {
                foreach ($displayValueArray as $key => $value) {
                    $displayValue = $value;
                }
            }
        } else {
            $displayValue = '';
            $valueType = '';
            $value = '';
        }
        $editview_label[] = array('options' => $entityTypes, 'selected' => $valueType, 'displaylabel' => getTranslatedString($fieldlabel, $module_name));
        $fieldvalue[] = array('displayvalue' => $displayValue, 'entityid' => $parent_id);
    } else {
        if ($uitype == 5 || $uitype == 6 || $uitype == 23) {
            $log->info("uitype is " . $uitype);
            if ($value == '') {
                //modified to fix the issue in trac(http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/1469)
                if ($fieldname != 'birthday' && $generatedtype != 2 && getTabid($module_name) != 14) {
                    $disp_value = getNewDisplayDate();
                }
                if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 6) {
                    $curr_time = date('H:i', strtotime('+5 minutes'));
                }
                if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 23) {
                    $curr_time = date('H:i', strtotime('+10 minutes'));
                }
                //Added to display the Contact - Support End Date as one year future instead of
                //today's date -- 30-11-2005
                if ($fieldname == 'support_end_date' && $_REQUEST['module'] == 'Contacts') {
                    $addyear = strtotime("+1 year");
                    $disp_value = DateTimeField::convertToUserFormat(date('Y-m-d', $addyear));
                } elseif ($fieldname == 'validtill' && $_REQUEST['module'] == 'Quotes') {
                    $disp_value = '';
                }
            } else {
                if ($uitype == 6) {
                    if ($col_fields['time_start'] != '' && ($module_name == 'Events' || $module_name == 'Calendar')) {
                        $curr_time = $col_fields['time_start'];
                        $value = $value . ' ' . $curr_time;
                    } else {
                        $curr_time = date('H:i', strtotime('+5 minutes'));
                    }
                }
                if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 23) {
                    if ($col_fields['time_end'] != '') {
                        $curr_time = $col_fields['time_end'];
                        $value = $value . ' ' . $curr_time;
                    } else {
                        $curr_time = date('H:i', strtotime('+10 minutes'));
                    }
                }
                $disp_value = getValidDisplayDate($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']);
            if (!empty($curr_time)) {
                if (($module_name == 'Events' || $module_name == 'Calendar') && ($uitype == 23 || $uitype == 6)) {
                    $curr_time = DateTimeField::convertToUserTimeZone($curr_time);
                    $curr_time = $curr_time->format('H:i');
                }
            } else {
                $curr_time = '';
            }
            if (empty($disp_value)) {
                $disp_value = '';
            }
            $fieldvalue[] = array($disp_value => $curr_time);
            if ($uitype == 5 || $uitype == 23) {
                if ($module_name == 'Events' && $uitype == 23) {
                    $fieldvalue[] = array($date_format => $current_user->date_format . ' ' . $app_strings['YEAR_MONTH_DATE']);
                } else {
                    $fieldvalue[] = array($date_format => $current_user->date_format);
                }
            } else {
                $fieldvalue[] = array($date_format => $current_user->date_format . ' ' . $app_strings['YEAR_MONTH_DATE']);
            }
        } elseif ($uitype == 16) {
            require_once 'modules/PickList/PickListUtils.php';
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldname = $adb->sql_escape_string($fieldname);
            $pick_query = "select {$fieldname} from vtiger_{$fieldname} order by sortorderid";
            $params = array();
            $pickListResult = $adb->pquery($pick_query, $params);
            $noofpickrows = $adb->num_rows($pickListResult);
            $options = array();
            $pickcount = 0;
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $value = decode_html($value);
                $pickListValue = decode_html($adb->query_result($pickListResult, $j, strtolower($fieldname)));
                if ($value == trim($pickListValue)) {
                    $chk_val = "selected";
                    $pickcount++;
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $pickListValue = to_html($pickListValue);
                if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                    $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                } else {
                    $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
                }
            }
            $fieldvalue[] = $options;
        } elseif ($uitype == 1613) {
            require_once 'modules/PickList/PickListUtils.php';
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldname = $adb->sql_escape_string($fieldname);
            $pickListResult = getAllowedPicklistModules();
            $options = array();
            $options[] = "";
            $pickcount = 0;
            $found = false;
            foreach ($pickListResult as $pKey => $pValue) {
                $value = decode_html($value);
                $pickListValue = decode_html($pValue);
                if ($value == trim($pickListValue)) {
                    $chk_val = "selected";
                    $pickcount++;
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $pickListValue = to_html($pickListValue);
                if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                    $options[] = array(htmlentities(getTranslatedString($pickListValue, $pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                } else {
                    $options[] = array(getTranslatedString($pickListValue, $pickListValue), $pickListValue, $chk_val);
                }
            }
            uasort($options, function ($a, $b) {
                return strtolower($a[0]) < strtolower($b[0]) ? -1 : 1;
            });
            $fieldvalue[] = $options;
        } elseif ($uitype == 15 || $uitype == 33) {
            require_once 'modules/PickList/PickListUtils.php';
            $roleid = $current_user->roleid;
            $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb);
            $valueArr = explode("|##|", $value);
            foreach ($valueArr as $key => $value) {
                $valueArr[$key] = trim(html_entity_decode($value, ENT_QUOTES, $default_charset));
            }
            $pickcount = 0;
            if (!empty($picklistValues)) {
                foreach ($picklistValues as $order => $pickListValue) {
                    if (in_array(trim($pickListValue), $valueArr)) {
                        $chk_val = "selected";
                        $pickcount++;
                    } else {
                        $chk_val = '';
                    }
                    if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                        $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                    } else {
                        $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
                    }
                }
                if ($pickcount == 0 && !empty($value)) {
                    $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected');
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $options;
        } elseif ($uitype == 3313) {
            require_once 'modules/PickList/PickListUtils.php';
            $picklistValues = getAllowedPicklistModules();
            $valueArr = explode("|##|", $value);
            foreach ($valueArr as $key => $value) {
                $valueArr[$key] = trim(html_entity_decode($value, ENT_QUOTES, $default_charset));
            }
            $pickcount = 0;
            if (!empty($picklistValues)) {
                foreach ($picklistValues as $order => $pickListValue) {
                    if (in_array(trim($pickListValue), $valueArr)) {
                        $chk_val = "selected";
                        $pickcount++;
                    } else {
                        $chk_val = '';
                    }
                    if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                        $options[] = array(htmlentities(getTranslatedString($pickListValue, $pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                    } else {
                        $options[] = array(getTranslatedString($pickListValue, $pickListValue), $pickListValue, $chk_val);
                    }
                }
                if ($pickcount == 0 && !empty($value)) {
                    $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected');
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            uasort($options, function ($a, $b) {
                return strtolower($a[0]) < strtolower($b[0]) ? -1 : 1;
            });
            $fieldvalue[] = $options;
        } elseif ($uitype == 1024) {
            $options = array();
            $arr_evo = explode(' |##| ', $value);
            $roleid = $current_user->roleid;
            $subrole = getRoleSubordinates($roleid);
            $uservalues = array_merge($subrole, array($roleid));
            for ($i = 0; $i < sizeof($uservalues); $i++) {
                $currentValId = $uservalues[$i];
                $currentValName = getRoleName($currentValId);
                if (in_array(trim($currentValId), $arr_evo)) {
                    $chk_val = 'selected';
                } else {
                    $chk_val = '';
                }
                $options[] = array($currentValName, $currentValId, $chk_val);
            }
            $fieldvalue[] = $options;
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
        } elseif ($uitype == 17) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 85) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 14) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 19 || $uitype == 20) {
            if (isset($_REQUEST['body'])) {
                $value = $_REQUEST['body'];
            }
            if ($fieldname == 'terms_conditions') {
                //Assign the value from focus->column_fields (if we create Invoice from SO the SO's terms and conditions will be loaded to Invoice's terms and conditions, etc.,)
                $value = $col_fields['terms_conditions'];
                //if the value is empty then only we should get the default Terms and Conditions
                if ($value == '' && $mode != 'edit') {
                    $value = getTermsandConditions();
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 21 || $uitype == 24) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 22) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 52 || $uitype == 77) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            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';
            }
            //Control will come here only for Products - Handler and Quotes - Inventory Manager
            if ($is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id);
            } else {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id);
            }
            $fieldvalue[] = $users_combo;
        } elseif ($uitype == 53) {
            global $noof_group_rows;
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            //Security Checks
            if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                $result = get_current_user_access_groups($module_name);
            } else {
                $result = get_group_options();
            }
            if ($result) {
                $nameArray = $adb->fetch_array($result);
            }
            $assigned_user_id = empty($value) ? $current_user->id : $value;
            if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id);
            } else {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id);
            }
            if ($noof_group_rows != 0) {
                if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                    $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id);
                } else {
                    $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $assigned_user_id), $assigned_user_id);
                }
            }
            $fieldvalue[] = $users_combo;
            $fieldvalue[] = $groups_combo;
        } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) {
            if (!isset($_REQUEST['convertmode']) || $_REQUEST['convertmode'] != 'update_quote_val' && $_REQUEST['convertmode'] != 'update_so_val') {
                if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') {
                    $value = vtlib_purify($_REQUEST['account_id']);
                }
            }
            if ($value != '') {
                $account_name = getAccountName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $account_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 54) {
            $options = array();
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $pick_query = "select * from vtiger_groups";
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, "name");
                if ($value == $pickListValue) {
                    $chk_val = "selected";
                } else {
                    $chk_val = '';
                }
                $options[] = array($pickListValue => $chk_val);
            }
            $fieldvalue[] = $options;
        } elseif ($uitype == 55 || $uitype == 255) {
            require_once 'modules/PickList/PickListUtils.php';
            if ($uitype == 255) {
                $fieldpermission = getFieldVisibilityPermission($module_name, $current_user->id, 'firstname', 'readwrite');
            }
            if ($uitype == 255 && $fieldpermission == '0') {
                $fieldvalue[] = '';
            } else {
                $fieldpermission = getFieldVisibilityPermission($module_name, $current_user->id, 'salutationtype', 'readwrite');
                if ($fieldpermission == '0') {
                    $roleid = $current_user->roleid;
                    $picklistValues = getAssignedPicklistValues('salutationtype', $roleid, $adb);
                    $pickcount = 0;
                    $salt_value = $col_fields["salutationtype"];
                    foreach ($picklistValues as $order => $pickListValue) {
                        if ($salt_value == trim($pickListValue)) {
                            $chk_val = "selected";
                            $pickcount++;
                        } else {
                            $chk_val = '';
                        }
                        if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                            $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                        } else {
                            $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
                        }
                    }
                    if ($pickcount == 0 && $salt_value != '') {
                        $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $salt_value, 'selected');
                    }
                    $fieldvalue[] = $options;
                } else {
                    $fieldvalue[] = '';
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } 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 = vtlib_purify($_REQUEST['parent_id']);
            }
            if ($value != '') {
                $product_name = getProductName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $product_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 63) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            if ($value == '') {
                $value = 1;
            }
            $options = array();
            $pick_query = "select * from vtiger_duration_minutes order by sortorderid";
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            $salt_value = $col_fields["duration_minutes"];
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, "duration_minutes");
                if ($salt_value == $pickListValue) {
                    $chk_val = "selected";
                } else {
                    $chk_val = '';
                }
                $options[$pickListValue] = $chk_val;
            }
            $fieldvalue[] = $value;
            $fieldvalue[] = $options;
        } elseif ($uitype == 64) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']);
            $fieldvalue[] = $value;
        } elseif ($uitype == 156) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
            $fieldvalue[] = $is_admin;
        } elseif ($uitype == 56) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 57) {
            if ($value != '') {
                $displayValueArray = getEntityName('Contacts', $value);
                if (!empty($displayValueArray)) {
                    foreach ($displayValueArray as $key => $field_value) {
                        $contact_name = $field_value;
                    }
                }
            } elseif (isset($_REQUEST['contact_id']) && $_REQUEST['contact_id'] != '') {
                if ($_REQUEST['module'] == 'Contacts' && ($fieldname = 'contact_id')) {
                    $contact_name = '';
                } else {
                    $value = $_REQUEST['contact_id'];
                    $displayValueArray = getEntityName('Contacts', $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $contact_name = $field_value;
                        }
                    } else {
                        $contact_name = '';
                    }
                }
            }
            //Checking for contacts duplicate
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $contact_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 58) {
            if ($value != '') {
                $campaign_name = getCampaignName($value);
            } elseif (isset($_REQUEST['campaignid']) && $_REQUEST['campaignid'] != '') {
                if ($_REQUEST['module'] == 'Campaigns' && ($fieldname = 'campaignid')) {
                    $campaign_name = '';
                } else {
                    $value = $_REQUEST['campaignid'];
                    $campaign_name = getCampaignName($value);
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $campaign_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 61) {
            if ($value != '') {
                $assigned_user_id = $value;
            } else {
                $assigned_user_id = $current_user->id;
            }
            if ($module_name == 'Emails' && $col_fields['record_id'] != '') {
                $attach_result = $adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id']));
                //to fix the issue in mail attachment on forwarding mails
                if (isset($_REQUEST['forward']) && $_REQUEST['forward'] != '') {
                    global $att_id_list;
                }
                for ($ii = 0; $ii < $adb->num_rows($attach_result); $ii++) {
                    $attachmentid = $adb->query_result($attach_result, $ii, 'attachmentsid');
                    if ($attachmentid != '') {
                        $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                        $attachmentsname = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
                        if ($attachmentsname != '') {
                            $fieldvalue[$attachmentid] = '[ ' . $attachmentsname . ' ]';
                        }
                        if (isset($_REQUEST['forward']) && $_REQUEST['forward'] != '') {
                            $att_id_list .= $attachmentid . ';';
                        }
                    }
                }
            } else {
                if ($col_fields['record_id'] != '') {
                    $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid');
                    if ($col_fields[$fieldname] == '' && $attachmentid != '') {
                        $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                        $value = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
                    }
                }
                if ($value != '') {
                    $filename = ' [ ' . $value . ' ]';
                }
                if ($filename != '') {
                    $fieldvalue[] = $filename;
                }
                if ($value != '') {
                    $fieldvalue[] = $value;
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
        } elseif ($uitype == 28) {
            if ($col_fields['record_id'] != '') {
                $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid');
                if ($col_fields[$fieldname] == '' && $attachmentid != '') {
                    $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                    $value = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
                }
            }
            if ($value != '' && $module_name != 'Documents') {
                $filename = ' [ ' . $value . ' ]';
            } elseif ($value != '' && $module_name == 'Documents') {
                $filename = $value;
            }
            if ($filename != '') {
                $fieldvalue[] = $filename;
            }
            if ($value != '') {
                $fieldvalue[] = $value;
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
        } elseif ($uitype == 69) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            if ($col_fields['record_id'] != "") {
                if ($module_name == 'Products') {
                    $query = 'select vtiger_attachments.path, vtiger_attachments.attachmentsid, vtiger_attachments.name ,vtiger_crmentity.setype from vtiger_products left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_products.productid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_attachments.attachmentsid where vtiger_crmentity.setype="Products Image" and productid=?';
                    $params = array($col_fields['record_id']);
                } else {
                    if ($module_name == 'Contacts') {
                        $imageattachment = 'Image';
                    } else {
                        $imageattachment = 'Attachment';
                    }
                    $query = "select vtiger_attachments.*,vtiger_crmentity.setype\n\t\t\t\t from vtiger_attachments\n\t\t\t\t inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n\t\t\t\t inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_attachments.attachmentsid\n\t\t\t\t where vtiger_crmentity.setype='{$module_name} {$imageattachment}'\n\t\t\t\t  and vtiger_attachments.name = ?\n\t\t\t\t  and vtiger_seattachmentsrel.crmid=?";
                    $params = array($col_fields[$fieldname], $col_fields['record_id']);
                }
                $result_image = $adb->pquery($query, $params);
                for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) {
                    $image_id_array[] = $adb->query_result($result_image, $image_iter, 'attachmentsid');
                    //decode_html  - added to handle UTF-8   characters in file names
                    //urlencode    - added to handle special characters like #, %, etc.,
                    $image_array[] = urlencode(decode_html($adb->query_result($result_image, $image_iter, 'name')));
                    $image_orgname_array[] = decode_html($adb->query_result($result_image, $image_iter, 'name'));
                    $image_path_array[] = $adb->query_result($result_image, $image_iter, 'path');
                }
                if (is_array($image_array)) {
                    for ($img_itr = 0; $img_itr < count($image_array); $img_itr++) {
                        $fieldvalue[] = array('name' => $image_array[$img_itr], 'path' => $image_path_array[$img_itr] . $image_id_array[$img_itr] . "_", "orgname" => $image_orgname_array[$img_itr]);
                    }
                } else {
                    $fieldvalue[] = '';
                }
            } else {
                $fieldvalue[] = '';
            }
        } elseif ($uitype == 62) {
            if (isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') {
                $value = vtlib_purify($_REQUEST['parent_id']);
            }
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
            }
            if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') {
                $parent_module = "Accounts";
                $value = $_REQUEST['account_id'];
            }
            if ($parent_module != 'Contacts') {
                if ($parent_module == "Leads") {
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $parent_name = $field_value;
                        }
                    }
                    $lead_selected = "selected";
                } elseif ($parent_module == "Accounts") {
                    $sql = "select * from vtiger_account where accountid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "accountname");
                    $account_selected = "selected";
                } elseif ($parent_module == "Potentials") {
                    $sql = "select * from vtiger_potential where potentialid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "potentialname");
                    $potential_selected = "selected";
                } elseif ($parent_module == "Products") {
                    $sql = "select * from vtiger_products where productid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "productname");
                    $product_selected = "selected";
                } elseif ($parent_module == "PurchaseOrder") {
                    $sql = "select * from vtiger_purchaseorder where purchaseorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "subject");
                    $porder_selected = "selected";
                } elseif ($parent_module == "SalesOrder") {
                    $sql = "select * from vtiger_salesorder where salesorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "subject");
                    $sorder_selected = "selected";
                } elseif ($parent_module == "Invoice") {
                    $sql = "select * from vtiger_invoice where invoiceid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "subject");
                    $invoice_selected = "selected";
                } elseif ($parent_module == "Quotes") {
                    $sql = "select * from vtiger_quotes where quoteid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "subject");
                    $quote_selected = "selected";
                } elseif ($parent_module == "HelpDesk") {
                    $sql = "select * from vtiger_troubletickets where ticketid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "title");
                    $ticket_selected = "selected";
                }
            }
            $editview_label[] = array($app_strings['COMBO_LEADS'], $app_strings['COMBO_ACCOUNTS'], $app_strings['COMBO_POTENTIALS'], $app_strings['COMBO_PRODUCTS'], $app_strings['COMBO_INVOICES'], $app_strings['COMBO_PORDER'], $app_strings['COMBO_SORDER'], $app_strings['COMBO_QUOTES'], $app_strings['COMBO_HELPDESK']);
            $editview_label[] = array($lead_selected, $account_selected, $potential_selected, $product_selected, $invoice_selected, $porder_selected, $sorder_selected, $quote_selected, $ticket_selected);
            $editview_label[] = array("Leads&action=Popup", "Accounts&action=Popup", "Potentials&action=Popup", "Products&action=Popup", "Invoice&action=Popup", "PurchaseOrder&action=Popup", "SalesOrder&action=Popup", "Quotes&action=Popup", "HelpDesk&action=Popup");
            $fieldvalue[] = $parent_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 66) {
            if (!empty($_REQUEST['parent_id'])) {
                $value = vtlib_purify($_REQUEST['parent_id']);
            }
            if (!empty($value)) {
                $parent_module = getSalesEntityType($value);
                if ($parent_module != "Contacts") {
                    $entity_names = getEntityName($parent_module, $value);
                    $parent_name = $entity_names[$value];
                    $fieldvalue[] = $parent_name;
                    $fieldvalue[] = $value;
                }
            }
            // Check for vtiger_activity type if task orders to be added in select option
            $act_mode = $_REQUEST['activity_mode'];
            $parentModulesList = array('Leads' => $app_strings['COMBO_LEADS'], 'Accounts' => $app_strings['COMBO_ACCOUNTS'], 'Potentials' => $app_strings['COMBO_POTENTIALS'], 'HelpDesk' => $app_strings['COMBO_HELPDESK'], 'Campaigns' => $app_strings['COMBO_CAMPAIGNS'], 'Vendors' => $app_strings['COMBO_VENDORS']);
            if ($act_mode == "Task") {
                $parentModulesList['Quotes'] = $app_strings['COMBO_QUOTES'];
                $parentModulesList['PurchaseOrder'] = $app_strings['COMBO_PORDER'];
                $parentModulesList['SalesOrder'] = $app_strings['COMBO_SORDER'];
                $parentModulesList['Invoice'] = $app_strings['COMBO_INVOICES'];
            }
            $parentModuleNames = array_keys($parentModulesList);
            $parentModuleLabels = array_values($parentModulesList);
            $editview_label[0] = $parentModuleLabels;
            $editview_label[1] = array_fill(0, count($parentModulesList), '');
            $selectedModuleIndex = array_search($parent_module, $parentModuleNames);
            if ($selectedModuleIndex > -1) {
                $editview_label[1][$selectedModuleIndex] = 'selected';
            }
            $parentModulePopupUrl = array();
            foreach ($parentModuleNames as $parentModule) {
                $parentModulePopupUrl[] = $parentModule . '&action=Popup';
            }
            $editview_label[2] = $parentModulePopupUrl;
        } elseif ($uitype == 357) {
            $pmodule = $_REQUEST['pmodule'];
            if (empty($pmodule)) {
                $pmodule = $_REQUEST['par_module'];
            }
            if ($pmodule == 'Contacts') {
                $contact_selected = 'selected';
            } elseif ($pmodule == 'Accounts') {
                $account_selected = 'selected';
            } elseif ($pmodule == 'Leads') {
                $lead_selected = 'selected';
            } elseif ($pmodule == 'Vendors') {
                $vendor_selected = 'selected';
            } elseif ($pmodule == 'Users') {
                $user_selected = 'selected';
            } elseif ($pmodule == 'Project') {
                $project_selected = 'selected';
            } elseif ($pmodule == 'ProjectTask') {
                $projecttask_selected = 'selected';
            } elseif ($pmodule == 'Potentials') {
                $potentials_selected = 'selected';
            } elseif ($pmodule == 'HelpDesk') {
                $helpdesk_selected = 'selected';
            }
            if (isset($_REQUEST['emailids']) && $_REQUEST['emailids'] != '') {
                $parent_id = $_REQUEST['emailids'];
                $parent_name = '';
                $myids = explode("|", $parent_id);
                for ($i = 0; $i < count($myids) - 1; $i++) {
                    $realid = explode("@", $myids[$i]);
                    $entityid = $realid[0];
                    $nemail = count($realid);
                    if ($pmodule == 'Accounts') {
                        require_once 'modules/Accounts/Accounts.php';
                        $myfocus = new Accounts();
                        $myfocus->retrieve_entity_info($entityid, "Accounts");
                        $fullname = br2nl($myfocus->column_fields['accountname']);
                        $account_selected = 'selected';
                    } elseif ($pmodule == 'Contacts') {
                        require_once 'modules/Contacts/Contacts.php';
                        $myfocus = new Contacts();
                        $myfocus->retrieve_entity_info($entityid, "Contacts");
                        $fname = br2nl($myfocus->column_fields['firstname']);
                        $lname = br2nl($myfocus->column_fields['lastname']);
                        $fullname = $lname . ' ' . $fname;
                        $contact_selected = 'selected';
                    } elseif ($pmodule == 'Leads') {
                        require_once 'modules/Leads/Leads.php';
                        $myfocus = new Leads();
                        $myfocus->retrieve_entity_info($entityid, "Leads");
                        $fname = br2nl($myfocus->column_fields['firstname']);
                        $lname = br2nl($myfocus->column_fields['lastname']);
                        $fullname = $lname . ' ' . $fname;
                        $lead_selected = 'selected';
                    } elseif ($pmodule == 'Project') {
                        require_once 'modules/Project/Project.php';
                        $myfocus = new Project();
                        $myfocus->retrieve_entity_info($entityid, "Project");
                        $fname = br2nl($myfocus->column_fields['projectname']);
                        $lname = br2nl($myfocus->column_fields['projectid']);
                        $fullname = $fname;
                        $project_selected = 'selected';
                    } elseif ($pmodule == 'ProjectTask') {
                        require_once 'modules/ProjectTask/ProjectTask.php';
                        $myfocus = new ProjectTask();
                        $myfocus->retrieve_entity_info($entityid, "ProjectTask");
                        $fname = br2nl($myfocus->column_fields['projecttaskname']);
                        $lname = br2nl($myfocus->column_fields['projecttaskid']);
                        $fullname = $fname;
                        $projecttask_selected = 'selected';
                    } elseif ($pmodule == 'Potentials') {
                        require_once 'modules/Potentials/Potentials.php';
                        $myfocus = new Potentials();
                        $myfocus->retrieve_entity_info($entityid, "Potentials");
                        $fname = br2nl($myfocus->column_fields['potentialname']);
                        $lname = br2nl($myfocus->column_fields['potentialid']);
                        $fullname = $fname;
                        $potentials_selected = 'selected';
                    } elseif ($pmodule == 'HelpDesk') {
                        require_once 'modules/HelpDesk/HelpDesk.php';
                        $myfocus = new HelpDesk();
                        $myfocus->retrieve_entity_info($entityid, "HelpDesk");
                        $fname = br2nl($myfocus->column_fields['title']);
                        $lname = br2nl($myfocus->column_fields['ticketid']);
                        $fullname = $fname;
                        $helpdesk_selected = 'selected';
                    }
                    for ($j = 1; $j < $nemail; $j++) {
                        $querystr = 'select columnname from vtiger_field where fieldid=? and vtiger_field.presence in (0,2)';
                        $result = $adb->pquery($querystr, array($realid[$j]));
                        $temp = $adb->query_result($result, 0, 'columnname');
                        $temp1 = br2nl($myfocus->column_fields[$temp]);
                        //Modified to display the entities in red which don't have email id
                        if (!empty($temp_parent_name) && strlen($temp_parent_name) > 150) {
                            $parent_name .= '<br>';
                            $temp_parent_name = '';
                        }
                        if ($temp1 != '') {
                            $parent_name .= $fullname . '&lt;' . $temp1 . '&gt;; ';
                            $temp_parent_name .= $fullname . '&lt;' . $temp1 . '&gt;; ';
                        } else {
                            $parent_name .= "<b style='color:red'>" . $fullname . '&lt;' . $temp1 . '&gt;; ' . "</b>";
                            $temp_parent_name .= "<b style='color:red'>" . $fullname . '&lt;' . $temp1 . '&gt;; ' . "</b>";
                        }
                    }
                }
            } else {
                if ($_REQUEST['record'] != '' && $_REQUEST['record'] != NULL) {
                    $parent_name = '';
                    $parent_id = '';
                    $myemailid = $_REQUEST['record'];
                    $mysql = "select crmid from vtiger_seactivityrel where activityid=?";
                    $myresult = $adb->pquery($mysql, array($myemailid));
                    $mycount = $adb->num_rows($myresult);
                    if ($mycount > 0) {
                        for ($i = 0; $i < $mycount; $i++) {
                            $mycrmid = $adb->query_result($myresult, $i, 'crmid');
                            $parent_module = getSalesEntityType($mycrmid);
                            if ($parent_module == "Leads") {
                                $sql = "select firstname,lastname,email from vtiger_leaddetails where leadid=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $full_name = getFullNameFromQResult($result, 0, "Leads");
                                $myemail = $adb->query_result($result, 0, "email");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $full_name . '<' . $myemail . '>; ';
                                $lead_selected = 'selected';
                            } elseif ($parent_module == "Contacts") {
                                $sql = "select * from vtiger_contactdetails where contactid=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $full_name = getFullNameFromQResult($result, 0, "Contacts");
                                $myemail = $adb->query_result($result, 0, "email");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $full_name . '<' . $myemail . '>; ';
                                $contact_selected = 'selected';
                            } elseif ($parent_module == "Accounts") {
                                $sql = "select * from vtiger_account where accountid=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $account_name = $adb->query_result($result, 0, "accountname");
                                $myemail = $adb->query_result($result, 0, "email1");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $account_name . '<' . $myemail . '>; ';
                                $account_selected = 'selected';
                            } elseif ($parent_module == "Users") {
                                $sql = "select user_name,email1 from vtiger_users where id=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $account_name = $adb->query_result($result, 0, "user_name");
                                $myemail = $adb->query_result($result, 0, "email1");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $account_name . '<' . $myemail . '>; ';
                                $user_selected = 'selected';
                            } elseif ($parent_module == "Vendors") {
                                $sql = "select * from vtiger_vendor where vendorid=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $vendor_name = $adb->query_result($result, 0, "vendorname");
                                $myemail = $adb->query_result($result, 0, "email");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $vendor_name . '<' . $myemail . '>; ';
                                $vendor_selected = 'selected';
                            }
                        }
                    }
                }
                $custfld .= '<td width="20%" class="dataLabel">' . $app_strings['To'] . '&nbsp;</td>';
                $custfld .= '<td width="90%" colspan="3"><input name="parent_id" type="hidden" value="' . $parent_id . '"><textarea readonly name="parent_name" cols="70" rows="2">' . $parent_name . '</textarea>&nbsp;<select name="parent_type" >';
                $custfld .= '<OPTION value="Contacts" selected>' . $app_strings['COMBO_CONTACTS'] . '</OPTION>';
                $custfld .= '<OPTION value="Accounts" >' . $app_strings['COMBO_ACCOUNTS'] . '</OPTION>';
                $custfld .= '<OPTION value="Leads" >' . $app_strings['COMBO_LEADS'] . '</OPTION>';
                $custfld .= '<OPTION value="Vendors" >' . $app_strings['COMBO_VENDORS'] . '</OPTION></select><img src="' . vtiger_imageurl('select.gif', $theme) . '" alt="Select" title="Select" LANGUAGE=javascript onclick=\'$log->debug("Exiting getOutputHtml method ..."); return window.open("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&popuptype=set_$log->debug("Exiting getOutputHtml method ..."); return_emails&form=EmailEditView&form_submit=false","test","width=600,height=400,resizable=1,scrollbars=1,top=150,left=200");\' align="absmiddle" style=\'cursor:hand;cursor:pointer\'>&nbsp;<input type="image" src="' . vtiger_imageurl('clear_field.gif', $theme) . '" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.parent_id.value=\'\';this.form.parent_name.value=\'\';$log->debug("Exiting getOutputHtml method ..."); return false;" align="absmiddle" style=\'cursor:hand;cursor:pointer\'></td>';
                $editview_label[] = array('Contacts' => $contact_selected, 'Accounts' => $account_selected, 'Vendors' => $vendor_selected, 'Leads' => $lead_selected, 'Users' => $user_selected);
                $fieldvalue[] = $parent_name;
                $fieldvalue[] = $parent_id;
            }
        } elseif ($uitype == 68) {
            if (empty($value) && isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') {
                $value = vtlib_purify($_REQUEST['parent_id']);
            }
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
                if ($parent_module == "Contacts") {
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $parent_name = $field_value;
                        }
                    }
                    $contact_selected = "selected";
                } elseif ($parent_module == "Accounts") {
                    $sql = "select * from vtiger_account where accountid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "accountname");
                    $account_selected = "selected";
                } else {
                    $parent_name = "";
                    $value = "";
                }
            }
            $editview_label[0] = array();
            $editview_label[1] = array();
            $editview_label[2] = array();
            if (vtlib_isModuleActive('Accounts')) {
                array_push($editview_label[0], $app_strings['COMBO_ACCOUNTS']);
                array_push($editview_label[1], $account_selected);
                array_push($editview_label[2], "Accounts");
            }
            if (vtlib_isModuleActive('Contacts')) {
                array_push($editview_label[0], $app_strings['COMBO_CONTACTS']);
                array_push($editview_label[1], $contact_selected);
                array_push($editview_label[2], "Contacts");
            }
            $fieldvalue[] = $parent_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 9 || $uitype == 7) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fldrs = $adb->pquery('select typeofdata from vtiger_field
			where vtiger_field.fieldname=? and vtiger_field.tabid=?', array($fieldname, getTabid($module_name)));
            $typeofdata = $adb->query_result($fldrs, 0, 0);
            $typeinfo = explode('~', $typeofdata);
            if ($typeinfo[0] == 'I') {
                $fieldvalue[] = $value;
            } else {
                $currencyField = new CurrencyField($value);
                $decimals = CurrencyField::getDecimalsFromTypeOfData($typeofdata);
                $currencyField->initialize($current_user);
                $currencyField->setNumberofDecimals(min($decimals, $currencyField->getCurrencyDecimalPlaces()));
                $fieldvalue[] = $currencyField->getDisplayValue(null, false, true);
            }
        } elseif ($uitype == 71 || $uitype == 72) {
            $currencyField = new CurrencyField($value);
            // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
            if ($col_fields['record_id'] != '' && $uitype == 72) {
                if ($fieldname == 'unit_price') {
                    $rate_symbol = getCurrencySymbolandCRate(getProductBaseCurrency($col_fields['record_id'], $module_name));
                    $currencySymbol = $rate_symbol['symbol'];
                } else {
                    $currency_info = getInventoryCurrencyInfo($module, $col_fields['record_id']);
                    $currencySymbol = $currency_info['currency_symbol'];
                }
                $fieldvalue[] = $currencyField->getDisplayValue(null, true);
            } else {
                $decimals = CurrencyField::getDecimalsFromTypeOfData($typeofdata);
                $currencyField->initialize($current_user);
                $currencyField->setNumberofDecimals(min($decimals, $currencyField->getCurrencyDecimalPlaces()));
                $fieldvalue[] = $currencyField->getDisplayValue(null, false, true);
                $currencySymbol = $currencyField->getCurrencySymbol();
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name) . ': (' . $currencySymbol . ')';
        } 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);
            }
            $pop_type = 'specific';
            if ($uitype == 81) {
                $pop_type = 'specific_vendor_address';
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $vendor_name;
            $fieldvalue[] = $value;
        } 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);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $potential_name;
            $fieldvalue[] = $value;
        } 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);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $quote_name;
            $fieldvalue[] = $value;
        } 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);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $purchaseorder_name;
            $fieldvalue[] = $value;
        } 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);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $salesorder_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 30) {
            $rem_days = 0;
            $rem_hrs = 0;
            $rem_min = 0;
            if ($value != '') {
                $SET_REM = 'CHECKED';
            } else {
                $SET_REM = '';
            }
            $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;
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $day_options = getReminderSelectOption(0, 31, 'remdays', $rem_days);
            $hr_options = getReminderSelectOption(0, 23, 'remhrs', $rem_hrs);
            $min_options = getReminderSelectOption(10, 59, 'remmin', $rem_min);
            $fieldvalue[] = array(array(0, 32, 'remdays', getTranslatedString('LBL_DAYS', 'Calendar'), $rem_days), array(0, 24, 'remhrs', getTranslatedString('LBL_HOURS', 'Calendar'), $rem_hrs), array(10, 60, 'remmin', getTranslatedString('LBL_MINUTES', 'Calendar') . '&nbsp;&nbsp;' . getTranslatedString('LBL_BEFORE_EVENT', 'Calendar'), $rem_min));
            $fieldvalue[] = array($SET_REM, getTranslatedString('LBL_YES'), getTranslatedString('LBL_NO'));
            $SET_REM = '';
        } elseif ($uitype == 115) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $pick_query = "select * from vtiger_" . $adb->sql_escape_string($fieldname);
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            //Mikecrowe fix to correctly default for custom pick lists
            $options = array();
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, strtolower($fieldname));
                if ($value == $pickListValue) {
                    $chk_val = "selected";
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
            }
            $fieldvalue[] = $options;
            $fieldvalue[] = $is_admin;
        } elseif ($uitype == 116 || $uitype == 117) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $pick_query = "select * from vtiger_currency_info where currency_status = 'Active' and deleted=0";
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            //Mikecrowe fix to correctly default for custom pick lists
            $options = array();
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, 'currency_name');
                $currency_id = $adb->query_result($pickListResult, $j, 'id');
                if ($value == $currency_id) {
                    $chk_val = "selected";
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $options[$currency_id] = array($pickListValue => $chk_val);
            }
            $fieldvalue[] = $options;
            $fieldvalue[] = $is_admin;
        } elseif ($uitype == 98) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
            $fieldvalue[] = getRoleName($value);
            $fieldvalue[] = $is_admin;
        } elseif ($uitype == 105) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            if (isset($col_fields['record_id']) && $col_fields['record_id'] != '') {
                $query = "select vtiger_attachments.path, vtiger_attachments.name from vtiger_contactdetails left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_contactdetails.contactid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid where vtiger_contactdetails.imagename=vtiger_attachments.name and contactid=?";
                $result_image = $adb->pquery($query, array($col_fields['record_id']));
                for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) {
                    $image_array[] = $adb->query_result($result_image, $image_iter, 'name');
                    $image_path_array[] = $adb->query_result($result_image, $image_iter, 'path');
                }
            }
            if (is_array($image_array)) {
                for ($img_itr = 0; $img_itr < count($image_array); $img_itr++) {
                    $fieldvalue[] = array('name' => $image_array[$img_itr], 'path' => $image_path_array[$img_itr]);
                }
            } else {
                $fieldvalue[] = '';
            }
        } elseif ($uitype == 101) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = getOwnerName($value);
            $fieldvalue[] = $value;
        } elseif ($uitype == 26) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $folderid = $col_fields['folderid'];
            $foldername_query = 'select foldername from vtiger_attachmentsfolder where folderid = ?';
            $res = $adb->pquery($foldername_query, array($folderid));
            $foldername = $adb->query_result($res, 0, 'foldername');
            if ($foldername != '' && $folderid != '') {
                $fldr_name[$folderid] = $foldername;
            }
            $sql = "select foldername,folderid from vtiger_attachmentsfolder order by foldername";
            $res = $adb->pquery($sql, array());
            for ($i = 0; $i < $adb->num_rows($res); $i++) {
                $fid = $adb->query_result($res, $i, "folderid");
                $fldr_name[$fid] = $adb->query_result($res, $i, "foldername");
            }
            $fieldvalue[] = $fldr_name;
        } elseif ($uitype == 27) {
            if ($value == 'E') {
                $external_selected = "selected";
                $filename = $col_fields['filename'];
            } else {
                $internal_selected = "selected";
                $filename = $col_fields['filename'];
            }
            $editview_label[] = array(getTranslatedString('Internal'), getTranslatedString('External'));
            $editview_label[] = array($internal_selected, $external_selected);
            $editview_label[] = array("I", "E");
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
            $fieldvalue[] = $filename;
        } elseif ($uitype == '31') {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $options = array();
            $themeList = get_themes();
            foreach ($themeList as $theme) {
                if ($value == $theme) {
                    $selected = 'selected';
                } else {
                    $selected = '';
                }
                $options[] = array(getTranslatedString($theme), $theme, $selected);
            }
            $fieldvalue[] = $options;
        } elseif ($uitype == '32') {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $options = array();
            $languageList = Vtiger_Language::getAll();
            foreach ($languageList as $prefix => $label) {
                if ($value == $prefix) {
                    $selected = 'selected';
                } else {
                    $selected = '';
                }
                $options[] = array(getTranslatedString($label), $prefix, $selected);
            }
            $fieldvalue[] = $options;
        } else {
            //Added condition to set the subject if click Reply All from web mail
            if ($_REQUEST['module'] == 'Emails' && $_REQUEST['mg_subject'] != '') {
                $value = $_REQUEST['mg_subject'];
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            if ($fieldname == 'fileversion') {
                if (empty($value)) {
                    $value = '';
                } else {
                    $fieldvalue[] = $value;
                }
            } else {
                $fieldvalue[] = $value;
            }
        }
    }
    // Mike Crowe Mod --------------------------------------------------------force numerics right justified.
    if (!preg_match("/id=/i", $custfld)) {
        $custfld = preg_replace("/<input/iS", "<input id='{$fieldname}' ", $custfld);
    }
    if (in_array($uitype, array(71, 72, 7, 9, 90))) {
        $custfld = preg_replace("/<input/iS", "<input align=right ", $custfld);
    }
    $final_arr[] = $ui_type;
    $final_arr[] = $editview_label;
    $final_arr[] = $editview_fldname;
    $final_arr[] = $fieldvalue;
    $type_of_data = explode('~', $typeofdata);
    $final_arr[] = $type_of_data[1];
    $log->debug('Exiting getOutputHtml method ...');
    return $final_arr;
}
예제 #5
0
파일: detail.php 프로젝트: sQcrm/sqcrm
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* Detail page 
* @author Abhik Chakraborty
*/
$do_crmfields = new CRMFields();
$do_block = new Block();
$do_block->get_block_by_module($module_id);
$module_obj = new Leads();
$module_obj->getId($sqcrm_record_id);
$converted_lead = false;
//updates detail, just add and last updated
$do_crmentity = new CRMEntity();
$update_history = $do_crmentity->get_last_updates($sqcrm_record_id, $module_id, $module_obj);
if ($module_obj->converted == 1) {
    $converted_lead = true;
    $lead_conversion = new LeadConversion();
    $lead_conversion_matrix = $lead_conversion->get_conversion_matrix($sqcrm_record_id);
}
if (isset($_GET['ajaxreq']) && $_GET['ajaxreq'] == true) {
    require_once 'view/detail_view_entry.php';
} else {
    require_once 'view/detail_view.php';
}
예제 #6
0
        $query = "insert into vtiger_freetags values (?,?,?)";
        $qparams = array($freetag, $cloudtag[2], $cloudtag[2]);
        $res1 = $adb->pquery($query, $qparams);
        $date = $adb->formatDate(date('YmdHis'), true);
        $query_tag = "insert into vtiger_freetagged_objects values (?,?,?,?,?)";
        $tag_params = array($freetag, 1, $contact->id, $date, 'Contacts');
        $result1 = $adb->pquery($query_tag, $tag_params);
    }
    // This assumes that there will be one opportunity per company in the seed data.
    $opportunity_key = array_rand($opportunity_ids);
    $query = "insert into vtiger_contpotentialrel ( contactid, potentialid ) values (?,?)";
    $adb->pquery($query, array($contact->id, $opportunity_ids[$opportunity_key]));
}
$company_count = 0;
for ($i = 0; $i < 10; $i++) {
    $lead = new Leads();
    $lead->column_fields["firstname"] = ucfirst(strtolower($first_name_array[$i]));
    $lead->column_fields["lastname"] = ucfirst(strtolower($last_name_array[$i]));
    if ($i < 5) {
        $lead->column_fields["company"] = ucfirst(strtolower($company_name_array[$i]));
    } else {
        $lead->column_fields["company"] = ucfirst(strtolower($company_name_array[$company_count]));
        $company_count++;
    }
    $lead->column_fields["assigned_user_id"] = $assigned_user_id;
    $lead->column_fields["email"] = strtolower($lead->column_fields["firstname"]) . "_" . strtolower($lead->column_fields["lastname"]) . "@company.com";
    $website = str_replace($whitespace, "", strtolower(ucfirst(strtolower($company_name_array[$i]))));
    $lead->column_fields["website"] = "www." . $website . ".com";
    $lead->column_fields["phone"] = create_phone_number();
    $lead->column_fields["mobile"] = create_phone_number();
    // Fill in a bogus address
예제 #7
0
파일: index.php 프로젝트: samxsam/conduct
    <title>Conduct Test Lead Form</title>
</head>
<body>
<div class="container">
    <form method="post" action="index.php">

    <?php 
if (isset($_POST['submit'])) {
    // Form has been submitted.
    $first_name = trim($_POST['first_name']);
    $last_name = trim($_POST['last_name']);
    $email = trim($_POST['email']);
    $mobile = trim($_POST['mobile']);
    $message = trim($_POST['message']);
    // Check database to see if username/password exist.
    $error_message = Leads::assign_agent($first_name, $last_name, $email, $mobile, $message);
    if (count($error_message) > 0) {
        // has error
        ?>
                <div class="error">
                    <?php 
        foreach ($error_message as $error) {
            echo $error . "<br/>";
        }
        ?>
                </div>
            <?php 
    } else {
        // form submit success
        $first_name = '';
        $last_name = '';
예제 #8
0
 /**
  * Store the data of a sub form field.
  *
  * @param int      $fieldId   The field id.
  * @param int|bool $leadStore The lead store field or setting.
  *
  * @return void
  */
 private function storeSubformFieldData($fieldId, $leadStore)
 {
     $field = \FormFieldModel::findByPK($fieldId);
     $data = array();
     if ($this->hasLeadMaster()) {
         $masterField = \FormFieldModel::findByPk($leadStore);
         if (!$masterField) {
             return;
         }
         $fieldName = $masterField->name;
         $masterId = $masterField->id;
     } else {
         $fieldName = $field->name;
         $masterId = $field->id;
     }
     // Regular data
     if (isset($this->postData[$field->name])) {
         $value = \Leads::prepareValue($this->postData[$field->name], $field);
         $label = \Leads::prepareLabel($value, $field);
         $data = array('pid' => $this->leadId, 'sorting' => $field->sorting, 'tstamp' => time(), 'master_id' => $masterId, 'field_id' => $field->id, 'name' => $fieldName, 'value' => $value, 'label' => $label);
     }
     // Files
     if (isset($this->files[$field->name]) && $this->files[$field->name]['uploaded']) {
         $value = \Leads::prepareValue($this->files[$field->name], $field);
         $label = \Leads::prepareLabel($value, $field);
         $data = array('pid' => $this->leadId, 'sorting' => $field->sorting, 'tstamp' => time(), 'master_id' => $field->master_id, 'field_id' => $field->id, 'name' => $field->name, 'value' => $value, 'label' => $label);
     }
     $this->insertIntoDatabase($field, $data);
 }
예제 #9
0
파일: utils.php 프로젝트: jgjermeni/corebos
function getEmailParentsList($module, $id, $focus = false)
{
    global $log, $adb;
    $log->debug("Entering getEmailParentsList(" . $module . "," . $id . ") method ...");
    // If the information is not sent then read it
    if ($focus === false) {
        if ($module == 'Contacts') {
            $focus = new Contacts();
        }
        if ($module == 'Leads') {
            $focus = new Leads();
        }
        $focus->retrieve_entity_info($id, $module);
    }
    $fieldid = 0;
    $fieldname = 'email';
    if ($focus->column_fields['email'] == '' && $focus->column_fields['yahooid'] != '') {
        $fieldname = 'yahooid';
    } elseif ($focus->column_fields['email'] == '' && $focus->column_fields['secondaryemail'] != '') {
        $fieldname = 'secondaryemail';
    }
    $res = $adb->pquery("select * from vtiger_field where tabid = ? and fieldname= ? and vtiger_field.presence in (0,2)", array(getTabid($module), $fieldname));
    $fieldid = $adb->query_result($res, 0, 'fieldid');
    $hidden .= '<input type="hidden" name="emailids" value="' . $id . '@' . $fieldid . '|">';
    $hidden .= '<input type="hidden" name="pmodule" value="' . $module . '">';
    $log->debug("Exiting getEmailParentsList method ...");
    return $hidden;
}
예제 #10
0
파일: Save.php 프로젝트: hardikk/HNH
 * Software distributed under the License is distributed on an  "AS IS"  basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 * The Original Code is:  SugarCRM Open Source
 * The Initial Developer of the Original Code is SugarCRM, Inc.
 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
 * All Rights Reserved.
 * Contributor(s): ______________________________________.
 ********************************************************************************/
require_once 'modules/Leads/Leads.php';
require_once 'include/logging.php';
require_once 'include/database/PearDatabase.php';
require_once 'include/utils/UserInfoUtil.php';
$local_log =& LoggerManager::getLogger('index');
global $log, $adb;
$focus = new Leads();
global $current_user;
$currencyid = fetchCurrency($current_user->id);
$rate_symbol = getCurrencySymbolandCRate($currencyid);
$rate = $rate_symbol['rate'];
$curr_symbol = $rate_symbol['symbol'];
//added to fix 4600
$search = vtlib_purify($_REQUEST['search_url']);
if (isset($_REQUEST['record'])) {
    $focus->id = $_REQUEST['record'];
}
if (isset($_REQUEST['mode'])) {
    $focus->mode = $_REQUEST['mode'];
}
//$focus->retrieve($_REQUEST['record']);
foreach ($focus->column_fields as $fieldname => $val) {
예제 #11
0
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* Convert Lead modal
* @author Abhik Chakraborty
*/
include_once "config.php";
$referrar = $_GET["referrar"];
$leads_obj = new Leads();
$leads_obj->getId((int) $sqcrm_record_id);
$e_add = new Event("LeadConversion->eventConvertLeads");
$e_add->addParam("idleads", (int) $sqcrm_record_id);
echo '<form class="form-horizontal" id="LeadConversion__eventConvertLeads" name="LeadConversion__eventConvertLeads" action="/eventcontroler.php" method="post">';
echo $e_add->getFormEvent();
?>
<div class="modal-dialog" role="document">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h3><span class="label label-info"><?php 
echo _('Convert ') . '"' . $leads_obj->firstname . ' ' . $leads_obj->lastname . '"';
?>
</span></h3>
			</div>
			<div class="modal-body">
				<!-- Organization section -->
				<div class="box_content" id="org">
					<input type="checkbox" name="org_convertion" id="org_convertion" CHECKED>
					<?php 
예제 #12
0
function create_lead_from_webform($username, $sessionid, $lastname, $email, $phone, $company, $country, $description, $firstname)
{
    global $log;
    global $adb;
    global $current_user;
    if (!validateSession($username, $sessionid)) {
        return null;
    }
    require_once "modules/Users/Users.php";
    $seed_user = new Users();
    $user_id = $seed_user->retrieve_user_id($username);
    $current_user = $seed_user;
    $current_user->retrieve_entity_info($user_id, 'Users');
    $adb->println("Create New Lead from Web Form - Starts");
    require_once "modules/Leads/Leads.php";
    $focus = new Leads();
    if (isPermitted("Leads", "EditView") == "yes") {
        $focus->column_fields['lastname'] = $lastname;
        $focus->column_fields['firstname'] = $firstname;
        $focus->column_fields['email'] = $email;
        $focus->column_fields['phone'] = $phone;
        $focus->column_fields['company'] = $company;
        $focus->column_fields['country'] = $country;
        $focus->column_fields['description'] = $description;
        $focus->column_fields['assigned_user_id'] = $user_id;
        $focus->save("Leads");
        $adb->println("Create New Lead from Web Form - Ends");
        if ($focus->id != '') {
            return "Thank you for your interest. Information has been successfully added as Lead.";
        } else {
            return "Lead creation failed. Try again";
        }
    } else {
        return $accessDenied;
    }
}
예제 #13
0
 function __construct($conx = NULL, $table_name = "")
 {
     parent::__construct($conx, $table_name);
 }
예제 #14
0
파일: ajax2.php 프로젝트: mrimran/dashboard
     } else {
         echo json_encode(getLeadsDataClient($calls_date_from, $calls_date_to));
     }
     die;
 }
 ////////////////////////////////////////////////////////////////////////////
 // Get leads chart data
 ////////////////////////////////////////////////////////////////////////////
 if ($_GET['act'] === 'get_leads_chart_data') {
     if (!isset($_GET['period'])) {
         $period = 'lifetime';
     }
     $period = $_GET['period'];
     //class based implementation
     require '../classes/dashboard/Leads.php';
     $leads = new Leads();
     $leads->setPeriod($period);
     if ($period == 'custom') {
         $leads->setCustomPeriod($_REQUEST['from'], $_REQUEST['to']);
     }
     header('Content-Type: application/json');
     echo json_encode($leads->getLeadsChartData($period));
     die;
     //non class based implementation
     $rangeArray = getDateRangeFromPeriod($period);
     $leads_date_from = $rangeArray['date_from'];
     $leads_date_to = $rangeArray['date_to'];
     header('Content-Type: application/json');
     echo json_encode(getLeadsChartData($leads_date_from, $leads_date_to, $period));
     die;
 }
예제 #15
0
파일: edit.php 프로젝트: sQcrm/sqcrm
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* User edit 
* @author Abhik Chakraborty
*/
$do_crmfields = new CRMFields();
$do_block = new Block();
$do_block->get_block_by_module($module_id);
$module_obj = new Leads();
$module_obj->getId($sqcrm_record_id);
if (isset($_GET["return_page"]) && $_GET["return_page"] != '') {
    $return = $_GET["return_page"];
    $cancel_return = NavigationControl::getNavigationLink($module, $return, $sqcrm_record_id);
} else {
    $cancel_return = NavigationControl::getNavigationLink($module, "list");
}
//Assigned to iduser or group ?
if ($module_obj->iduser > 0) {
    $assigned_to = 'user_' . $module_obj->iduser;
} elseif ($module_obj->idgroup > 0) {
    $assigned_to = 'group_' . $module_obj->idgroup;
}
if ($module_obj->converted == 1) {
    echo _('The lead is converted and can not be edited');
} else {
    require_once 'view/edit_view.php';
}
예제 #16
0
 /**
  * Get Lead record information based on email.
  */
 function GetLeadRecord($email)
 {
     require_once 'modules/Leads/Leads.php';
     $leadid = $this->LookupLead($email);
     $lead_focus = false;
     if ($leadid) {
         if ($this->_cachedLeads[$leadid]) {
             $lead_focus = $this->_cachedLeads[$leadid];
             $this->log("Reusing Cached Lead [" . $lead_focus->column_fields[lastname] . '-' . $lead_focus->column_fields[firstname] . "]");
         } else {
             $lead_focus = new Leads();
             $lead_focus->retrieve_entity_info($leadid, 'Leads');
             $lead_focus->id = $leadid;
             $this->log("Caching Lead [" . $lead_focus->column_fields[lastname] . '-' . $lead_focus->column_fields[firstname] . "]");
             $this->_cachedLeads[$leadid] = $lead_focus;
         }
     }
     return $lead_focus;
 }
예제 #17
0
<?php

require '../class/Leads.php';
require 'insereSolicita.php';
$leads = new Leads();
$leads->para = $_POST['para'];
$leads->solicito = $_POST['solicito'];
if ($leads->para == "Departamento Offline") {
    $to = "#";
    $subject = "Solicitação ao Marketing";
} else {
    $to = "*****@*****.**";
    $subject = "Solicitação ao Marketing";
}
$leads->nome_coordenador = $_POST['nome_coordenador'];
$leads->tel_coordenador = $_POST['tel_coordenador'];
$leads->email_coordenador = $_POST['email_coordenador'];
$leads->nome_evento = $_POST['nome_evento'];
$leads->data_evento = $_POST['inicial'];
$leads->horai_evento = $_POST['horai_evento'];
$leads->horaf_evento = $_POST['horaf_evento'];
$leads->observacoes = $_POST['observacoes'];
$leads->campus = $_POST['campus'];
$leads->local = $_POST['local'];
$leads->valor = $_POST['valor'];
$leads->publicoalvo = juntarCheck($_REQUEST['publicoalvo']);
$leads->atComplementar = $_POST['atComplementar'];
$leads->publicoEstimado = $_POST['publicoEstimado'];
$leads->necInscricao = $_POST['necInscricao'];
$leads->certificado = $_POST['certificado'];
$leads->objetivo = $_POST['objetivo'];
예제 #18
0
global $app_strings;
global $current_user;
global $list_max_entries_per_page;
$log = LoggerManager::getLogger('contact_list');
global $currentModule;
global $theme;
// Get _dom arrays from Database
$comboFieldNames = array('leadstatus' => 'leadstatus_dom');
$comboFieldArray = getComboArray($comboFieldNames);
$category = getParentTab();
if (!isset($where)) {
    $where = "";
}
$url_string = '';
// assigning http url string
$focus = new Leads();
// Initialize sort by fields
$focus->initSortbyField('Leads');
// END
$smarty = new vtigerCRM_Smarty();
$other_text = array();
if (!$_SESSION['lvs'][$currentModule]) {
    unset($_SESSION['lvs']);
    $modObj = new ListViewSession();
    $modObj->sorder = $sorder;
    $modObj->sortby = $order_by;
    $_SESSION['lvs'][$currentModule] = get_object_vars($modObj);
}
if ($_REQUEST['errormsg'] != '') {
    $errormsg = vtlib_purify($_REQUEST['errormsg']);
    $smarty->assign("ERROR", "The User does not have permission to Change/Delete " . $errormsg . " " . $currentModule);
$potential_amount = $_REQUEST['potential_amount'];
$potential_sales_stage = $_REQUEST['potential_sales_stage'];
global $log, $current_user;
require 'user_privileges/user_privileges_' . $current_user->id . '.php';
if ($assigned_to == "U") {
    $log->debug("id = {$id} \n assigned_user_id = {$assigned_user_id} \n createpotential = {$createpotential} \n close date = {$close_date} \n current user id = {$current_user_id} \n accountname = {$accountname} \n module = {$module}");
} else {
    $log->debug("id = {$id} \n assigned_user_id = {$assigned_group_id} \n createpotential = {$createpotential} \n close date = {$close_date} \n current user id = {$current_user_id} \n accountname = {$accountname} \n module = {$module}");
}
$rate_symbol = getCurrencySymbolandCRate($user_info['currency_id']);
$rate = $rate_symbol['rate'];
if ($potential_amount != '') {
    $potential_amount = convertToDollar($potential_amount, $rate);
}
//Retrieve info from all the vtiger_tables related to leads
$focus = new Leads();
$focus->retrieve_entity_info($id, "Leads");
//get all the lead related columns
$row = $focus->column_fields;
$date_entered = $adb->formatDate(date('Y-m-d H:i:s'), true);
$date_modified = $adb->formatDate(date('Y-m-d H:i:s'), true);
/** Function for getting the custom values from leads and saving to vtiger_account/contact/potential custom vtiger_fields.
 *  @param string $type - Field Type (eg: text, list)
 *  @param integer $type_id - Field Type ID 
*/
function getInsertValues($type, $type_id)
{
    global $id, $adb, $log;
    $log->debug("Entering getInsertValues(" . $type . "," . $type_id . ") method ...");
    $sql_convert_lead = "select * from vtiger_convertleadmapping ";
    $convert_result = $adb->pquery($sql_convert_lead, array());
예제 #20
0
파일: mailsend.php 프로젝트: hardikk/HNH
 $pmodule = getSalesEntityType($mycrmid);
 for ($j = 1; $j < $nemail; $j++) {
     $temp = $realid[$j];
     $myquery = 'Select columnname from vtiger_field where fieldid = ? and vtiger_field.presence in (0,2)';
     $fresult = $adb->pquery($myquery, array($temp));
     if ($pmodule == 'Contacts') {
         require_once 'modules/Contacts/Contacts.php';
         $myfocus = new Contacts();
         $myfocus->retrieve_entity_info($mycrmid, "Contacts");
     } elseif ($pmodule == 'Accounts') {
         require_once 'modules/Accounts/Accounts.php';
         $myfocus = new Accounts();
         $myfocus->retrieve_entity_info($mycrmid, "Accounts");
     } elseif ($pmodule == 'Leads') {
         require_once 'modules/Leads/Leads.php';
         $myfocus = new Leads();
         $myfocus->retrieve_entity_info($mycrmid, "Leads");
     } elseif ($pmodule == 'Vendors') {
         require_once 'modules/Vendors/Vendors.php';
         $myfocus = new Vendors();
         $myfocus->retrieve_entity_info($mycrmid, "Vendors");
     } else {
         // vtlib customization: Enabling mail send from other modules
         $myfocus = CRMEntity::getInstance($pmodule);
         $myfocus->retrieve_entity_info($mycrmid, $pmodule);
         // END
     }
     $fldname = $adb->query_result($fresult, 0, "columnname");
     $emailadd = br2nl($myfocus->column_fields[$fldname]);
     //This is to convert the html encoded string to original html entities so that in mail description contents will be displayed correctly
     //$focus->column_fields['description'] = from_html($focus->column_fields['description']);
예제 #21
0
global $app_strings;
global $current_user;
global $list_max_entries_per_page;
$log = LoggerManager::getLogger('contact_list');
global $currentModule;
global $theme;
// Get _dom arrays from Database
$comboFieldNames = array('leadstatus' => 'leadstatus_dom');
$comboFieldArray = getComboArray($comboFieldNames);
$category = getParentTab();
if (!isset($where)) {
    $where = "";
}
$url_string = '';
// assigning http url string
$focus = new Leads();
// Initialize sort by fields
$focus->initSortbyField('Leads');
// END
$smarty = new vtigerCRM_Smarty();
$other_text = array();
if (!$_SESSION['lvs'][$currentModule]) {
    unset($_SESSION['lvs']);
    $modObj = new ListViewSession();
    $modObj->sorder = $sorder;
    $modObj->sortby = $order_by;
    $_SESSION['lvs'][$currentModule] = get_object_vars($modObj);
}
if ($_REQUEST['errormsg'] != '') {
    $errormsg = vtlib_purify($_REQUEST['errormsg']);
    $smarty->assign("ERROR", "The User does not have permission to Change/Delete " . $errormsg . " " . $currentModule);
예제 #22
0
function get_leads_columns($user_name, $session)
{
    if (!validateSession($user_name, $session)) {
        return null;
    }
    global $current_user, $log;
    require_once "modules/Users/Users.php";
    $seed_user = new Users();
    $user_id = $seed_user->retrieve_user_id($user_name);
    $current_user = $seed_user;
    $current_user->retrieve_entity_info($user_id, 'Users');
    if (isPermitted("Leads", "index") == "yes") {
        require_once 'modules/Leads/Leads.php';
        $lead = new Leads();
        $log->debug($lead->getColumnNames_Lead());
        return $lead->getColumnNames_Lead();
    } else {
        $return_array = array();
        return $return_array;
    }
}
예제 #23
0
    /**
     * Static function to display form for the field type
     * @param string $name
     * @param string $value
     * @param string $css
     * @return html for the form containing the field
     */
    public static function display_field($name, $value = '', $css = '')
    {
        $html = '';
        $display_val = '';
        if ((int) $value > 0) {
            $object = new Leads();
            $retrun_fields = $object->popup_selection_return_field;
            $retrun_field_list = explode(",", $retrun_fields);
            $object->query("select " . $retrun_fields . " from leads where idleads = ?", array($value));
            if ($object->getNumRows() > 0) {
                $object->next();
                $cnt_return_fields = 0;
                foreach ($retrun_field_list as $retrun_fields) {
                    if ($cnt_return_fields > 0) {
                        $display_val .= ' ';
                    }
                    $display_val .= $object->{$retrun_fields};
                    $cnt_return_fields++;
                }
            }
        }
        $special_field = false;
        if (preg_match("/:::/", $name)) {
            $name_explode = explode(':::', $name);
            $name = 'lead_' . $name_explode[1];
            $special_field = true;
        }
        $html .= '<input type="text" class = "' . $css . '" name="lead_' . $name . '" id="lead_' . $name . '" value="' . $display_val . '" readonly>';
        $html .= '&nbsp;&nbsp;<a href="#"  id="select_' . $name . '"  class="btn btn-primary btn-mini"><i class="icon-white icon-plus-sign"></i></a>';
        $html .= '&nbsp;&nbsp;<a href="#" id="remove_' . $name . '" class="btn btn-primary btn-mini"><i class="icon-white icon-remove"></i></a>';
        $html .= '<input type="hidden" name="' . $name . '" id="' . $name . '" value="' . $value . '">';
        $html .= "\n" . '<script>';
        // add icon click function
        $html .= '$(\'#select_' . $name . '\').click(function(){ ';
        if ($special_field === true) {
            $html .= 'var href = \'/popups/listdata_popup_modal?m=Leads&action=list&fielddisp=lead&special_field=yes&special_field_name=' . $name_explode[1] . '&fieldname=' . $name . '\';';
        } else {
            $html .= 'var href = \'/popups/listdata_popup_modal?m=Leads&action=list&fielddisp=lead&fieldname=' . $name . '\';';
        }
        $html .= "\n" . ' 
		if (href.indexOf(\'#\') == 0) {
				$(href).modal(\'open\');
		} else {
			$.get(href, function(data) {
				//ugly heck to prevent the content getting append when opening the same modal multiple time
				$("#listdata_popup_selector").html(\'\'); 
				$("#listdata_popup_selector").attr("id","ugly_heck");
				$(\'<div class="modal hide fade in" id="listdata_popup_selector" style="width:700px;">\' + data + \'</div>\').modal();
			}).success(function() { $(\'input:text:visible:first\').focus(); });
		}
		';
        $html .= "\n" . '});';
        // click function ends here
        // remove icon click function
        if ($special_field === true) {
            $html .= "\n" . '$(\'#remove_' . $name . '\').click( function(){
					$("#lead_' . $name . '").attr(\'value\',\'\');
					$("#' . $name . '").attr(\'value\',\'\');
					$("#' . $name_explode[1] . '").attr(\'value\',\'\');
			});';
        } else {
            $html .= "\n" . '$(\'#remove_' . $name . '\').click( function(){
				$("#lead_' . $name . '").attr(\'value\',\'\');
				$("#' . $name . '").attr(\'value\',\'\');
			});';
        }
        // remove icon click function ends here
        $html .= '</script>';
        if ($special_field === true) {
            return $html;
        } else {
            echo $html;
        }
    }
예제 #24
0
function AddLead($user_name, $first_name, $last_name, $email_address, $account_name, $salutation, $title, $phone_mobile, $reports_to, $primary_address_street, $website, $primary_address_city, $primary_address_state, $primary_address_postalcode, $primary_address_country, $alt_address_city, $alt_address_street, $alt_address_state, $alt_address_postalcode, $alt_address_country, $office_phone = "", $home_phone = "", $fax = "", $department = "", $password, $description = "")
{
    if (authentication($user_name, $password)) {
        global $adb;
        global $current_user;
        require_once 'modules/Users/Users.php';
        require_once 'modules/Leads/Leads.php';
        $seed_user = new Users();
        $user_id = $seed_user->retrieve_user_id($user_name);
        $current_user = $seed_user;
        $current_user->retrieve_entity_info($user_id, "Users");
        checkFileAccessForInclusion('user_privileges/user_privileges_' . $current_user->id . '.php');
        require 'user_privileges/user_privileges_' . $current_user->id . '.php';
        checkFileAccessForInclusion('user_privileges/sharing_privileges_' . $current_user->id . '.php');
        require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
        if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) {
            $sql1 = "select fieldname,columnname from vtiger_field where tabid=7 and block <> 14 and vtiger_field.presence in (0,2)";
            $params1 = array();
        } else {
            $profileList = getCurrentUserProfileList();
            $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=7 and vtiger_field.block <> 14 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_field.presence in (0,2)";
            $params1 = array();
            if (count($profileList) > 0) {
                $sql1 .= " and vtiger_profile2field.profileid in (" . generateQuestionMarks($profileList) . ")";
                array_push($params1, $profileList);
            }
        }
        $result1 = $adb->pquery($sql1, $params1);
        for ($i = 0; $i < $adb->num_rows($result1); $i++) {
            $permitted_lists[] = $adb->query_result($result1, $i, 'fieldname');
        }
        $Lead = new Leads();
        $Lead->column_fields[firstname] = in_array('firstname', $permitted_lists) ? $first_name : "";
        $Lead->column_fields[lastname] = in_array('lastname', $permitted_lists) ? $last_name : "";
        $Lead->column_fields[company] = in_array('company', $permitted_lists) ? $account_name : "";
        $Lead->column_fields[email] = in_array('email', $permitted_lists) ? $email_address : "";
        $Lead->column_fields[title] = in_array('title', $permitted_lists) ? $title : "";
        $Lead->column_fields[designation] = in_array('designation', $permitted_lists) ? $department : "";
        $Lead->column_fields[phone] = in_array('phone', $permitted_lists) ? $office_phone : "";
        $Lead->column_fields[homephone] = in_array('homephone', $permitted_lists) ? $home_phone : "";
        $Lead->column_fields[website] = in_array('website', $permitted_lists) ? $website : "";
        $Lead->column_fields[fax] = in_array('fax', $permitted_lists) ? $fax : "";
        $Lead->column_fields[mobile] = in_array('mobile', $permitted_lists) ? $phone_mobile : "";
        $Lead->column_fields[mailingstreet] = in_array('mailingstreet', $permitted_lists) ? $primary_address_street : "";
        $Lead->column_fields[mailingcity] = in_array('mailingcity', $permitted_lists) ? $primary_address_city : "";
        $Lead->column_fields[mailingstate] = in_array('mailingstate', $permitted_lists) ? $primary_address_state : "";
        $Lead->column_fields[mailingzip] = in_array('mailingzip', $permitted_lists) ? $primary_address_postalcode : "";
        $Lead->column_fields[workCountry] = in_array('mailingcountry', $permitted_lists) ? $workCountry : "";
        $Lead->column_fields[lane] = in_array('lane', $permitted_lists) ? $alt_address_street : "";
        $Lead->column_fields[city] = in_array('city', $permitted_lists) ? $alt_address_city : "";
        $Lead->column_fields[state] = in_array('state', $permitted_lists) ? $alt_address_state : "";
        $Lead->column_fields[code] = in_array('code', $permitted_lists) ? $alt_address_postalcode : "";
        $Lead->column_fields[country] = in_array('country', $permitted_lists) ? $alt_address_country : "";
        $Lead->column_fields[assigned_user_id] = in_array('assigned_user_id', $permitted_lists) ? $user_id : "";
        $Lead->column_fields[description] = "";
        //	$log->fatal($Lead->column_fields);
        $Lead->save("Leads");
        $Lead = $Lead;
        return $Lead->id;
    }
}
예제 #25
0
    } elseif (strpos($_POST['user_photo_id'], 'price') === 0) {
        $update['photo_id'] = str_replace('price-', '', $_POST['user_photo_id']);
        $update['photo_title'] = $_POST['title'];
        //echo 'editing type: ';
        echo $photos->updatePhotoPrice($update);
    } else {
        echo 'nothing going on ';
    }
    // paypal_url
    //echo 'The photo: '.$update['photo_id'].' will be updated to '.$update['photo_title'];
}
// ------------------------------------------------------------ //
// 		UPDATE LEADS SCRIPT
// ------------------------------------------------------------ //
if (isset($_POST['lead_script_id'])) {
    $leads = new Leads();
    if (strpos($_POST['lead_script_id'], 'lead-script') === 0) {
        $arr = explode('-', str_replace('lead-script-', '', $_POST['lead_script_id']));
        $update['table_col'] = $arr[0];
        $update['row_id'] = $arr[1];
        //$update['row_id'] = str_replace('title-', '', $_POST['title']) ;
        $update['user_title'] = $_POST['title'];
        $update['db_table'] = 'script';
        //echo 'editing TITLE: ';
        //echo $photos->updateUserEmail($update);
        //print_r($_POST);
        //echo '<hr>';
        echo $leads->updateDB($update);
    }
    // print_r($update);
    // exit;