Skip to content
Permalink
287780a61f
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
226 lines (206 sloc) 10.6 KB
<?php
/*+**********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
************************************************************************************/
global $app_strings, $mod_strings, $current_language, $currentModule, $theme, $adb;
require_once('Smarty_setup.php');
global $current_user;
$focus = CRMEntity::getInstance($currentModule);
$smarty = new vtigerCRM_Smarty();
// Identify this module as custom module.
$smarty->assign('CUSTOM_MODULE', $focus->IsCustomModule);
$category = getParentTab($currentModule);
$record = isset($_REQUEST['record']) ? vtlib_purify($_REQUEST['record']) : null;
$isduplicate = isset($_REQUEST['isDuplicate']) ? vtlib_purify($_REQUEST['isDuplicate']) : null;
//added to fix the issue4600
$searchurl = getBasic_Advance_SearchURL();
$smarty->assign("SEARCH", $searchurl);
//4600 ends
if($record) {
$focus->id = $record;
$focus->mode = 'edit';
$focus->retrieve_entity_info($record, $currentModule);
$focus->firstname = $focus->column_fields['firstname'];
$focus->lastname = $focus->column_fields['lastname'];
}
//added for contact image
$errormessage = isset($_REQUEST['error_msg']) ? vtlib_purify($_REQUEST['error_msg']) : '';
if ($errormessage == 2) {
$errormessage = $mod_strings['LBL_MAXIMUM_LIMIT_ERROR'];
} else if ($errormessage == 3) {
$errormessage = $mod_strings['LBL_UPLOAD_ERROR'];
} else if ($errormessage == "image") {
$errormessage = $mod_strings['LBL_IMAGE_ERROR'];
} else if ($errormessage == "invalid") {
$errormessage = $mod_strings['LBL_INVALID_IMAGE'];
}
if ($errormessage != '') {
$smarty->assign("ERROR_MESSAGE", $errormessage);
}
if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '' && empty($record)) {
require_once('modules/Accounts/Accounts.php');
$focus->column_fields['account_id'] = vtlib_purify($_REQUEST['account_id']);
$acct_focus = new Accounts();
$acct_focus->retrieve_entity_info($focus->column_fields['account_id'], 'Accounts');
$focus->column_fields['fax'] = $acct_focus->column_fields['fax'];
$focus->column_fields['otherphone'] = $acct_focus->column_fields['phone'];
$focus->column_fields['mailingcity'] = $acct_focus->column_fields['bill_city'];
$focus->column_fields['othercity'] = $acct_focus->column_fields['ship_city'];
$focus->column_fields['mailingstreet'] = $acct_focus->column_fields['bill_street'];
$focus->column_fields['otherstreet'] = $acct_focus->column_fields['ship_street'];
$focus->column_fields['mailingstate'] = $acct_focus->column_fields['bill_state'];
$focus->column_fields['otherstate'] = $acct_focus->column_fields['ship_state'];
$focus->column_fields['mailingzip'] = $acct_focus->column_fields['bill_code'];
$focus->column_fields['otherzip'] = $acct_focus->column_fields['ship_code'];
$focus->column_fields['mailingcountry'] = $acct_focus->column_fields['bill_country'];
$focus->column_fields['othercountry'] = $acct_focus->column_fields['ship_country'];
$focus->column_fields['mailingpobox'] = $acct_focus->column_fields['bill_pobox'];
$focus->column_fields['otherpobox'] = $acct_focus->column_fields['ship_pobox'];
}
//needed when creating a new contact with a default account value passed in
if (isset($_REQUEST['account_name']) && empty($focus->account_name)) {
$focus->account_name = vtlib_purify($_REQUEST['account_name']);
}
if (isset($_REQUEST['account_id']) && empty($focus->account_id)) {
$focus->account_id = vtlib_purify($_REQUEST['account_id']);
}
if (isset($_REQUEST['campaignid']))
$smarty->assign('campaignid', vtlib_purify($_REQUEST['campaignid']));
$contact_name = (isset($focus->lastname) ? $focus->lastname : '');
if (getFieldVisibilityPermission($currentModule, $current_user->id, 'firstname') == '0') {
$contact_name .= ' ' . (isset($focus->firstname) ? $focus->firstname : '');
}
if($isduplicate == 'true') {
$focus->id = '';
$focus->mode = '';
$focus->column_fields['isduplicatedfromrecordid'] = $record; // in order to support duplicate workflows
$smarty->assign('__cbisduplicatedfromrecordid', $record);
}
$focus->preEditCheck($_REQUEST,$smarty);
if (!empty($_REQUEST['save_error']) and $_REQUEST['save_error'] == "true") {
if (!empty($_REQUEST['encode_val'])) {
global $current_user;
$encode_val = vtlib_purify($_REQUEST['encode_val']);
$decode_val = base64_decode($encode_val);
$explode_decode_val = explode('&', trim($decode_val,'&'));
$tabid = getTabid($currentModule);
foreach ($explode_decode_val as $fieldvalue) {
$value = explode("=", $fieldvalue);
$field_name_val = $value[0];
$field_value =urldecode($value[1]);
$finfo = VTCacheUtils::lookupFieldInfo($tabid, $field_name_val);
if ($finfo !== false) {
switch ($finfo['uitype']) {
case '56':
$field_value = $field_value=='on' ? '1' : '0';
break;
case '7':
case '9':
case '72':
$field_value = CurrencyField::convertToDBFormat($field_value, null, true);
break;
case '71':
$field_value = CurrencyField::convertToDBFormat($field_value);
break;
case '33':
case '3313':
case '3314':
if (is_array($field_value)) {
$field_value = implode(' |##| ', $field_value);
}
break;
}
}
$focus->column_fields[$field_name_val] = $field_value;
}
}
$errormessageclass = isset($_REQUEST['error_msgclass']) ? vtlib_purify($_REQUEST['error_msgclass']) : '';
$errormessage = isset($_REQUEST['error_msg']) ? vtlib_purify($_REQUEST['error_msg']) : '';
$smarty->assign('ERROR_MESSAGE_CLASS', $errormessageclass);
$smarty->assign('ERROR_MESSAGE', $errormessage);
} elseif($focus->mode != 'edit'){
setObjectValuesFromRequest($focus);
}
$smarty->assign('MASS_EDIT','0');
$disp_view = getView($focus->mode);
$blocks = getBlocks($currentModule, $disp_view, $focus->mode, $focus->column_fields);
$smarty->assign('BLOCKS', $blocks);
$basblocks = getBlocks($currentModule, $disp_view, $focus->mode, $focus->column_fields, 'BAS');
$smarty->assign('BASBLOCKS', $basblocks);
$advblocks = getBlocks($currentModule,$disp_view,$focus->mode,$focus->column_fields,'ADV');
$smarty->assign('ADVBLOCKS', $advblocks);
$custom_blocks = getCustomBlocks($currentModule,$disp_view);
$smarty->assign('CUSTOMBLOCKS', $custom_blocks);
$smarty->assign('FIELDS',$focus->column_fields);
$smarty->assign('OP_MODE',$disp_view);
$smarty->assign('APP', $app_strings);
$smarty->assign('MOD', $mod_strings);
$smarty->assign('MODULE', $currentModule);
$smarty->assign('SINGLE_MOD', 'SINGLE_'.$currentModule);
$smarty->assign('CATEGORY', $category);
$smarty->assign("THEME", $theme);
$smarty->assign('IMAGE_PATH', "themes/$theme/images/");
$smarty->assign('ID', $focus->id);
$smarty->assign('MODE', $focus->mode);
$smarty->assign('CREATEMODE', isset($_REQUEST['createmode']) ? vtlib_purify($_REQUEST['createmode']) : '');
$smarty->assign('CHECK', Button_Check($currentModule));
$smarty->assign('DUPLICATE', $isduplicate);
$smarty->assign('NAME', $contact_name);
if($focus->mode == 'edit' || $isduplicate == 'true') {
$smarty->assign('UPDATEINFO',updateInfo($record));
}
if(isset($_REQUEST['return_module'])) $smarty->assign("RETURN_MODULE", vtlib_purify($_REQUEST['return_module']));
if(isset($_REQUEST['return_action'])) $smarty->assign("RETURN_ACTION", vtlib_purify($_REQUEST['return_action']));
if(isset($_REQUEST['return_id'])) $smarty->assign("RETURN_ID", vtlib_purify($_REQUEST['return_id']));
if (isset($_REQUEST['return_viewname'])) $smarty->assign("RETURN_VIEWNAME", vtlib_purify($_REQUEST['return_viewname']));
$upload_maxsize = GlobalVariable::getVariable('Application_Upload_MaxSize',3000000,$currentModule);
$smarty->assign("UPLOADSIZE", $upload_maxsize/1000000); //Convert to MB
$smarty->assign("UPLOAD_MAXSIZE",$upload_maxsize);
// Field Validation Information
$tabid = getTabid($currentModule);
$validationData = getDBValidationData($focus->tab_name,$tabid);
$validationArray = split_validationdataArray($validationData);
$smarty->assign("VALIDATION_DATA_FIELDNAME",$validationArray['fieldname']);
$smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$validationArray['datatype']);
$smarty->assign("VALIDATION_DATA_FIELDLABEL",$validationArray['fieldlabel']);
// In case you have a date field
$smarty->assign("CALENDAR_LANG", $app_strings['LBL_JSCALENDAR_LANG']);
$smarty->assign("CALENDAR_DATEFORMAT", parse_calendardate($app_strings['NTC_DATE_FORMAT']));
// Module Sequence Numbering
$mod_seq_field = getModuleSequenceField($currentModule);
if($focus->mode != 'edit' && $mod_seq_field != null) {
$autostr = getTranslatedString('MSG_AUTO_GEN_ON_SAVE');
list($mod_seq_string, $mod_seq_prefix, $mod_seq_no, $doNative) = cbEventHandler::do_filter('corebos.filter.ModuleSeqNumber.get', array('', '', '', true));
if ($doNative) {
$mod_seq_string = $adb->pquery("SELECT prefix, cur_id from vtiger_modentity_num where semodule = ? and active=1",array($currentModule));
$mod_seq_prefix = $adb->query_result($mod_seq_string,0,'prefix');
$mod_seq_no = $adb->query_result($mod_seq_string,0,'cur_id');
}
if ($adb->num_rows($mod_seq_string) == 0 || $focus->checkModuleSeqNumber($focus->table_name, $mod_seq_field['column'], $mod_seq_prefix.$mod_seq_no)) {
$smarty->assign('ERROR_MESSAGE_CLASS', 'cb-alert-warning');
$smarty->assign('ERROR_MESSAGE', '<b>'. getTranslatedString($mod_seq_field['label']). ' '. getTranslatedString('LBL_NOT_CONFIGURED')
.' - '. getTranslatedString('LBL_PLEASE_CLICK') .' <a href="index.php?module=Settings&action=CustomModEntityNo&parenttab=Settings&selmodule='.$currentModule.'">'.getTranslatedString('LBL_HERE').'</a> '
. getTranslatedString('LBL_TO_CONFIGURE'). ' '. getTranslatedString($mod_seq_field['label']) .'</b>');
} else {
$smarty->assign("MOD_SEQ_ID",$autostr);
}
} else {
if (!empty($mod_seq_field) and !empty($mod_seq_field['name']) and !empty($focus->column_fields[$mod_seq_field['name']])) {
$smarty->assign('MOD_SEQ_ID', $focus->column_fields[$mod_seq_field['name']]);
} else {
$smarty->assign('MOD_SEQ_ID', '');
}
}
// Gather the help information associated with fields
$smarty->assign('FIELDHELPINFO', vtlib_getFieldHelpInfo($currentModule));
$picklistDependencyDatasource = Vtiger_DependencyPicklist::getPicklistDependencyDatasource($currentModule);
$smarty->assign("PICKIST_DEPENDENCY_DATASOURCE", json_encode($picklistDependencyDatasource));
//Show or not the Header to copy address to left or right
$smarty->assign('SHOW_COPY_ADDRESS', GlobalVariable::getVariable('Application_Show_Copy_Address', 1, $currentModule, $current_user->id));
$smarty->display("salesEditView.tpl");
?>