Commit 6068b190 authored by Frank Bergmann's avatar Frank Bergmann

- Reporting/DynFields:

  Moved auxillary DynField code from intranet-reporting-finance
  to the intranet-dynfield package where they belong
parent 3f9fd776
...@@ -27,95 +27,3 @@ ad_proc -private im_package_reporting_finance_id_helper {} { ...@@ -27,95 +27,3 @@ ad_proc -private im_package_reporting_finance_id_helper {} {
} -default 0] } -default 0]
} }
# ------------------------------------------------------------
# Find out all fields per object type
# -------------------------------------------------------
ad_proc im_dynfield_object_attributes_for_select {
-object_type:required
} {
Returns a list {key1 value1 key2 value2 ...} of attributes
and pretty_names for object.
The result is meant to be appended to the select list of
a report with custom fields
} {
set dynfield_sql "
select
aa.attribute_name,
aa.pretty_name,
ot.pretty_name as object_type_pretty_name,
w.deref_plpgsql_function
from
acs_attributes aa
RIGHT OUTER JOIN
im_dynfield_attributes fa
ON (aa.attribute_id = fa.acs_attribute_id)
LEFT OUTER JOIN
(select * from im_dynfield_layout where page_url = '') la
ON (fa.attribute_id = la.attribute_id)
LEFT OUTER JOIN
user_tab_columns c
ON (c.table_name = upper(aa.table_name) and c.column_name = upper(aa.attribute_name)),
im_dynfield_widgets w,
acs_object_types ot
where
aa.object_type = :object_type
and fa.widget_name = w.widget_name
and aa.object_type = ot.object_type
order by
la.pos_y, la.pos_x, aa.attribute_name
"
set field_options [list]
db_foreach dynfield_fields $dynfield_sql {
lappend field_options "${attribute_name}_deref"
lappend field_options "$object_type_pretty_name - $pretty_name"
}
return $field_options
}
ad_proc im_dynfield_object_attributes_derefs {
-object_type:required
{-prefix ""}
} {
Returns a list list of dereferentiation "SELECT" statements.
} {
set dynfield_sql "
select
aa.attribute_name,
aa.pretty_name,
ot.pretty_name as object_type_pretty_name,
w.deref_plpgsql_function
from
acs_attributes aa
RIGHT OUTER JOIN
im_dynfield_attributes fa
ON (aa.attribute_id = fa.acs_attribute_id)
LEFT OUTER JOIN
(select * from im_dynfield_layout where page_url = '') la
ON (fa.attribute_id = la.attribute_id)
LEFT OUTER JOIN
user_tab_columns c
ON (c.table_name = upper(aa.table_name) and c.column_name = upper(aa.attribute_name)),
im_dynfield_widgets w,
acs_object_types ot
where
aa.object_type = :object_type
and fa.widget_name = w.widget_name
and aa.object_type = ot.object_type
order by
la.pos_y, la.pos_x, aa.attribute_name
"
set deref_list [list]
db_foreach dynfield_fields $dynfield_sql {
lappend deref_list "${deref_plpgsql_function}($prefix$attribute_name) as ${attribute_name}_deref"
}
return $deref_list
}
...@@ -199,8 +199,8 @@ im_invoices_check_for_multi_project_invoices ...@@ -199,8 +199,8 @@ im_invoices_check_for_multi_project_invoices
# ------------------------------------------------------------ # ------------------------------------------------------------
set deref_list [im_dynfield_object_attributes_derefs -object_type "im_company" -prefix "cust."] set deref_list [im_dynfield::object_attributes_derefs -object_type "im_company" -prefix "cust."]
set deref_list [concat $deref_list [im_dynfield_object_attributes_derefs -object_type "im_project" -prefix "p."]] set deref_list [concat $deref_list [im_dynfield::object_attributes_derefs -object_type "im_project" -prefix "p."]]
set deref_extra_select [join $deref_list ",\n\t"] set deref_extra_select [join $deref_list ",\n\t"]
if {"" != $deref_extra_select} { set deref_extra_select ",\n\t$deref_extra_select" } if {"" != $deref_extra_select} { set deref_extra_select ",\n\t$deref_extra_select" }
...@@ -581,7 +581,7 @@ set field_options { ...@@ -581,7 +581,7 @@ set field_options {
project_customer_type "Company - Company Type" project_customer_type "Company - Company Type"
project_customer_manager_link "Company - Key Account" project_customer_manager_link "Company - Key Account"
} }
set field_options [concat $field_options [im_dynfield_object_attributes_for_select -object_type "im_company"]] set field_options [concat $field_options [im_dynfield::object_attributes_for_select -object_type "im_company"]]
set field_options [concat $field_options { set field_options [concat $field_options {
project_status "Project - Project Status" project_status "Project - Project Status"
...@@ -604,7 +604,7 @@ set field_options [concat $field_options { ...@@ -604,7 +604,7 @@ set field_options [concat $field_options {
cost_expense_logged_cache "Project - Exenses" cost_expense_logged_cache "Project - Exenses"
cost_delivery_notes_cache "Project - Delivery Notes" cost_delivery_notes_cache "Project - Delivery Notes"
}] }]
set field_options [concat $field_options [im_dynfield_object_attributes_for_select -object_type "im_project"]] set field_options [concat $field_options [im_dynfield::object_attributes_for_select -object_type "im_project"]]
set location_options {"" ""} set location_options {"" ""}
......
...@@ -294,8 +294,8 @@ im_invoices_check_for_multi_project_invoices ...@@ -294,8 +294,8 @@ im_invoices_check_for_multi_project_invoices
# ------------------------------------------------------------ # ------------------------------------------------------------
# #
set deref_list [im_dynfield_object_attributes_derefs -object_type "im_company" -prefix "cust."] set deref_list [im_dynfield::object_attributes_derefs -object_type "im_company" -prefix "cust."]
set deref_list [concat $deref_list [im_dynfield_object_attributes_derefs -object_type "im_project" -prefix "p."]] set deref_list [concat $deref_list [im_dynfield::object_attributes_derefs -object_type "im_project" -prefix "p."]]
set deref_extra_select [join $deref_list ",\n\t"] set deref_extra_select [join $deref_list ",\n\t"]
if {"" != $deref_extra_select} { set deref_extra_select ",\n\t$deref_extra_select" } if {"" != $deref_extra_select} { set deref_extra_select ",\n\t$deref_extra_select" }
...@@ -602,7 +602,7 @@ set field_options { ...@@ -602,7 +602,7 @@ set field_options {
project_customer_type "Company - Company Type" project_customer_type "Company - Company Type"
project_customer_manager_link "Company - Key Account" project_customer_manager_link "Company - Key Account"
} }
set field_options [concat $field_options [im_dynfield_object_attributes_for_select -object_type "im_company"]] set field_options [concat $field_options [im_dynfield::object_attributes_for_select -object_type "im_company"]]
set field_options [concat $field_options { set field_options [concat $field_options {
project_status "Project - Project Status" project_status "Project - Project Status"
...@@ -625,7 +625,7 @@ set field_options [concat $field_options { ...@@ -625,7 +625,7 @@ set field_options [concat $field_options {
cost_expense_logged_cache "Project - Exenses" cost_expense_logged_cache "Project - Exenses"
cost_delivery_notes_cache "Project - Delivery Notes" cost_delivery_notes_cache "Project - Delivery Notes"
}] }]
set field_options [concat $field_options [im_dynfield_object_attributes_for_select -object_type "im_project"]] set field_options [concat $field_options [im_dynfield::object_attributes_for_select -object_type "im_project"]]
set location_options {"" ""} set location_options {"" ""}
......
...@@ -230,8 +230,8 @@ im_invoices_check_for_multi_project_invoices ...@@ -230,8 +230,8 @@ im_invoices_check_for_multi_project_invoices
# ------------------------------------------------------------ # ------------------------------------------------------------
# Define the report - SQL, counters, headers and footers # Define the report - SQL, counters, headers and footers
# #
set deref_list [im_dynfield_object_attributes_derefs -object_type "im_company" -prefix "cust."] set deref_list [im_dynfield::object_attributes_derefs -object_type "im_company" -prefix "cust."]
set deref_list [concat $deref_list [im_dynfield_object_attributes_derefs -object_type "im_project" -prefix "child."]] set deref_list [concat $deref_list [im_dynfield::object_attributes_derefs -object_type "im_project" -prefix "child."]]
set deref_extra_select [join $deref_list ",\n\t"] set deref_extra_select [join $deref_list ",\n\t"]
if {"" != $deref_extra_select} { set deref_extra_select ",\n\t$deref_extra_select" } if {"" != $deref_extra_select} { set deref_extra_select ",\n\t$deref_extra_select" }
...@@ -579,7 +579,7 @@ set field_options { ...@@ -579,7 +579,7 @@ set field_options {
project_customer_type "Company - Company Type" project_customer_type "Company - Company Type"
project_customer_manager_link "Company - Key Account" project_customer_manager_link "Company - Key Account"
} }
set field_options [concat $field_options [im_dynfield_object_attributes_for_select -object_type "im_company"]] set field_options [concat $field_options [im_dynfield::object_attributes_for_select -object_type "im_company"]]
set field_options [concat $field_options { set field_options [concat $field_options {
project_status "Project - Project Status" project_status "Project - Project Status"
...@@ -602,7 +602,7 @@ set field_options [concat $field_options { ...@@ -602,7 +602,7 @@ set field_options [concat $field_options {
cost_expense_logged_cache "Project - Exenses" cost_expense_logged_cache "Project - Exenses"
cost_delivery_notes_cache "Project - Delivery Notes" cost_delivery_notes_cache "Project - Delivery Notes"
}] }]
set field_options [concat $field_options [im_dynfield_object_attributes_for_select -object_type "im_project"]] set field_options [concat $field_options [im_dynfield::object_attributes_for_select -object_type "im_project"]]
set location_options {"" ""} set location_options {"" ""}
......
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