Commit 8a803576 authored by Frank Bergmann's avatar Frank Bergmann

- Added CSV import for Budget Items

parent 94e23af7
......@@ -479,7 +479,7 @@ ad_proc -public im_csv_import_parser_conf_item_parent_nrs {
{-parser_args "" }
arg
} {
Returns a project_id from a list of project_nr's
Returns a conf_item_id from a list of conf_item Nrs.
} {
set arg [string tolower [string trim $arg]]
set parent_id ""
......@@ -517,3 +517,48 @@ ad_proc -public im_csv_import_parser_conf_item_parent_nrs {
}
return [list $parent_id ""]
}
ad_proc -public im_csv_import_parser_budget_item_parent_nrs {
{-parser_args "" }
arg
} {
Returns a budget_item_id from a list of parent budget item numbers
} {
set arg [string tolower [string trim $arg]]
set parent_id ""
# Shortcut: Accept the name of a budget_item if it's found
set budget_item_ids [db_list budget_item_ids "select budget_item_id from im_budget_items where lower(budget_item_nr) = :arg"]
if {"" ne $budget_item_ids} {
if {1 eq [llength $budget_item_ids]} {
return [list [lindex $budget_item_ids 0] ""]
} else {
return [list "" "Found multiple budget_items with name '$arg': Please use a space separated list of budget_item_nrs."]
}
}
if {"" eq $budget_item_ids} {
set budget_item_ids [db_list budget_item_ids "select budget_item_id from im_budget_items where lower(budget_item_name) = :arg"]
if {"" ne $budget_item_ids} {
if {1 eq [llength $budget_item_ids]} {
return [list [lindex $budget_item_ids 0] ""]
} else {
return [list "" "Found multiple budget_items with name '$arg': Please use a space separated list of budget_item_nrs."]
}
}
}
# Loop through the list of parent_nrs
foreach parent_nr $arg {
set parent_sql "budget_item_parent_id = $parent_id"
if {"" eq $parent_id} { set parent_sql "budget_item_parent_id is null" }
set project_id [db_string pid "select budget_item_id from im_budget_items where $parent_sql and lower(budget_item_nr) = :parent_nr" -default ""]
if {"" eq $project_id} {
return [list "" "Didn't find budget_item with budget_item_nr='$parent_nr' and parent_id='$parent_id'"]
}
set parent_id $project_id
}
return [list $parent_id ""]
}
......@@ -346,6 +346,32 @@ ad_proc -public im_csv_import_guess_im_conf_item { } {} {
return $mapping
}
ad_proc -public im_csv_import_guess_im_budget_item { } {} {
set mapping {
{budget_item_parent_id "Parent Budget Item Nr" budget_item_parent_nrs ""}
{budget_item_parent_id "Budget Item Parent Nrs" budget_item_parent_nrs ""}
{budget_item_name "Budget Item Name" no_change ""}
{budget_item_nr "Budget Item Nr" no_change ""}
{budget_item_code "Budget Item Code" no_change ""}
{budget_item_object_id "Budget Item Project" project_parent_nrs ""}
{budget_item_object_id "Budget Item Object" project_parent_nrs ""}
{budget_item_status_id "Budget Item Status" category "Intranet Budget Item Status"}
{budget_item_type_id "Budget Item Type" category "Intranet Budget Item Type"}
{budget_item_owner_id "Budget Item Owner" user_name ""}
{budget_item_owner_id "Budget Item Owner Email" user_name ""}
{budget_item_max_value "Value" number ""}
{budget_item_max_value "Maximum Amount" number ""}
{budget_item_alarm_value "Alarm Value" number ""}
{match_cost_type_id "Cost Type" category "Intranet Cost Type"}
{match_expense_type_id "Expense Type" category "Intranet Expense Type"}
{match_task_id "Project Phase" project_parent_nrs ""}
{match_material_type_id "Material Type" category "Intranet Material Type"}
{description "Description" no_change ""}
{note "Note" no_change ""}
}
return $mapping
}
ad_proc -public im_csv_import_guess_im_hour { } {} {
set mapping {
{project_id "Project Nr Path " project_parent_nrs ""}
......@@ -395,9 +421,10 @@ 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_expense_bundle - im_expense - rels {
im_project - im_company - im_budget_item - im_conf_item - im_cost - im_invoice - im_risk - im_timesheet_task - im_ticket - im_hour - person - im_expense_bundle - im_expense - rels {
set parsers {
no_change "No Change"
budget_item_parent_nrs "Budget Item Parent Nrs"
boolean "Boolean"
category "Category ID from Category Name"
company_name "Company ID from Company Name or Company Path"
......
Budget Item Parent Nrs;Budget Item Nr;Budget Item Name;Budget Item Project;Budget Item Owner;Budget Item Status;Budget Item Type;Maximum Amount;Description;Note
;WBS.031/17;Extended Systems Monitoring;Car Configurator;Ben Bigboss;Approved;Default;400.000 ;Build an extended version of current system's monitoring;
WBS.031/17;WBS.031/17.A;Provider Hardware;Car Configurator;Ben Bigboss;Approved;Default;100.000 ;;
WBS.031/17;WBS.031/17.B;Installation Hardware;Car Configurator;Ben Bigboss;Approved;Default;20.000 ;;
WBS.031/17;WBS.031/17.C;Software Licenses;Car Configurator;Ben Bigboss;Approved;Default;50.000 ;;
WBS.031/17;WBS.031/17.D;Software Installation;Car Configurator;Ben Bigboss;Approved;Default;10.000 ;;
WBS.031/17;WBS.052/17.A;Extend Fiber Network;Car Configurator;Ben Bigboss;Approved;Default;60.000 ;;Need to clarify existing network
WBS.031/17;WBS.052/17.B;Additional Sensors;Car Configurator;Ben Bigboss;Approved;Default;30.000 ;;
WBS.031/17;WBS.052/17.C;Database & OS Licenses;Car Configurator;Ben Bigboss;Approved;Default;15.000 ;;
WBS.031/17;WBS.052/17.D;Integration with legacy systems;Car Configurator;Ben Bigboss;Approved;Default;80.000 ;;
WBS.031/17;WBS.052/17.E;Optional Add-On Monitors;Car Configurator;Ben Bigboss;Requested;Default;20.000 ;Optional. Supervisory board will decide;
This diff is collapsed.
......@@ -11,19 +11,20 @@
<td>#intranet-csv-import.Object_Type#</td>
<td>
<%= [im_select object_type [list \
person "Person" \
im_budget_item "Budget Item" \
im_company "Company" \
im_conf_item "Configuration Item" \
im_expense "Expense" \
im_expense_bundle "Expense Bundle" \
im_invoice "Financial Document" \
im_timesheet_task "Gantt Task" \
im_membership "Membership" \
person "Person" \
im_project "Project" \
rels "Relationship: Projects/Tasks - Members " \
im_risk "Risk" \
im_hour "Timesheet Hour" \
im_ticket "Ticket" \
im_expense "Expense" \
im_expense_bundle "Expense Bundle" \
rels "Relationship: Projects/Tasks<->Members " \
] $object_type] %>
</td>
</tr>
......@@ -52,14 +53,20 @@
<th><nobr>Example<br/>Export SQL</nobr></th>
<th align="left">Comments</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 align=center><a href="/intranet-reporting/view?report_id=<%=$report_id_export_persons%>"><%= [im_gif database_table] %></a></td>
<td><!--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>
<td><%= [im_gif [db_string gif "select object_type_gif from acs_object_types where object_type = 'im_budget_item'"]] %></td>
<td>Budget Item</td>
<td align=center><a href="examples/im_budget_item.csv"><%= [im_gif csv-doc] %></a></td>
<td align="center"></td>
<td>
Please note that this import requires exact naming of column headers.<br>
Budget Item <a href="/intranet-dynfield/object-type?object_type=im_budget_item">DynFields</a> are also recognized by their "pretty name" or "column name".</p>
</td>
</tr>
<tr>
<td><%= [im_gif [db_string gif "select object_type_gif from acs_object_types where object_type = 'im_company'"]] %></td>
<td>Company</td>
......@@ -69,6 +76,36 @@
</td>
</tr>
<tr>
<td><%= [im_gif [db_string gif "select object_type_gif from acs_object_types where object_type = 'im_conf_item'"]] %></td>
<td>Conf Item</td>
<td align=center><a href="examples/im_conf_item.csv"><%= [im_gif csv-doc] %></a></td>
<td align="center"></td>
<td>
Please note that this import requires exact naming of column headers.<br>
Conf Item <a href="/intranet-dynfield/object-type?object_type=im_conf_item">DynFields</a> are also recognized by their "pretty name" or "column name".</p>
</td>
</tr>
<tr>
<td><%= [im_gif money] %></td>
<td>Expense Items</td>
<td align=center><a href="examples/im_expense.csv"><%= [im_gif csv-doc] %></a></td>
<td align=center><a href="/intranet-reporting/view?report_id=<%=$report_id_export_expense_items%>"><%= [im_gif database_table] %></a></td>
<td>
Expense <a href="/intranet-dynfield/object-type?object_type=im_expense">DynFields</a> are also recognized by their "pretty name" or "column name".
</td>
</tr>
<tr>
<td><%= [im_gif box] %></td>
<td>Expense Bundles</td>
<td align=center><a href="examples/im_expense_bundle.csv"><%= [im_gif csv-doc] %></a></td>
<td align=center><a href="/intranet-reporting/view?report_id=<%=$report_id_export_expense_bundles%>"><%= [im_gif database_table] %></a></td>
<td></td>
</tr>
<tr>
<td><%= [im_gif [db_string gif "select object_type_gif from acs_object_types where object_type = 'im_invoice'"]] %></td>
<td>Financial Documents (Invoices, Purchase Orders, etc.)</td>
......@@ -93,16 +130,6 @@
</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>
<td align=center><a href="examples/im_project.csv"><%= [im_gif csv-doc] %></a></td>
<td align=center><a href="/intranet-reporting/view?report_id=<%=$report_id_export_projects%>"><%= [im_gif database_table] %></a></td>
<td>
Project <a href="/intranet-dynfield/object-type?object_type=im_project">DynFields</a> are also recognized by their "pretty name" or "column name".</p>
</td>
</tr>
<tr>
<td><%= [im_gif [db_string gif "select object_type_gif from acs_object_types where object_type = 'im_gantt_task'" -default ""]] %></td>
<td>Gantt Task</td>
......@@ -111,41 +138,32 @@
<td>Allows to import Timesheet Tasks separately from projects/sub-projects.</td>
</tr>
<tr>
<td><%= [im_gif hourglass] %></td>
<td>Timesheet Hour</td>
<td align=center><a href="examples/im_hour.csv"><%= [im_gif csv-doc] %></a></td>
<td align=center><a href="/intranet-reporting/view?report_id=<%=$report_id_export_hours%>"><%= [im_gif database_table] %></a></td>
<td>DynFields for hours are not supported.</td>
<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 align=center><a href="/intranet-reporting/view?report_id=<%=$report_id_export_persons%>"><%= [im_gif database_table] %></a></td>
<td><!--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 money] %></td>
<td>Expense Items</td>
<td align=center><a href="examples/im_expense.csv"><%= [im_gif csv-doc] %></a></td>
<td align=center><a href="/intranet-reporting/view?report_id=<%=$report_id_export_expense_items%>"><%= [im_gif database_table] %></a></td>
<td><%= [im_gif [db_string gif "select object_type_gif from acs_object_types where object_type = 'im_project'"]] %></td>
<td>Project</td>
<td align=center><a href="examples/im_project.csv"><%= [im_gif csv-doc] %></a></td>
<td align=center><a href="/intranet-reporting/view?report_id=<%=$report_id_export_projects%>"><%= [im_gif database_table] %></a></td>
<td>
Expense <a href="/intranet-dynfield/object-type?object_type=im_expense">DynFields</a> are also recognized by their "pretty name" or "column name".
Project <a href="/intranet-dynfield/object-type?object_type=im_project">DynFields</a> are also recognized by their "pretty name" or "column name".</p>
</td>
</tr>
<tr>
<td><%= [im_gif box] %></td>
<td>Expense Bundles</td>
<td align=center><a href="examples/im_expense_bundle.csv"><%= [im_gif csv-doc] %></a></td>
<td align=center><a href="/intranet-reporting/view?report_id=<%=$report_id_export_expense_bundles%>"><%= [im_gif database_table] %></a></td>
<td></td>
</tr>
<tr>
<td><%= [im_gif [db_string gif "select object_type_gif from acs_object_types where object_type = 'im_conf_item'"]] %></td>
<td>Conf Item</td>
<td align=center><a href="examples/im_conf_item.csv"><%= [im_gif csv-doc] %></a></td>
<td align="center"></td>
<td>
Please note that this import requires exact naming of column headers.<br>
Conf Item <a href="/intranet-dynfield/object-type?object_type=im_conf_item">DynFields</a> are also recognized by their "pretty name" or "column name".</p>
</td>
<td><%=[im_gif brick_link]%></td>
<td>Relationships</td>
<td align=center><a href="examples/im_relation.csv"><%= [im_gif csv-doc] %></a></td>
<td align=center><a href="/intranet-reporting/view?report_id=<%=$report_id_export_project_task_relationships%>"><%= [im_gif database_table] %></a></td>
<td>Import relationships between projects/tasks and persons.</td>
</tr>
<tr>
......@@ -157,21 +175,11 @@
</tr>
<tr>
<td><%=[im_gif brick_link]%></td>
<td>Relationships</td>
<td align=center><a href="examples/im_relation.csv"><%= [im_gif csv-doc] %></a></td>
<td align=center><a href="/intranet-reporting/view?report_id=<%=$report_id_export_project_task_relationships%>"><%= [im_gif database_table] %></a></td>
<td>Import relationships between projects/tasks and persons.</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>
<td align=center></td>
<td align=center></td>
<td>
Absence 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.
</td>
<td><%= [im_gif hourglass] %></td>
<td>Timesheet Hour</td>
<td align=center><a href="examples/im_hour.csv"><%= [im_gif csv-doc] %></a></td>
<td align=center><a href="/intranet-reporting/view?report_id=<%=$report_id_export_hours%>"><%= [im_gif database_table] %></a></td>
<td>DynFields for hours are not supported.</td>
</tr>
<tr>
......@@ -184,6 +192,16 @@
</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>User Absence</td>
<td align=center></td>
<td align=center></td>
<td>
Absence 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.
</td>
</tr>
<!--
<tr>
<td><%= [im_gif [db_string gif "select object_type_gif from acs_object_types where object_type = 'im_cost'"]] %></td>
......
......@@ -32,6 +32,7 @@ set main_navbar_label [im_csv_import_label_from_object_type -object_type $object
db_1row get_report_ids "
select
(select report_id from im_reports where report_name = 'Export Absences') as report_id_export_absemces,
(select report_id from im_reports where report_name = 'Export Budget Items') as report_id_export_budget_items,
(select report_id from im_reports where report_name = 'Export Companies') as report_id_export_companies,
(select report_id from im_reports where report_name = 'Export Conf Items') as report_id_export_conf_items,
(select report_id from im_reports where report_name = 'Export Expense Bundles') as report_id_export_expense_bundles,
......
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