Commit 7132574c authored by Frank Bergmann's avatar Frank Bergmann

-- several improvements

parent fa49917a
This diff is collapsed.
......@@ -23,6 +23,61 @@
</tr>
</table>
</if>
<if @object_type@ eq person>
<%
foreach profile_tuple [im_profile::profile_options_all] {
set profile_name [lindex $profile_tuple 0]
regsub -all {\[} $profile_name {} profile_name
regsub -all {\]} $profile_name {} profile_name
set profile_arr($profile_name) [lindex $profile_tuple 1]
}
%>
<table cellpadding="5" cellspacing="5" border="0">
<tr>
<td>
<h2>Settings:</h2>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top"><input type="checkbox" name="overwrite_existing_user_attributes_p" value="1">&nbsp;</td>
<td valign="top"><strong>Should already existing user attributes be overwritten?</strong><br/>Check to overwrite.</td>
</tr>
</table>
</td>
<td>
<h2>Please note:</h2>
<ul><li>Accepted ]po[ Profiles: <%=[array names profile_arr]%></li></ul>
</td>
</tr>
</table>
</if>
<if @object_type@ eq im_company>
<table cellpadding="5" cellspacing="5" border="0">
<tr>
<td>
<h2>Settings:</h2>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top"><input type="checkbox" name="overwrite_existing_company_attributes_p" value="1">&nbsp;</td>
<td valign="top"><strong>Should already existing company attributes be overwritten?</strong><br/>Check to overwrite.</td>
</tr>
</table>
</td>
<!--
<td>
<h2>Please note:</h2>
<ul><li></li></ul>
</td>
-->
</tr>
</table>
</if>
<br/>
<h2>Mapping</h2>
<table>
......
......@@ -113,8 +113,6 @@ set object_type_pairs [list "" ""]
foreach field $object_fields { lappend object_type_pairs [string tolower $field] [string tolower $field] }
lappend object_type_pairs "hard_coded" "Hard Coded Functionality"
# --------------------------------------------------
# Main Loop
# Try to guess the mapping and the parser for each field
......@@ -136,12 +134,13 @@ foreach header_name $headers {
}
# Guess the object's field to which to map.
set object_field_best_guess [im_csv_import_guess_map -object_type $object_type -field_name $header_name -sample_values $parser_sample_values]
set object_field_best_guess [im_csv_import_guess_map -object_type $object_type -field_name $header_name -sample_values $parser_sample_values ]
ns_log Notice "import-2: im_csv_import_guess_map -object_type $object_type -field_name $header_name -sample_values {$parser_sample_values}"
ns_log Notice "import-2: => $object_field_best_guess"
set guess_parser_field_name $header_name
if {"" != $object_field_best_guess} { set guess_parser_field_name $object_field_best_guess }
if {"" != $object_field_best_guess} {
set guess_parser_field_name $object_field_best_guess
}
# Guess the parser how to convert the field values
set defs [im_csv_import_guess_parser -object_type $object_type -field_name $guess_parser_field_name -sample_values $parser_sample_values]
......@@ -150,6 +149,7 @@ foreach header_name $headers {
set default_parser [lindex $defs 0]
set default_parser_args [lindex $defs 1]
set override_map [lindex $defs 2]
set parser [im_select parser.$cnt $parser_pairs $default_parser]
set args "<input type=text name=parser_args.$cnt value=\"$default_parser_args\" size=\"40\">\n"
......@@ -158,6 +158,7 @@ foreach header_name $headers {
if {"" != $override_map} { set default_map $override_map }
set map [im_select map.$cnt $object_type_pairs $default_map]
ns_log Notice "import-2: header_name=$header_name, default_map=$default_map, override_map=$override_map, map=$map"
if {"hard_coded" == $default_parser} { set map [im_select map.$cnt $object_type_pairs "hard_coded"] }
......
......@@ -14,6 +14,7 @@ ad_page_contract {
{ import_filename "" }
{ mapping_name "" }
{ ns_write_p 1 }
{ overwrite_existing_company_attributes_p 0 }
column:array
map:array
parser:array
......@@ -317,6 +318,11 @@ foreach csv_line_fields $values_list_of_lists {
} else {
if {$ns_write_p} { ns_write "<li>Company already exists: name='$company_name', id='$company_id'\n" }
if { !$overwrite_existing_company_attributes_p } {
if {$ns_write_p} { ns_write "<li>Skipping update - no attributes will be updated or added \n" }
continue
}
db_1row company_info "
select main_office_id
from im_companies
......
......@@ -34,7 +34,6 @@ if {!$admin_p} {
ad_script_abort
}
# ---------------------------------------------------------------------
# Check and open the file
# ---------------------------------------------------------------------
......
......@@ -11,6 +11,7 @@
<td>#intranet-csv-import.Object_Type#</td>
<td>
<%= [im_select object_type [list \
person "Person" \
im_company "Company" \
im_conf_item "Configuration Item" \
im_invoice "Financial Document" \
......@@ -43,13 +44,22 @@
Column names are case insensitive and spaces may be replaced by "_" (underscore characters).</p>
</td>
</tr>
<tr>
<th colspan=2><nobr>Object Type</nobr></th>
<th><nobr>Example CSV</nobr></th>
<th>Available Column Headers</th>
</tr>
<tr>
<td><%= [im_gif [db_string gif "select object_type_gif from acs_object_types where object_type = 'person'"]] %></td>
<td>Person</td>
<td align=center>
<a href="examples/person.csv"><%= [im_gif csv-doc] %></a>
</td>
<td>
Person import has BETA status. Please <a href="http://www.project-open.com/en/contact">contact us</a> for updates.<br/>
Alternatively you can use the old facilities for <a href="<%= [export_vars -base "/intranet/users/upload-contacts" {return_url}] %>">importing users from MS-Outlook exports</a>.
</td>
</tr>
<tr>
<td><%= [im_gif [db_string gif "select object_type_gif from acs_object_types where object_type = 'im_user_absence'"]] %></td>
<td>Absence</td>
......@@ -122,19 +132,6 @@
</td>
</tr>
<tr>
<td><%= [im_gif [db_string gif "select object_type_gif from acs_object_types where object_type = 'person'"]] %></td>
<td>Person</td>
<td align=center>
</td>
<td>
Person import is under active development at the moment.<br>
Please <a href="http://www.project-open.com/en/contact">contact us</a> for the current status or updates.
Meanwhile, please use the old facilities for
<a href="<%= [export_vars -base "/intranet/users/upload-contacts" {return_url}] %>">importing users from MS-Outlook exports</a>.
</td>
</tr>
<tr>
<td><%= [im_gif [db_string gif "select object_type_gif from acs_object_types where object_type = 'im_project'"]] %></td>
<td>Project</td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment