Commit 26d139fa authored by Frank Bergmann's avatar Frank Bergmann

-- several improvements and extensions

parent bbb7af66
......@@ -7,6 +7,7 @@
ad_library {
@author frank.bergmann@project-open.com
@autor klaus.hofeditz@project-open.com
}
# ---------------------------------------------------------------------
......@@ -19,6 +20,19 @@ ad_library {
# - Parser arguments (important for im_category type)
# ---------------------------------------------------------------------
ad_proc -public im_csv_import_guess_rels { } {} {
set mapping {
{object_type_1 "Object Type 1" no_change "" }
{object_name_1 "Object Name 1" user_name "" }
{object_type_2 "Object Type 2" no_change "" }
{object_name_2 "Object Name 2" project_parent_nrs "" }
{role_id "Role" category "Intranet Biz Object Role" }
{percentage "Percentage" number "" }
}
return $mapping
}
ad_proc -public im_csv_import_guess_person { } {} {
set mapping {
{email "Email" no_change "" }
......@@ -198,7 +212,7 @@ ad_proc -public im_csv_import_guess_im_timesheet_task { } {} {
{note "Note" no_change ""}
{description "Description" no_change ""}
{material_id "Material" material ""}
{uom_id "" category "Intranet UoM"}
{uom_id "Unit of measure" category "Intranet UoM"}
{planned_units "Planned Units" number ""}
{billable_units "Billable Units" number ""}
{cost_center_id "Cost Center" cost_center ""}
......@@ -298,7 +312,7 @@ ad_proc -public im_csv_import_parsers {
Returns the list of available parsers
} {
switch $object_type {
im_project - im_company - im_conf_item - im_cost - im_invoice - im_risk - im_timesheet_task - im_ticket - im_hour - person {
im_project - im_company - im_conf_item - im_cost - im_invoice - im_risk - im_timesheet_task - im_ticket - im_hour - person - rels {
set parsers {
boolean "Boolean"
category "Category ID from Category Name"
......
......@@ -245,6 +245,7 @@ foreach csv_line_fields $values_list_of_lists {
# -------------------------------------------------------
# Specific field transformations
# project_name needs to be there
if {"" == $project_name} {
if {$ns_write_p} {
......@@ -276,7 +277,7 @@ foreach csv_line_fields $values_list_of_lists {
if {$ns_write_p} { ns_write "<li><font color=red>Error: <pre>$err</pre></font>\n" }
continue
}
# Status is a required field
set project_status_id [im_id_from_category $project_status "Intranet Project Status"]
if {"" == $project_status_id} {
......@@ -291,17 +292,18 @@ foreach csv_line_fields $values_list_of_lists {
set project_type_id [im_project_type_other]
}
# start_date and end_date are required fields
if {"" == $start_date} {
if {$ns_write_p} { ns_write "<li><font color=brown>Warning: Didn't find project start_date, using today.</font>\n" }
set start_date [db_string today "select now()::date from dual"]
}
if {"" == $end_date} {
if {$ns_write_p} { ns_write "<li><font color=brown>Warning: Didn't find project end_date, using today.</font>\n" }
set end_date [db_string today "select now()::date from dual"]
# start_date and end_date are required fields for projects, not tasks
if { $project_type_id != 100 } {
if {"" == $start_date} {
if {$ns_write_p} { ns_write "<li><font color=brown>Warning: Didn't find project start_date, using today.</font>\n" }
set start_date [db_string today "select now()::date from dual"]
}
if {"" == $end_date} {
if {$ns_write_p} { ns_write "<li><font color=brown>Warning: Didn't find project end_date, using today.</font>\n" }
set end_date [db_string today "select now()::date from dual"]
}
}
# On track status can be NULL without problems
set on_track_status_id [im_id_from_category [list $on_track_status] "Intranet Project On Track Status"]
......@@ -317,11 +319,25 @@ foreach csv_line_fields $values_list_of_lists {
set company_id $company_id
if {"" == $company_id } {
set company_id [im_company_internal]
if {$ns_write_p} { ns_write "<li><font color=brown>Warning: Didn't find customer_name='$customer_name', using 'internal' customer</font>\n" }
if { 100 == $project_type_id } {
# Get company_id from top_project
set sql "
select company_id from im_projects where project_id in (
select parent.project_id
from im_projects parent,
im_projects child
where child.project_id = :parent_id and
parent.tree_sortkey = tree_root_key(child.tree_sortkey)
)
"
set company_id [db_string get_company_id $sql -default 0]
} else {
set company_id [im_company_internal]
if {$ns_write_p} { ns_write "<li><font color=brown>Warning: Didn't find customer_name='$customer_name', using 'internal' customer</font>\n" }
}
}
if { "" eq $project_lead_id } {
if { "" eq $project_lead_id && 100 != $project_type_id } {
if {$ns_write_p} { ns_write "<li><font color=brown>Warning: No project manager found. Will try to create project w/o PM. </font>\n" }
}
......@@ -526,10 +542,8 @@ foreach csv_line_fields $values_list_of_lists {
where
task_id = :project_id
"
}
# -------------------------------------------------------
# Import DynFields
set project_dynfield_updates {}
......
......@@ -21,7 +21,8 @@
im_risk "Risk" \
im_hour "Timesheet Hour" \
im_ticket "Ticket" \
] $object_type] %>
rels "Relationships (e.g. Projects/Tasks<->Members" \
] $object_type] %>
</td>
</tr>
<tr>
......
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