Commit 9f1ed9da authored by Frank Bergmann's avatar Frank Bergmann

- Added financial comparison portlet

parent 3a08b645
# project_id set by portlet TCL
if {![info exists project_id]} {
ad_page_contract {} {project_id:integer}
}
set current_user_id [auth::require_login]
im_project_permissions $current_user_id $project_id view_p read_p write_p admin_p
if {!$read_p} {
ad_return_complaint 1 "You don't have read permissions on #$project_id"
ad_script_abort
}
set html [im_ad_hoc_query -format html "
select i.item_outline_number as outline,
i.item_name,
im_category_from_id(i.item_uom_id) as uom,
(
select sum(tii.item_units)
from im_costs tc,
im_invoice_items tii,
im_projects p
where tii.invoice_id = tc.cost_id and
tii.item_outline_number = i.item_outline_number and
tii.item_uom_id = i.item_uom_id and
tc.cost_type_id = 3702 and
tc.project_id = p.project_id and
p.tree_sortkey between i.tree_sortkey and tree_right(i.tree_sortkey)
) as quotes,
(
select sum(tii.item_units)
from im_costs tc,
im_invoice_items tii,
im_projects p
where tii.invoice_id = tc.cost_id and
tii.item_outline_number = i.item_outline_number and
tii.item_uom_id = i.item_uom_id and
tc.cost_type_id = 3700 and
tc.project_id = p.project_id and
p.tree_sortkey between i.tree_sortkey and tree_right(i.tree_sortkey)
) as invoices,
(
select sum(tii.item_units)
from im_costs tc,
im_invoice_items tii,
im_projects p
where tii.invoice_id = tc.cost_id and
tii.item_outline_number = i.item_outline_number and
tii.item_uom_id = i.item_uom_id and
tc.cost_type_id = 3706 and
tc.project_id = p.project_id and
p.tree_sortkey between i.tree_sortkey and tree_right(i.tree_sortkey)
) as pos,
(
select sum(tii.item_units)
from im_costs tc,
im_invoice_items tii,
im_projects p
where tii.invoice_id = tc.cost_id and
tii.item_outline_number = i.item_outline_number and
tii.item_uom_id = i.item_uom_id and
tc.cost_type_id = 3704 and
tc.project_id = p.project_id and
p.tree_sortkey between i.tree_sortkey and tree_right(i.tree_sortkey)
) as bills
from (select distinct
ii.item_outline_number,
ii.item_uom_id,
ii.item_name,
main_p.tree_sortkey
from im_costs c,
im_invoices i,
im_invoice_items ii,
im_projects sub_p,
im_projects main_p
where c.cost_id = i.invoice_id and
ii.invoice_id = i.invoice_id and
c.project_id = sub_p.project_id and
sub_p.tree_sortkey between main_p.tree_sortkey and tree_right(main_p.tree_sortkey) and
main_p.project_id = :project_id
) i
order by i.item_outline_number
"]
......@@ -1458,7 +1458,67 @@ SELECT im_component_plugin__new (
SELECT im_grant_permission(
(select plugin_id from im_component_plugins where plugin_name = 'Filestorage Financial Document'),
(select group_id from groups where name = 'Employees'),
(select group_id from groups where group_name = 'Employees'),
'read'
);
SELECT im_component_plugin__new (
null, -- plugin_id
'im_component_plugin', -- object_type
now(), -- creation_date
null, -- creation_user
null, -- creation_ip
null, -- context_id
'Financial Cross-Tracking', -- plugin_name
'intranet-invoices', -- package_name
'bottom', -- location
'/intranet/projects/view', -- page_url
null, -- view_name
100, -- sort_order
'im_invoice_cross_tracking_component $project_id' -- component_tcl
);
SELECT im_grant_permission(
(select plugin_id from im_component_plugins where plugin_name = 'Financial Cross-Tracking'),
(select group_id from groups where group_name = 'Accounting'),
'read'
);
SELECT im_grant_permission(
(select plugin_id from im_component_plugins where plugin_name = 'Financial Cross-Tracking'),
(select group_id from groups where group_name = 'Senior Managers'),
'read'
);
SELECT im_component_plugin__new (
null, -- plugin_id
'im_component_plugin', -- object_type
now(), -- creation_date
null, -- creation_user
null, -- creation_ip
null, -- context_id
'Financial Document Comparison', -- plugin_name
'intranet-invoices', -- package_name
'bottom', -- location
'/intranet/projects/view', -- page_url
null, -- view_name
100, -- sort_order
'im_invoices_finance_document_comparison_component $project_id' -- component_tcl
);
SELECT im_grant_permission(
(select plugin_id from im_component_plugins where plugin_name = 'Financial Document Comparison'),
(select group_id from groups where group_name = 'Accounting'),
'read'
);
SELECT im_grant_permission(
(select plugin_id from im_component_plugins where plugin_name = 'Financial Document Comparison'),
(select group_id from groups where group_name = 'Senior Managers'),
'read'
);
......
......@@ -392,6 +392,48 @@ ad_proc im_invoices_default_company_template {
# Components
# ---------------------------------------------------------------
ad_proc -public im_invoices_finance_document_comparison_component {
project_id
} {
Returns a HTML table with a comparison of the volume of FinDocs
per type and outline_number.
} {
set params [list \
[list project_id $project_id] \
]
set result [ad_parse_template -params $params "/packages/intranet-invoices/lib/finance-document-comparison"]
return [string trim $result]
}
ad_proc im_invoices_project_cross_tracking_component { project_id } {
Track the financial performance of projects based on outline numbers.
} {
set outline_number_enabled_p [im_column_exists im_invoice_items item_outline_number]
if {!$outline_number_enabled_p} { return "" }
# Get the list of all invoice outline numbers across the project
set outline_numbers [db_list outline_numbers "
select distinct item_outline_number
from im_invoice_items ii,
im_invoices i,
im_costs c,
im_projects main_p,
im_projects sub_p
where c.cost_id = i.invoice_id and
c.cost_id = ii.invoice_id and
c.project_id = sub_p.project_id and
sub_p.tree_sortkey between main_p.tree_sortkey and tree_right(main_p.tree_sortkey) and
main_p.project_id = :project_id
order by item_outline_number
"]
return ""
}
ad_proc im_invoices_object_list_component { user_id invoice_id read write return_url } {
Returns a HTML table containing a list of objects
associated with a particular financial document.
......
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