From 2556c057cd1fd4785031375120bf8b40cdabbb3b Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Tue, 16 Nov 2010 07:50:50 +0000 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=B0=205.2=20=E6=AD=A3?= =?UTF-8?q?=E5=BC=8F=E7=89=88=E5=90=8E=E7=AC=AC=E4=B8=80=E6=AC=A1=20SVN=20?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit yuchenghu@hawebs.net git-svn-id: https://svn.code.sf.net/p/hawebs/svn@611 a2543c7e-f6e9-4f8a-8bff-1ffc34733512 --- oss/vtiger/trunk/modules/Import/Forms.php | 259 +++++++++ .../trunk/modules/Import/ImportAccount.php | 217 +++++++ .../trunk/modules/Import/ImportAjax.php | 82 +++ .../trunk/modules/Import/ImportButton.php | 51 ++ .../trunk/modules/Import/ImportContact.php | 305 ++++++++++ .../trunk/modules/Import/ImportLead.php | 100 ++++ oss/vtiger/trunk/modules/Import/ImportMap.php | 226 ++++++++ .../modules/Import/ImportOpportunity.php | 125 ++++ .../trunk/modules/Import/ImportProduct.php | 163 ++++++ .../trunk/modules/Import/ImportSave.php | 548 ++++++++++++++++++ .../trunk/modules/Import/ImportStep1.php | 104 ++++ .../trunk/modules/Import/ImportStep2.php | 459 +++++++++++++++ .../trunk/modules/Import/ImportStep3.php | 312 ++++++++++ .../trunk/modules/Import/ImportSteplast.php | 306 ++++++++++ .../trunk/modules/Import/ImportStepundo.php | 129 +++++ .../trunk/modules/Import/ImportTicket.php | 136 +++++ .../trunk/modules/Import/ImportVendors.php | 80 +++ .../trunk/modules/Import/UsersLastImport.php | 475 +++++++++++++++ oss/vtiger/trunk/modules/Import/error.php | 68 +++ oss/vtiger/trunk/modules/Import/index.php | 252 ++++++++ .../modules/Import/language/en_us.lang.php | 432 ++++++++++++++ .../modules/Import/language/zh_cn.lang.php | 431 ++++++++++++++ .../trunk/modules/Import/lastImport.php | 207 +++++++ .../trunk/modules/Import/parse_utils.php | 158 +++++ .../modules/Import/picklist_addition.php | 89 +++ 25 files changed, 5714 insertions(+) create mode 100644 oss/vtiger/trunk/modules/Import/Forms.php create mode 100644 oss/vtiger/trunk/modules/Import/ImportAccount.php create mode 100644 oss/vtiger/trunk/modules/Import/ImportAjax.php create mode 100644 oss/vtiger/trunk/modules/Import/ImportButton.php create mode 100644 oss/vtiger/trunk/modules/Import/ImportContact.php create mode 100644 oss/vtiger/trunk/modules/Import/ImportLead.php create mode 100644 oss/vtiger/trunk/modules/Import/ImportMap.php create mode 100644 oss/vtiger/trunk/modules/Import/ImportOpportunity.php create mode 100644 oss/vtiger/trunk/modules/Import/ImportProduct.php create mode 100644 oss/vtiger/trunk/modules/Import/ImportSave.php create mode 100644 oss/vtiger/trunk/modules/Import/ImportStep1.php create mode 100644 oss/vtiger/trunk/modules/Import/ImportStep2.php create mode 100644 oss/vtiger/trunk/modules/Import/ImportStep3.php create mode 100644 oss/vtiger/trunk/modules/Import/ImportSteplast.php create mode 100644 oss/vtiger/trunk/modules/Import/ImportStepundo.php create mode 100644 oss/vtiger/trunk/modules/Import/ImportTicket.php create mode 100644 oss/vtiger/trunk/modules/Import/ImportVendors.php create mode 100644 oss/vtiger/trunk/modules/Import/UsersLastImport.php create mode 100644 oss/vtiger/trunk/modules/Import/error.php create mode 100644 oss/vtiger/trunk/modules/Import/index.php create mode 100644 oss/vtiger/trunk/modules/Import/language/en_us.lang.php create mode 100644 oss/vtiger/trunk/modules/Import/language/zh_cn.lang.php create mode 100644 oss/vtiger/trunk/modules/Import/lastImport.php create mode 100644 oss/vtiger/trunk/modules/Import/parse_utils.php create mode 100644 oss/vtiger/trunk/modules/Import/picklist_addition.php diff --git a/oss/vtiger/trunk/modules/Import/Forms.php b/oss/vtiger/trunk/modules/Import/Forms.php new file mode 100644 index 00000000..1bcda405 --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/Forms.php @@ -0,0 +1,259 @@ +$unused) + { + $print_required_array .= "required['$required'] = '". $all_fields[$required] . "';\n"; + + } + + $the_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; + + 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 = "\n"; + return $output; +} + + +function get_readonly_js () +{ +?> + + + diff --git a/oss/vtiger/trunk/modules/Import/ImportAccount.php b/oss/vtiger/trunk/modules/Import/ImportAccount.php new file mode 100644 index 00000000..f9d8e8aa --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/ImportAccount.php @@ -0,0 +1,217 @@ +'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 + +} + + + +?> diff --git a/oss/vtiger/trunk/modules/Import/ImportAjax.php b/oss/vtiger/trunk/modules/Import/ImportAjax.php new file mode 100644 index 00000000..45b8c905 --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/ImportAjax.php @@ -0,0 +1,82 @@ +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'); + +} + +?> diff --git a/oss/vtiger/trunk/modules/Import/ImportButton.php b/oss/vtiger/trunk/modules/Import/ImportButton.php new file mode 100644 index 00000000..93b15edc --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/ImportButton.php @@ -0,0 +1,51 @@ + +
  • + +
  • + +
  • + +
  • + \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Import/ImportContact.php b/oss/vtiger/trunk/modules/Import/ImportContact.php new file mode 100644 index 00000000..94da2cc1 --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/ImportContact.php @@ -0,0 +1,305 @@ +salutation) && + ! isset( $comboFieldArray['salutation_dom'][ $this->salutation ]) ) + { + $this->salutation = ''; + } + } + + function add_lead_source() + { + if ( isset($this->lead_source) && + ! isset( $comboFieldArray['lead_source_dom'][ $this->lead_source ]) ) + { + $this->lead_source = ''; + } + + } + + function add_birthdate() + { + if ( isset($this->birthdate)) + { + if (! preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/',$this->birthdate)) + { + $this->birthdate = ''; + } + } + + } + + function add_do_not_call() + { + if ( isset($this->do_not_call) && $this->do_not_call != 'on') + { + $this->do_not_call = ''; + } + + } + + function add_email_opt_out() + { + if ( isset($this->email_opt_out) && $this->email_opt_out != 'on') + { + $this->email_opt_out = ''; + } + } + + function add_primary_address_streets() + { + if ( isset($this->primary_address_street_2)) + { + $this->primary_address_street .= " ". $this->primary_address_street_2; + } + + if ( isset($this->primary_address_street_3)) + { + $this->primary_address_street .= " ". $this->primary_address_street_3; + } + } + + function add_alt_address_streets() + { + if ( isset($this->alt_address_street_2)) + { + $this->alt_address_street .= " ". $this->alt_address_street_2; + } + + if ( isset($this->alt_address_street_3)) + { + $this->alt_address_street .= " ". $this->alt_address_street_3; + } + + } + + function get_names_from_full_name() + { + if ( ! isset($this->full_name)) + { + return; + } + $arr = array(); + + $name_arr = preg_split('/\s+/',$this->full_name); + + if ( count($name_arr) == 1) + { + $this->last_name = $this->full_name; + } + + $this->first_name = array_shift($name_arr); + + $this->last_name = join(' ',$name_arr); + + } + */ + + // Module Sequence Numbering + function modseq_number() { + $this->column_fields['contact_no'] = ''; + } + // END + + /** function used to create or map with existing account if the contact has mapped with an account during import + */ + function add_create_account() + { + global $adb; + // global is defined in UsersLastImport.php + global $imported_ids; + global $current_user; + + $acc_name = $this->column_fields['account_id']; + $adb->println("contact add_create acc=".$acc_name); + + if ((! isset($acc_name) || $acc_name == '') ) + { + return; + } + + $arr = array(); + + // check if it already exists + $focus = new Accounts(); + + $query = ''; + + // if user is defining the vtiger_account id to be associated with this contact.. + + //Modified to remove the spaces at first and last in vtiger_account name -- after 4.2 patch 2 + $acc_name = trim($acc_name); + + //Modified the query to get the available account only ie., which is not deleted + $query = "select vtiger_crmentity.deleted, vtiger_account.* from vtiger_account, vtiger_crmentity WHERE accountname=? and vtiger_crmentity.crmid =vtiger_account.accountid and vtiger_crmentity.deleted=0"; + $result = $adb->pquery($query, array($acc_name)); + + $row = $this->db->fetchByAssoc($result, -1, false); + + $adb->println("fetched account"); + $adb->println($row); + + // we found a row with that id + if (isset($row['accountid']) && $row['accountid'] != -1) + { + $focus->id = $row['accountid']; + $adb->println("Account row exists - using same id=".$focus->id); + } + + // if we didnt find the vtiger_account, so create it + if (! isset($focus->id) || $focus->id == '') + { + $adb->println("Createing new vtiger_account"); + $focus->column_fields['accountname'] = $acc_name; + $focus->column_fields['assigned_user_id'] = $current_user->id; + $focus->column_fields['modified_user_id'] = $current_user->id; + + //$focus->saveentity("Accounts"); + $focus->save("Accounts"); + $acc_id = $focus->id; + + $adb->println("New Account created id=".$focus->id); + + // avoid duplicate mappings: + if (! isset( $imported_ids[$acc_id]) ) + { + $adb->println("inserting vtiger_users last import for vtiger_accounts"); + // save the new vtiger_account as a vtiger_users_last_import + $last_import = new UsersLastImport(); + $last_import->assigned_user_id = $current_user->id; + $last_import->bean_type = "Accounts"; + $last_import->bean_id = $focus->id; + $last_import->save(); + $imported_ids[$acc_id] = 1; + } + } + + $adb->println("prev contact accid=".$this->column_fields["account_id"]); + // now just link the vtiger_account + $this->column_fields["account_id"] = $focus->id; + $adb->println("curr contact accid=".$this->column_fields["account_id"]); + + } + + /** function used to map with existing Reports To(Contact) if the contact is map with reports to during import + */ + function map_reports_to() + { + global $adb; + + $contact_name = $this->column_fields['contact_id']; + $adb->println("Entering map_reports_to contact_id=".$contact_name); + + if ((! isset($contact_name) || $contact_name == '') ) + { + $adb->println("Exit map_reports_to. Contact Name(Reports To) not set for this entity."); + return; + } + + $contact_name = trim($contact_name); + + //Query to get the available Contact (Reports To) which is not deleted + $query = "select contactid from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid WHERE concat(vtiger_contactdetails.lastname,' ',vtiger_contactdetails.firstname) = ? and vtiger_crmentity.deleted=0"; + $contact_id = $adb->query_result($adb->pquery($query, array($contact_name)),0,'contactid'); + + if($contact_id == '' || !isset($contact_id)) + $contact_id = 0; + + $this->column_fields['contact_id'] = $contact_id; + + $adb->println("Exit map_reports_to. Fetched Contact (Reports To) for '".$contact_name."' and the contactid = $contact_id"); + } + + + // This is the list of vtiger_fields that can be imported + // some of these don't map directly to columns in the db + + //we need to add two or more arrays as the columns are distributed across the vtiger_tables now + /*var $importable_fields = array( + "contactid"=>1, + "firstname"=>1, + "lastname"=>1, + "salutation"=>1, + "donotcall"=>1, + "emailoptout"=>1, + "accountid"=>1, + "title"=>1, + "department"=>1, + "phone"=>1, + "mobile"=>1, + "fax"=>1, + "email"=>1, + "otheremail"=>1, + "yahooid"=>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 ImportContact() { + parent::Contacts(); + $this->log = LoggerManager::getLogger('import_contact'); + $this->db = PearDatabase::getInstance(); + $this->db->println("IMP ImportContact"); + $this->initImportableFields("Contacts"); + $this->db->println($this->importable_fields); + } + +} + + + +?> diff --git a/oss/vtiger/trunk/modules/Import/ImportLead.php b/oss/vtiger/trunk/modules/Import/ImportLead.php new file mode 100644 index 00000000..1c381e6c --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/ImportLead.php @@ -0,0 +1,100 @@ +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); + } + +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Import/ImportMap.php b/oss/vtiger/trunk/modules/Import/ImportMap.php new file mode 100644 index 00000000..4aa1d40e --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/ImportMap.php @@ -0,0 +1,226 @@ +"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; + } + +} + + +?> diff --git a/oss/vtiger/trunk/modules/Import/ImportOpportunity.php b/oss/vtiger/trunk/modules/Import/ImportOpportunity.php new file mode 100644 index 00000000..3ae55bfc --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/ImportOpportunity.php @@ -0,0 +1,125 @@ +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 +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Import/ImportProduct.php b/oss/vtiger/trunk/modules/Import/ImportProduct.php new file mode 100644 index 00000000..f1d80f96 --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/ImportProduct.php @@ -0,0 +1,163 @@ +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 +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Import/ImportSave.php b/oss/vtiger/trunk/modules/Import/ImportSave.php new file mode 100644 index 00000000..ffd8f1d4 --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/ImportSave.php @@ -0,0 +1,548 @@ +$data) + $users_groups_list[$data] = $key; + + $temp = get_group_array(FALSE); + foreach ( $temp as $key=>$data) + $users_groups_list[$data] = $key; + + p(print_r(users_groups_list,1)); + $adb->println("Users List : "); + $adb->println($users_groups_list); + $dup_count = 0; + $count = 0; + $dup_ow_count = 0; + $process_fields='false'; + if($start == 0) + { + $_SESSION['totalrows'] = $rows; + $_SESSION['return_field_count'] = $ret_field_count; + $_SESSION['column_position_to_field'] = $col_pos_to_field; + } + $ii = $start; + // go thru each row, process and save() + foreach ($rows1 as $row) + { + $adb->println("Going to Save the row ".$ii." =====> "); + $adb->println($row); + global $mod_strings; + + $do_save = 1; + //MWC + $my_userid = $current_user->id; + + //If we want to set default values for some fields for each entity then we have to set here + if($module == 'Products' || $module == 'Services')//discontinued is not null. if we unmap active, NULL will be inserted and query will fail + $focus->column_fields['discontinued'] = 'on'; + + for($field_count = 0; $field_count < $ret_field_count; $field_count++) + { + p("col_pos[".$field_count."]=".$col_pos_to_field[$field_count]); + + if ( isset( $col_pos_to_field[$field_count]) ) + { + p("set =".$field_count); + if (! isset( $row[$field_count]) ) + { + continue; + } + + p("setting"); + + // TODO: add check for user input + // addslashes, striptags, etc.. + $field = $col_pos_to_field[$field_count]; + + //picklist function is added to avoid duplicate picklist entries + $pick_orginal_val = getPicklist($field,$row[$field_count]); + + if($pick_orginal_val != null) + { + $focus->column_fields[$field]=$pick_orginal_val; + } + //MWC + elseif ( $field == "assignedto" || $field == "assigned_user_id" ) + { + //Here we are assigning the user id in column fields, so in function assign_user (ImportLead.php and ImportProduct.php files) we should use the id instead of user name when query the user + //or we can use $focus->column_fields['smownerid'] = $users_groups_list[$row[$field_count]]; + $focus->column_fields[$field] = $users_groups_list[trim($row[$field_count])]; + p("setting my_userid=$my_userid for user=".$row[$field_count]); + } + else + { + //$focus->$field = $row[$field_count]; + $focus->column_fields[$field] = $row[$field_count]; + p("Setting ".$field."=".$row[$field_count]); + } + + } + + } + if($focus->column_fields['notify_owner'] == '') + { + $focus->column_fields['notify_owner'] = '0'; + } + if($focus->column_fields['reference'] == '') + { + $focus->column_fields['reference'] = '0'; + } + if($focus->column_fields['emailoptout'] == '') + { + $focus->column_fields['emailoptout'] = '0'; + } + if($focus->column_fields['donotcall'] == '') + { + $focus->column_fields['donotcall'] = '0'; + } + if($focus->column_fields['discontinued'] == '') + { + $focus->column_fields['discontinued'] = '0'; + } + if($focus->column_fields['active'] == '') + { + $focus->column_fields['active'] = '0'; + } + p("setting done"); + + p("do save before req vtiger_fields=".$do_save); + + $adb->println($focus->required_fields); + foreach ($focus->required_fields as $field=>$notused) + { + $fv = trim($focus->column_fields[$field]); + if (! isset($fv) || $fv == '') + { + // Leads Import does not allow an empty lastname because the link is created on the lastname + // Without lastname the Lead could not be opened. + // But what if the import file has only company and telefone information? + // It would be stupid to skip all the companies which don't have a contact person yet! + // So we set lastname ="?????" and the user can later enter a name. + // So the lastname is still mandatory but may be empty. + if ($field == 'lastname' && $module == 'Leads') + { + $focus->column_fields[$field] = '?????'; + } + else + { + p("fv ".$field." not set"); + $do_save = 0; + $skip_required_count++; + break; + } + } + } + + if ( ! isset($focus->column_fields["assigned_user_id"]) || $focus->column_fields["assigned_user_id"]==='' || $focus->column_fields["assigned_user_id"]===NULL) { + $focus->column_fields["assigned_user_id"] = $my_userid; + } + + //added for duplicate handling + if(is_record_exist($module,$focus)) + { + if($do_save != 0) + { + $do_save = 0; + $dup_count++; + } + } + p("do save=".$do_save); + + if ($do_save) + { + p("saving.."); + + if ( ! isset($focus->column_fields["assigned_user_id"]) || $focus->column_fields["assigned_user_id"]=='') + { + //$focus->column_fields["assigned_user_id"] = $current_user->id; + //MWC + $focus->column_fields["assigned_user_id"] = $my_userid; + } + + //handle uitype 10 + foreach($focus->importable_fields as $fieldname=>$uitype){ + $uitype = $focus->importable_fields[$fieldname]; + if($uitype == 10){ + //added to handle security permissions for related modules :: for e.g. Accounts/Contacts in Potentials + if(method_exists($focus, "add_related_to")){ + if(!$focus->add_related_to($module, $fieldname)){ + if(array_key_exists($fieldname, $focus->required_fields)){ + $do_save = 0; + $skip_required_count++; + continue 2; + } + } + } + } + } + + // now do any special processing for ex., map account with contact and potential + if($process_fields == 'false'){ + $focus->process_special_fields(); + } + $focus->saveentity($module); + //$focus->saveentity($module); + $return_id = $focus->id; + + $last_import = new UsersLastImport(); + $last_import->assigned_user_id = $current_user->id; + $last_import->bean_type = $_REQUEST['module']; + $last_import->bean_id = $focus->id; + $last_import->save(); + $count++; + } + $ii++; + } + + $_REQUEST['count'] = $ii; + if(isset($_REQUEST['module'])) + $modulename = vtlib_purify($_REQUEST['module']); + + $end = $start+$recordcount; + $START = $start + $recordcount; + $RECORDCOUNT = $recordcount; + $dup_check_type = $_REQUEST['dup_type']; + $auto_dup_type = $_REQUEST['auto_type']; + + if($end >= $totalnoofrows) { + $module = 'Import';//$_REQUEST['module']; + $action = 'ImportSteplast'; + //exit; + $imported_records = $totalnoofrows - $skip_required_count; + if($imported_records == $totalnoofrows) { + $skip_required_count = 0; + } + if($dup_check_type == "auto") { + if($auto_dup_type == "ignore") { + $dup_info = $mod_strings['Duplicate_Records_Skipped_Info'].$dup_count; + $imported_records -= $dup_count; + } + else if($auto_dup_type == "overwrite") { + $dup_info = $mod_strings['Duplicate_Records_Overwrite_Info'].$dup_ow_count; + $imported_records -= $dup_ow_count; + } + } + else + $dup_info = ""; + + if($imported_records < 0) $imported_records = 0; + + $message= urlencode("".$mod_strings['LBL_SUCCESS'].""."

    " .$mod_strings['LBL_SUCCESS_1']." $imported_records " .$mod_strings['of'].' '.$totalnoofrows."

    " .$mod_strings['LBL_SKIPPED_1']." $skip_required_count

    ".$dup_info ); + } else { + $module = 'Import'; + $action = 'ImportStep3'; + } +?> + + + +'.$start.' '.$mod_strings['to'].' '.$end.' '.$mod_strings['of'].' '.$totalnoofrows.' '.$mod_strings['are_imported_succesfully']; + //return $_SESSION['import_display_message']; +} + +function is_record_exist($module,$focus) +{ + global $adb; + global $dup_ow_count; + $dup_check_type = $_REQUEST['dup_type']; + $auto_dup_type = ""; + $sec_parameter = ""; + if($dup_check_type == 'auto') + { + $auto_dup_type = $_REQUEST['auto_type']; + } + if($auto_dup_type == "ignore") + { + $sec_parameter = getSecParameterforMerge($module); + if($module == "Leads") + { + $sel_qry = "select count(*) as count from vtiger_leaddetails + inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_leaddetails.leadid + inner join vtiger_leadsubdetails on vtiger_leaddetails.leadid = vtiger_leadsubdetails.leadsubscriptionid + inner join vtiger_leadaddress on vtiger_leadaddress.leadaddressid = vtiger_leaddetails.leadid + left join vtiger_leadscf on vtiger_leadscf.leadid = vtiger_leaddetails.leadid + LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid + LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid + where vtiger_crmentity.deleted = 0 AND vtiger_leaddetails.converted = 0 $sec_parameter"; + } + else if($module == "Accounts") + { + $sel_qry = "SELECT count(*) as count FROM vtiger_account + INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_account.accountid + INNER JOIN vtiger_accountbillads ON vtiger_account.accountid = vtiger_accountbillads.accountaddressid + INNER JOIN vtiger_accountshipads ON vtiger_account.accountid = vtiger_accountshipads.accountaddressid + LEFT JOIN vtiger_accountscf ON vtiger_account.accountid = vtiger_accountscf.accountid + LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid + LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid + WHERE vtiger_crmentity.deleted = 0 $sec_parameter"; + } + else if($module == "Contacts") + { + $sel_qry = "SELECT count(*) as count FROM vtiger_contactdetails + INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid + INNER JOIN vtiger_contactaddress ON vtiger_contactaddress.contactaddressid = vtiger_contactdetails.contactid + INNER JOIN vtiger_contactsubdetails ON vtiger_contactsubdetails.contactsubscriptionid = vtiger_contactdetails.contactid + LEFT JOIN vtiger_contactscf ON vtiger_contactscf.contactid = vtiger_contactdetails.contactid + LEFT JOIN vtiger_customerdetails ON vtiger_customerdetails.customerid=vtiger_contactdetails.contactid + LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid + LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid + WHERE vtiger_crmentity.deleted = 0 $sec_parameter"; + } + else if($module == "Products") + { + $sel_qry = "SELECT count(*) as count FROM vtiger_products + INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_products.productid + LEFT JOIN vtiger_productcf ON vtiger_productcf.productid = vtiger_products.productid + WHERE vtiger_crmentity.deleted = 0 "; + } + else if($module == "Vendors") + { + $sel_qry = "select count(*) as count from vtiger_vendor + INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_vendor.vendorid + LEFT JOIN vtiger_vendorcf ON vtiger_vendorcf.vendorid = vtiger_vendor.vendorid + WHERE vtiger_crmentity.deleted = 0"; + } else { + $sel_qry = "select count(*) as count from $focus->table_name + INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = $focus->table_name.$focus->table_index"; + // Consider custom table join as well. + if(isset($focus->customFieldTable)) { + $sel_qry .= " INNER JOIN ".$focus->customFieldTable[0]." ON ".$focus->customFieldTable[0].'.'.$focus->customFieldTable[1] . + " = $focus->table_name.$focus->table_index"; + } + $sel_qry .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid + LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id + WHERE vtiger_crmentity.deleted = 0 $sec_parameter"; + } + $sel_qry .= get_where_clause($module,$focus->column_fields); + $result = $adb->query($sel_qry); + $cnt = $adb->query_result($result,0,"count"); + if($cnt > 0) + return true; + else + return false; + } + else if($auto_dup_type == "overwrite") + { + return overwrite_duplicate_records($module,$focus); + } + else + return false; +} +//function to get the where clause for the duplicate - select query +function get_where_clause($module,$column_fields) { + global $current_user, $dup_ow_count, $adb; + $where_clause = ""; + $field_values_array=getFieldValues($module); + $field_values=$field_values_array['fieldnames_list']; + $tblname_field_arr = explode(",",$field_values); + $uitype_arr = $field_values_array['fieldname_uitype']; + + $focus = CRMEntity::getInstance($module); + + foreach($tblname_field_arr as $val) { + list($tbl,$col,$fld) = explode(".",$val); + $col_name = $tbl ."." . $col; + $field_value=$column_fields[$fld]; + + if($fld == $focus->table_index && $column_fields[$focus->table_index] !='' && !is_integer($column_fields[$focus->table_index])) { + $field_value = getEntityId($module, $column_fields[$focus->table_index]); + } + + if(is_uitype($uitype_arr[$fld],'_users_list_') && $field_value == '') { + $field_value = $current_user->id; + } + $where_clause .= " AND ifnull(". $adb->sql_escape_string($col_name) .",'') = ifnull('". $adb->sql_escape_string($field_value) ."','') "; + } + return $where_clause; +} +//function to overwrite the existing duplicate records with the importing record's values +function overwrite_duplicate_records($module,$focus) +{ + global $adb; + global $dup_ow_count; + global $process_fields; + + //Fix for 6187 : overwriting records during duplicate merge to handle uitype 10 + //handle uitype 10 + foreach($focus->importable_fields as $fieldname=>$uitype){ + $uitype = $focus->importable_fields[$fieldname]; + if($uitype == 10){ + //added to handle security permissions for related modules :: for e.g. Accounts/Contacts in Potentials + if(method_exists($focus, "add_related_to")){ + if(!$focus->add_related_to($module, $fieldname)){ + if(array_key_exists($fieldname, $focus->required_fields)){ + $do_save = 0; + $skip_required_count++; + continue 2; + } + } + } + } + } + $where_clause = ""; + $where = get_where_clause($module,$focus->column_fields); + $sec_parameter = getSecParameterforMerge($module); + if($module == "Leads") + { + $sel_qry = "select vtiger_leaddetails.leadid from vtiger_leaddetails + inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_leaddetails.leadid + inner join vtiger_leadsubdetails on vtiger_leaddetails.leadid = vtiger_leadsubdetails.leadsubscriptionid + inner join vtiger_leadaddress on vtiger_leadaddress.leadaddressid = vtiger_leaddetails.leadid + left join vtiger_leadscf on vtiger_leadscf.leadid = vtiger_leaddetails.leadid + LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid + LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid + where vtiger_crmentity.deleted = 0 AND vtiger_leaddetails.converted = 0 $where $sec_parameter order by vtiger_leaddetails.leadid ASC"; + } + else if($module == "Accounts") + { + $sel_qry = "SELECT vtiger_account.accountid FROM vtiger_account + INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_account.accountid + INNER JOIN vtiger_accountbillads ON vtiger_account.accountid = vtiger_accountbillads.accountaddressid + INNER JOIN vtiger_accountshipads ON vtiger_account.accountid = vtiger_accountshipads.accountaddressid + LEFT JOIN vtiger_accountscf ON vtiger_account.accountid = vtiger_accountscf.accountid + LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid + LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid + WHERE vtiger_crmentity.deleted = 0 $where $sec_parameter order by vtiger_account.accountid ASC"; + } + else if($module == "Contacts") + { + $sel_qry = "SELECT vtiger_contactdetails.contactid FROM vtiger_contactdetails + INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid + INNER JOIN vtiger_contactaddress ON vtiger_contactaddress.contactaddressid = vtiger_contactdetails.contactid + INNER JOIN vtiger_contactsubdetails ON vtiger_contactsubdetails.contactsubscriptionid = vtiger_contactdetails.contactid + LEFT JOIN vtiger_contactscf ON vtiger_contactscf.contactid = vtiger_contactdetails.contactid + LEFT JOIN vtiger_customerdetails ON vtiger_customerdetails.customerid=vtiger_contactdetails.contactid + LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid + LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid + WHERE vtiger_crmentity.deleted = 0 $where $sec_parameter order by vtiger_contactdetails.contactid ASC"; + } + else if($module == "Products") + { + $sel_qry = "SELECT vtiger_products.productid FROM vtiger_products + INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_products.productid + LEFT JOIN vtiger_productcf ON vtiger_productcf.productid = vtiger_products.productid + WHERE vtiger_crmentity.deleted = 0 $where order by vtiger_products.productid ASC"; + } + else if($module == "Vendors") + { + $sel_qry = "SELECT vtiger_vendor.vendorid FROM vtiger_vendor + INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_vendor.vendorid + LEFT JOIN vtiger_vendorcf ON vtiger_vendorcf.vendorid = vtiger_vendor.vendorid + WHERE vtiger_crmentity.deleted = 0 $where order by vtiger_vendor.vendorid ASC"; + } + else { + $sel_qry = "SELECT $focus->table_name.$focus->table_index FROM $focus->table_name + INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = $focus->table_name.$focus->table_index"; + // Consider custom table join as well. + if(isset($focus->customFieldTable)) { + $sel_qry .= " INNER JOIN ".$focus->customFieldTable[0]." ON ".$focus->customFieldTable[0].'.'.$focus->customFieldTable[1] . + " = $focus->table_name.$focus->table_index"; + } + $sel_qry .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid + LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id + WHERE vtiger_crmentity.deleted = 0 $where $sec_parameter order by $focus->table_name.$focus->table_index ASC"; + } + $result = $adb->query($sel_qry); + $no_rows = $adb->num_rows($result); + // now do any special processing for ex., map account with contact and potential + $focus->process_special_fields(); + $process_fields='true'; + $moduleObj = new $module(); + if($no_rows > 0) + { + for($i=0;$i<$no_rows;$i++) + { + $id_field = $moduleObj->table_index; + $id_value = $adb->query_result($result,$i,$id_field); + if($i == 0) + { + $moduleObj->mode = "edit"; + $moduleObj->id = $id_value; + $moduleObj->column_fields = $focus->column_fields; + $moduleObj->save($module); + } + else{ + DeleteEntity($module,$module,$moduleObj,$id_value,""); + } + } + $dup_ow_count = $dup_ow_count+$no_rows; + return true; + } + else + return false; +} + +//picklist function is added to avoid duplicate picklist entries +function getPicklist($field,$value) +{ + global $table_picklist,$converted_table_picklist_values; + + //for the first run these will be defined and for the subsequent redirections + //pick up from session. + if(is_array($table_picklist)){ + $_SESSION['import_table_picklist'] = $table_picklist; + }else{ + $table_picklist = $_SESSION['import_table_picklist']; + } + if(is_array($converted_table_picklist_values)){ + $_SESSION['import_converted_picklist_values'] = $converted_table_picklist_values; + }else{ + $converted_table_picklist_values = $_SESSION['import_converted_picklist_values']; + } + + $orginal_val = $table_picklist[$field]; + $converted_val = $converted_table_picklist_values[$field]; + $temp_val = strtolower($value); + if(is_array($converted_val) && in_array($temp_val,$converted_val)) { + $existkey = array_search($temp_val,$converted_val); + $correct_val=$orginal_val[$existkey]; + return $correct_val; + } + return null; + +} + +?> diff --git a/oss/vtiger/trunk/modules/Import/ImportStep1.php b/oss/vtiger/trunk/modules/Import/ImportStep1.php new file mode 100644 index 00000000..f88ea776 --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/ImportStep1.php @@ -0,0 +1,104 @@ +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"); + +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Import/ImportStep2.php b/oss/vtiger/trunk/modules/Import/ImportStep2.php new file mode 100644 index 00000000..35892960 --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/ImportStep2.php @@ -0,0 +1,459 @@ + $upload_maxsize) +{ + show_error_import( $mod_strings['LBL_IMPORT_MODULE_ERROR_LARGE_FILE'] . " ". $upload_maxsize. " ". $mod_strings['LBL_IMPORT_MODULE_ERROR_LARGE_FILE_END']); + exit; +} +if( !is_writable( $import_dir )) +{ + show_error_import($mod_strings['LBL_IMPORT_MODULE_NO_DIRECTORY'].$import_dir.$mod_strings['LBL_IMPORT_MODULE_NO_DIRECTORY_END']); + exit; +} + +$tmp_file_name = $import_dir. "IMPORT_".$current_user->id; + +move_uploaded_file($_FILES['userfile']['tmp_name'], $tmp_file_name); + +// Convert ISO-8859 file (as saved by MS Excel) into UTF-8 to preserve umlauts and accents +if ($_REQUEST["format"] != "UTF-8") +{ + $fh = fopen($tmp_file_name,"r"); + $content = fread($fh, filesize($tmp_file_name)); + fclose($fh); + + if (function_exists("mb_convert_encoding")) + { + $content = mb_convert_encoding($content, 'UTF-8', $_REQUEST["format"]); + } else { + $content = iconv('UTF-8', $_REQUEST["format"], $content); + } + + $fh = fopen($tmp_file_name,"w"); + fwrite($fh, $content); + fclose($fh); +} + +// Now parse the file and look for errors +$ret_value = 0; + +if ($_REQUEST['source'] == 'act') +{ + $ret_value = parse_import_act($tmp_file_name,$delimiter,$max_lines,$has_header); +} +else +{ + $ret_value = parse_import($tmp_file_name,$delimiter,$max_lines,$has_header); +} + +if ($ret_value == -1) +{ + show_error_import( $mod_strings['LBL_CANNOT_OPEN'] ); + exit; +} +else if ($ret_value == -2) +{ + show_error_import( $mod_strings['LBL_NOT_SAME_NUMBER'] ); + exit; +} +else if ( $ret_value == -3 ) +{ + show_error_import( $mod_strings['LBL_NO_LINES'] ); + exit; +} + +$rows = $ret_value['rows']; +$ret_field_count = $ret_value['field_count']; + +$smarty = new vtigerCRM_Smarty; + +$smarty->assign("TMP_FILE", $tmp_file_name ); +$smarty->assign("SOURCE", vtlib_purify($_REQUEST['source'])); + +$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); +$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("HASHEADER", $has_header); + +$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); + //initialized the required fields,used to check for mandatory fields while importing + $focus->initRequiredFields($module); + // END +} +else +{ + $focus = new ImportContact(); +} + + +$total_num_rows=sizeof($rows); +$firstrow = $rows[0]; +if($total_num_rows >1 ) +{ + $secondrow = $rows[1]; +} +if($total_num_rows >2) +{ + $thirdrow = $rows[2]; +} + +//If the cell value is very large then UI mapping will be collpased. So we will display partial text +foreach($firstrow as $ind => $val) +{ + if(strlen($val) > 30) + $firstrow[$ind] = substr(to_html($val),0,30)." .........."; + else + $firstrow[$ind] = to_html($val); +} +if (isset($secondrow)) { //Asha: Fix for ticket #4432 + foreach($secondrow as $ind => $val) + { + if(strlen($val) > 30) + $secondrow[$ind] = substr(to_html($val),0,30)." .........."; + else + $secondrow[$ind] = to_html($val); + + } + if (isset($thirdrow)) { //Asha: Fix for ticket #4432 + foreach($thirdrow as $ind => $val) + { + if(strlen($val) > 30) + $thirdrow[$ind] = substr(to_html($val),0,30)." .........."; + else + $thirdrow[$ind] = to_html($val); + } + } +} + +$field_map = $outlook_contacts_field_map; + +$mapping_file = new ImportMap(); +$saved_map_lists = $mapping_file->getSavedMappingsList($_REQUEST['return_module']); +$map_list_combo = ''; +//This link is Delete link for the selected mapping +$map_list_combo .= "   "; +$smarty->assign("SAVED_MAP_LISTS",$map_list_combo); + + +if ( count($mapping_arr) > 0){ + $field_map = &$mapping_arr; +}else if ($_REQUEST['source'] == 'other'){ + if ($_REQUEST['module'] == 'Contacts'){ + $field_map = $outlook_contacts_field_map; + }else if ($_REQUEST['module'] == 'Accounts'){ + $field_map = $outlook_accounts_field_map; + }else if ($_REQUEST['module'] == 'Potentials'){ + $field_map = $salesforce_opportunities_field_map; + } +} + +$add_one = 1; +$start_at = 0; + +if($has_header){ + $add_one = 0; + $start_at = 1; +} + +for($row_count = $start_at; $row_count < count($rows); $row_count++){ + $smarty->assign("ROWCOUNT", $row_count + $add_one); +} + +$list_string_key = strtolower($_REQUEST['module']); +$list_string_key .= "_import_fields"; + +//Now we are getting the import fields from DB instead of hard coded array $mod_list_strings +$translated_column_fields = getImportFieldsList($_REQUEST['module']);//$mod_list_strings[$list_string_key]; + +$cnt=1; +for($field_count = 0; $field_count < $ret_field_count; $field_count++){ + + $smarty->assign("COLCOUNT", $field_count + 1); + $suggest = ""; + + if($_REQUEST['module']=='Accounts'){ + $tablename='account'; + $focus1=new Accounts(); + } + if($_REQUEST['module']=='Contacts'){ + $tablename='contactdetails'; + $focus1=new Contacts(); + } + if($_REQUEST['module']=='Leads'){ + $tablename='leaddetails'; + $focus1=new Leads(); + } + if($_REQUEST['module']=='Potentials'){ + $tablename='potential'; + $focus1=new Potentials(); + } + if($_REQUEST['module']=='Products'){ + $tablename='products'; + $focus1=new Products(); + } + if($_REQUEST['module']=='HelpDesk'){ + $tablename='troubletickets'; + $focus1=new HelpDesk(); + } + if($_REQUEST['module']=='Vendors'){ + $tablename='Vendors'; + $focus1=new Vendors(); + } + + // vtlib customization: Hook to provide generic import for other modules + if($_REQUEST['module']) { + $focus1 = CRMEntity::getInstance($_REQUEST['module']); + $tablename = $focus->table_name; + } + // END + + $smarty->assign("FIRSTROW",$firstrow); + $smarty->assign("SECONDROW",$secondrow); + $smarty->assign("THIRDROW",$thirdrow); + $smarty_array[$field_count + 1] = getFieldSelect( $focus->importable_fields, + $field_count, + $focus->required_fields, + $suggest, + $translated_column_fields, + $tablename + ); + + $pos = 0; + foreach($rows as $row ){ + if( isset($row[$field_count]) && $row[$field_count] != ''){ + $smarty->assign("CELL",htmlspecialchars($row[$field_count])); + } + $cnt++; + } +} +@session_unregister('import_delimiter'); +@session_unregister('import_has_header'); +@session_unregister('import_firstrow'); +@session_unregister('import_field_map'); +@session_unregister('import_module_object_column_fields'); +@session_unregister('import_module_field_count'); +@session_unregister('import_module_object_required_fields'); +@session_unregister('import_module_translated_column_fields'); +$_SESSION['import_delimiter'] = $delimiter; +$_SESSION['import_has_header'] = $has_header; +$_SESSION['import_firstrow'] = $firstrow; +$_SESSION['import_field_map'] = $field_map; +$_SESSION['import_module_object_column_fields'] = $focus->importable_fields; +$_SESSION['import_module_field_count'] = $field_count; +$_SESSION['import_module_object_required_fields'] = $focus1->required_fields; +$_SESSION['import_module_translated_column_fields'] = $translated_column_fields; + +$smarty->assign("SELECTFIELD",$smarty_array); +$smarty->assign("ROW", $row); + +$module_key = "LBL_".strtoupper($_REQUEST['module'])."_NOTE_"; + +for ($i = 1;isset($mod_strings[$module_key.$i]);$i++){ + $smarty->assign("NOTETEXT", $mod_strings[$module_key.$i]); +} + +if($has_header){ + $smarty->assign("HAS_HEADER", 'on'); +}else{ + $smarty->assign("HAS_HEADER", 'off'); +} + +$smarty->assign("AVALABLE_FIELDS", getMergeFields($module,"available_fields")); +$smarty->assign("FIELDS_TO_MERGE", getMergeFields($module,"fileds_to_merge")); +if(isPermitted($module,'DuplicatesHandling','') == 'yes'){ + $smarty->assign("DUPLICATESHANDLING", 'DuplicatesHandling'); +} + +$smarty->assign("MODULE", vtlib_purify($_REQUEST['module'])); +$smarty->assign("MODULELABEL", getTranslatedString($_REQUEST['module'],$_REQUEST['module'])); +$parenttab = getParentTab(); +$smarty->assign('CATEGORY' , $parenttab); +$_SESSION['import_parenttab'] = $parenttab; +$smarty->assign("JAVASCRIPT2", get_readonly_js() ); + +$smarty->display('ImportStep2.tpl'); + +?> + diff --git a/oss/vtiger/trunk/modules/Import/ImportStep3.php b/oss/vtiger/trunk/modules/Import/ImportStep3.php new file mode 100644 index 00000000..97835175 --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/ImportStep3.php @@ -0,0 +1,312 @@ +println("IMP :".$str); +} + +function implode_assoc($inner_delim, $outer_delim, $array){ + $output = array(); + foreach( $array as $key => $item ){ + $output[] = $key . $inner_delim . $item; + } + return implode($outer_delim, $output); +} + +global $mod_strings; +global $app_list_strings; +global $app_strings; +global $current_user; +global $import_file_name; +global $theme; +global $upload_maxsize; +global $site_URL; + +$theme_path="themes/".$theme."/"; +$image_path=$theme_path."images/"; + +$log->info("Upload Step 3"); + +include("include/saveMergeCriteria.php"); + +$delimiter = ','; +// file handle +$count = 0; +$error = ""; +$col_pos_to_field = array(); +$header_to_field = array(); +$field_to_pos = array(); +$focus = 0; +$current_bean_type = ""; +$id_exists_count = 0; +$broken_ids = 0; + +$delimiter = $_SESSION['import_delimiter']; + +$has_header = 0; + +if(isset( $_REQUEST['has_header']) && $_REQUEST['has_header'] == 'on'){ + $has_header = 1; +} + +if($_REQUEST['modulename'] != ''){ + $_REQUEST['module'] = vtlib_purify($_REQUEST['modulename']); +} + +$import_object_array = Array( + "Leads"=>"ImportLead", + "Accounts"=>"ImportAccount", + "Contacts"=>"ImportContact", + "Potentials"=>"ImportOpportunity", + "Products"=>"ImportProduct", + "HelpDesk"=>"ImportTicket", + "Vendors"=>"ImportVendors" + ); + +if(isset($_REQUEST['module']) && $_REQUEST['module'] != ''){ + $current_bean_type = $import_object_array[$_REQUEST['module']]; + // vtlib customization: Hook added to enable import for un-mapped modules + $module = $_REQUEST['module']; + if($current_bean_type == null) { + checkFileAccess("modules/$module/$module.php"); + require_once("modules/$module/$module.php"); + $current_bean_type = $module; + $callInitImport = true; + } + // END +}else{ + $current_bean_type = "ImportContact"; +} + +$focus = new $current_bean_type(); +// vtlib customization: Call the import initializer +if($callInitImport) $focus->initImport($module); +// END + +//Constructing the custom vtiger_field Array +require_once('include/CustomFieldUtil.php'); +$custFldArray = getCustomFieldArray($_REQUEST['module']); +p("IMP 3: custFldArray"); +p($custFldArray); + +//Initializing an empty Array to store the custom vtiger_field Column Name and Value +$resCustFldArray = Array(); + +p("Getting from request"); +// loop through all request variables +foreach ($_REQUEST as $name=>$value){ + p("name=".$name." value=".$value); + // only look for var names that start with "colnum" + if ( strncasecmp( $name, "colnum", 6) != 0 ){ + continue; + } + if ($value == "-1"){ + continue; + } + + $user_field = $value; + $pos = substr($name,6); + + if ( isset( $field_to_pos[$user_field]) ){ + show_error_import($mod_strings['LBL_ERROR_MULTIPLE']); + exit; + } + + p("user_field=".$user_field." if=".$focus->importable_fields[$user_field]); + + if ( isset( $focus->importable_fields[$user_field] ) || isset( $custFldArray[$user_field] )){ + p("user_field SET=".$user_field); + $field_to_pos[$user_field] = $pos; + $col_pos_to_field[$pos] = $user_field; + } +} + +p("field_to_pos"); +$adb->println($field_to_pos); +p("col_pos_to_field"); +$adb->println($col_pos_to_field); + +$max_lines = -1; +$ret_value = 0; + +if(isset($_REQUEST['tmp_file'])) { + $_SESSION['tmp_file'] = vtlib_purify($_REQUEST['tmp_file']); +} else { + $_REQUEST['tmp_file'] = vtlib_purify($_SESSION['tmp_file']); +} +// End + +if ($_REQUEST['source'] == 'act'){ + $ret_value = parse_import_act($_REQUEST['tmp_file'],$delimiter,$max_lines,$has_header); +}else{ + $ret_value = parse_import($_REQUEST['tmp_file'],$delimiter,$max_lines,$has_header); +} + +$datarows = $ret_value['rows']; + +$ret_field_count = $ret_value['field_count']; + +//we have to get all picklist entries and add with the corresponding picklist table +if(isset($datarows) && is_array($datarows)){ + //This file will be included only once at the first time. Will not be included when we redirect from ImportSave + include("modules/Import/picklist_addition.php"); +} + +$saved_ids = array(); + +$firstrow = 0; + +if (! isset($datarows)){ + $error = $mod_strings['LBL_FILE_ALREADY_BEEN_OR']; + $datarows = array(); +} + +if ($has_header == 1){ + $firstrow = array_shift($datarows); +} + +//Mark the last imported records as deleted which are imported by the current user in vtiger_users_last_import vtiger_table +if(!isset($_REQUEST['startval'])){ + $seedUsersLastImport = new UsersLastImport(); + $seedUsersLastImport->mark_deleted_by_user_id($current_user->id); +} +$skip_required_count = 0; + +p("processing started ret_field_count=".$ret_field_count); +$adb->println($datarows); + +$error = ''; +$focus = new $current_bean_type(); +$focus->initRequiredFields($module); + +// SAVE MAPPING IF REQUESTED +if(isset($_REQUEST['save_map']) && $_REQUEST['save_map'] == 'on' && isset($_REQUEST['save_map_as']) && $_REQUEST['save_map_as'] != ''){ + p("save map"); + $serialized_mapping = ''; + + if( $has_header){ + foreach($col_pos_to_field as $pos=>$field_name){ + if ( isset($firstrow[$pos]) && isset( $field_name)){ + $header_to_field[ $firstrow[$pos] ] = $field_name; + } + } + $serialized_mapping = implode_assoc("=","&",$header_to_field); + }else{ + $serialized_mapping = implode_assoc("=","&",$col_pos_to_field); + } + + $mapping_file_name = $_REQUEST['save_map_as']; + $mapping_file = new ImportMap(); + + $result = $mapping_file->save_map( $current_user->id, + $mapping_file_name, + $_REQUEST['module'], + $has_header, + $serialized_mapping ); + + $adb->println("Save map done"); + $adb->println($result); +} +//save map - ends + +if(isset($_SESSION['totalrows']) && $_SESSION['totalrows'] != ''){ + $xrows = $_SESSION['totalrows']; +}else{ + $xrows = $datarows; +} +if(isset($_SESSION['return_field_count'])){ + $ret_field_count = $_SESSION['return_field_count']; +} +if(isset($_SESSION['column_position_to_field'])){ + $col_pos_to_field = $_SESSION['column_position_to_field']; +} +if($xrows != ''){ + $datarows = $xrows; +} +if($_REQUEST['skipped_record_count'] != ''){ + $skipped_record_count = vtlib_purify($_REQUEST['skipped_record_count']); +}else{ + $_REQUEST['skipped_record_count'] = 0; +} + +if($_REQUEST['noofrows'] != ''){ + $totalnoofrows = vtlib_purify($_REQUEST['noofrows']); +}else{ + $totalnoofrows = count($datarows); +} + +if($_REQUEST['recordcount'] != ''){ + $RECORDCOUNT = vtlib_purify($_REQUEST['recordcount']); +}else{ + $RECORDCOUNT = vtlib_purify($_SESSION['recordcount']); +} + +if($_REQUEST['startval'] != ''){ + $START = vtlib_purify($_REQUEST['startval']); +}else{ + $START = vtlib_purify($_SESSION['startval']); +} + +if(($START+$RECORDCOUNT) > $totalnoofrows){ + $RECORDCOUNT = $totalnoofrows - $START; +} + +$loopcount = ($totalnoofrows/$RECORDCOUNT)+1; + +$focus->initImportableFields($module); +if($totalnoofrows > $RECORDCOUNT && $START < $totalnoofrows){ + $rows1 = Array(); + for($j=$START;$j<$START+$RECORDCOUNT;$j++){ + $rows1[] = $datarows[$j]; + } + + $res = InsertImportRecords($datarows,$rows1,$focus,$ret_field_count,$col_pos_to_field,$START,$RECORDCOUNT,vtlib_purify($_REQUEST['module']),$totalnoofrows,$skipped_record_count); + if($START != 0){ + echo ''.$res.''; + } + + $count = vtlib_purify($_REQUEST['count']); +}else{ + if($START == 0){ + $res = InsertImportRecords($datarows,$datarows,$focus,$ret_field_count,$col_pos_to_field,$START,$totalnoofrows,vtlib_purify($_REQUEST['module']),$totalnoofrows,$skipped_record_count); + } +} + +//Display the imported records message +echo "
    ".$_SESSION['import_display_message']."
    "; +?> diff --git a/oss/vtiger/trunk/modules/Import/ImportSteplast.php b/oss/vtiger/trunk/modules/Import/ImportSteplast.php new file mode 100644 index 00000000..8a8caae4 --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/ImportSteplast.php @@ -0,0 +1,306 @@ +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['modulename'])); +$smarty->assign("SINGLE_MOD", vtlib_purify($_REQUEST['modulename'])); +$smarty->assign("CATEGORY", vtlib_purify($_SESSION['import_parenttab'])); +//@session_unregister("import_parenttab"); +if($req_module != 'Accounts' || $req_module != 'Contacts' || $req_module != 'Products' || $req_module != 'Leads' || $req_module != 'HelpDesk' || $req_module != 'Potentials' || $req_module != 'Vendors' ) +{ + $smarty->display("Buttons_List1.tpl"); +} + +if ( isset($_REQUEST['message'])) +{ + ?> +
    + + + + + + + + + + + + + + + +
    + +
     
    + +   + +   + + +
    + +


    + + + + +
    + + + + + + + + + + + + +
    + + + + +
    +
    + + + + + + + + +
    + "; + $return_module=vtlib_purify($_REQUEST['modulename']); + + $ret_arr=getDuplicateRecordsArr($req_module); + $fld_values=$ret_arr[0]; + $total_num_group=count($fld_values); + $fld_name=$ret_arr[1]; + + $smarty->assign("MODULE",$req_module); + $smarty->assign("MODULELABEL",getTranslatedString($req_module,$req_module)); + $smarty->assign("NUM_GROUP",$total_num_group); + $smarty->assign("FIELD_NAMES",$fld_name); + $smarty->assign("CATEGORY",$parenttab); + $smarty->assign("ALL_VALUES",$fld_values); + $smarty->assign("MOD", return_module_language($current_language,$req_module)); + $smarty->assign("IMAGE_PATH",$image_path); + $smarty->assign("APP", $app_strings); + $smarty->assign("CMOD", $mod_strings); + $smarty->assign("MODE",'view'); + $smarty->assign("NAVIGATION",$ret_arr["navigation"]);//Added for page navigation + if(isPermitted($req_module,'Delete','') == 'yes') + $button_del = $app_strings[LBL_MASS_DELETE]; + $smarty->assign("DELETE",$button_del); + if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '') + $smarty->display("FindDuplicateAjax.tpl"); + else + $smarty->display('FindDuplicateDisplay.tpl'); +} +else +{ + echo "

    "; + $currentModule = "Import"; + 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" + ); + + // vtlib customization: Hook provide to include custom modules + $module = $_REQUEST['modulename']; + checkFileAccess("modules/$module/$module.php"); + require_once("modules/$module/$module.php"); + $import_modules_array[$module] = $module; + // END + + 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 != '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 " + + + + +
    + ".$mod_strings['LBL_LAST_IMPORTED']." ".$app_strings[$module_name]." +
    + "; + + $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("MODULELABEL",getTranslatedString($module_name,$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;$iassign("LISTHEADER", $listview_header); + $smarty->assign("LISTENTITY", $listview_entries); + + $smarty->display("ListViewEntries.tpl"); + } + } +} + +unset($_SESSION['import_table_picklist']); +unset($_SESSION['import_converted_picklist_values+95']); +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Import/ImportStepundo.php b/oss/vtiger/trunk/modules/Import/ImportStepundo.php new file mode 100644 index 00000000..fce7afe8 --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/ImportStepundo.php @@ -0,0 +1,129 @@ +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 + +?> + +
    + + + + + + + + + + + + + + + + +
     
    + +   + +   + + +
    +
    + + " . $mod_strings['LBL_SUCCESS']."" ?>

    + + +
    + + +
    +
    +
    +
    + + + + + + + + +
    +
    + diff --git a/oss/vtiger/trunk/modules/Import/ImportTicket.php b/oss/vtiger/trunk/modules/Import/ImportTicket.php new file mode 100644 index 00000000..dfc0353c --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/ImportTicket.php @@ -0,0 +1,136 @@ +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 + +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Import/ImportVendors.php b/oss/vtiger/trunk/modules/Import/ImportVendors.php new file mode 100644 index 00000000..b3f9d1a8 --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/ImportVendors.php @@ -0,0 +1,80 @@ +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 + +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Import/UsersLastImport.php b/oss/vtiger/trunk/modules/Import/UsersLastImport.php new file mode 100644 index 00000000..52319829 --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/UsersLastImport.php @@ -0,0 +1,475 @@ +log = LoggerManager::getLogger('UsersLastImport'); + $this->db = PearDatabase::getInstance(); + } + + /** function used to delete the old entries for this user + * @param int $user_id - user id to whom's last imported records to delete + * @return void + */ + function mark_deleted_by_user_id($user_id) + { + $query = "DELETE FROM $this->table_name where assigned_user_id=?"; + $this->db->pquery($query,array($user_id),true,"Error deleting last imported records: "); + } + + /** function used to get the list query of the imported records + * @param reference &$order_by - reference of the variable order_by to add with the query + * @param reference &$where - where condition to add with the query + * @return string $query - return the list query to get the imported records list + */ + function create_list_query(&$order_by, &$where) + { + global $current_user; + $query = ''; + + $this->db->println("create list bean_type = ".$this->bean_type." where = ".$where); + + if ($this->bean_type == 'Contacts') + { + $query = "SELECT distinct crmid, + vtiger_account.accountname as accountname, + vtiger_contactdetails.contactid, + vtiger_contactdetails.accountid, + vtiger_contactdetails.yahooid, + vtiger_contactdetails.firstname, + vtiger_contactdetails.lastname, + vtiger_contactdetails.phone, + vtiger_contactdetails.title, + vtiger_contactdetails.email, + vtiger_users.id as assigned_user_id, + smownerid, + case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name + FROM vtiger_contactdetails + left join vtiger_users_last_import on vtiger_users_last_import.bean_id=vtiger_contactdetails.contactid + inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid + LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id + LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid + LEFT JOIN vtiger_account ON vtiger_account.accountid=vtiger_contactdetails.accountid + WHERE vtiger_users_last_import.assigned_user_id= '{$current_user->id}' + AND vtiger_users_last_import.bean_type='Contacts' + AND vtiger_users_last_import.deleted=0 AND vtiger_crmentity.deleted=0"; + + } + else if ($this->bean_type == 'Accounts') + { + $query = "SELECT distinct vtiger_account.*, vtiger_accountbillads.bill_city, + case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name, + crmid, smownerid + FROM vtiger_account + inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid + inner join vtiger_accountbillads on vtiger_crmentity.crmid=vtiger_accountbillads.accountaddressid + left join vtiger_users_last_import on vtiger_users_last_import.bean_id=vtiger_crmentity.crmid + left join vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id + LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid + WHERE + vtiger_users_last_import.assigned_user_id= + '{$current_user->id}' + AND vtiger_users_last_import.bean_type='Accounts' + AND vtiger_users_last_import.deleted=0 + AND vtiger_crmentity.deleted=0"; + }else if ($this->bean_type == 'Potentials'){ + $query = "SELECT distinct vtiger_account.accountid accountid, vtiger_account.accountname accountname, + case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_crmentity.crmid, smownerid, + vtiger_potential.* + FROM vtiger_potential + inner join vtiger_crmentity + on vtiger_crmentity.crmid=vtiger_potential.potentialid + left join vtiger_account + on vtiger_account.accountid=vtiger_potential.related_to + left join vtiger_users + ON vtiger_crmentity.smownerid=vtiger_users.id + LEFT JOIN vtiger_groups + ON vtiger_groups.groupid = vtiger_crmentity.smownerid + left join vtiger_users_last_import + on vtiger_users_last_import.bean_id=vtiger_crmentity.crmid + where vtiger_users_last_import.assigned_user_id='{$current_user->id}' + AND vtiger_users_last_import.bean_type='Potentials' + AND vtiger_users_last_import.bean_id=vtiger_crmentity.crmid + AND vtiger_users_last_import.deleted=0 + AND vtiger_crmentity.deleted=0"; + }else if($this->bean_type == 'Leads'){ + $query = "SELECT distinct vtiger_leaddetails.*, vtiger_crmentity.crmid, vtiger_leadaddress.phone,vtiger_leadsubdetails.website, + case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name, + smownerid + FROM vtiger_leaddetails + inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_leaddetails.leadid + inner join vtiger_leadaddress on vtiger_crmentity.crmid=vtiger_leadaddress.leadaddressid + inner join vtiger_leadsubdetails on vtiger_crmentity.crmid=vtiger_leadsubdetails.leadsubscriptionid + left join vtiger_users_last_import on vtiger_users_last_import.bean_id=vtiger_crmentity.crmid + left join vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id + LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid + WHERE + vtiger_users_last_import.assigned_user_id= + '{$current_user->id}' + AND vtiger_users_last_import.bean_type='Leads' + AND vtiger_users_last_import.deleted=0 + AND vtiger_crmentity.deleted=0"; + } + + //Pavani: Query to retrieve trouble tickets, vendors data from database + else if($this->bean_type == 'HelpDesk') + { + $query = "SELECT distinct vtiger_troubletickets.*, vtiger_crmentity.crmid, + case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name, + smownerid + FROM vtiger_troubletickets + inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid + left join vtiger_users_last_import on vtiger_users_last_import.bean_id=vtiger_crmentity.crmid + left join vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id + LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid + WHERE + vtiger_users_last_import.assigned_user_id= + '{$current_user->id}' + AND vtiger_users_last_import.bean_type='HelpDesk' + AND vtiger_users_last_import.deleted=0 + AND vtiger_crmentity.deleted=0"; + } + + else if($this->bean_type == 'Vendors') + { + $query = "SELECT distinct vtiger_vendor.*, vtiger_crmentity.crmid, + case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name, + smownerid + FROM vtiger_vendor + inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_vendor.vendorid + left join vtiger_users_last_import on vtiger_users_last_import.bean_id=vtiger_crmentity.crmid + left join vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id + LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid + WHERE + vtiger_users_last_import.assigned_user_id= + '{$current_user->id}' + AND vtiger_users_last_import.bean_type='Vendors' + AND vtiger_users_last_import.deleted=0 + AND vtiger_crmentity.deleted=0"; + } + //pavani...end + + else if($this->bean_type == 'Products') + { + $query = "SELECT vtiger_crmentity.crmid, vtiger_products.*, vtiger_productcf.* + FROM vtiger_products + INNER JOIN vtiger_crmentity + ON vtiger_crmentity.crmid = vtiger_products.productid + INNER JOIN vtiger_productcf + ON vtiger_products.productid = vtiger_productcf.productid + LEFT JOIN vtiger_vendor + ON vtiger_vendor.vendorid = vtiger_products.vendor_id + LEFT JOIN vtiger_users_last_import + ON vtiger_users_last_import.bean_id=vtiger_crmentity.crmid + LEFT JOIN vtiger_users + ON vtiger_users.id = vtiger_products.handler + WHERE + vtiger_users_last_import.assigned_user_id= '{$current_user->id}' + AND vtiger_users_last_import.bean_type='Products' + AND vtiger_users_last_import.deleted=0 + AND vtiger_crmentity.deleted = 0"; + + } + // vtlib customization: Hook for getting the query from the module class itself. + else { + require_once("modules/$this->bean_type/$this->bean_type.php"); + $bean_focus = new $this->bean_type(); + $query = $bean_focus->create_import_query($this->bean_type); + } + // END + + return $query; + + } + + /* + function list_view_parse_additional_sections(&$list_form) + { + if ($this->bean_type == "Contacts") + { + if( isset($this->yahoo_id) && $this->yahoo_id != '') + { + $list_form->parse("main.row.yahoo_id"); + } + else + { + $list_form->parse("main.row.no_yahoo_id"); + } + } + return $list_form; + + } + */ + + /** function used to delete (update deleted=1 in crmentity table) the last imported records of the current user + * @param int $user_id - user id, whose last imported records want to be deleted + * @return int $count - return the number of total deleted records (contacts, accounts, opportunities, leads and products) + */ + function undo($user_id) + { + $count = 0; + + $count += $this->undo_contacts($user_id); + $count += $this->undo_accounts($user_id); + $count += $this->undo_opportunities($user_id); + $count += $this->undo_leads($user_id); + $count += $this->undo_products($user_id); + $count += $this->undo_HelpDesk($user_id); + $count += $this->undo_activities($user_id); + $count += $this->undo_Vendors($user_id); + return $count; + } + + /** function used to delete (update deleted=1 in crmentity table) the last imported contacts of the current user + * @param int $user_id - user id, whose last imported contacts want to be deleted + * @return int $count - return the number of deleted contacts + */ + function undo_contacts($user_id) + { + $count = 0; + $query1 = "select bean_id from vtiger_users_last_import where assigned_user_id=? AND bean_type='Contacts' AND deleted=0"; + $this->log->info($query1); + $result1 = $this->db->pquery($query1, array($user_id)) or die("Error getting last import for undo: ".mysql_error()); + + while ( $row1 = $this->db->fetchByAssoc($result1)) + { + $query2 = "update vtiger_crmentity set deleted=1 where crmid=?"; + $this->log->info($query2); + $result2 = $this->db->pquery($query2, array($row1['bean_id'])) or die("Error undoing last import: ".mysql_error()); + + $count++; + + } + return $count; + } + + /** function used to delete (update deleted=1 in crmentity table) the last imported leads of the current user + * @param int $user_id - user id, whose last imported leads want to be deleted + * @return int $count - return the number of deleted leads + */ + function undo_leads($user_id) + { + $count = 0; + $query1 = "select bean_id from vtiger_users_last_import where assigned_user_id=? AND bean_type='Leads' AND deleted=0"; + $this->log->info($query1); + $result1 = $this->db->pquery($query1, array($user_id)) or die("Error getting last import for undo: ".mysql_error()); + + while ( $row1 = $this->db->fetchByAssoc($result1)) + { + $query2 = "update vtiger_crmentity set deleted=1 where crmid=?"; + $this->log->info($query2); + $result2 = $this->db->pquery($query2, array($row1['bean_id'])) or die("Error undoing last import: ".mysql_error()); + + $count++; + + } + return $count; + } + //Pavani: Function to cancel latest import of trouble tickets and vendors of the particular user + /** function used to delete (update deleted=1 in crmentity table) the last imported tickets of the current user + * @param int $user_id - user id, whose last imported tickets want to be deleted + * @return int $count - return the number of deleted tickets + */ + function undo_HelpDesk($user_id) + { + $count = 0; + $query1 = "select bean_id from vtiger_users_last_import where assigned_user_id='$user_id' AND bean_type='HelpDesk' AND deleted=0"; + + $this->log->info($query1); + + $result1 = $this->db->query($query1) or die("Error getting last import for undo: ".mysql_error()); + + while ( $row1 = $this->db->fetchByAssoc($result1)) + { + $query2 = "update vtiger_crmentity set deleted=1 where crmid='{$row1['bean_id']}'"; + + $this->log->info($query2); + + $result2 = $this->db->query($query2) or die("Error undoing last import: ".mysql_error()); + + $count++; + + } + return $count; + } + + /** function used to delete (update deleted=1 in crmentity table) the last imported vendors of the current user + * @param int $user_id - user id, whose last imported vendors want to be deleted + * @return int $count - return the number of deleted vendors + */ + function undo_Vendors($user_id) + { + $count = 0; + $query1 = "select bean_id from vtiger_users_last_import where assigned_user_id='$user_id' AND bean_type='Vendors' AND deleted=0"; + + $this->log->info($query1); + + $result1 = $this->db->query($query1) or die("Error getting last import for undo: ".mysql_error()); + + while ( $row1 = $this->db->fetchByAssoc($result1)) + { + $query2 = "update vtiger_crmentity set deleted=1 where crmid='{$row1['bean_id']}'"; + + $this->log->info($query2); + + $result2 = $this->db->query($query2) or die("Error undoing last import: ".mysql_error()); + + $count++; + + } + return $count; + } + + /** function used to delete (update deleted=1 in crmentity table) the last imported accounts of the current user + * @param int $user_id - user id, whose last imported accounts want to be deleted + * @return int $count - return the number of deleted accounts + */ + function undo_accounts($user_id) + { + // this should just be a loop foreach module type + $count = 0; + $query1 = "select bean_id from vtiger_users_last_import where assigned_user_id=? AND bean_type='Accounts' AND deleted=0"; + $this->log->info($query1); + $result1 = $this->db->pquery($query1, array($user_id)) or die("Error getting last import for undo: ".mysql_error()); + + while ( $row1 = $this->db->fetchByAssoc($result1)) + { + $query2 = "update vtiger_crmentity set deleted=1 where crmid=?"; + $this->log->info($query2); + $result2 = $this->db->pquery($query2, array($row1['bean_id'])) or die("Error undoing last import: ".mysql_error()); + + $count++; + + } + return $count; + } + + /** function used to delete (update deleted=1 in crmentity table) the last imported potentials of the current user + * @param int $user_id - user id, whose last imported potentials want to be deleted + * @return int $count - return the number of deleted potentials + */ + function undo_opportunities($user_id) + { + // this should just be a loop foreach module type + $count = 0; + $query1 = "select bean_id from vtiger_users_last_import where assigned_user_id=? AND bean_type='Potentials' AND deleted=0"; + + $this->log->info($query1); + + $result1 = $this->db->pquery($query1, array($user_id)) or die("Error getting last import for undo: ".mysql_error()); + + while ( $row1 = $this->db->fetchByAssoc($result1)) + { + $query2 = "update vtiger_crmentity set deleted=1 where crmid=?"; + $this->log->info($query2); + $result2 = $this->db->pquery($query2, array($row1['bean_id'])) or die("Error undoing last import: ".mysql_error()); + + $count++; + + } + return $count; + } + + /** function used to delete (update deleted=1 in crmentity table) the last imported products of the current user + * @param int $user_id - user id, whose last imported products want to be deleted + * @return int $count - return the number of deleted products + */ + function undo_products($user_id) + { + $count = 0; + $query1 = "select bean_id from vtiger_users_last_import where assigned_user_id=? AND bean_type='Products' AND deleted=0"; + $this->log->info($query1); + $result1 = $this->db->pquery($query1, array($user_id)) or die("Error getting last import for undo: ".mysql_error()); + + while ( $row1 = $this->db->fetchByAssoc($result1)) + { + $query2 = "update vtiger_crmentity set deleted=1 where crmid=?"; + $this->log->info($query2); + $result2 = $this->db->pquery($query2, array($row1['bean_id'])) or die("Error undoing last import: ".mysql_error()); + + $count++; + } + return $count; + } + + /** function used to delete (update deleted=1 in crmentity table) the last imported products of the current user + * @param int $user_id - user id, whose last imported products want to be deleted + * @return int $count - return the number of deleted products + */ + function undo_activities($user_id) + { + $count = 0; + $query1 = "select bean_id from vtiger_users_last_import where assigned_user_id=? AND bean_type='Calendar' AND deleted=0"; + $this->log->info($query1); + $result1 = $this->db->pquery($query1, array($user_id)) or die("Error getting last import for undo: ".mysql_error()); + + while ( $row1 = $this->db->fetchByAssoc($result1)) + { + $query2 = "update vtiger_crmentity set deleted=1 where crmid=?"; + $this->log->info($query2); + $result2 = $this->db->pquery($query2, array($row1['bean_id'])) or die("Error undoing last import: ".mysql_error()); + + $count++; + } + return $count; + } +} + + +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Import/error.php b/oss/vtiger/trunk/modules/Import/error.php new file mode 100644 index 00000000..e480fabb --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/error.php @@ -0,0 +1,68 @@ +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'); +} + +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Import/index.php b/oss/vtiger/trunk/modules/Import/index.php new file mode 100644 index 00000000..42faee04 --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/index.php @@ -0,0 +1,252 @@ +"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'); + +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Import/language/en_us.lang.php b/oss/vtiger/trunk/modules/Import/language/en_us.lang.php new file mode 100644 index 00000000..27e45c31 --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/language/en_us.lang.php @@ -0,0 +1,432 @@ +'The directory ', +'LBL_IMPORT_MODULE_NO_DIRECTORY_END'=>' does not exist or is not writable', +'LBL_IMPORT_MODULE_ERROR_NO_UPLOAD'=>'File was not uploaded successfully, try again', +'LBL_IMPORT_MODULE_ERROR_LARGE_FILE'=>'File is too large. Max:', +'LBL_IMPORT_MODULE_ERROR_LARGE_FILE_END'=>'Bytes. Change $upload_maxsize in config.php', +'LBL_MODULE_NAME'=>'Import', +'LBL_TRY_AGAIN'=>'Try Again', +'LBL_ERROR'=>'Error:', +'ERR_MULTIPLE'=>'Multiple columns have been defined with the same field name.', +'ERR_MISSING_REQUIRED_FIELDS'=>'Missing required fields:', +'ERR_SELECT_FULL_NAME'=>'You cannot select Full Name when First Name and Last Name are selected.', +'ERR_SELECT_FILE'=>'Select a file to upload.', +'LBL_SELECT_FILE'=>'Select file:', +'LBL_CUSTOM'=>'Custom', +'LBL_DONT_MAP'=>'-- Do not map this field --', +'LBL_STEP_1_TITLE'=>'Step 1 of 4: Select Data Source', +'LBL_WHAT_IS'=>'Please select a data source from the following:', +'LBL_MICROSOFT_OUTLOOK'=>'Microsoft Outlook', +'LBL_ACT'=>'Act!', +'LBL_SALESFORCE'=>'Salesforce.com', +'LBL_MY_SAVED'=>'My Saved Sources:', +'LBL_PUBLISH'=>'publish', +'LBL_DELETE'=>'delete', +'LBL_PUBLISHED_SOURCES'=>'Published Sources:', +'LBL_UNPUBLISH'=>'un-publish', +'LBL_NEXT'=>'Next', +'LBL_BACK'=>'Back', +'LBL_STEP_2_TITLE'=>'Step 2 of 4: Upload Export File', +'LBL_HAS_HEADER'=>'Has Header', + +'LBL_NUM_1'=>'1.', +'LBL_NUM_2'=>'2.', +'LBL_NUM_3'=>'3.', +'LBL_NUM_4'=>'4.', +'LBL_NUM_5'=>'5.', +'LBL_NUM_6'=>'6.', +'LBL_NUM_7'=>'7.', +'LBL_NUM_8'=>'8.', +'LBL_NUM_9'=>'9.', +'LBL_NUM_10'=>'10.', +'LBL_NUM_11'=>'11.', +'LBL_NUM_12'=>'12.', +'LBL_NOW_CHOOSE'=>'Now choose that file to import:', +'LBL_IMPORT_OUTLOOK_TITLE'=>'Microsoft Outlook 98 and 2000 can export data in the Comma Separated Values format which can be used to import data into the system. To export your data from Outlook, follow the steps below:', +'LBL_OUTLOOK_NUM_1'=>'Start Outlook', +'LBL_OUTLOOK_NUM_2'=>'Select the File menu, then the Import and Export ... menu option', +'LBL_OUTLOOK_NUM_3'=>'Choose Export to a file and click Next', +'LBL_OUTLOOK_NUM_4'=>'Choose Comma Separated Values (Windows) and click Next.
    Note: You may be prompted to install the export component', +'LBL_OUTLOOK_NUM_5'=>'Select the Contacts folder and click Next. You can select different contacts folders if your contacts are stored in multiple folders', +'LBL_OUTLOOK_NUM_6'=>'Choose a filename and click Next', +'LBL_OUTLOOK_NUM_7'=>'Click Finish', +'LBL_IMPORT_ACT_TITLE'=>'Act! can export data in the Comma Separated Values format which can be used to import data into the system. To export your data from Act!, follow the steps below:', +'LBL_ACT_NUM_1'=>'Launch ACT!', +'LBL_ACT_NUM_2'=>'Select the File menu, the Data Exchange menu option, then the Export... menu option', +'LBL_ACT_NUM_3'=>'Select the file type Text-Delimited', +'LBL_ACT_NUM_4'=>'Choose a filename and location for the exported data and click Next', +'LBL_ACT_NUM_5'=>'Select Contacts records only', +'LBL_ACT_NUM_6'=>'Click the Options... button', +'LBL_ACT_NUM_7'=>'Select Comma as the field separator character', +'LBL_ACT_NUM_8'=>'Check the Yes, export field names checkbox and click OK', +'LBL_ACT_NUM_9'=>'Click Next', +'LBL_ACT_NUM_10'=>'Select All Records and then Click Finish', + +'LBL_IMPORT_SF_TITLE'=>'Salesforce.com can export data in the Comma Separated Values format which can be used to import data into the system. To export your data from Salesforce.com, follow the steps below:', +'LBL_SF_NUM_1'=>'Open your browser, go to http://www.salesforce.com, and login with your email address and password', +'LBL_SF_NUM_2'=>'Click on the Reports tab on the top menu', +'LBL_SF_NUM_3'=>'To export Accounts: Click on the Active Accounts link
    To export Contacts: Click on the Mailing List link', +'LBL_SF_NUM_4'=>'On Step 1: Select your report type, select Tabular Reportclick Next', +'LBL_SF_NUM_5'=>'On Step 2: Select the report columns, choose the columns you want to export and click Next', +'LBL_SF_NUM_6'=>'On Step 3: Select the information to summarize, just click Next', +'LBL_SF_NUM_7'=>'On Step 4: Order the report columns, just click Next', +'LBL_SF_NUM_8'=>'On Step 5: Select your report criteria, under Start Date, choose a date far enough in the past to include all your Accounts. You can also export a subset of Accounts using more advanced criteria. When you are done, click Run Report', +'LBL_SF_NUM_9'=>'A report will be generated, and the page should display Report Generation Status: Complete. Now click Export to Excel', +'LBL_SF_NUM_10'=>'On Export Report:, for Export File Format:, choose Comma Delimited .csv. Click Export.', +'LBL_SF_NUM_11'=>'A dialog will pop up for you to save the export file to your computer.', +'LBL_IMPORT_CUSTOM_TITLE'=>'Many applications will allow you to export data into a Comma Delimited text file (.csv). Generally most applications follow these general steps:', +'LBL_CUSTOM_NUM_1'=>'Launch the application and Open the data file', +'LBL_CUSTOM_NUM_2'=>'Select the Save As... or Export... menu option', +'LBL_CUSTOM_NUM_3'=>'Save the file in a CSV or Comma Separated Values format', + +'LBL_STEP_3_TITLE'=>'Step 3 of 4: Confirm Fields and Import', +'LBL_STEP_1'=>'Step 1 of 3 : ', +'LBL_STEP_1_TITLE'=>'Select the .CSV File', +'LBL_STEP_1_TEXT'=> ' vtiger CRM supports importing records from .csv ( Comma Separated Values ) files. To start import, browse to locate the .CSV file and click on the Next button to Continue.', + +'LBL_SELECT_FIELDS_TO_MAP'=>'In the list below, select the fields in your import file that should be imported into each field in the system. When you are finished, click Import Now', + +'LBL_DATABASE_FIELD'=>'Database Field', +'LBL_HEADER_ROW'=>'Header Row', +'LBL_ROW'=>'Row', +'LBL_SAVE_AS_CUSTOM'=>'Save as Custom Mapping :', +'LBL_CONTACTS_NOTE_1'=>'Either Last Name or Full Name must be mapped.', +'LBL_CONTACTS_NOTE_2'=>'If Full Name is mapped, then First Name and Last Name are ignored.', +'LBL_CONTACTS_NOTE_3'=>'If Full Name is mapped, then the data in Full Name will be split into First Name and Last Name when inserted into the database.', +'LBL_CONTACTS_NOTE_4'=>'Fields ending in Address Street 2 and Address Street 3 are concatenated together with the main Address Street Field when inserted into the database.', +'LBL_ACCOUNTS_NOTE_1'=>'Account Name must be mapped.', +'LBL_ACCOUNTS_NOTE_2'=>'Fields ending in Address Street 2 and Address Street 3 are concatenated together with the main Address Street Field when inserted into the database.', +'LBL_POTENTIALS_NOTE_1'=>'Potential Name, Account Name, Date Closed, and Sales Stage are required fields.', +'LBL_OPPORTUNITIES_NOTE_1'=>'Opportunity Name, Account Name, Date Closed, and Sales Stage are required fields.', +'LBL_LEADS_NOTE_1'=>'Last Name must be mapped.', +'LBL_LEADS_NOTE_2'=>'Company Name must be mapped.', +'LBL_IMPORT_NOW'=>'Import Now', +'LBL_'=>'', +'LBL_CANNOT_OPEN'=>'Cannot open the imported file for reading', +'LBL_NOT_SAME_NUMBER'=>'There were not the same number of fields per line in your file', +'LBL_NO_LINES'=>'There were no lines in your import file', +'LBL_FILE_ALREADY_BEEN_OR'=>'The import file has already been processed or does not exist', +'LBL_SUCCESS'=>'Success! ', +'LBL_SUCCESSFULLY'=>'Succesfully Imported', +'LBL_LAST_IMPORT_UNDONE'=>'Your Last Import Was Undone', +'LBL_NO_IMPORT_TO_UNDO'=>'There was no import to undo.', +'LBL_FAIL'=>'Fail:', +'LBL_RECORDS_SKIPPED'=>'records skipped because they were missing one or more required fields', +'LBL_IDS_EXISTED_OR_LONGER'=>'records skipped because the id\'s either existed or where longer than 36 characters', +'LBL_RESULTS'=>'Results', +'LBL_IMPORT_MORE'=>'Import More', +'LBL_FINISHED'=>'Finished', +'LBL_UNDO_LAST_IMPORT'=>'Undo Last Import', + +'LBL_SUCCESS_1' => 'No. of Records Successfully Imported : ', +'LBL_SKIPPED_1' => 'No. of Records Skipped as they were missing one or more required fields : ', + +//Added for patch2 - Products Import Notes +'LBL_PRODUCTS_NOTE_1'=>'Product Name must be mapped', +'LBL_PRODUCTS_NOTE_2'=>'Before import please check whether a single column has been mapped twice', + +//Added for version 5 +'LBL_FILE_LOCATION'=>'File Location :', +'LBL_STEP_2_3'=>'Step 2 of 3 :', +'LBL_LIST_MAPPING'=>'List & Mapping', +'LBL_STEP_2_MSG'=>'The following tables shows the imported', +'LBL_STEP_2_MSG1'=>'and other details.', +'LBL_STEP_2_TXT'=>'To map the fields, select the corresponding in combo boxes for each', +'LBL_USE_SAVED_MAPPING'=>'Use Saved Mapping :', +'LBL_MAPPING'=>'Mapping', +'LBL_HEADERS'=>'Headers :', +'LBL_ERROR_MULTIPLE'=>'Same fields may be mapped twice. Please check the mapped fields.', +'LBL_STEP_3_3'=>'Step 3 of 3 : ', +'LBL_MAPPING_RESULTS'=>'Mapping Results ', +'LBL_LAST_IMPORTED'=>'Last Imported', +//Added for sript alerts +'PLEASE_CHECK_MAPPING' => "' is mapped more than once. Please check the mapping.", +'MAP_MANDATORY_FIELD' => 'Please map the mandatory field "', +'ENTER_SAVEMAP_NAME' => 'Please Enter Save Map Name', + +//Added for 5.0.3 +'to'=>'to', +'of'=>'of', +'are_imported_succesfully'=>'are imported successfully', + +// Added after 5.0.4 GA + +//added for duplicate handling +'LBL_LAST_IMPORT'=>'Last Imported', +'Select_Criteria_For_Duplicate' => 'Select Criteria For Duplicate Records Handling', +'Manual_Merging' => 'Manual Merging', +'Auto_Merging' => 'Auto Merging', +'Ignore_Duplicate' => 'Ignore the duplicate import records', +'Overwrite_Duplicate' => 'Overwrite the duplicate records', +'Duplicate_Records_Skipped_Info' => 'No. of Records Skipped as they were duplicates : ', +'Duplicate_Records_Overwrite_Info' => 'No. of Records Overwritten as they were duplicates : ', +'LBL_STEP_4_4' => 'Step 4 of 4 : ', +'LBL_STEP_3_4'=>'Step 3 of 4 :', +'LBL_STEP_2_4'=>'Step 2 of 4 :', +'LBL_STEP_1_4'=>'Step 1 of 4 : ', + +'LBL_DELIMITER' => 'Delimiter:', +'LBL_FORMAT' => 'Format:', +); + +/*$mod_list_strings = Array( + "id"=>"Contact ID" + ,"first_name"=>"First Name" + ,"last_name"=>"Last Name" + ,"salutation"=>"Salutation" + ,"lead_source"=>"Lead Source" + ,"birthdate"=>"Lead Source" + ,"do_not_call"=>"Do Not Call" + ,"email_opt_out"=>"Email Opt Out" + ,"primary_address_street_2"=>"Primary Address Street 2" + ,"primary_address_street_3"=>"Primary Address Street 3" + ,"alt_address_street_2"=>"Other Address Street 2" + ,"alt_address_street_3"=>"Other Address Street 3" + ,"full_name"=>"Full Name" + ,"account_name"=>"Account Name" + ,"account_id"=>"Account ID" + ,"title"=>"Title" + ,"department"=>"Department" + ,"birthdate"=>"Birthdate" + ,"do_not_call"=>"Do Not Call" + ,"phone_home"=>"Phone (Home)" + ,"phone_mobile"=>"Phone (Mobile)" + ,"phone_work"=>"Phone (Work)" + ,"phone_other"=>"Phone (Other)" + ,"phone_fax"=>"Fax" + ,"email1"=>"Email" + ,"email2"=>"Email (Other)" + ,"yahoo_id"=>"Yahoo! ID" + ,"assistant"=>"Assistant" + ,"assistant_phone"=>"Assistant Phone" + ,"primary_address_street"=>"Primary Address Street" + ,"primary_address_city"=>"Primary Address City" + ,"primary_address_state"=>"Primary Address State" + ,"primary_address_postalcode"=>"Primary Address Postalcode" + ,"primary_address_country"=>"Primary Address Country" + ,"alt_address_street"=>"Other Address Street" + ,"alt_address_city"=>"Other Address City" + ,"alt_address_state"=>"Other Address State" + ,"alt_address_postalcode"=>"Other Address Postalcode" + ,"alt_address_country"=>"Other Address Country" + ,"description"=>"Description" + + ),*/ +$mod_list_strings = Array( +'contacts_import_fields' => Array( + //"id"=>"Contact ID" + "firstname"=>"First Name" + ,"lastname"=>"Last Name" + ,"salutationtype"=>"Salutation" + ,"leadsource"=>"Lead Source" + ,"birthday"=>"Birthdate" + ,"donotcall"=>"Do Not Call" + ,"emailoptout"=>"Email Opt Out" + //,"primary_address_street_2"=>"Primary Address Street 2" + //,"primary_address_street_3"=>"Primary Address Street 3" + //,"alt_address_street_2"=>"Other Address Street 2" + //,"alt_address_street_3"=>"Other Address Street 3" + //,"full_name"=>"Full Name" + //,"account_name"=>"Account Name" + ,"account_id"=>"Account Name" + ,"title"=>"Title" + ,"department"=>"Department" + //,"birthdate"=>"Birthdate" + //,"do_not_call"=>"Do Not Call" + ,"homephone"=>"Phone (Home)" + ,"mobile"=>"Phone (Mobile)" + ,"phone"=>"Phone (Work)" + ,"otherphone"=>"Phone (Other)" + ,"fax"=>"Fax" + ,"email"=>"Email" + ,"otheremail"=>"Email (Other)" + ,"yahooid"=>"Yahoo! ID" + ,"assistant"=>"Assistant" + ,"assistantphone"=>"Assistant Phone" + ,"mailingstreet"=>"Mailing Address Street" + ,"mailingpobox"=>"Mailing Address PO Box" + ,"mailingcity"=>"Mailing Address City" + ,"mailingstate"=>"Mailing Address State" + ,"mailingzip"=>"Mailing Address Postalcode" + ,"mailingcountry"=>"Mailing Address Country" + ,"otherstreet"=>"Other Address Street" + ,"otherpobox"=>"Other Address PO Box" + ,"othercity"=>"Other Address City" + ,"otherstate"=>"Other Address State" + ,"otherzip"=>"Other Address Postalcode" + ,"othercountry"=>"Other Address Country" + ,"description"=>"Description" + ,"assigned_user_id"=>"Assigned To" + ), + +'accounts_import_fields' => Array( + //"id"=>"Account ID", + "accountname"=>"Account Name", + "website"=>"Website", + "industry"=>"Industry", + "accounttype"=>"Type", + "tickersymbol"=>"Ticker Symbol", + "parent_name"=>"Member of", + "employees"=>"Employees", + "ownership"=>"Ownership", + "phone"=>"Phone", + "fax"=>"Fax", + "otherphone"=>"Other Phone", + "email1"=>"Email", + "email2"=>"Other Email", + "rating"=>"Rating", + "siccode"=>"SIC Code", + "annual_revenue"=>"Annual Revenue", + "bill_street"=>"Billing Address Street", + //"billing_address_street_2"=>"Billing Address Street 2", + //"billing_address_street_3"=>"Billing Address Street 3", + //"billing_address_street_4"=>"Billing Address Street 4", + "bill_pobox"=>"Billing Address PO Box", + "bill_city"=>"Billing Address City", + "bill_state"=>"Billing Address State", + "bill_code"=>"Billing Address Postalcode", + "bill_country"=>"Billing Address Country", + "ship_street"=>"Shipping Address Street", + //"shipping_address_street_2"=>"Shipping Address Street 2", + //"shipping_address_street_3"=>"Shipping Address Street 3", + //"shipping_address_street_4"=>"Shipping Address Street 4", + "ship_pobox"=>"Shipping Address PO Box", + "ship_city"=>"Shipping Address City", + "ship_state"=>"Shipping Address State", + "ship_code"=>"Shipping Address Postalcode", + "ship_country"=>"Shipping Address Country", + "description"=>"Description", + "assigned_user_id"=>"Assigned To" + ), + +'potentials_import_fields' => Array( + //"id"=>"Account ID" + "potentialname"=>"Potential Name" + , "account_id"=>"Account Name" + , "opportunity_type"=>"Potential Type" + , "leadsource"=>"Lead Source" + , "amount"=>"Amount" + , "closingdate"=>"Closing Date" + , "nextstep"=>"Next Step" + , "sales_stage"=>"Sales Stage" + , "probability"=>"Probability" + , "description"=>"Description" + ,"assigned_user_id"=>"Assigned To" + ), + + +'leads_import_fields' => Array( + "salutationtype"=>"Salutation", + "firstname"=>"First Name", + "phone"=>"Phone", + "lastname"=>"Last Name", + "mobile"=>"Mobile", + "company"=>"Company", + "fax"=>"Fax", + "designation"=>"Designation", + "email"=>"Email", + "leadsource"=>"Lead Source", + "website"=>"Website", + "industry"=>"Industry", + "leadstatus"=>"Lead Status", + "annualrevenue"=>"Annual Revenue", + "rating"=>"Rating", + "noofemployees"=>"No Of Employees", + "assigned_user_id"=>"Assigned To", + "yahooid"=>"Yahoo Id", + "lane"=>"Street", + "pobox"=>"PO Box", + "code"=>"Postal Code", + "city"=>"City", + "country"=>"Country", + "state"=>"State", + "description"=>"Description" + ,"assigned_user_id"=>"Assigned To" + ), + + 'products_import_fields' => Array( + 'productname'=>'Product Name', + 'productcode'=>'Product Code', + 'productcategory'=>'Product Category', + 'manufacturer'=>'Manufacturer', + 'product_description'=>'Product Description', + 'qty_per_unit'=>'Quantity Per/Unit', + 'unit_price'=>'Unit Price', + 'weight'=>'Weight', + 'pack_size'=>'Pack Size', + 'start_date'=>'Start Date', + 'expiry_date'=>'Expiration Date', + 'cost_factor'=>'Cost Factor', + 'commissionmethod'=>'Commission Method', + 'discontinued'=>'Discontinued', + 'commissionrate'=>'Commission Rate', + 'sales_start_date'=>'Sales Start Date', + 'sales_end_date'=>'Sales End Date', + 'usageunit'=>'Usage Unit', + 'serialno'=>'Serial No', + 'currency'=>'currency', + 'reorderlevel'=>'Reorder Level', + 'website'=>'Web Site', + 'taxclass'=>'Tax Class', + 'mfr_part_no'=>'Manufacture Part No', + 'vendor_part_no'=>'Vendor Part No', + 'qtyinstock'=>'Quantity in Stock', + 'productsheet'=>'Product Sheet', + 'qtyindemand'=>'Quantity in Demand', + 'glacct'=>'GL Account', + 'assigned_user_id'=>'Assigned To' + ), +//Pavani...adding list of import fields for helpdesk and vendors +'helpdesk_import_fields' => Array( + "ticketid"=>"Ticket Id", + "priority"=>"Priority", + "severity"=>"Severity", + "status"=>"Status", + "category"=>"Category", + "title"=>"Title", + "description"=>"Description", + "solution"=>"Solution" + ), + +'vendors_import_fields' => Array( + "vendorid"=>"Vender Id", + "vendorname"=>"Vendor Name", + "phone"=>"Phone", + "email"=>"Email", + "website"=>"Website", + "category"=>"Category", + "street"=>"Street", + "city"=>"City", + "state"=>"State", + "pobox"=>"Post Box", + "postalcode"=>"Postal Code", + "country"=>"Country", + "description"=>"Description" + ) +//Pavani...end list +); + +?> diff --git a/oss/vtiger/trunk/modules/Import/language/zh_cn.lang.php b/oss/vtiger/trunk/modules/Import/language/zh_cn.lang.php new file mode 100644 index 00000000..53d7fedd --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/language/zh_cn.lang.php @@ -0,0 +1,431 @@ + '目录 ', +'LBL_IMPORT_MODULE_NO_DIRECTORY_END' => ' 不存在或没有记录', +'LBL_IMPORT_MODULE_ERROR_NO_UPLOAD' => '文件无法顺利上传,请再重试', +'LBL_IMPORT_MODULE_ERROR_LARGE_FILE' => '文件太大,大小上限:', +'LBL_IMPORT_MODULE_ERROR_LARGE_FILE_END' => '字节,在 config.php 中调整 $upload_maxsize设定', +'LBL_MODULE_NAME' => '导入', +'LBL_TRY_AGAIN' => '重试', +'LBL_ERROR' => '错误:', +'ERR_MULTIPLE' => '定义字段可多行输入.', +'ERR_MISSING_REQUIRED_FIELDS' => '漏填必须字段:', +'ERR_SELECT_FULL_NAME' => '当姓或名被选择时,您就不能再选全名.', +'ERR_SELECT_FILE' => '选择文件以供上传.', +'LBL_SELECT_FILE' => '选择文件:', +'LBL_CUSTOM' => '自订', +'LBL_DONT_MAP' => '-- 没有标记这个字段 --', +'LBL_STEP_1_TITLE' => '步骤 1 到 4: 选择数据来源', +'LBL_WHAT_IS' => '请选择数据来源:', +'LBL_MICROSOFT_OUTLOOK' => 'Microsoft Outlook', +'LBL_ACT' => 'Act!', +'LBL_SALESFORCE' => 'Salesforce.com', +'LBL_MY_SAVED' => '我所储存的来源:', +'LBL_PUBLISH' => '发布', +'LBL_DELETE' => '删除', +'LBL_PUBLISHED_SOURCES' => '发布来源:', +'LBL_UNPUBLISH' => '不发布', +'LBL_NEXT' => '下一步', +'LBL_BACK' => '上一步', +'LBL_STEP_2_TITLE' => '步骤 2 of 4: 上传导入文件', +'LBL_HAS_HEADER' => '标题行:', + +'LBL_NUM_1'=>'1.', +'LBL_NUM_2'=>'2.', +'LBL_NUM_3'=>'3.', +'LBL_NUM_4'=>'4.', +'LBL_NUM_5'=>'5.', +'LBL_NUM_6'=>'6.', +'LBL_NUM_7'=>'7.', +'LBL_NUM_8'=>'8.', +'LBL_NUM_9'=>'9.', +'LBL_NUM_10'=>'10.', +'LBL_NUM_11'=>'11.', +'LBL_NUM_12'=>'12.', +'LBL_NOW_CHOOSE' => '选择读入文件:', + 'LBL_IMPORT_OUTLOOK_TITLE' => 'Microsoft Outlook 98 and 2000 能依据标点符号区分各字段数据以读入或导出数据,请随后续的指示操作:', +'LBL_OUTLOOK_NUM_1' => '开始 Outlook', +'LBL_OUTLOOK_NUM_2' => '选择指定的 文件 清单, 以利 读入及导出 ... 清单选项', +'LBL_OUTLOOK_NUM_3' => '选择 导出文件 和点选下一步', +'LBL_OUTLOOK_NUM_4' => '选择 区分逗号值 (Windows) 并点选 下一步.
    备注: 您在安装导出组件时所必须作的相关提示', +'LBL_OUTLOOK_NUM_5' => '选择 联络人 数据夹和点选 下一步. 如果您选择重了复选数据夹,您就能够选择不同的联络人数据夹', +'LBL_OUTLOOK_NUM_6' => '选择文件名称并点选 下一步', +'LBL_OUTLOOK_NUM_7' => '选择 完成', +'LBL_IMPORT_ACT_TITLE' => '动作提示! 您所读入导出的数据会依据 区分标点符号 格式来执行!, 请随后续的指示操作:', +'LBL_ACT_NUM_1' => '开始 执行!', +'LBL_ACT_NUM_2' => '选择 文件 清单, 数据交换 清单选项, 以利 导出... 清单选项', +'LBL_ACT_NUM_3' => '选择文件类型 Text-Delimited', +'LBL_ACT_NUM_4' => '选择文件及其位置以利输出数据,并点选 下一步', +'LBL_ACT_NUM_5' => '选择 仅限联络人记录', +'LBL_ACT_NUM_6' => '点选 选项... 按钮', +'LBL_ACT_NUM_7' => '选择 标点符号 区分字段字符', +'LBL_ACT_NUM_8' => '检查 确定, 导出字段名称 核取并点选选 OK', +'LBL_ACT_NUM_9' => '点选 下一步', +'LBL_ACT_NUM_10' => '选择 全部记录 和点选 完成', + +'LBL_IMPORT_SF_TITLE' => 'Salesforce.com 能输出数据以导入数据到系统中,利用 区分标点符号 格式来执行,请随后续的指示操作:', +'LBL_SF_NUM_1' => '开启您的浏览器, 到 http://www.salesforce.com, 和登入您的电子邮件地址及密码', +'LBL_SF_NUM_2' => '在顶层清单中,点选 导出 ', +'LBL_SF_NUM_3' => '输出公司: 点选 经常往来公司 连结
    输出联络人: 选择 电子邮件列表 连结', +'LBL_SF_NUM_4' => '步骤 1: 选择您的报告类型, 选择 表格报告点选 下一步', +'LBL_SF_NUM_5' => '步骤 2: 选择报告栏, 点选您要输出的字段 下一步', +'LBL_SF_NUM_6' => '步骤 3: 选择总结讯息, 点选 下一步', +'LBL_SF_NUM_7' => '步骤 4: 命令输出字段, 点选 下一步', +'LBL_SF_NUM_8' => '步骤 5: 选择您的输出标准, 在 开始日期下方, 选择足够的日期范围值到您的公司. 您您可以输出公司相关的信息利用更多的进阶选项. 当您完成, 点选 报告', +'LBL_SF_NUM_9' => '报告将产生, 并且该页面会显示 报告执行身份: 编译. 立即点选 输出到Excel电子电子表格', +'LBL_SF_NUM_10' => '在 输出报告:, 从 输出文件格式:, 选择 标点符号区分.csv. 点选 输出.', +'LBL_SF_NUM_11' => '将会弹出对话窗口让您可以储存输出文件.', +'LBL_IMPORT_CUSTOM_TITLE' => '许多应用将会依您的输出数据所设定的 标点符号区分 (.csv). 通常将会依一般设定值来执行:', +'LBL_CUSTOM_NUM_1' => '开始应用执行并打开数据文件', +'LBL_CUSTOM_NUM_2' => '选择 另存...输出... 清单选项', +'LBL_CUSTOM_NUM_3' => '储存文件的格式依据 CSV标点符号设定值', + +'LBL_STEP_3_TITLE' => '步骤 3 / 4: 确认导入字段', +'LBL_STEP_1' => '步骤 1 / 3:', +'LBL_STEP_1_TITLE'=>'选择 .CSV 文件', +'LBL_STEP_1_TEXT' => ' vtiger CRM 支持从 .csv ( 逗点分隔数据 ) 文件导入数据,请选择指定的文件后点选继续按钮。
    注意:请在执行导入前,首先修改导入文件的编码为:UTF-8或ISO-8859-1', + +'LBL_SELECT_FIELDS_TO_MAP' => '在列表下方, 从您读入的文件中选择输入的字段. 当您完成时,点选 立即读入', + +'LBL_DATABASE_FIELD' => '数据库字段', +'LBL_HEADER_ROW' => '字段标题', +'LBL_ROW' => '列', +'LBL_SAVE_AS_CUSTOM' => '储存自订标记:', +'LBL_CONTACTS_NOTE_1' => '不管是名或全名都必须被标记选择.', +'LBL_CONTACTS_NOTE_2' => '如果全名被标记选择, 那姓与名字段就会取消.', +'LBL_CONTACTS_NOTE_3' => '如果全名被标记选择,当要写入数据库时它们会被自动分割成姓与名.', +'LBL_CONTACTS_NOTE_4' => '数据新增到数据库时,在地址2与地址3的信息会与主要地址字段合并', +'LBL_ACCOUNTS_NOTE_1' => '公司名称必须被选择标记.', +'LBL_ACCOUNTS_NOTE_2' => '当要写入数据库时,将地址街道巷号2和街道巷号3的数据合并在主要地址字段.', +'LBL_POTENTIALS_NOTE_1' => '潜在机会名称,公司名称,结束日期与销售策略都是必填字段', +'LBL_OPPORTUNITIES_NOTE_1' => '潜在案件名称, 公司名称, 结束日期, 和客服场地所需的字段.', +'LBL_LEADS_NOTE_1' => '必须指定姓氏', +'LBL_LEADS_NOTE_2' => '必须指定公司名称', +'LBL_IMPORT_NOW' => '立即读入', +'LBL_' => '', +'LBL_CANNOT_OPEN' => '无法读取导入的文件', +'LBL_NOT_SAME_NUMBER' => '在您指定的文件中每列的各字段的号码不一致', +'LBL_NO_LINES' => '在您读入的文件中没有行号', +'LBL_FILE_ALREADY_BEEN_OR' => '您所指定导入的文件已经处理过或不存在', +'LBL_SUCCESS' => '服务系统操作:', +'LBL_SUCCESSFULLY' => '读入系统操作', +'LBL_LAST_IMPORT_UNDONE' => '您最后一笔读入的信息已取消', +'LBL_NO_IMPORT_TO_UNDO' => '没有读入的信息供取消.', +'LBL_FAIL' => '失败:', +'LBL_RECORDS_SKIPPED' => '该笔记录略过,因为缺漏必要字段值', +'LBL_IDS_EXISTED_OR_LONGER' => '该笔记录略过,因为记录编号已存在或长度超过36字符', +'LBL_RESULTS' => '结果', +'LBL_IMPORT_MORE' => '读入更多...', +'LBL_FINISHED' => '已完成', +'LBL_UNDO_LAST_IMPORT' => '取消最后一笔的读入', + +'LBL_SUCCESS_1' => '成功导入数据笔数:', +'LBL_SKIPPED_1' => '略过的数据笔数(可能缺少一或多个字段):', + +//Added for patch2 - Products Import Notes +'LBL_PRODUCTS_NOTE_1' => '必须对应产品名称', +'LBL_PRODUCTS_NOTE_2' => '在导入前请先确认单一字段是否被指定两次', + +//Added for version 5 +'LBL_FILE_LOCATION' => '文件位置:', +'LBL_STEP_2_3' => '步骤 2 / 3:', +'LBL_LIST_MAPPING' => '列表与对应', +'LBL_STEP_2_MSG' => '下面数据表显示导入的数据', +'LBL_STEP_2_MSG1' => '与其它细节。', +'LBL_STEP_2_TXT' => '对应字段的方式是在下面相对方块中调整个别项目', +'LBL_USE_SAVED_MAPPING' => '使用预存对应:', +'LBL_MAPPING' => '对应', +'LBL_HEADERS' => '页首:', +'LBL_ERROR_MULTIPLE' => '同样的字段对应两次,请检查对应字段。', +'LBL_STEP_3_3' => '步骤 3 / 3 :', +'LBL_MAPPING_RESULTS' => '对应结果', +'LBL_LAST_IMPORTED' => '最新导入的', +//Added for sript alerts +'PLEASE_CHECK_MAPPING' => "' 映射一次以上。请检查映射.", +'MAP_MANDATORY_FIELD' => 'Please map the mandatory field "', +'ENTER_SAVEMAP_NAME' => '请输入要保存的地图名', + +//Added for 5.0.3 +'to'=>'to', +'of'=>'of', +'are_imported_succesfully'=>'导入成功', + +// Added after 5.0.4 GA + +//added for duplicate handling +'LBL_LAST_IMPORT'=>'Last Imported', +'Select_Criteria_For_Duplicate' => 'Select Criteria For Duplicate Records Handling', +'Manual_Merging' => 'Manual Merging', +'Auto_Merging' => 'Auto Merging', +'Ignore_Duplicate' => 'Ignore the duplicate import records', +'Overwrite_Duplicate' => 'Overwrite the duplicate records', +'Duplicate_Records_Skipped_Info' => 'No. of Records Skipped as they were duplicates : ', +'Duplicate_Records_Overwrite_Info' => 'No. of Records Overwritten as they were duplicates : ', +'LBL_STEP_4_4' => 'Step 4 of 4 : ', +'LBL_STEP_3_4'=>'Step 3 of 4 :', +'LBL_STEP_2_4'=>'Step 2 of 4 :', +'LBL_STEP_1_4'=>'Step 1 of 4 : ', + +'LBL_DELIMITER' => '定界符:', +'LBL_FORMAT' => '编码:', +); + +/*$mod_list_strings = Array( + "id"=>"Contact ID" + ,"first_name"=>"First Name" + ,"last_name"=>"Last Name" + ,"salutation"=>"Salutation" + ,"lead_source"=>"Lead Source" + ,"birthdate"=>"Lead Source" + ,"do_not_call"=>"Do Not Call" + ,"email_opt_out"=>"Email Opt Out" + ,"primary_address_street_2"=>"Primary Address Street 2" + ,"primary_address_street_3"=>"Primary Address Street 3" + ,"alt_address_street_2"=>"Other Address Street 2" + ,"alt_address_street_3"=>"Other Address Street 3" + ,"full_name"=>"Full Name" + ,"account_name"=>"Account Name" + ,"account_id"=>"Account ID" + ,"title"=>"Title" + ,"department"=>"Department" + ,"birthdate"=>"Birthdate" + ,"do_not_call"=>"Do Not Call" + ,"phone_home"=>"Phone (Home)" + ,"phone_mobile"=>"Phone (Mobile)" + ,"phone_work"=>"Phone (Work)" + ,"phone_other"=>"Phone (Other)" + ,"phone_fax"=>"Fax" + ,"email1"=>"Email" + ,"email2"=>"Email (Other)" + ,"yahoo_id"=>"Yahoo! ID" + ,"assistant"=>"Assistant" + ,"assistant_phone"=>"Assistant Phone" + ,"primary_address_street"=>"Primary Address Street" + ,"primary_address_city"=>"Primary Address City" + ,"primary_address_state"=>"Primary Address State" + ,"primary_address_postalcode"=>"Primary Address Postalcode" + ,"primary_address_country"=>"Primary Address Country" + ,"alt_address_street"=>"Other Address Street" + ,"alt_address_city"=>"Other Address City" + ,"alt_address_state"=>"Other Address State" + ,"alt_address_postalcode"=>"Other Address Postalcode" + ,"alt_address_country"=>"Other Address Country" + ,"description"=>"Description" + + ),*/ +$mod_list_strings = Array( +'contacts_import_fields' => Array( + //"id"=>"Contact ID" + "firstname"=>"名字" + ,"lastname"=>"姓氏" + ,"salutationtype"=>"称号" + ,"leadsource"=>"资料来源" + ,"birthday"=>"出生日期" + ,"donotcall"=>"请勿来电" + ,"emailoptout"=>"请勿来信" + //,"primary_address_street_2"=>"Primary Address Street 2" + //,"primary_address_street_3"=>"Primary Address Street 3" + //,"alt_address_street_2"=>"Other Address Street 2" + //,"alt_address_street_3"=>"Other Address Street 3" + //,"full_name"=>"Full Name" + //,"account_name"=>"Account Name" + ,"account_id" => "公司名称" + ,"title"=>"标题" + ,"department"=>"部门" + //,"birthdate"=>"Birthdate" + //,"do_not_call"=>"Do Not Call" + ,"homephone"=>"电话(家庭)" + ,"mobile"=>"电话 (手机)" + ,"phone"=>"电话 (工作)" + ,"otherphone"=>"电话 (其他)" + ,"fax"=>"传真" + ,"email"=>"Email" + ,"otheremail"=>"Email (其他)" + ,"yahooid"=>"Yahoo! ID" + ,"assistant"=>"助理" + ,"assistantphone"=>"助理电话" + ,"mailingstreet"=>"信件地址(街道巷号)" + ,"mailingpobox"=>"信件地址(邮政信箱)" + ,"mailingcity"=>"信件地址(乡镇市区)" + ,"mailingstate"=>"信件地址(县市)" + ,"mailingzip"=>"信件地址(邮政编码)" + ,"mailingcountry"=>"信件地址(国家)" + ,"otherstreet"=>"其它地址(街道巷号)" + ,"otherpobox"=>"其它地址(邮政信箱)" + ,"othercity"=>"其它地址(乡镇市区)" + ,"otherstate"=>"其它地址(县市)" + ,"otherzip"=>"其它地址(邮政编码)" + ,"othercountry"=>"其它地址(国家)" + ,"description"=>"描述" + ,"assigned_user_id"=>"担当者" + ), + +'accounts_import_fields' => Array( + //"id"=>"Account ID", + "accountname"=>"公司名称", + "website"=>"网站", + "industry"=>"企业", + "accounttype"=>"类型", + "tickersymbol"=>"传票符号", + "parent_name"=>"成员", + "employees"=>"员工", + "ownership"=>"潜在客户", + "phone"=>"电话", + "fax"=>"传真", + "otherphone"=>"其他电话", + "email1"=>"Email", + "email2"=>"其他电邮", + "rating"=>"评价", + "siccode"=>"统一编号", + "annual_revenue"=>"年营业额", + "bill_street"=>"账单地址(街道巷号)", + //"billing_address_street_2"=>"Billing Address Street 2", + //"billing_address_street_3"=>"Billing Address Street 3", + //"billing_address_street_4"=>"Billing Address Street 4", + "bill_pobox"=>"账单地址(邮政信箱)", + "bill_city"=>"账单地址(乡镇市区)", + "bill_state"=>"账单地址(县市)", + "bill_code"=>"账单地址(邮政编码)", + "bill_country"=>"账单地址(国家)", + "ship_street"=>"送货地址(街道巷号)", + //"shipping_address_street_2"=>"Shipping Address Street 2", + //"shipping_address_street_3"=>"Shipping Address Street 3", + //"shipping_address_street_4"=>"Shipping Address Street 4", + "ship_pobox"=>"收货住址(邮政信箱)", + "ship_city"=>"送货地址(乡镇市区)", + "ship_state"=>"送货地址(县市)", + "ship_code"=>"送货地址(邮政编码)", + "ship_country"=>"送货地址(国家)", + "description"=>"描述", + "assigned_user_id"=>"负责人" + ), + +'potentials_import_fields' => Array( + //"id"=>"Account ID" + "potentialname"=>"潜在案件名称" + , "account_id"=>"公司名称" + , "opportunity_type"=>"潜在案件类型" + , "leadsource"=>"资料来源" + , "amount"=>"合计" + , "closingdate"=>"关闭日期" + , "nextstep"=>"下一步设定" + , "sales_stage"=>"客服位置" + , "probability"=>"可能性" + , "description"=>"描述" + ,"assigned_user_id"=>"负责人" + ), + + +'leads_import_fields' => Array( + "salutationtype"=>"称号", + "firstname"=>"姓", + "phone"=>"电话", + "lastname"=>"名", + "mobile"=>"手机", + "company"=>"公司", + "fax"=>"传真", + "designation"=>"任命", + "email"=>"Email", + "leadsource"=>"资料来源", + "website"=>"网站", + "industry"=>"企业", + "leadstatus"=>"潜在客户职位", + "annualrevenue"=>"年营业额", + "rating"=>"评价", + "noofemployees"=>"没有雇员", + "assigned_user_id"=>"负责人", + "yahooid"=>"Yahoo Id", + "lane"=>"街道巷号", + "pobox"=>"邮政信箱", + "code"=>"邮政编码", + "city"=>"乡镇市区", + "country"=>"国家", + "state"=>"县市", + "description"=>"描述", + "assigned_user_id"=>"负责人" + ), + + 'products_import_fields' => Array( + 'productname' => '产品名称', + 'productcode' => '产品代码', + 'productcategory' => '产品类别', + 'manufacturer' => '制造商', + 'product_description' => '产品介绍', + 'qty_per_unit' => '单位数量', + 'unit_price' => '单位价格', + 'weight' => '重量', + 'pack_size' => '包装大小', + 'start_date' => '开始日期', + 'expiry_date' => '到期日', + 'cost_factor' => '成本要素', + 'commissionmethod' => '佣金计算方式', + 'discontinued' => '停售', + 'commissionrate' => '佣金率', + 'sales_start_date' => '开始销售日期', + 'sales_end_date' => '停止销售日期', + 'usageunit' => '使用单位', + 'serialno' => '序号', + 'currency' => '货币', + 'reorderlevel' => '安全库存', + 'website' => '网站', + 'taxclass' => '税别', + 'mfr_part_no' => '制造零件编号', + 'vendor_part_no' => '厂商零件编号', + 'qtyinstock' => '库存数量', + 'productsheet' => '产品表', + 'qtyindemand' => '需求数量', + 'glacct' => '会计科目', + 'assigned_user_id' => '负责人' + ), +//Pavani...adding list of import fields for helpdesk and vendors +'helpdesk_import_fields' => Array( + "ticketid"=>"Ticket Id", + "priority"=>"Priority", + "severity"=>"Severity", + "status"=>"Status", + "category"=>"Category", + "title"=>"Title", + "description"=>"Description", + "solution"=>"Solution" + ), + +'vendors_import_fields' => Array( + "vendorid"=>"Vender Id", + "vendorname"=>"Vendor Name", + "phone"=>"Phone", + "email"=>"Email", + "website"=>"Website", + "category"=>"Category", + "street"=>"Street", + "city"=>"City", + "state"=>"State", + "pobox"=>"Post Box", + "postalcode"=>"Postal Code", + "country"=>"Country", + "description"=>"Description" + ) +//Pavani...end list +); + +?> diff --git a/oss/vtiger/trunk/modules/Import/lastImport.php b/oss/vtiger/trunk/modules/Import/lastImport.php new file mode 100644 index 00000000..70e0d050 --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/lastImport.php @@ -0,0 +1,207 @@ +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 ""; + echo "
    "; + echo "
    + + + + + + +
    + $app_strings[LBL_NO] $mod_strings[LBL_LAST_IMPORTED] $app_strings[$module_name]
    +
    "; + echo "
    "; + } + } 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 " + + + + +
    + ".$mod_strings['LBL_LAST_IMPORTED']." ".$app_strings[$module_name]." +
    + "; + + $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;$iassign("LISTHEADER", $listview_header); + $smarty->assign("LISTENTITY", $listview_entries); + + // Include required scripts + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + $smarty->display("ListViewEntries.tpl"); + } +} + +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Import/parse_utils.php b/oss/vtiger/trunk/modules/Import/parse_utils.php new file mode 100644 index 00000000..d81008a1 --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/parse_utils.php @@ -0,0 +1,158 @@ +&$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; + +} +?> diff --git a/oss/vtiger/trunk/modules/Import/picklist_addition.php b/oss/vtiger/trunk/modules/Import/picklist_addition.php new file mode 100644 index 00000000..f5550404 --- /dev/null +++ b/oss/vtiger/trunk/modules/Import/picklist_addition.php @@ -0,0 +1,89 @@ +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 $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)); + } + + + } + +} + +?>