更新到 5.2 正式版后第一次 SVN 提交。
[email protected] git-svn-id: https://svn.code.sf.net/p/hawebs/svn@611 a2543c7e-f6e9-4f8a-8bff-1ffc34733512
This commit is contained in:
@@ -0,0 +1,259 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* The contents of this file are subject to the SugarCRM Public License Version 1.1.2
|
||||
* ("License"); You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
|
||||
* 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): ______________________________________.
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
* $Header$
|
||||
* Description: Contains a variety of utility functions used to display UI
|
||||
* components such as form vtiger_headers and footers. Intended to be modified on a per
|
||||
* theme basis.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
function get_validate_import_fields_js (&$req_fields,&$all_fields)
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
$err_multiple = $mod_strings['ERR_MULTIPLE'];
|
||||
$err_required = $mod_strings['ERR_MISSING_REQUIRED_FIELDS'];
|
||||
$err_select_full_name = $mod_strings['ERR_SELECT_FULL_NAME'];
|
||||
$print_required_array = "";
|
||||
|
||||
foreach ($req_fields as $required=>$unused)
|
||||
{
|
||||
$print_required_array .= "required['$required'] = '". $all_fields[$required] . "';\n";
|
||||
|
||||
}
|
||||
|
||||
$the_script = <<<EOQ
|
||||
|
||||
<script type="text/javascript" language="Javascript">
|
||||
<!-- to hide script contents from old browsers
|
||||
|
||||
function verify_data(form)
|
||||
{
|
||||
var isError = false;
|
||||
var errorMessage = "";
|
||||
|
||||
var hash = new Object();
|
||||
|
||||
var required = new Object();
|
||||
|
||||
$print_required_array
|
||||
|
||||
for(i=0;i < form.length;i++)
|
||||
{
|
||||
if ( form.elements[i].name.indexOf("colnum",0) == 0)
|
||||
{
|
||||
|
||||
if ( form.elements[i].value == "-1")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( hash[ form.elements[i].value ] == 1)
|
||||
{
|
||||
// got same vtiger_field more than once
|
||||
isError = true;
|
||||
}
|
||||
hash[form.elements[i].value] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (isError == true)
|
||||
{
|
||||
alert( "$err_multiple" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hash['full_name'] == 1 && (hash['last_name'] == 1 || hash['first_name'] == 1) )
|
||||
{
|
||||
alert( "$err_select_full_name" );
|
||||
return false;
|
||||
}
|
||||
|
||||
for(var vtiger_field_name in required)
|
||||
{
|
||||
// contacts hack to bypass errors if full_name is set
|
||||
if (field_name == 'last_name' &&
|
||||
hash['full_name'] == 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( hash[ vtiger_field_name ] != 1 )
|
||||
{
|
||||
isError = true;
|
||||
errorMessage += "$err_required " + required[field_name];
|
||||
}
|
||||
}
|
||||
|
||||
if (isError == true)
|
||||
{
|
||||
alert( errorMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// end hiding contents from old browsers -->
|
||||
</script>
|
||||
|
||||
EOQ;
|
||||
|
||||
return $the_script;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function get_validate_upload_js ()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
$err_missing_required_fields = $mod_strings['ERR_MISSING_REQUIRED_FIELDS'];
|
||||
$lbl_select_file = $mod_strings['ERR_SELECT_FILE'];
|
||||
$lbl_custom = $mod_strings['LBL_CUSTOM'];
|
||||
|
||||
$the_script = <<<EOQ
|
||||
|
||||
<script type="text/javascript" language="Javascript">
|
||||
<!-- to hide script contents from old browsers
|
||||
|
||||
function verify_data(form)
|
||||
{
|
||||
var isError = false;
|
||||
var errorMessage = "";
|
||||
if (form.userfile.value == "")
|
||||
{
|
||||
isError = true;
|
||||
errorMessage += "\\n$lbl_select_file";
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i=0;i < form.delimiter.length;i++)
|
||||
{
|
||||
if ( form.delimiter[i].value == "custom"
|
||||
&& form.delimiter[i].checked == true
|
||||
&& form.custom_delim.value == "")
|
||||
{
|
||||
isError = true;
|
||||
errorMessage += "\\n$lbl_custom";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isError == true)
|
||||
{
|
||||
alert("$err_missing_required_fields" + errorMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// end hiding contents from old browsers -->
|
||||
</script>
|
||||
|
||||
EOQ;
|
||||
|
||||
return $the_script;
|
||||
}
|
||||
|
||||
/** function used to form the combo values with the available importable fields
|
||||
* @param array reference &$column_fields - reference of the column fields which will be like lastname=>1, etc where as the key is the field name based on the import module and value is 1
|
||||
* @param int $colnum - column number
|
||||
* @param array reference &$required_fields - required fields of the import module
|
||||
* @param string $suggest_field - field to show as selected in the combo box
|
||||
* @param array $translated_fields - list of fields which are available to map
|
||||
* @param string $module - tablename for the import module
|
||||
* @return picklist $output - return the combo box ie., picklist with the fields which are available to map
|
||||
*/
|
||||
function getFieldSelect(&$column_fields,$colnum,&$required_fields,$suggest_field,$translated_fields,$module)
|
||||
{
|
||||
global $mod_strings;
|
||||
global $app_strings;
|
||||
global $outlook_contacts_field_map;
|
||||
require_once('include/database/PearDatabase.php');
|
||||
global $adb;
|
||||
|
||||
$output = "<select class=\"small\" id=\"colnum" . $colnum ."\" name=\"colnum" . $colnum ."\">\n";
|
||||
$output .= "<option value=\"-1\">". $mod_strings['LBL_DONT_MAP'] . "</option>";
|
||||
|
||||
$count = 0;
|
||||
$req_mark = "";
|
||||
|
||||
require_once("include/database/PearDatabase.php");
|
||||
|
||||
$adb->println("Field select");
|
||||
$adb->println($translated_fields);
|
||||
|
||||
asort($translated_fields);
|
||||
|
||||
foreach ($translated_fields as $field=>$name){
|
||||
if (! isset($column_fields[$field])){
|
||||
continue;
|
||||
}
|
||||
$output .= "<option value=\"".$field;
|
||||
|
||||
if ( isset( $suggest_field) && $field == $suggest_field){
|
||||
$output .= "\" SELECTED>";
|
||||
}else{
|
||||
$output .= "\">";
|
||||
}
|
||||
|
||||
if ( isset( $required_fields[$field])){
|
||||
$req_mark = " ". $app_strings['LBL_REQUIRED_SYMBOL'];
|
||||
}else{
|
||||
$req_mark = "";
|
||||
}
|
||||
|
||||
$output .= $name . $req_mark."</option>\n";
|
||||
$count ++;
|
||||
}
|
||||
|
||||
$output .= "</select>\n";
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
function get_readonly_js ()
|
||||
{
|
||||
?>
|
||||
<script type="text/javascript" language="Javascript">
|
||||
<!-- to hide script contents from old browsers
|
||||
|
||||
function set_readonly(form){
|
||||
if (form.save_map.checked){
|
||||
form.save_map.value='on';
|
||||
form.save_map_as.readOnly=false;
|
||||
form.save_map_as.focus();
|
||||
}else{
|
||||
form.save_map.value='off';
|
||||
form.save_map_as.value="";
|
||||
form.save_map_as.readOnly=true;
|
||||
}
|
||||
}
|
||||
|
||||
// end hiding contents from old browsers -->
|
||||
</script>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,217 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* The contents of this file are subject to the SugarCRM Public License Version 1.1.2
|
||||
* ("License"); You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
|
||||
* 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): ______________________________________.
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
* $Header$
|
||||
* Description: Defines the Account SugarBean Account entity with the necessary
|
||||
* methods and variables.
|
||||
********************************************************************************/
|
||||
|
||||
include_once('config.php');
|
||||
require_once('include/logging.php');
|
||||
require_once('include/database/PearDatabase.php');
|
||||
require_once('data/SugarBean.php');
|
||||
require_once('modules/Contacts/Contacts.php');
|
||||
require_once('modules/Potentials/Potentials.php');
|
||||
require_once('modules/Documents/Documents.php');
|
||||
require_once('modules/Emails/Emails.php');
|
||||
require_once('modules/Accounts/Accounts.php');
|
||||
require_once('include/ComboUtil.php');
|
||||
|
||||
// Account is used to store vtiger_account information.
|
||||
class ImportAccount extends Accounts {
|
||||
var $db;
|
||||
|
||||
// Get _dom arrays from Database
|
||||
//$comboFieldNames = Array('accounttype'=>'account_type_dom'
|
||||
// ,'industry'=>'industry_dom');
|
||||
//$comboFieldArray = getComboArray($comboFieldNames);
|
||||
|
||||
|
||||
// This is the list of vtiger_fields that are required.
|
||||
var $required_fields = array("accountname"=>1);
|
||||
|
||||
// This is the list of the functions to run when importing
|
||||
var $special_functions = array(
|
||||
"map_member_of","modseq_number",
|
||||
//"add_billing_address_streets"
|
||||
//,"add_shipping_address_streets"
|
||||
//,"fix_website"
|
||||
);
|
||||
|
||||
/*
|
||||
function fix_website()
|
||||
{
|
||||
if ( isset($this->website) &&
|
||||
preg_match("/^http:\/\//",$this->website) )
|
||||
{
|
||||
$this->website = substr($this->website,7);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function add_industry()
|
||||
{
|
||||
if ( isset($this->industry) &&
|
||||
! isset( $comboFieldArray['industry_dom'][$this->industry]))
|
||||
{
|
||||
unset($this->industry);
|
||||
}
|
||||
}
|
||||
|
||||
function add_type()
|
||||
{
|
||||
if ( isset($this->type) &&
|
||||
! isset($comboFieldArray['account_type_dom'][$this->type]))
|
||||
{
|
||||
unset($this->type);
|
||||
}
|
||||
}
|
||||
|
||||
function add_billing_address_streets()
|
||||
{
|
||||
if ( isset($this->billing_address_street_2))
|
||||
{
|
||||
$this->billing_address_street .=
|
||||
" ". $this->billing_address_street_2;
|
||||
}
|
||||
|
||||
if ( isset($this->billing_address_street_3))
|
||||
{
|
||||
$this->billing_address_street .=
|
||||
" ". $this->billing_address_street_3;
|
||||
}
|
||||
if ( isset($this->billing_address_street_4))
|
||||
{
|
||||
$this->billing_address_street .=
|
||||
" ". $this->billing_address_street_4;
|
||||
}
|
||||
}
|
||||
|
||||
function add_shipping_address_streets()
|
||||
{
|
||||
if ( isset($this->shipping_address_street_2))
|
||||
{
|
||||
$this->shipping_address_street .=
|
||||
" ". $this->shipping_address_street_2;
|
||||
}
|
||||
|
||||
if ( isset($this->shipping_address_street_3))
|
||||
{
|
||||
$this->shipping_address_street .=
|
||||
" ". $this->shipping_address_street_3;
|
||||
}
|
||||
|
||||
if ( isset($this->shipping_address_street_4))
|
||||
{
|
||||
$this->shipping_address_street .=
|
||||
" ". $this->shipping_address_street_4;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// This is the list of vtiger_fields that are importable.
|
||||
// some if these do not map directly to database columns
|
||||
/*var $importable_fields = Array(
|
||||
"id"=>1
|
||||
,"name"=>1
|
||||
,"website"=>1
|
||||
,"industry"=>1
|
||||
,"account_type"=>1
|
||||
,"ticker_symbol"=>1
|
||||
,"parent_name"=>1
|
||||
,"employees"=>1
|
||||
,"ownership"=>1
|
||||
,"phone_office"=>1
|
||||
,"phone_fax"=>1
|
||||
,"phone_alternate"=>1
|
||||
,"email1"=>1
|
||||
,"email2"=>1
|
||||
,"rating"=>1
|
||||
,"sic_code"=>1
|
||||
,"annual_revenue"=>1
|
||||
,"billing_address_street"=>1
|
||||
,"billing_address_street_2"=>1
|
||||
,"billing_address_street_3"=>1
|
||||
,"billing_address_street_4"=>1
|
||||
,"billing_address_city"=>1
|
||||
,"billing_address_state"=>1
|
||||
,"billing_address_postalcode"=>1
|
||||
,"billing_address_country"=>1
|
||||
,"shipping_address_street"=>1
|
||||
,"shipping_address_street_2"=>1
|
||||
,"shipping_address_street_3"=>1
|
||||
,"shipping_address_street_4"=>1
|
||||
,"shipping_address_city"=>1
|
||||
,"shipping_address_state"=>1
|
||||
,"shipping_address_postalcode"=>1
|
||||
,"shipping_address_country"=>1
|
||||
,"description"=>1
|
||||
);
|
||||
*/
|
||||
|
||||
var $importable_fields = Array();
|
||||
|
||||
/** 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 ImportAccount() {
|
||||
parent::Accounts();
|
||||
$this->log = LoggerManager::getLogger('import_account');
|
||||
$this->db = PearDatabase::getInstance();
|
||||
$this->db->println("IMP ImportAccount");
|
||||
$this->initImportableFields("Accounts");
|
||||
|
||||
$this->db->println($this->importable_fields);
|
||||
}
|
||||
|
||||
/** function used to map with existing Mamber Of(Account) if the account is map with an member of during import
|
||||
*/
|
||||
function map_member_of()
|
||||
{
|
||||
global $adb;
|
||||
|
||||
$account_name = $this->column_fields['account_id'];
|
||||
$adb->println("Entering map_member_of account_id=".$account_name);
|
||||
|
||||
if ((! isset($account_name) || $account_name == '') )
|
||||
{
|
||||
$adb->println("Exit map_member_of. Account Name(Member Of) not set for this entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
$account_name = trim($account_name);
|
||||
|
||||
//Query to get the available Account which is not deleted
|
||||
$query = "select accountid from vtiger_account inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid WHERE vtiger_account.accountname=? and vtiger_crmentity.deleted=0";
|
||||
$account_id = $adb->query_result($adb->pquery($query, array($account_name)),0,'accountid');
|
||||
|
||||
if($account_id == '' || !isset($account_id))
|
||||
$account_id = 0;
|
||||
|
||||
$this->column_fields['account_id'] = $account_id;
|
||||
|
||||
$adb->println("Exit map_member_of. Fetched Account for '".$account_name."' and the account_id = $account_id");
|
||||
}
|
||||
|
||||
// Module Sequence Numbering
|
||||
function modseq_number() {
|
||||
$this->column_fields['account_no'] = '';
|
||||
}
|
||||
// END
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,82 @@
|
||||
<?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.
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
require_once('Smarty_setup.php');
|
||||
include('modules/Import/ImportMap.php');
|
||||
include('modules/Import/Forms.php');
|
||||
|
||||
//This is to delete the map
|
||||
|
||||
if($_REQUEST['ajax_action'] == 'check_dup_map_name')
|
||||
{
|
||||
$map_name=$_REQUEST['name'];
|
||||
global $adb;
|
||||
$query="select * from vtiger_import_maps where deleted=0 and name=?";
|
||||
$Result = $adb->pquery($query, array($map_name));
|
||||
$noofrows = $adb->num_rows($Result);
|
||||
if($noofrows > 0)
|
||||
echo "false"; //Map name already exists
|
||||
else
|
||||
echo "true";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if($_REQUEST['delete_map'] != '')
|
||||
{
|
||||
$query = "update vtiger_import_maps set deleted=1 where id = ?";
|
||||
$adb->pquery($query, array($_REQUEST['mapping']));
|
||||
}
|
||||
|
||||
$mapping_file = new ImportMap();
|
||||
$mapping_arr = $mapping_file->getSavedMappingContent($_REQUEST['mapping']);
|
||||
|
||||
$importable_fields = $_SESSION['import_module_object_column_fields'];
|
||||
$field_count = $_SESSION['import_module_field_count'];
|
||||
$required_fields = $_SESSION['import_module_object_required_fields'];
|
||||
$translated_column_fields = $_SESSION['import_module_translated_column_fields'];
|
||||
|
||||
$tablename = '';
|
||||
$has_header = $_SESSION['import_has_header'];
|
||||
$firstrow = $_SESSION['import_firstrow'];
|
||||
$field_map = &$mapping_arr;//$_SESSION['import_field_map'];
|
||||
$smarty_array1 = array();
|
||||
|
||||
for($i=0;$i<$field_count;$i++)
|
||||
{
|
||||
$suggest = '';
|
||||
if ($has_header && isset( $field_map[$firstrow[$i]] ) )
|
||||
{
|
||||
$suggest = $field_map[$firstrow[$i]];
|
||||
}
|
||||
else if (isset($field_map[$i]))
|
||||
{
|
||||
$suggest = $field_map[$i];
|
||||
}
|
||||
|
||||
$smarty_array1[$i+1] = getFieldSelect( $importable_fields,
|
||||
$i,
|
||||
$required_fields,
|
||||
$suggest,
|
||||
$translated_column_fields,
|
||||
$tablename
|
||||
);
|
||||
}
|
||||
|
||||
$smarty = new vtigerCRM_Smarty;
|
||||
$smarty->assign("FIRSTROW",$firstrow);
|
||||
$smarty->assign("SELECTFIELD",$smarty_array1);
|
||||
|
||||
$smarty->display('ImportMap.tpl');
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* The contents of this file are subject to the SugarCRM Public License Version 1.1.2
|
||||
* ("License"); You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
|
||||
* 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): ______________________________________.
|
||||
********************************************************************************/
|
||||
|
||||
global $mod_strings;
|
||||
global $allow_exports;
|
||||
|
||||
require_once('include/utils/UserInfoUtil.php');
|
||||
if ($_REQUEST['module'] == 'Products' ||
|
||||
$_REQUEST['module'] == 'Contacts' ||
|
||||
$_REQUEST['module'] == 'Potentials' ||
|
||||
$_REQUEST['module'] == 'Accounts' ||
|
||||
$_REQUEST['module'] == 'Leads')
|
||||
{
|
||||
if(isPermitted($_REQUEST['module'],'Import') == 0)
|
||||
{
|
||||
?>
|
||||
<li>
|
||||
<a href="index.php?module=<?php echo vtlib_purify($_REQUEST['module']); ?>&action=Import&step=1&return_module=<?php echo vtlib_purify($_REQUEST['module']); ?>&return_action=index"><?php echo $app_strings['LBL_IMPORT']; ?> <?php echo $mod_strings['LBL_MODULE_NAME']?></a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( $allow_exports=='all' ||
|
||||
( $allow_exports=='admin' && is_admin($current_user)) )
|
||||
{
|
||||
if($_REQUEST['module'] != 'Calendar')
|
||||
{
|
||||
if(isPermitted($_REQUEST['module'],'Export') == 'yes')
|
||||
{
|
||||
?>
|
||||
<li>
|
||||
<a href="index.php?module=<?php echo vtlib_purify($_REQUEST['module']); ?>&action=Export&all=1"><?php echo $app_strings['LBL_EXPORT_ALL']?> <?php echo $mod_strings['LBL_MODULE_NAME']?></a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* The contents of this file are subject to the SugarCRM Public License Version 1.1.2
|
||||
* ("License"); You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
|
||||
* 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): ______________________________________.
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
* $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Import/ImportLead.php,v 1.3 2005/03/05 05:41:09 jack Exp $
|
||||
* Description: Defines the Account SugarBean Account entity with the necessary
|
||||
* methods and variables.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
include_once('config.php');
|
||||
require_once('include/logging.php');
|
||||
require_once('include/database/PearDatabase.php');
|
||||
require_once('data/SugarBean.php');
|
||||
require_once('modules/Contacts/Contacts.php');
|
||||
require_once('modules/Potentials/Potentials.php');
|
||||
require_once('modules/Documents/Documents.php');
|
||||
require_once('modules/Emails/Emails.php');
|
||||
require_once('modules/Accounts/Accounts.php');
|
||||
require_once('include/ComboUtil.php');
|
||||
require_once('modules/Leads/Leads.php');
|
||||
|
||||
|
||||
class ImportLead extends Leads {
|
||||
var $db;
|
||||
|
||||
// This is the list of the functions to run when importing
|
||||
var $special_functions = array("assign_user", "modseq_number");
|
||||
|
||||
var $importable_fields = Array();
|
||||
|
||||
/** function used to set the assigned_user_id value in the column_fields when we map the username during import
|
||||
*/
|
||||
function assign_user()
|
||||
{
|
||||
global $current_user;
|
||||
$ass_user = $this->column_fields["assigned_user_id"];
|
||||
$this->db->println("assign_user ".$ass_user." cur_user=".$current_user->id);
|
||||
|
||||
if( $ass_user != $current_user->id)
|
||||
{
|
||||
$this->db->println("searching and assigning ".$ass_user);
|
||||
|
||||
$result = $this->db->pquery("select id from vtiger_users where id = ? union select groupid as id from vtiger_groups where groupid = ?", array($ass_user, $ass_user));
|
||||
if($this->db->num_rows($result)!=1)
|
||||
{
|
||||
$this->db->println("not exact records setting current userid");
|
||||
$this->column_fields["assigned_user_id"] = $current_user->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$row = $this->db->fetchByAssoc($result, -1, false);
|
||||
if (isset($row['id']) && $row['id'] != -1)
|
||||
{
|
||||
$this->db->println("setting id as ".$row['id']);
|
||||
$this->column_fields["assigned_user_id"] = $row['id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->println("setting current userid");
|
||||
$this->column_fields["assigned_user_id"] = $current_user->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Module Sequence Numbering
|
||||
function modseq_number() {
|
||||
$this->column_fields['lead_no'] = '';
|
||||
}
|
||||
// END
|
||||
|
||||
/** 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);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* The contents of this file are subject to the SugarCRM Public License Version 1.1.2
|
||||
* ("License"); You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
|
||||
* 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): ______________________________________.
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
* Description: TODO: To be written.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
include_once('config.php');
|
||||
require_once('include/logging.php');
|
||||
require_once('include/database/PearDatabase.php');
|
||||
require_once('data/SugarBean.php');
|
||||
|
||||
// Contact is used to store customer information.
|
||||
class ImportMap extends SugarBean
|
||||
{
|
||||
var $log;
|
||||
var $db;
|
||||
|
||||
// Stored vtiger_fields
|
||||
var $id;
|
||||
var $name;
|
||||
var $module;
|
||||
var $content;
|
||||
var $has_header;
|
||||
var $deleted;
|
||||
var $date_entered;
|
||||
var $date_modified;
|
||||
var $assigned_user_id;
|
||||
var $is_published;
|
||||
|
||||
var $table_name = "vtiger_import_maps";
|
||||
var $table_index= 'id';
|
||||
var $object_name = "ImportMap";
|
||||
|
||||
var $tab_name_index = Array("import_maps"=>"id");
|
||||
var $new_schema = true;
|
||||
|
||||
var $column_fields = Array("id"
|
||||
,"name"
|
||||
,"module"
|
||||
,"content"
|
||||
,"has_header"
|
||||
,"deleted"
|
||||
,"date_entered"
|
||||
,"date_modified"
|
||||
,"assigned_user_id"
|
||||
,"is_published"
|
||||
);
|
||||
|
||||
/** Constructor
|
||||
*/
|
||||
function ImportMap()
|
||||
{
|
||||
$this->log = LoggerManager::getLogger('file');
|
||||
$this->db = PearDatabase::getInstance();
|
||||
}
|
||||
|
||||
/** function used to get the id, name, module and content as string
|
||||
* @return string Object:ImportMap id=$this->id name=$this->name module=$this->module content=$this->content
|
||||
*/
|
||||
function toString()
|
||||
{
|
||||
return "Object:ImportMap id=$this->id name=$this->name module=$this->module content=$this->content";
|
||||
}
|
||||
|
||||
/** function used to save the mapping
|
||||
* @param int $owner_id - user id who is the owner for this mapping
|
||||
* @param string $name - name of the mapping
|
||||
* @param string $module - module name in which we have saved the mapping
|
||||
* @param string $has_header - has_header value
|
||||
* @param string $content - all fields which are concatenated with & symbol
|
||||
* @return int $result - return 1 if the mapping contents updated
|
||||
*/
|
||||
function save_map( $owner_id, $name, $module, $has_header,$content )
|
||||
{
|
||||
$query_arr = array('assigned_user_id'=>$owner_id,'name'=>$name);
|
||||
|
||||
//$this->retrieve_by_string_fields($query_arr, false);
|
||||
|
||||
$result = 1;
|
||||
$this->assigned_user_id = $owner_id;
|
||||
|
||||
$this->name = $name;
|
||||
$this->module = $module;
|
||||
|
||||
$this->content = "".$this->db->getEmptyBlob()."";
|
||||
$this->has_header = $has_header;
|
||||
$this->deleted = 0;
|
||||
|
||||
//check whether this map name is already exist, if yes then overwrite the existing one, else create new
|
||||
$res = $this->db->pquery("select id from vtiger_import_maps where name=?", array(trim($name)));
|
||||
if($this->db->num_rows($res) > 0)
|
||||
{
|
||||
$this->id = $this->db->query_result($res,0,'id');
|
||||
}
|
||||
|
||||
$returnid = $this->save();
|
||||
|
||||
$this->db->updateBlob($this->table_name,"content","name='". $this->db->sql_escape_string($name)."' and module='".$module."'",$content);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/** function used to publish or unpublish the mapping
|
||||
* @param int $user_id - user id who is publishing the map
|
||||
* @param string $flag - yes or no
|
||||
* @return value - if flag is yes then update the db and return 1 otherwise return -1
|
||||
*/
|
||||
function mark_published($user_id,$flag)
|
||||
{
|
||||
$other_map = new ImportMap();
|
||||
|
||||
if ($flag == 'yes')
|
||||
{
|
||||
// if you are trying to publish your map
|
||||
// but there's another published map
|
||||
// by the same name
|
||||
|
||||
$query_arr = array('name'=>$this->name,
|
||||
'is_published'=>'yes');
|
||||
}
|
||||
else
|
||||
{
|
||||
// if you are trying to unpublish a map
|
||||
// but you own an unpublished map by the same name
|
||||
$query_arr = array('name'=>$this->name,
|
||||
'assigned_user_id'=>$user_id,
|
||||
'is_published'=>'no');
|
||||
}
|
||||
$other_map->retrieve_by_string_fields($query_arr, false);
|
||||
|
||||
if ( isset($other_map->id) )
|
||||
{
|
||||
//.. don't do it!
|
||||
return -1;
|
||||
}
|
||||
|
||||
$query = "UPDATE $this->table_name set is_published=?, assigned_user_id=? where id=?";
|
||||
$params = array($flag, $user_id, $this->id);
|
||||
$this->db->pquery($query,$params,true,"Error marking import map published: ");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/** function to retrieve all the column fields and set as properties
|
||||
* @param array $fields_array - fields array of the corresponding module
|
||||
* @return array $obj_arr - return an array which contains the retrieved column_field values as properties
|
||||
*/
|
||||
function retrieve_all_by_string_fields($fields_array)
|
||||
{
|
||||
$where_clause = $this->get_where($fields_array);
|
||||
$query = "SELECT * FROM $this->table_name $where_clause";
|
||||
$this->log->debug("Retrieve $this->object_name: ".$query);
|
||||
$result = & $this->db->query($query,true," Error: ");
|
||||
$obj_arr = array();
|
||||
|
||||
while ($row = $this->db->fetchByAssoc($result,-1,FALSE) )
|
||||
{
|
||||
$focus = new ImportMap();
|
||||
|
||||
foreach($this->column_fields as $field)
|
||||
{
|
||||
if(isset($row[$field]))
|
||||
{
|
||||
$focus->$field = $row[$field];
|
||||
}
|
||||
}
|
||||
array_push($obj_arr,$focus);
|
||||
}
|
||||
return $obj_arr;
|
||||
}
|
||||
|
||||
/** function used to get the list of saved mappings
|
||||
* @param string $module - module name which we currently importing
|
||||
* @return array $map_lists - return the list of mappings in the format of [id]=>name
|
||||
*/
|
||||
function getSavedMappingsList($module)
|
||||
{
|
||||
$query = "SELECT * FROM $this->table_name where module=? and deleted=0";
|
||||
$result = $this->db->pquery($query,array($module),true," Error: ");
|
||||
$map_lists = array();
|
||||
|
||||
while ($row = $this->db->fetchByAssoc($result,-1,FALSE) )
|
||||
{
|
||||
$map_lists[$row['id']] = $row['name'];
|
||||
}
|
||||
return $map_lists;
|
||||
}
|
||||
|
||||
/** function used to retrieve the mapping content for the passed mapid
|
||||
* @param int $mapid - mapid for the selected map
|
||||
* @return array $mapping_arr - return the array which contains the mapping_arr[name]=value from the content of the map
|
||||
*/
|
||||
function getSavedMappingContent($mapid)
|
||||
{
|
||||
$query = "SELECT * FROM $this->table_name where id=? and deleted=0";
|
||||
$result = $this->db->pquery($query,array($mapid),true," Error: ");
|
||||
$mapping_arr = array();
|
||||
|
||||
$pairs = split("&",$this->db->query_result($result,0,'content'));
|
||||
foreach ($pairs as $pair)
|
||||
{
|
||||
list($name,$value) = split("=",$pair);
|
||||
$mapping_arr["$name"] = $value;
|
||||
}
|
||||
|
||||
return $mapping_arr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* The contents of this file are subject to the SugarCRM Public License Version 1.1.2
|
||||
* ("License"); You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
|
||||
* 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): ______________________________________.
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
* $Header$
|
||||
* Description: Defines the Account SugarBean Account entity with the necessary
|
||||
* methods and variables.
|
||||
********************************************************************************/
|
||||
|
||||
include_once('config.php');
|
||||
require_once('include/logging.php');
|
||||
require_once('include/database/PearDatabase.php');
|
||||
require_once('data/SugarBean.php');
|
||||
require_once('modules/Contacts/Contacts.php');
|
||||
require_once('modules/Potentials/Potentials.php');
|
||||
require_once('modules/Documents/Documents.php');
|
||||
require_once('modules/Emails/Emails.php');
|
||||
require_once('modules/Accounts/Accounts.php');
|
||||
require_once('include/ComboUtil.php');
|
||||
|
||||
// Account is used to store vtiger_account information.
|
||||
class ImportOpportunity extends Potentials {
|
||||
var $db;
|
||||
|
||||
// This is the list of the functions to run when importing
|
||||
var $special_functions = array(
|
||||
"assign_user",
|
||||
"map_campaign_source",
|
||||
"modseq_number",
|
||||
);
|
||||
/** function used to set the assigned_user_id value in the column_fields when we map the username during import
|
||||
*/
|
||||
function assign_user()
|
||||
{
|
||||
global $current_user;
|
||||
$ass_user = $this->column_fields["assigned_user_id"];
|
||||
$this->db->println("assign_user ".$ass_user." cur_user=".$current_user->id);
|
||||
|
||||
if( $ass_user != $current_user->id)
|
||||
{
|
||||
$this->db->println("searching and assigning ".$ass_user);
|
||||
|
||||
$result = $this->db->pquery("select id from vtiger_users where id = ? union select groupid as id from vtiger_groups where groupid = ?", array($ass_user, $ass_user));
|
||||
if($this->db->num_rows($result)!=1)
|
||||
{
|
||||
$this->db->println("not exact records setting current userid");
|
||||
$this->column_fields["assigned_user_id"] = $current_user->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$row = $this->db->fetchByAssoc($result, -1, false);
|
||||
if (isset($row['id']) && $row['id'] != -1)
|
||||
{
|
||||
$this->db->println("setting id as ".$row['id']);
|
||||
$this->column_fields["assigned_user_id"] = $row['id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->println("setting current userid");
|
||||
$this->column_fields["assigned_user_id"] = $current_user->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/** function used to map with existing Campaign Source if the potential is map with an campaign during import
|
||||
*/
|
||||
function map_campaign_source(){
|
||||
global $adb;
|
||||
|
||||
$campaign_name = $this->column_fields['campaignid'];
|
||||
$adb->println("Entering map_campaign_source campaignid=".$campaign_name);
|
||||
|
||||
if ((! isset($campaign_name) || $campaign_name == '') ){
|
||||
$adb->println("Exit map_campaign_source. Campaign Name not set for this entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
$campaign_name = trim($campaign_name);
|
||||
|
||||
//Query to get the available campaign which is not deleted
|
||||
$query = "select campaignid from vtiger_campaign inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_campaign.campaignid WHERE vtiger_campaign.campaignname=? and vtiger_crmentity.deleted=0";
|
||||
|
||||
$campaignid = $adb->query_result($adb->pquery($query, array($campaign_name)),0,'campaignid');
|
||||
|
||||
if($campaignid == '' || !isset($campaignid)){
|
||||
$campaignid = 0;
|
||||
}
|
||||
|
||||
$this->column_fields['campaignid'] = $campaignid;
|
||||
$adb->println("Exit map_campaign_source. Fetched Campaign for '".$campaign_name."' and the campaignid = $campaignid");
|
||||
}
|
||||
|
||||
var $importable_fields = Array();
|
||||
|
||||
/** 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 ImportOpportunity() {
|
||||
parent::Potentials();
|
||||
$this->log = LoggerManager::getLogger('import_opportunity');
|
||||
$this->db = PearDatabase::getInstance();
|
||||
|
||||
$this->db->println("IMP ImportOpportunity");
|
||||
$this->initImportableFields("Potentials");
|
||||
$this->db->println($this->importable_fields);
|
||||
}
|
||||
|
||||
// Module Sequence Numbering
|
||||
function modseq_number() {
|
||||
$this->column_fields['potential_no'] = '';
|
||||
}
|
||||
// END
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* The contents of this file are subject to the SugarCRM Public License Version 1.1.2
|
||||
* ("License"); You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
|
||||
* 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): ______________________________________.
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
* $Header$
|
||||
* Description: Defines the Account SugarBean Account entity with the necessary
|
||||
* methods and variables.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
include_once('config.php');
|
||||
require_once('include/logging.php');
|
||||
require_once('include/database/PearDatabase.php');
|
||||
require_once('data/SugarBean.php');
|
||||
require_once('modules/Contacts/Contacts.php');
|
||||
require_once('modules/Potentials/Potentials.php');
|
||||
require_once('modules/Documents/Documents.php');
|
||||
require_once('modules/Emails/Emails.php');
|
||||
require_once('modules/Accounts/Accounts.php');
|
||||
require_once('modules/Products/Products.php');
|
||||
require_once('include/ComboUtil.php');
|
||||
require_once('modules/Leads/Leads.php');
|
||||
|
||||
|
||||
class ImportProduct extends Products {
|
||||
var $db;
|
||||
|
||||
// This is the list of the functions to run when importing
|
||||
var $special_functions = array(
|
||||
"assign_user",
|
||||
"map_vendor_name",
|
||||
"map_member_of",
|
||||
"modseq_number",
|
||||
);
|
||||
|
||||
var $importable_fields = Array();
|
||||
|
||||
/** function used to set the assigned_user_id value in the column_fields when we map the username during import
|
||||
*/
|
||||
function assign_user()
|
||||
{
|
||||
global $current_user;
|
||||
$ass_user = $this->column_fields["assigned_user_id"];
|
||||
$this->db->println("assign_user ".$ass_user." cur_user=".$current_user->id);
|
||||
|
||||
if( $ass_user != $current_user->id)
|
||||
{
|
||||
$this->db->println("searching and assigning ".$ass_user);
|
||||
|
||||
$result = $this->db->pquery("select id from vtiger_users where id = ?", array($ass_user));
|
||||
if($this->db->num_rows($result)!=1)
|
||||
{
|
||||
$this->db->println("not exact records setting current userid");
|
||||
$this->column_fields["assigned_user_id"] = $current_user->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$row = $this->db->fetchByAssoc($result, -1, false);
|
||||
if (isset($row['id']) && $row['id'] != -1)
|
||||
{
|
||||
$this->db->println("setting id as ".$row['id']);
|
||||
$this->column_fields["assigned_user_id"] = $row['id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->println("setting current userid");
|
||||
$this->column_fields["assigned_user_id"] = $current_user->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 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 ImportProduct() {
|
||||
parent::Products();
|
||||
$this->log = LoggerManager::getLogger('import_product');
|
||||
$this->db = PearDatabase::getInstance();
|
||||
$this->db->println("IMP ImportProduct");
|
||||
$this->initImportableFields("Products");
|
||||
$this->db->println($this->importable_fields);
|
||||
}
|
||||
|
||||
/** function used to map with existing Vendor if the product is map with an vendor during import
|
||||
*/
|
||||
function map_vendor_name()
|
||||
{
|
||||
global $adb;
|
||||
|
||||
$vendor_name = $this->column_fields['vendor_id'];
|
||||
$adb->println("Entering map_vendor_name vendor_id=".$vendor_name);
|
||||
|
||||
if ((! isset($vendor_name) || $vendor_name == '') )
|
||||
{
|
||||
$adb->println("Exit map_vendor_name. Vendor Name not set for this entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
$vendor_name = trim($vendor_name);
|
||||
|
||||
//Query to get the available Vendor which is not deleted
|
||||
$query = "select vendorid from vtiger_vendor inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_vendor.vendorid WHERE vtiger_vendor.vendorname=? and vtiger_crmentity.deleted=0";
|
||||
$vendor_id = $adb->query_result($adb->pquery($query, array($vendor_name)),0,'vendorid');
|
||||
|
||||
if($vendor_id == '' || !isset($vendor_id))
|
||||
$vendor_id = 0;
|
||||
|
||||
$this->column_fields['vendor_id'] = $vendor_id;
|
||||
|
||||
$adb->println("Exit map_vendor_name. Fetched Vendor for '".$vendor_name."' and the vendorid = $vendor_id");
|
||||
}
|
||||
|
||||
/** Function used to map with existing Member Of(Product) if the product is map with an member of during import
|
||||
*/
|
||||
function map_member_of()
|
||||
{
|
||||
global $adb;
|
||||
|
||||
$product_name = $this->column_fields['product_id'];
|
||||
$adb->println("Entering map_member_of product_id=".$product_name);
|
||||
|
||||
if ((! isset($product_name) || $product_name == '') )
|
||||
{
|
||||
$adb->println("Exit map_member_of. Product Name(Member Of) not set for this entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
$product_name = trim($product_name);
|
||||
|
||||
//Query to get the available Product which is not deleted
|
||||
$query = "select productid from vtiger_products inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_products.productid WHERE vtiger_products.productname=? and vtiger_crmentity.deleted=0";
|
||||
$product_id = $adb->query_result($adb->pquery($query, array($product_name)),0,'productid');
|
||||
|
||||
if($product_id == '' || !isset($product_id))
|
||||
$product_id = 0;
|
||||
|
||||
$this->column_fields['product_id'] = $product_id;
|
||||
|
||||
$adb->println("Exit map_member_of. Fetched Account for '".$product_name."' and the account_id = $product_id");
|
||||
}
|
||||
|
||||
//Module Sequence Numbering
|
||||
function modseq_number() {
|
||||
$this->column_fields['product_no'] = '';
|
||||
}
|
||||
// END
|
||||
}
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,104 @@
|
||||
<?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.
|
||||
*********************************************************************************/
|
||||
|
||||
require_once('Smarty_setup.php');
|
||||
require_once('modules/Import/ImportLead.php');
|
||||
require_once('modules/Import/ImportAccount.php');
|
||||
require_once('modules/Import/ImportContact.php');
|
||||
require_once('modules/Import/ImportOpportunity.php');
|
||||
require_once('modules/Import/ImportProduct.php');
|
||||
require_once('modules/Import/ImportMap.php');
|
||||
require_once('modules/Import/ImportTicket.php');
|
||||
require_once('modules/Import/ImportVendors.php');
|
||||
require_once('include/utils/CommonUtils.php');
|
||||
|
||||
global $mod_strings;
|
||||
global $app_strings;
|
||||
global $app_list_strings;
|
||||
global $current_user,$default_charset;
|
||||
|
||||
global $import_mod_strings;
|
||||
|
||||
$focus = 0;
|
||||
|
||||
global $theme;
|
||||
$theme_path="themes/".$theme."/";
|
||||
$image_path=$theme_path."images/";
|
||||
|
||||
$log->info($mod_strings['LBL_MODULE_NAME'] . " Upload Step 1");
|
||||
|
||||
$smarty = new vtigerCRM_Smarty;
|
||||
|
||||
$smarty->assign("MOD", $mod_strings);
|
||||
$smarty->assign("APP", $app_strings);
|
||||
$smarty->assign("IMP", $import_mod_strings);
|
||||
|
||||
$smarty->assign("CATEGORY", htmlspecialchars($_REQUEST['parenttab'],ENT_QUOTES,$default_charset));
|
||||
|
||||
$import_object_array = Array(
|
||||
"Leads"=>"ImportLead",
|
||||
"Accounts"=>"ImportAccount",
|
||||
"Contacts"=>"ImportContact",
|
||||
"Potentials"=>"ImportOpportunity",
|
||||
"Products"=>"ImportProduct",
|
||||
"HelpDesk"=>"ImportTicket",
|
||||
"Vendors"=>"ImportVendors"
|
||||
);
|
||||
|
||||
if(isset($_REQUEST['module']) && $_REQUEST['module'] != '')
|
||||
{
|
||||
$object_name = $import_object_array[$_REQUEST['module']];
|
||||
// vtlib customization: Hook added to enable import for un-mapped modules
|
||||
$module = $_REQUEST['module'];
|
||||
if($object_name == null) {
|
||||
checkFileAccess("modules/$module/$module.php");
|
||||
require_once("modules/$module/$module.php");
|
||||
$object_name = $module;
|
||||
$callInitImport = true;
|
||||
}
|
||||
// END
|
||||
$focus = new $object_name();
|
||||
// vtlib customization: Call the import initializer
|
||||
if($callInitImport) $focus->initImport($module);
|
||||
// END
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Sorry! Import Option is not provided for this module.";
|
||||
exit;
|
||||
}
|
||||
|
||||
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']));
|
||||
|
||||
$smarty->assign("THEME", $theme);
|
||||
$smarty->assign("IMAGE_PATH", $image_path);
|
||||
$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
|
||||
|
||||
$smarty->assign("HEADER", $app_strings['LBL_IMPORT']." ". $mod_strings['LBL_MODULE_NAME']);
|
||||
$smarty->assign("HAS_HEADER_CHECKED"," CHECKED");
|
||||
|
||||
$smarty->assign("MODULE", $_REQUEST['module']);
|
||||
$smarty->assign("MODULELABEL", getTranslatedString($_REQUEST['module'],$_REQUEST['module']));
|
||||
$smarty->assign("SOURCE", $_REQUEST['source']);
|
||||
|
||||
//we have set this as default. upto 4.2.3 we have Outlook, Act, SF formats. but now CUSTOM is enough to import
|
||||
$lang_key = "CUSTOM";
|
||||
$smarty->assign("INSTRUCTIONS_TITLE",$mod_strings["LBL_IMPORT_{$lang_key}_TITLE"]);
|
||||
|
||||
for($i = 1; isset($mod_strings["LBL_{$lang_key}_NUM_$i"]);$i++)
|
||||
{
|
||||
$smarty->assign("STEP_NUM",$mod_strings["LBL_NUM_$i"]);
|
||||
$smarty->assign("INSTRUCTION_STEP",$mod_strings["LBL_{$lang_key}_NUM_$i"]);
|
||||
}
|
||||
|
||||
$smarty->display("ImportStep1.tpl");
|
||||
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* The contents of this file are subject to the SugarCRM Public License Version 1.1.2
|
||||
* ("License"); You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
|
||||
* 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): ______________________________________.
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
* $Header$
|
||||
* Description: TODO: To be written.
|
||||
********************************************************************************/
|
||||
|
||||
require_once('data/Tracker.php');
|
||||
require_once('modules/Import/ImportContact.php');
|
||||
require_once('modules/Import/ImportAccount.php');
|
||||
require_once('modules/Import/UsersLastImport.php');
|
||||
require_once('modules/Import/parse_utils.php');
|
||||
require_once('include/utils/utils.php');
|
||||
|
||||
global $mod_strings;
|
||||
global $app_list_strings;
|
||||
global $app_strings;
|
||||
global $current_user;
|
||||
global $theme;
|
||||
|
||||
if (! isset( $_REQUEST['module']))
|
||||
{
|
||||
$_REQUEST['module'] = 'Home';
|
||||
}
|
||||
|
||||
if (! isset( $_REQUEST['return_id']))
|
||||
{
|
||||
$_REQUEST['return_id'] = '';
|
||||
}
|
||||
if (! isset( $_REQUEST['return_module']))
|
||||
{
|
||||
$_REQUEST['return_module'] = '';
|
||||
}
|
||||
|
||||
if (! isset( $_REQUEST['return_action']))
|
||||
{
|
||||
$_REQUEST['return_action'] = '';
|
||||
}
|
||||
|
||||
$parenttab = getParenttab();
|
||||
|
||||
$theme_path="themes/".$theme."/";
|
||||
$image_path=$theme_path."images/";
|
||||
|
||||
$log->info("Import Undo");
|
||||
$last_import = new UsersLastImport();
|
||||
$ret_value = $last_import->undo($current_user->id);
|
||||
|
||||
// vtlib customization: Invoke undo import function of the module.
|
||||
$module = $_REQUEST['module'];
|
||||
$undo_focus = CRMEntity::getInstance($module);
|
||||
if(method_exists($undo_focus, 'undo_import')) {
|
||||
$ret_value += $undo_focus->undo_import($module, $current_user->id);
|
||||
}
|
||||
// END
|
||||
|
||||
?>
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
<table align="center" cellpadding="5" cellspacing="0" width="95%" class="mailClient importLeadUI small">
|
||||
<tr>
|
||||
<td bgcolor="#FFFFFF" height="50" valign="middle" align="left" class="mailClientBg genHeaderSmall"> <?php echo $mod_strings['LBL_MODULE_NAME']; ?> <?php echo $app_strings[$_REQUEST['module']] ; ?> </td>
|
||||
</tr>
|
||||
<tr><td> </td></tr>
|
||||
<tr>
|
||||
<td align="left" style="padding-left:40px;">
|
||||
<?php $req_module = vtlib_purify($_REQUEST['module']);
|
||||
if($req_module == 'Contacts' || $req_module == 'Accounts' || $req_module == 'Leads' || $req_module == 'Products' || $req_module == 'HelpDesk' || $req_module == 'Potentials' || $req_module == 'Vendors')
|
||||
{ ?>
|
||||
<span class="genHeaderGray"><?php echo $mod_strings['LBL_STEP_4_4']; ?></span>
|
||||
<?php }
|
||||
else { ?>
|
||||
<span class="genHeaderGray"><?php echo $mod_strings['LBL_STEP_3_3']; ?></span>
|
||||
<?php } ?>
|
||||
<span class="genHeaderSmall"><?php echo $mod_strings['LBL_MAPPING_RESULTS']; ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left:140px;">
|
||||
<br>
|
||||
<?php
|
||||
if ($ret_value) {
|
||||
?>
|
||||
<?php echo "<b>" . $mod_strings['LBL_SUCCESS']."</b>" ?><BR><br>
|
||||
<?php echo $mod_strings['LBL_LAST_IMPORT_UNDONE'] ?>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
<?php echo $mod_strings['LBL_FAIL'] ?><br>
|
||||
<?php echo $mod_strings['LBL_NO_IMPORT_TO_UNDO'] ?>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<br>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" class="reportCreateBottom" >
|
||||
<form name="Import" method="POST" action="index.php" onsubmit="VtigerJS_DialogBox.block();">
|
||||
<input type="hidden" name="module" value="<?php echo vtlib_purify($_REQUEST['module']); ?>">
|
||||
<input type="hidden" name="action" value="Import">
|
||||
<input type="hidden" name="step" value="1">
|
||||
<input type="hidden" name="return_module" value="<?php echo vtlib_purify($_REQUEST['module']) ?>">
|
||||
<input type="hidden" name="return_id" value="<?php echo vtlib_purify($_REQUEST['RETURN_ID']) ?>">
|
||||
<input type="hidden" name="return_action" value="<?php echo vtlib_purify($_REQUEST['RETURN_ACTION']) ?>">
|
||||
<input type="hidden" name="parenttab" value="<?php echo $parenttab ?>">
|
||||
<input title="<?php echo $mod_strings['LBL_TRY_AGAIN'] ?>" accessKey="" class="crmbutton small save" type="submit" name="button" value=" <?php echo $mod_strings['LBL_TRY_AGAIN'] ?> ">
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
<?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.
|
||||
*********************************************************************************/
|
||||
|
||||
include_once('config.php');
|
||||
require_once('include/logging.php');
|
||||
require_once('modules/HelpDesk/HelpDesk.php');
|
||||
require_once('modules/Import/UsersLastImport.php');
|
||||
require_once('include/database/PearDatabase.php');
|
||||
require_once('include/ComboUtil.php');
|
||||
|
||||
class ImportTicket extends HelpDesk {
|
||||
var $db;
|
||||
|
||||
// This is the list of the functions to run when importing
|
||||
var $special_functions = array("assign_user","add_product","empty_relatedto","modseq_number");
|
||||
|
||||
var $importable_fields = Array();
|
||||
|
||||
/** function used to set the assigned_user_id value in the column_fields when we map the username during import
|
||||
*/
|
||||
function assign_user()
|
||||
{
|
||||
global $current_user;
|
||||
$ass_user = $this->column_fields["assigned_user_id"];
|
||||
$this->db->println("assign_user ".$ass_user." cur_user=".$current_user->id);
|
||||
|
||||
if( $ass_user != $current_user->id)
|
||||
{
|
||||
$this->db->println("searching and assigning ".$ass_user);
|
||||
|
||||
$result = $this->db->pquery("select id from vtiger_users where id = ? union select groupid as id from vtiger_groups where groupid = ?",array($ass_user, $ass_user));
|
||||
if($this->db->num_rows($result)!=1)
|
||||
{
|
||||
$this->db->println("not exact records setting current userid");
|
||||
$this->column_fields["assigned_user_id"] = $current_user->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$row = $this->db->fetchByAssoc($result, -1, false);
|
||||
if (isset($row['id']) && $row['id'] != -1)
|
||||
{
|
||||
$this->db->println("setting id as ".$row['id']);
|
||||
$this->column_fields["assigned_user_id"] = $row['id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->println("setting current userid");
|
||||
$this->column_fields["assigned_user_id"] = $current_user->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function add_product()
|
||||
{
|
||||
global $adb,$imported_ids,$current_user;
|
||||
|
||||
$pro_name = $this->column_fields['product_id'];
|
||||
if((! isset($pro_name) || $pro_name == '') )
|
||||
return;
|
||||
|
||||
//check if it already exists
|
||||
$focus = new Products();
|
||||
$query = '';
|
||||
|
||||
//Modified to remove the spaces at first and last in vtiger_product name
|
||||
$pro_name = trim($pro_name);
|
||||
|
||||
//Modified the query to get the available product only ie., which is not deleted
|
||||
$query = "select vtiger_products.* ,vtiger_crmentity.deleted from vtiger_products,vtiger_crmentity WHERE productname=? and vtiger_crmentity.crmid = vtiger_products.productid and vtiger_crmentity.deleted=0";
|
||||
$result = $adb->pquery($query, array($pro_name));
|
||||
$row = $this->db->fetchByAssoc($result, -1, false);
|
||||
$adb->println($row);
|
||||
|
||||
// we found a row with that id
|
||||
if (isset($row['productid']) && $row['productid'] != -1)
|
||||
$focus->id = $row['productid'];
|
||||
|
||||
$this->column_fields["product_id"] = $focus->id;
|
||||
}
|
||||
function empty_relatedto()
|
||||
{
|
||||
global $adb;
|
||||
$parent_name = $this->column_fields["parent_id"];
|
||||
if($parent_name == '' || $parent_name == NULL)
|
||||
$parent_id = 0;
|
||||
else
|
||||
{ //get the account
|
||||
$relatedTo = explode(':',$parent_name);
|
||||
$parent_module = $relatedTo[0]; $parent_module = trim($parent_module," ");
|
||||
$parent_name = $relatedTo[3]; $parent_name = trim($parent_name," ");
|
||||
$num_rows = 0;
|
||||
if($parent_module == 'Contacts')
|
||||
{
|
||||
$query ="select crmid from vtiger_contactdetails, vtiger_crmentity WHERE concat(lastname,' ',firstname)=? and vtiger_crmentity.crmid =vtiger_contactdetails.contactid and vtiger_crmentity.deleted=0";
|
||||
$result = $adb->pquery($query, array($parent_name));
|
||||
$num_rows=$adb->num_rows($result);
|
||||
}
|
||||
else if($parent_module == 'Accounts')
|
||||
{
|
||||
$query = "select crmid from vtiger_account, vtiger_crmentity WHERE accountname=? and vtiger_crmentity.crmid =vtiger_account.accountid and vtiger_crmentity.deleted=0";
|
||||
$result = $adb->pquery($query, array($parent_name));
|
||||
$num_rows = $adb->num_rows($result);
|
||||
}
|
||||
else $num_rows=0;
|
||||
if($num_rows == 0) $parent_id = 0;
|
||||
else $parent_id = $adb->query_result($result,0,"crmid");
|
||||
}
|
||||
$this->column_fields['parent_id'] = $parent_id;
|
||||
}
|
||||
/** 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 ImportTicket() {
|
||||
parent::HelpDesk();
|
||||
$this->log = LoggerManager::getLogger('import_ticket');
|
||||
$this->db = PearDatabase::getInstance();
|
||||
$this->db->println("IMP ImportTicket");
|
||||
$this->initImportableFields("HelpDesk");
|
||||
$this->db->println($this->importable_fields);
|
||||
}
|
||||
|
||||
// Module Sequence Numbering
|
||||
function modseq_number() {
|
||||
$this->column_fields['ticket_no'] = '';
|
||||
}
|
||||
// END
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,80 @@
|
||||
<?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.
|
||||
*********************************************************************************/
|
||||
|
||||
include_once('config.php');
|
||||
require_once('include/logging.php');
|
||||
require_once('modules/Vendors/Vendors.php');
|
||||
require_once('modules/Import/UsersLastImport.php');
|
||||
require_once('include/database/PearDatabase.php');
|
||||
require_once('include/ComboUtil.php');
|
||||
|
||||
class ImportVendors extends Vendors {
|
||||
var $db;
|
||||
|
||||
// This is the list of the functions to run when importing
|
||||
var $special_functions = array("assign_user","modseq_number");
|
||||
|
||||
var $importable_fields = Array();
|
||||
|
||||
/** function used to set the assigned_user_id value in the column_fields when we map the username during import
|
||||
*/
|
||||
function assign_user()
|
||||
{
|
||||
global $current_user;
|
||||
$ass_user = $this->column_fields["assigned_user_id"];
|
||||
$this->db->println("assign_user ".$ass_user." cur_user=".$current_user->id);
|
||||
|
||||
if( $ass_user != $current_user->id)
|
||||
{
|
||||
$this->db->println("searching and assigning ".$ass_user);
|
||||
|
||||
$result = $this->db->query("select id from vtiger_users where id = '".$ass_user."'");
|
||||
if($this->db->num_rows($result)!=1)
|
||||
{
|
||||
$this->db->println("not exact records setting current userid");
|
||||
$this->column_fields["assigned_user_id"] = $current_user->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$row = $this->db->fetchByAssoc($result, -1, false);
|
||||
if (isset($row['id']) && $row['id'] != -1)
|
||||
{
|
||||
$this->db->println("setting id as ".$row['id']);
|
||||
$this->column_fields["assigned_user_id"] = $row['id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->println("setting current userid");
|
||||
$this->column_fields["assigned_user_id"] = $current_user->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 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 ImportVendors() {
|
||||
parent::Vendors();
|
||||
$this->log = LoggerManager::getLogger('import_vendors');
|
||||
$this->db = PearDatabase::getInstance();
|
||||
$this->db->println("IMP ImportVendors");
|
||||
$this->initImportableFields("Vendors");
|
||||
$this->db->println($this->importable_fields);
|
||||
}
|
||||
|
||||
//Module Sequence Numbering
|
||||
function modseq_number() {
|
||||
$this->column_fields['vendor_no'] = '';
|
||||
}
|
||||
// END
|
||||
|
||||
}
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* The contents of this file are subject to the SugarCRM Public License Version 1.1.2
|
||||
* ("License"); You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
|
||||
* 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): ______________________________________.
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
* $Header$
|
||||
* Description: TODO: To be written.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
require_once('Smarty_setup.php');
|
||||
require_once('include/utils/utils.php');
|
||||
|
||||
/** function used to show the error message occured during import process
|
||||
* @param string $message - Error message to display in the screen, where the passed error message will be displayed in screen using Importerror.tpl file
|
||||
*/
|
||||
function show_error_import($message)
|
||||
{
|
||||
global $import_mod_strings;
|
||||
|
||||
global $theme;
|
||||
|
||||
global $log;
|
||||
global $mod_strings;
|
||||
global $app_strings;
|
||||
|
||||
$theme_path="themes/".$theme."/";
|
||||
|
||||
$image_path=$theme_path."images/";
|
||||
|
||||
$log->info("Upload Error");
|
||||
|
||||
$smarty = new vtigerCRM_Smarty;
|
||||
$smarty->assign("MOD", $mod_strings);
|
||||
$smarty->assign("APP", $app_strings);
|
||||
|
||||
|
||||
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']));
|
||||
|
||||
$smarty->assign("THEME", $theme);
|
||||
|
||||
$category = getParenttab();
|
||||
$smarty->assign("CATEGORY", $category);
|
||||
|
||||
$smarty->assign("IMAGE_PATH", $image_path);
|
||||
$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
|
||||
|
||||
$smarty->assign("MODULE", vtlib_purify($_REQUEST['module']));
|
||||
$smarty->assign("MESSAGE", $message);
|
||||
|
||||
$smarty->display('Importerror.tpl');
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,252 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* The contents of this file are subject to the SugarCRM Public License Version 1.1.2
|
||||
* ("License"); You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
|
||||
* 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): ______________________________________.
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
* $Header$
|
||||
* Description: TODO: To be written.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
//error_reporting(E_ALL);
|
||||
//error_reporting(0);
|
||||
global $current_language;
|
||||
|
||||
$mod_strings = return_module_language($current_language, "Import");
|
||||
|
||||
include_once('modules/Import/error.php');
|
||||
|
||||
|
||||
$outlook_contacts_field_map = array(
|
||||
"Title"=>"salutation",
|
||||
// SPECIAL FIELD:
|
||||
"Full Name"=>"full_name",
|
||||
"Company"=>"company",
|
||||
// END
|
||||
"First Name"=>"first_name",
|
||||
"Last Name"=>"last_name",
|
||||
"Job Title"=>"title",
|
||||
"Department"=>"department",
|
||||
"Birthday"=>"birthdate",
|
||||
"Home Phone"=>"phone_home",
|
||||
"Mobile Phone"=>"phone_mobile",
|
||||
"Business Phone"=>"phone_work",
|
||||
"Other Phone"=>"phone_other",
|
||||
"Business Fax"=>"phone_fax",
|
||||
"E-mail Address"=>"email1",
|
||||
"E-mail 2"=>"email2",
|
||||
"Assistant's Name"=>"assistant",
|
||||
"Assistant's Phone"=>"assistant_phone",
|
||||
"Business Street"=>"primary_address_street",
|
||||
"Business City"=>"primary_address_city",
|
||||
"Business State"=>"primary_address_state",
|
||||
"Business Postal Code"=>"primary_address_postalcode",
|
||||
"Business Country/Region"=>"primary_address_country",
|
||||
"Home Street"=>"alt_address_street",
|
||||
"Home City"=>"alt_address_city",
|
||||
"Home State"=>"alt_address_state",
|
||||
"Home Postal Code"=>"alt_address_postalcode",
|
||||
"Home Country/Region"=>"alt_address_country",
|
||||
);
|
||||
|
||||
|
||||
$outlook_accounts_field_map = array(
|
||||
"Company"=>"name",
|
||||
"Business Street"=>"billing_address_street",
|
||||
"Business City"=>"billing_address_city",
|
||||
"Business State"=>"billing_address_state",
|
||||
"Business Country"=>"billing_address_country",
|
||||
"Business Postal Code"=>"billing_address_postalcode",
|
||||
"Business Fax"=>"phone_fax",
|
||||
"Company Main Phone"=>"phone_office",
|
||||
"Web Page"=>"website",
|
||||
//Government ID Number,
|
||||
//Organizational ID Number,
|
||||
);
|
||||
|
||||
$act_contacts_field_map = array(
|
||||
"Web Site"=>"website",
|
||||
"Company"=>"account_name",
|
||||
"Name Suffix"=>"salutation",
|
||||
"Title"=>"title",
|
||||
"First Name"=>"first_name",
|
||||
"Last Name"=>"last_name",
|
||||
"Address 1"=>"primary_address_street",
|
||||
"Address 2"=>"primary_address_street_2",
|
||||
"Address 3"=>"primary_address_street_3",
|
||||
"City"=>"primary_address_city",
|
||||
"State"=>"primary_address_state",
|
||||
"Zip"=>"primary_address_postalcode",
|
||||
"Country"=>"primary_address_country",
|
||||
"Phone"=>"phone_work",
|
||||
"Phone Ext-"=>"phone_work_ext",
|
||||
"Mobile Phone"=>"phone_mobile",
|
||||
"Alt Phone"=>"phone_other",
|
||||
"Fax"=>"phone_fax",
|
||||
"E-mail Login"=>"email1",
|
||||
"E-mail"=>"email1",
|
||||
"E-Mail 2"=>"email2",
|
||||
"Assistant"=>"assistant",
|
||||
"Asst. Phone"=>"assistant_phone",
|
||||
"Home Address 1"=>"alt_address_street",
|
||||
"Home Address 2"=>"alt_address_street_2",
|
||||
"Home Address 3"=>"alt_address_street_3",
|
||||
"Home City"=>"alt_address_city",
|
||||
"Home State"=>"alt_address_state",
|
||||
"Home Zip"=>"alt_address_postalcode",
|
||||
"Home Country"=>"alt_address_country",
|
||||
"Home Phone"=>"phone_home",
|
||||
);
|
||||
|
||||
|
||||
$act_accounts_field_map = array(
|
||||
"Revenue"=>"annual_revenue",
|
||||
"Number of Employees"=>"employees",
|
||||
"Company"=>"name",
|
||||
"Address 1"=>"billing_address_street",
|
||||
"City"=>"billing_address_city",
|
||||
"State"=>"billing_address_state",
|
||||
"Zip Code"=>"billing_address_postalcode",
|
||||
"Country"=>"billing_address_country",
|
||||
"Phone"=>"phone_office",
|
||||
"Fax Phone"=>"phone_fax",
|
||||
"Ticker Symbol"=>"ticker_symbol",
|
||||
"Web Site"=>"website",
|
||||
);
|
||||
|
||||
/*
|
||||
"Last Activity"=>"",
|
||||
"Last Modified Date"=>"",
|
||||
"Created Date"=>"",
|
||||
"Reports To"=>"",
|
||||
"Last Stay-in-Touch Request Date"=>"",
|
||||
"Last Stay-in-Touch Save Date"=>"",
|
||||
*/
|
||||
$salesforce_contacts_field_map = array(
|
||||
"Salutation"=>"salutation",
|
||||
"Description"=>"description",
|
||||
"First Name"=>"first_name",
|
||||
"Last Name"=>"last_name",
|
||||
"Title"=>"title",
|
||||
"Department"=>"department",
|
||||
"Birthdate"=>"birthdate",
|
||||
"Lead Source"=>"lead_source",
|
||||
"Assistant"=>"assistant",
|
||||
"Asst. Phone"=>"assistant_phone",
|
||||
"Contact ID"=>"id",
|
||||
"Mailing Street"=>"primary_address_street",
|
||||
"Mailing Address Line1"=>"primary_address_street_2",
|
||||
"Mailing Address Line2"=>"primary_address_street_3",
|
||||
"Mailing Address Line3"=>"primary_address_street_4",
|
||||
"Mailing City"=>"primary_address_city",
|
||||
"Mailing State"=>"primary_address_state",
|
||||
"Mailing Zip/Postal Code"=>"primary_address_postalcod3",
|
||||
"Mailing Country"=>"primary_address_country",
|
||||
"Other Street"=>"alt_address_street",
|
||||
"Other Address Line 1"=>"alt_address_street_2",
|
||||
"Other Address Line 2"=>"alt_address_street_3",
|
||||
"Other Address Line 3"=>"alt_address_street_4",
|
||||
"Other City"=>"alt_address_city",
|
||||
"Other State"=>"alt_address_state",
|
||||
"Other Zip/Postal Code"=>"alt_address_postalcode",
|
||||
"Other Country"=>"alt_address_country",
|
||||
"Phone"=>"phone_work",
|
||||
"Mobile"=>"phone_mobile",
|
||||
"Home Phone"=>"phone_home",
|
||||
"Other Phone"=>"phone_other",
|
||||
"Fax"=>"phone_fax",
|
||||
"Email"=>"email1",
|
||||
"Email Opt Out"=>"email_opt_out",
|
||||
"Do Not Call"=>"do_not_call",
|
||||
"Account Name"=>"account_name",
|
||||
"Account ID"=>"account_id",
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
ommited vtiger_fields to map:
|
||||
"Account Number"=>"",
|
||||
"Account Site"=>"",
|
||||
"Last Activity"=>"",
|
||||
"Parent Account"=>"",
|
||||
"Parent Account ID"=>"",
|
||||
"Parent Account Site"=>"",
|
||||
"Created Date"=>"",
|
||||
"Last Modified Date"=>"",
|
||||
"Billing Address Line3"=>"",
|
||||
"Shipping Address Line3"=>"",
|
||||
*/
|
||||
$salesforce_accounts_field_map = array(
|
||||
"Account Name"=>"name",
|
||||
"Annual Revenue"=>"annual_revenue",
|
||||
"Type"=>"type",
|
||||
"Ticker Symbol"=>"ticker_symbol",
|
||||
"Rating"=>"rating",
|
||||
"Industry"=>"industry",
|
||||
"SIC Code"=>"sic_code",
|
||||
"Ownership"=>"ownership",
|
||||
"Employees"=>"employees",
|
||||
"Description"=>"description",
|
||||
"Account ID"=>"id",
|
||||
"Billing Street"=>"billing_address_street",
|
||||
"Billing Address Line1"=>"billing_address_street_2",
|
||||
"Billing Address Line2"=>"billing_address_street_3",
|
||||
"Billing City"=>"billing_address_city",
|
||||
"Billing State"=>"billing_address_state",
|
||||
"Billing Zip/Postal Code"=>"billing_address_postalcode",
|
||||
"Billing Country"=>"billing_address_country",
|
||||
"Shipping Street"=>"shipping_address_street",
|
||||
"Shipping Address Line1"=>"shipping_address_street_2",
|
||||
"Shipping Address Line2"=>"shipping_address_street_3",
|
||||
"Shipping City"=>"shipping_address_city",
|
||||
"Shipping State"=>"shipping_address_state",
|
||||
"Shipping Zip/Postal Code"=>"shipping_address_postalcode",
|
||||
"Shipping Country"=>"shipping_address_country",
|
||||
"Phone"=>"phone_office",
|
||||
"Fax"=>"phone_fax",
|
||||
"Website"=>"website"
|
||||
);
|
||||
|
||||
/*
|
||||
"Fiscal Quarter"=>"",
|
||||
"Age"=>"",
|
||||
"Expected Revenue"=>"",
|
||||
*/
|
||||
$salesforce_opportunities_field_map = array(
|
||||
|
||||
"Opportunity Name"=>"name" ,
|
||||
"Type"=>"opportunity_type",
|
||||
"Lead Source"=>"lead_source",
|
||||
"Amount"=>"amount",
|
||||
"Created Date"=>"date_entered",
|
||||
"Close Date"=>"date_closed",
|
||||
"Next Step"=>"next_step",
|
||||
"Stage"=>"sales_stage",
|
||||
"Probability (%)"=>"probability",
|
||||
"Account Name"=>"account_name"
|
||||
);
|
||||
|
||||
if (! isset($_REQUEST['step'] ) )
|
||||
{
|
||||
$_REQUEST['step'] = 1;
|
||||
}
|
||||
|
||||
$mod_list_strings = return_mod_list_strings_language($current_language,"Import");
|
||||
|
||||
checkFileAccess('modules/Import/ImportStep'. $_REQUEST['step']. '.php');
|
||||
include_once('modules/Import/ImportStep'. $_REQUEST['step']. '.php');
|
||||
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,207 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* The contents of this file are subject to the SugarCRM Public License Version 1.1.2
|
||||
* ("License"); You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
|
||||
* 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): ______________________________________.
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
* $Header$
|
||||
* Description: TODO: To be written.
|
||||
********************************************************************************/
|
||||
|
||||
require_once('Smarty_setup.php');
|
||||
require_once('data/Tracker.php');
|
||||
require_once('modules/Import/ImportContact.php');
|
||||
require_once('modules/Import/ImportAccount.php');
|
||||
require_once('modules/Import/ImportOpportunity.php');
|
||||
require_once('modules/Import/ImportLead.php');
|
||||
//Pavani: Import this file to Support Imports for Trouble tickets and vendors
|
||||
require_once('modules/Import/ImportTicket.php');
|
||||
require_once('modules/Import/ImportVendors.php');
|
||||
require_once('modules/Import/UsersLastImport.php');
|
||||
require_once('modules/Import/parse_utils.php');
|
||||
require_once('include/ListView/ListView.php');
|
||||
require_once('modules/Contacts/Contacts.php');
|
||||
require_once('include/utils/utils.php');
|
||||
|
||||
global $mod_strings;
|
||||
global $app_list_strings;
|
||||
global $app_strings;
|
||||
global $current_user;
|
||||
$currentModule = "Import";
|
||||
|
||||
if (! isset( $_REQUEST['module']))
|
||||
{
|
||||
$_REQUEST['module'] = 'Home';
|
||||
}
|
||||
|
||||
if (! isset( $_REQUEST['return_id']))
|
||||
{
|
||||
$_REQUEST['return_id'] = '';
|
||||
}
|
||||
if (! isset( $_REQUEST['return_module']))
|
||||
{
|
||||
$_REQUEST['return_module'] = '';
|
||||
}
|
||||
|
||||
if (! isset( $_REQUEST['return_action']))
|
||||
{
|
||||
$_REQUEST['return_action'] = '';
|
||||
}
|
||||
|
||||
global $theme;
|
||||
$theme_path="themes/".$theme."/";
|
||||
$image_path=$theme_path."images/";
|
||||
require_once($theme_path.'layout_utils.php');
|
||||
|
||||
$log->info("Import Step last");
|
||||
|
||||
$parenttab = getParenttab();
|
||||
//This Buttons_List1.tpl is is called to display the add, search, import and export buttons ie., second level tabs
|
||||
$smarty = new vtigerCRM_Smarty;
|
||||
|
||||
$smarty->assign("MOD", $mod_strings);
|
||||
$smarty->assign("APP", $app_strings);
|
||||
$smarty->assign("IMP", $import_mod_strings);
|
||||
$smarty->assign("THEME", $theme);
|
||||
$smarty->assign("IMAGE_PATH", $image_path);
|
||||
|
||||
$smarty->assign("MODULE", vtlib_purify($_REQUEST['req_mod']));
|
||||
$smarty->assign("SINGLE_MOD", vtlib_purify($_REQUEST['modulename']));
|
||||
$smarty->assign("CATEGORY", vtlib_purify($_SESSION['import_parenttab']));
|
||||
|
||||
global $limit;
|
||||
global $list_max_entries_per_page;
|
||||
|
||||
$implict_account = false;
|
||||
|
||||
$import_modules_array = Array(
|
||||
"Leads"=>"Leads",
|
||||
"Accounts"=>"Accounts",
|
||||
"Contacts"=>"Contacts",
|
||||
"Potentials"=>"Potentials",
|
||||
"Products"=>"Products",
|
||||
"HelpDesk"=>"ImportTicket",
|
||||
"Vendors"=>"ImportVendors"
|
||||
);
|
||||
|
||||
if(!empty($_REQUEST['req_mod'])) {
|
||||
$req_mod = $_REQUEST['req_mod'];
|
||||
checkFileAccess("modules/$req_mod/$req_mod.php");
|
||||
require_once("modules/$req_mod/$req_mod.php");
|
||||
if(!isset($import_modules_array[$req_mod])) {
|
||||
$import_modules_array[$req_mod] = $req_mod;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($import_modules_array as $module_name => $object_name)
|
||||
{
|
||||
|
||||
$seedUsersLastImport = new UsersLastImport();
|
||||
$seedUsersLastImport->bean_type = $module_name;
|
||||
$list_query = $seedUsersLastImport->create_list_query($o,$w);
|
||||
$current_module_strings = return_module_language($current_language, $module_name);
|
||||
|
||||
$object = new $object_name();
|
||||
$seedUsersLastImport->list_fields = $object->list_fields;
|
||||
|
||||
$list_result = $adb->query($list_query);
|
||||
//Retreiving the no of rows
|
||||
$noofrows = $adb->num_rows($list_result);
|
||||
|
||||
if($noofrows < 1) {
|
||||
if($module_name == $_REQUEST['req_mod']) {
|
||||
echo "<link rel='stylesheet' type='text/css' href='themes/$theme/style.css'>";
|
||||
echo "<table border='0' cellpadding='5' cellspacing='0' width='100%' height='450px'><tr><td align='center'>";
|
||||
echo "<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 55%; position: relative; z-index: 10000000;'>
|
||||
|
||||
<table border='0' cellpadding='5' cellspacing='0' width='98%'>
|
||||
<tbody><tr>
|
||||
<td rowspan='2' width='11%'><img src='". vtiger_imageurl('empty.jpg', $theme) ."' ></td>
|
||||
<td style='border-bottom: 1px solid rgb(204, 204, 204);' nowrap='nowrap' width='70%'>
|
||||
<span class='genHeaderSmall'>$app_strings[LBL_NO] $mod_strings[LBL_LAST_IMPORTED] $app_strings[$module_name]</span></td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
</div>";
|
||||
echo "</td></tr></table>";
|
||||
}
|
||||
} else {
|
||||
if($module_name != 'Accounts')
|
||||
{
|
||||
$implict_account=true;
|
||||
}
|
||||
|
||||
if($module_name == 'Accounts' && $implict_account==true)
|
||||
$display_header_msg = "Newly created Accounts";
|
||||
else
|
||||
$display_header_msg = "".$mod_strings['LBL_LAST_IMPORTED']." ".$app_strings[$module_name]."";
|
||||
|
||||
//Display the Header Message
|
||||
echo "
|
||||
<table width='100%' border='0' cellpadding='5' cellspacing='0'>
|
||||
<tr>
|
||||
<td class='dvtCellLabel' align='left'>
|
||||
<b>".$mod_strings['LBL_LAST_IMPORTED']." ".$app_strings[$module_name]." </b>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
";
|
||||
|
||||
$smarty = new vtigerCRM_Smarty;
|
||||
|
||||
$smarty->assign("MOD", $mod_strings);
|
||||
$smarty->assign("APP", $app_strings);
|
||||
$smarty->assign("IMAGE_PATH",$image_path);
|
||||
$smarty->assign("MODULE",$module_name);
|
||||
$smarty->assign("SINGLE_MOD",$module_name);
|
||||
$smarty->assign("SHOW_MASS_SELECT",'false');
|
||||
|
||||
//Retreiving the start value from request
|
||||
if($module_name == $_REQUEST['nav_module'] && isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
|
||||
$start = vtlib_purify($_REQUEST['start']);
|
||||
} else {
|
||||
$start = 1;
|
||||
}
|
||||
|
||||
$info_message='&recordcount='.vtlib_purify($_REQUEST['recordcount']).'&noofrows='.vtlib_purify($_REQUEST['noofrows']).'&message='.vtlib_purify($_REQUEST['message']).'&skipped_record_count='.vtlib_purify($_REQUEST['skipped_record_count']);
|
||||
$url_string = '&modulename='.vtlib_purify($_REQUEST['modulename']).'&nav_module='.$module_name.$info_message;
|
||||
$viewid = '';
|
||||
|
||||
//Retreive the Navigation array
|
||||
$navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
|
||||
$navigationOutput = getTableHeaderNavigation($navigation_array, $url_string,"Import","ImportSteplast",$viewid);
|
||||
|
||||
//Retreive the List View Header and Entries
|
||||
$listview_header = getListViewHeader($object,$module_name);
|
||||
$listview_entries = getListViewEntries($object,$module_name,$list_result,$navigation_array,"","","EditView","Delete","");
|
||||
//commented to remove navigation buttons from import list view
|
||||
//$smarty->assign("NAVIGATION", $navigationOutput);
|
||||
$smarty->assign("HIDE_CUSTOM_LINKS", 1);//Added to hide the CustomView links in imported records ListView
|
||||
|
||||
// Remove all the links for the list view header as they do not work in this page.
|
||||
for($i=0;$i<count($listview_header);$i++) {
|
||||
$listview_header[$i] = strip_tags($listview_header[$i]);
|
||||
}
|
||||
$smarty->assign("LISTHEADER", $listview_header);
|
||||
$smarty->assign("LISTENTITY", $listview_entries);
|
||||
|
||||
// Include required scripts
|
||||
echo '<link rel="stylesheet" type="text/css" href="'.$theme_path.'/style.css">';
|
||||
echo '<script language="JavaScript" type="text/javascript" src="include/js/general.js"></script>';
|
||||
echo '<script language="JavaScript" type="text/javascript" src="include/js/' . $_SESSION['authenticated_user_language'] . '.lang.js?' . $_SESSION['vtiger_version'] . '"></script>';
|
||||
echo '<script language="JavaScript" type="text/javascript" src="modules/'. vtlib_purify($_REQUEST['req_mod']) . '/' . vtlib_purify($_REQUEST['req_mod']) . '.js"></script>';
|
||||
echo '<script language="javascript" type="text/javascript" src="include/scriptaculous/prototype.js"></script>';
|
||||
|
||||
$smarty->display("ListViewEntries.tpl");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* The contents of this file are subject to the SugarCRM Public License Version 1.1.2
|
||||
* ("License"); You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
|
||||
* 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): ______________________________________.
|
||||
********************************************************************************/
|
||||
|
||||
// takes a string and parses it into one record per line,
|
||||
// one vtiger_field per delimiter, to a maximum number of lines
|
||||
// some vtiger_files have a header, some dont.
|
||||
// keeps track of which vtiger_fields are used
|
||||
|
||||
/** function used to parse the file
|
||||
* @param string $file_name - file name
|
||||
* @param character $delimiter - delimiter of the csv file
|
||||
* @param int $max_lines - maximum number of lines to parse
|
||||
* @param int $has_header - if the file has header then 1 otherwise 0
|
||||
* @return array $ret_array - return an array which will be "rows"=>&$rows, "field_count"=>$field_count where as &rows is the reference of rows which contains all the parsed rows and $field_count is the number of fields available per row
|
||||
*/
|
||||
function parse_import($file_name,$delimiter,$max_lines,$has_header)
|
||||
{
|
||||
$line_count = 0;
|
||||
|
||||
$field_count = 0;
|
||||
|
||||
$rows = array();
|
||||
|
||||
if (! file_exists($file_name))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
$fh = fopen($file_name,"r");
|
||||
|
||||
if (! $fh)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
while ( (( $fields = fgetcsv($fh, 4096, $delimiter) ) !== FALSE)
|
||||
&& ( $max_lines == -1 || $line_count < $max_lines))
|
||||
{
|
||||
|
||||
if ( count($fields) == 1 && isset($fields[0]) && $fields[0] == '')
|
||||
{
|
||||
break;
|
||||
}
|
||||
$this_field_count = count($fields);
|
||||
|
||||
//Added to handle the case where the last value in a row is "" and
|
||||
//the field value in the next row is "" then for some reason these rows
|
||||
//are getting parsed as same row, this does not happen if the line seperator is
|
||||
// linux line endings.
|
||||
$matches = array();
|
||||
preg_match("/^''\s*''$/",$fields[$field_count - 1],$matches);
|
||||
if(($this_field_count + 1)/2 == $field_count && count($matches) > 0){
|
||||
$chunks = array_chunk($fields,$field_count);
|
||||
$fields = $chunks[0];
|
||||
array_push($rows,$chunks[1]);
|
||||
$line_count++;
|
||||
}else{
|
||||
$field_count = $this_field_count;
|
||||
}
|
||||
|
||||
array_push($rows,$fields);
|
||||
|
||||
$line_count++;
|
||||
|
||||
}
|
||||
|
||||
// got no rows
|
||||
if ( count($rows) == 0)
|
||||
{
|
||||
return -3;
|
||||
}
|
||||
|
||||
$ret_array = array(
|
||||
"rows"=>&$rows,
|
||||
"field_count"=>$field_count
|
||||
);
|
||||
|
||||
return $ret_array;
|
||||
|
||||
}
|
||||
|
||||
/** function used to parse the act file
|
||||
* @param string $file_name - file name
|
||||
* @param character $delimiter - delimiter of the csv file
|
||||
* @param int $max_lines - maximum number of lines to parse
|
||||
* @param int $has_header - if the file has header then 1 otherwise 0
|
||||
* @return array $ret_array - return an array which will be "rows"=>&$rows, "field_count"=>$field_count where as &rows is the reference of rows which contains all the parsed rows and $field_count is the number of fields available per row
|
||||
*/
|
||||
function parse_import_act($file_name,$delimiter,$max_lines,$has_header)
|
||||
{
|
||||
$line_count = 0;
|
||||
|
||||
$field_count = 0;
|
||||
|
||||
$rows = array();
|
||||
|
||||
if (! file_exists($file_name))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
$fh = fopen($file_name,"r");
|
||||
|
||||
if (! $fh)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
while ( ($line = fgets($fh, 4096))
|
||||
&& ( $max_lines == -1 || $line_count < $max_lines) )
|
||||
|
||||
{
|
||||
|
||||
$line = trim($line);
|
||||
$line = substr_replace($line,"",0,1);
|
||||
$line = substr_replace($line,"",-1);
|
||||
$fields = explode("\",\"",$line);
|
||||
|
||||
$this_field_count = count($fields);
|
||||
|
||||
if ( $this_field_count > $field_count)
|
||||
{
|
||||
$field_count = $this_field_count;
|
||||
}
|
||||
|
||||
array_push($rows,$fields);
|
||||
|
||||
$line_count++;
|
||||
|
||||
}
|
||||
|
||||
// got no rows
|
||||
if ( count($rows) == 0)
|
||||
{
|
||||
return -3;
|
||||
}
|
||||
|
||||
$ret_array = array(
|
||||
"rows"=>&$rows,
|
||||
"field_count"=>$field_count
|
||||
);
|
||||
|
||||
return $ret_array;
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,89 @@
|
||||
<?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 $adb;
|
||||
$tabid = getTabid($_REQUEST['module']);
|
||||
|
||||
//First we have to collect all available picklist and their values from the corresponding picklist tables
|
||||
$picklist_result = $adb->pquery("select fieldname from vtiger_field where uitype in ('15') and tabid=? and vtiger_field.presence in (0,2)", array($tabid));
|
||||
$no_of_picklists = $adb->num_rows($picklist_result);
|
||||
for($i=0;$i<$no_of_picklists;$i++)
|
||||
{
|
||||
$fieldname = $adb->query_result($picklist_result, $i, 'fieldname');
|
||||
$tablename = "vtiger_".$fieldname;
|
||||
$picklist_result2 = $adb->query("select * from $tablename");
|
||||
$available_picklists[] = $fieldname;
|
||||
//Now get all picklist values
|
||||
for($j=0;$j<$adb->num_rows($picklist_result2);$j++)
|
||||
{
|
||||
$table_picklist[$fieldname][$j]=$adb->query_result($picklist_result2, $j, $fieldname);
|
||||
$converted_table_picklist_values[$fieldname][$j] = strtolower($adb->query_result($picklist_result2, $j, $fieldname));
|
||||
}
|
||||
}
|
||||
|
||||
$csv_picklist_values = array();
|
||||
//Collect all picklist values from csv file
|
||||
foreach($field_to_pos as $fieldname => $ind)
|
||||
{
|
||||
if(in_array($fieldname,$available_picklists))
|
||||
{
|
||||
$adb->println("Picklist - $fieldname is mapped.");
|
||||
$picklist_pos[$fieldname] = $ind;
|
||||
for($i=1;$i<count($datarows);$i++)
|
||||
{
|
||||
$csv_picklist_values[$fieldname][] = $datarows[$i][$ind];
|
||||
}
|
||||
//Remove the repeated entries and make this array with unique entries
|
||||
|
||||
$csv_picklist_values[$fieldname] = array_unique($csv_picklist_values[$fieldname]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Now we have to add the CSV picklists in the picklist table if it is not exist
|
||||
foreach($csv_picklist_values as $fieldname => $temp_array)
|
||||
{
|
||||
$tablename = "vtiger_$fieldname";
|
||||
|
||||
foreach($temp_array as $ind => $picklist_value)
|
||||
{
|
||||
$pick_val = strtolower($picklist_value);
|
||||
//Check whether $picklist_value is exist in the array of available picklist entries
|
||||
if(!in_array($pick_val, $converted_table_picklist_values[$fieldname]))
|
||||
{
|
||||
|
||||
//Not exist, so we have to add this $picklist_value in $fieldname(picklist name) table
|
||||
$picklist_value = addslashes($picklist_value);
|
||||
|
||||
$adb->println("$picklist_value has to be added in the table $tablename");
|
||||
|
||||
$cfId=$adb->getUniqueID($tablename);
|
||||
$unique_picklist_value = getUniquePicklistID();
|
||||
$qry="insert into $tablename values(?,?,?,?)";
|
||||
$adb->pquery($qry, array($cfId,$picklist_value,1,$unique_picklist_value));
|
||||
//added to fix ticket#4492
|
||||
$picklistId_qry = "select picklistid from vtiger_picklist where name=?";
|
||||
$picklistId_res = $adb->pquery($picklistId_qry,array($fieldname));
|
||||
$picklist_Id = $adb->query_result($picklistId_res,0,'picklistid');
|
||||
|
||||
$role_id = $current_user->roleid;
|
||||
$sort_qry = "select max(sortid)+1 as sortid from vtiger_role2picklist where picklistid=? and roleid=?";
|
||||
$sort_qry_res = $adb->pquery($sort_qry,array($picklist_Id,$role_id));
|
||||
$sort_id = $adb->query_result($sort_qry_res,0,'sortid');
|
||||
$role_picklist = "insert into vtiger_role2picklist values (?,?,?,?)";
|
||||
$adb->pquery($role_picklist,array($role_id,$unique_picklist_value,$picklist_Id,$sort_id));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user