Index: openacs-4/packages/invoices-portlet/lib/invoice-list.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices-portlet/lib/invoice-list.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/invoices-portlet/lib/invoice-list.adp 31 Aug 2005 17:05:21 -0000 1.1 @@ -0,0 +1 @@ + Index: openacs-4/packages/invoices-portlet/lib/invoice-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices-portlet/lib/invoice-list.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/invoices-portlet/lib/invoice-list.tcl 31 Aug 2005 17:05:21 -0000 1.1 @@ -0,0 +1,119 @@ +if {![info exists format]} { + set format "normal" +} +if {![info exists orderby]} { + set orderby "" +} +if {![info exists page_size]} { + set page_size "25" +} + +if {![info exists package_id]} { + set package_id [ad_conn package_id] +} + +if {![info exists base_url]} { + set base_url [apm_package_url_from_id $package_id] +} + + +foreach optional_param {organization_id row_list} { + if {![info exists $optional_param]} { + set $optional_param {} + } +} + +set dotlrn_club_id [lindex [application_data_link::get_linked -from_object_id $organization_id -to_object_type "dotlrn_club"] 0] +set pm_base_url [apm_package_url_from_id [dotlrn_community::get_package_id_from_package_key -package_key "project-manager" -community_id $dotlrn_club_id]] + + +#set package_id [ad_conn package_id] +set community_id [dotlrn_community::get_community_id] +set date_format [lc_get formbuilder_date_format] +set timestamp_format "$date_format [lc_get formbuilder_time_format]" + + +if { ![empty_string_p $community_id] } { + + set base_url [apm_package_key_from_id \ + [dotlrn_community::get_package_id_from_package_key \ + -package_key "invoices" \ + -community_id $community_id]] +} else { + set base_url "/invoices" +} + +set actions [list "[_ invoices.iv_invoice_New]" [export_vars -base ${base_url}/invoice-add {organization_id}] "[_ invoices.iv_invoice_New2]" "[_ invoices.iv_invoice_credit_New]" [export_vars -base ${base_url}/invoice-credit {organization_id}] "[_ invoices.iv_invoice_credit_New2]" "[_ invoices.iv_offer_2]" [export_vars -base ${base_url}/offer-list {organization_id}] "[_ invoices.iv_offer_2]" "[_ invoices.projects]" $pm_base_url "[_ invoices.projects]"] + +template::list::create \ + -name iv_invoice \ + -key invoice_id \ + -no_data "[_ invoices.None]" \ + -selected_format $format \ + -elements { + invoice_nr { + label {[_ invoices.iv_invoice_invoice_nr]} + } + title { + label {[_ invoices.iv_invoice_1]} + link_url_eval {[export_vars -base "invoice-ae" {invoice_id {mode display}}]} + } + description { + label {[_ invoices.iv_invoice_Description]} + } + total_amount { + label {[_ invoices.iv_invoice_total_amount]} + display_template {@iv_invoice.total_amount@ @iv_invoice.currency@} + } + paid_amount { + label {[_ invoices.iv_invoice_paid_amount]} + display_template {@iv_invoice.paid_amount@ @iv_invoice.paid_currency@} + } + creation_user { + label {[_ invoices.iv_invoice_creation_user]} + display_template {@iv_invoice.first_names@ @iv_invoice.last_name@} + } + creation_date { + label {[_ invoices.iv_invoice_creation_date]} + } + due_date { + label {[_ invoices.iv_invoice_due_date]} + } + action { + display_template {#invoices.Edit# #invoices.Cancel# #invoices.Delete#} + } + } -actions $actions -sub_class narrow \ + -page_size_variable_p 1 \ + -page_size $page_size \ + -page_flush_p 0 \ + -page_query_name iv_invoice_paginated \ + -filters {organization_id {}} \ + -formats { + normal { + label "[_ invoices.Table]" + layout table + row $row_list + } + csv { + label "[_ invoices.CSV]" + output csv + page_size 0 + row $row_list + } + } + + +db_multirow -extend {creator_link edit_link cancel_link delete_link} iv_invoice iv_invoice {} { + # Ugly hack. We should find out which contact package is linked + set creator_link "/contacts/$creation_user" + set edit_link [export_vars -base "${base_url}invoice-ae" {invoice_id}] + set cancel_link [export_vars -base "${base_url}invoice-cancellation" {organization_id {parent_id $invoice_rev_id}}] + set delete_link [export_vars -base "${base_url}invoice-delete" {invoice_id}] + if {[empty_string_p $total_amount]} { + set total_amount 0 + } + set total_amount [format "%.2f" $total_amount] + if {![empty_string_p $paid_amount]} { + set paid_amount [format "%.2f" $paid_amount] + } +} Index: openacs-4/packages/invoices-portlet/lib/invoice-list.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices-portlet/lib/invoice-list.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/invoices-portlet/lib/invoice-list.xql 31 Aug 2005 17:05:21 -0000 1.1 @@ -0,0 +1,46 @@ + + + + + + + select cr.item_id as invoice_id, cr.title, cr.description, + t.invoice_nr, t.total_amount, t.currency, t.paid_amount, + t.paid_currency, p.first_names, p.last_name, o.creation_user, + to_char(o.creation_date, :timestamp_format) as creation_date, + to_char(t.due_date, :date_format) as due_date, t.parent_invoice_id, + t.invoice_id as invoice_rev_id, t.cancelled_p + from cr_folders cf, cr_items ci, cr_revisions cr, iv_invoices t, + acs_objects o, persons p + where cr.revision_id = ci.latest_revision + and t.invoice_id = cr.revision_id + and t.organization_id = :organization_id + and ci.parent_id = cf.folder_id + and cf.package_id = :package_id + and o.object_id = t.invoice_id + and p.person_id = o.creation_user + [template::list::filter_where_clauses -and -name iv_invoice] + + + + + + + + select cr.item_id as invoice_id + from cr_folders cf, cr_items ci, cr_revisions cr, iv_invoices t, + acs_objects o, persons p + where cr.revision_id = ci.latest_revision + and t.invoice_id = cr.revision_id + and t.organization_id = :organization_id + and ci.parent_id = cf.folder_id + and cf.package_id = :package_id + and o.object_id = t.invoice_id + and p.person_id = o.creation_user + [template::list::filter_where_clauses -and -name iv_invoice] + + + + + + Index: openacs-4/packages/invoices-portlet/lib/offer-list.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices-portlet/lib/offer-list.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/invoices-portlet/lib/offer-list.adp 31 Aug 2005 17:05:21 -0000 1.1 @@ -0,0 +1 @@ + Index: openacs-4/packages/invoices-portlet/lib/offer-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices-portlet/lib/offer-list.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/invoices-portlet/lib/offer-list.tcl 31 Aug 2005 17:05:21 -0000 1.1 @@ -0,0 +1,133 @@ +set required_param_list [list] +set optional_param_list [list orderby elements base_url package_id organization_id] +set optional_unset_list [list] + +foreach required_param $required_param_list { + if {![info exists $required_param]} { + return -code error "$required_param is a required parameter." + } +} + +foreach optional_param $optional_param_list { + if {![info exists $optional_param]} { + set $optional_param {} + } +} + +foreach optional_unset $optional_unset_list { + if {[info exists $optional_unset]} { + if {[empty_string_p [set $optional_unset]]} { + unset $optional_unset + } + } +} + +if {![info exists format]} { + set format "normal" +} +if {![info exists page_size]} { + set page_size "25" +} + +if {[empty_string_p $package_id]} { + set package_id [apm_package_id_from_key "invoices"] +} + +if {[empty_string_p $base_url]} { + set base_url [apm_package_url_from_id $package_id] +} + +foreach element $elements { + append row_list "$element {}\n" +} + +set dotlrn_club_id [lindex [application_data_link::get_linked -from_object_id $organization_id -to_object_type "dotlrn_club"] 0] + +if {$dotlrn_club_id > 0} { + set pm_base_url [apm_package_url_from_id [dotlrn_community::get_package_id_from_package_key -package_key "project-manager" -community_id $dotlrn_club_id]] +} + +#set package_id [ad_conn package_id] +set date_format [lc_get formbuilder_date_format] +set timestamp_format "$date_format [lc_get formbuilder_time_format]" + +if {[exists_and_not_null organization_id]} { + set price_list_id [iv::price_list::get_list_id -organization_id $organization_id] + set actions [list "[_ invoices.iv_offer_New]" [export_vars -base "${base_url}offer-ae" {organization_id}] "[_ invoices.iv_offer_New2]" "[_ invoices.iv_invoice_2]" [export_vars -base "${base_url}invoice-list" {organization_id}] "[_ invoices.iv_invoice_2]" "[_ invoices.iv_price_list]" [export_vars -base "${base_url}price_list" {{list_id $price_list_id}}] "[_ invoices.iv_display_price_list]"] + if {[exists_and_not_null pm_base_url]} { + lappend actions "[_ project-manager.Projects]" $pm_base_url "[_ project-manager.Projects]" + } +} else { + set actions "" +} + +template::list::create \ + -name iv_offer \ + -key offer_id \ + -no_data "[_ invoices.None]" \ + -selected_format $format \ + -elements { + offer_nr { + label {[_ invoices.iv_offer_offer_nr]} + } + title { + label {[_ invoices.iv_offer_1]} + display_template {@iv_offer.title@} + } + description { + label {[_ invoices.iv_offer_Description]} + } + amount_total { + label {[_ invoices.iv_offer_amount_total]} + display_template {@iv_offer.amount_total@ @iv_offer.currency@} + } + creation_user { + label {[_ invoices.iv_offer_creation_user]} + display_template {@iv_offer.first_names@ @iv_offer.last_name@} + } + creation_date { + label {[_ invoices.iv_offer_creation_date]} + } + finish_date { + label {[_ invoices.iv_offer_finish_date]} + } + accepted_date { + label {[_ invoices.iv_offer_accepted_date]} + } + action { + display_template {#invoices.Edit# #invoices.Delete#} + } + } -actions $actions -sub_class narrow \ + -page_size_variable_p 1 \ + -page_size $page_size \ + -page_flush_p 0 \ + -page_query_name iv_offer_paginated \ + -filters { + organization_id { + where_clause {t.organization_id = :organization_id} + } + } \ + -formats { + normal { + label "[_ invoices.Table]" + layout table + row $row_list + } + csv { + label "[_ invoices.CSV]" + output csv + page_size 0 + row $row_list + } + } + + +db_multirow -extend {creator_link edit_link delete_link title_link} iv_offer iv_offer {} { + + # Ugly hack. We should find out which contact package is linked + # aso. asf. + set creator_link "/contacts/$creation_user" + set edit_link [export_vars -base "${base_url}offer-ae" {offer_id}] + set title_link [export_vars -base "${base_url}offer-ae" {offer_id {mode display}}] + set delete_link [export_vars -base "${base_url}offer-delete" {offer_id}] +} Index: openacs-4/packages/invoices-portlet/lib/offer-list.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices-portlet/lib/offer-list.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/invoices-portlet/lib/offer-list.xql 31 Aug 2005 17:05:21 -0000 1.1 @@ -0,0 +1,44 @@ + + + + + + + select cr.item_id as offer_id, cr.title, cr.description, + t.offer_nr, t.amount_total, t.amount_sum, t.currency, + p.first_names, p.last_name, o.creation_user, + to_char(o.creation_date, :timestamp_format) as creation_date, + to_char(t.accepted_date, :timestamp_format) as accepted_date, + to_char(t.finish_date, :timestamp_format) as finish_date + from cr_folders cf, cr_items ci, cr_revisions cr, iv_offers t, + acs_objects o, persons p + where cr.revision_id = ci.latest_revision + and t.offer_id = cr.revision_id + and ci.parent_id = cf.folder_id + and cf.package_id = :package_id + and o.object_id = t.offer_id + and p.person_id = o.creation_user + [template::list::filter_where_clauses -and -name iv_offer] + + + + + + + + select cr.item_id as offer_id + from cr_folders cf, cr_items ci, cr_revisions cr, iv_offers t, + acs_objects o, persons p + where cr.revision_id = ci.latest_revision + and t.offer_id = cr.revision_id + and ci.parent_id = cf.folder_id + and cf.package_id = :package_id + and o.object_id = t.offer_id + and p.person_id = o.creation_user + [template::list::filter_where_clauses -and -name iv_offer] + + + + + + Index: openacs-4/packages/invoices-portlet/lib/projects-billable.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices-portlet/lib/projects-billable.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/invoices-portlet/lib/projects-billable.adp 31 Aug 2005 17:05:21 -0000 1.1 @@ -0,0 +1 @@ + Index: openacs-4/packages/invoices-portlet/lib/projects-billable.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices-portlet/lib/projects-billable.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/invoices-portlet/lib/projects-billable.tcl 31 Aug 2005 17:05:21 -0000 1.1 @@ -0,0 +1,119 @@ +set required_param_list [list organization_id] +set optional_param_list [list orderby elements base_url package_id] +set optional_unset_list [list] + +foreach required_param $required_param_list { + if {![info exists $required_param]} { + return -code error "$required_param is a required parameter." + } +} + +foreach optional_param $optional_param_list { + if {![info exists $optional_param]} { + set $optional_param {} + } +} + +foreach optional_unset $optional_unset_list { + if {[info exists $optional_unset]} { + if {[empty_string_p [set $optional_unset]]} { + unset $optional_unset + } + } +} + +foreach element $elements { + append row_list "$element {}\n" +} + +if {![info exists format]} { + set format "normal" +} +if {![info exists orderby]} { + set orderby "" +} +if {![info exists page_size]} { + set page_size "25" +} + +if {[empty_string_p $package_id]} { + set package_id [apm_package_id_from_key invoices] +} + +if {[empty_string_p $base_url]} { + set base_url [apm_package_url_from_id $package_id] +} + +set dotlrn_club_id [lindex [application_data_link::get_linked -from_object_id $organization_id -to_object_type "dotlrn_club"] 0] +set pm_base_url [apm_package_url_from_id [dotlrn_community::get_package_id_from_package_key -package_key "project-manager" -community_id $dotlrn_club_id]] + +set p_closed_id [pm::project::default_status_closed] +set t_closed_id [pm::task::default_status_closed] +set date_format [lc_get formbuilder_date_format] +set timestamp_format "$date_format [lc_get formbuilder_time_format]" +set currency [iv::price_list::get_currency -organization_id $organization_id] +set contacts_url [apm_package_url_from_key contacts] + +set actions [list "[_ invoices.iv_invoice_New]" "${base_url}invoice-ae" "[_ invoices.iv_invoice_New2]" ] + +template::list::create \ + -name projects \ + -key project_id \ + -no_data "[_ invoices.None]" \ + -selected_format $format \ + -pass_properties {currency} \ + -elements { + project_id { + label {[_ invoices.iv_invoice_project_id]} + } + name { + label {[_ invoices.Customer]} + display_template {@projects.name@} + } + title { + label {[_ invoices.iv_invoice_project_title]} + display_template {@projects.title@} + } + description { + label {[_ invoices.iv_invoice_project_descr]} + } + amount_open { + label {[_ invoices.iv_invoice_amount_open]} + display_template {@projects.amount_open@ @currency@} + } + count_total { + label {[_ invoices.iv_invoice_count_total]} + } + count_billed { + label {[_ invoices.iv_invoice_count_billed]} + } + creation_date { + label {[_ invoices.iv_invoice_closed_date]} + } + } -bulk_actions $actions \ + -bulk_action_export_vars {organization_id} \ + -sub_class narrow \ + -filters { + organization_id { + where_clause {sub.customer_id = :organization_id} + } + } \ + -formats { + normal { + label "[_ invoices.Table]" + layout table + row $row_list + } + csv { + label "[_ invoices.CSV]" + output csv + page_size 0 + row $row_list + } + } + + +db_multirow -extend {project_link} projects projects_to_bill {} { + set project_link [export_vars -base "${pm_base_url}one" {{project_item_id $project_id}}] + set amount_open [format "%.2f" $amount_open] +} Index: openacs-4/packages/invoices-portlet/lib/projects-billable.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices-portlet/lib/projects-billable.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/invoices-portlet/lib/projects-billable.xql 31 Aug 2005 17:05:21 -0000 1.1 @@ -0,0 +1,57 @@ + + + + + + + select r.item_id as project_id, r.title, r.description, sub.amount_open, + to_char(sub.creation_date, :timestamp_format) as creation_date, total.count_total, billed.count_billed, name + from ( + select oi.item_id as offer_id, pr.revision_id, o.creation_date, + sum(ofi.item_units * ofi.price_per_unit * (1-(ofi.rebate/100))) as amount_open, + p.customer_id , (oz.name ) as name + from cr_items pi, cr_revisions pr, pm_projects p, + acs_objects o, acs_rels r, iv_offer_items ofi, + acs_objects oo, cr_items oi , organizations oz + where pi.latest_revision = pr.revision_id + and p.project_id = pr.revision_id + and o.object_id = p.project_id + and r.object_id_one = pi.item_id + and r.object_id_two = oi.item_id + and r.rel_type = 'application_data_link' + and p.status_id = :p_closed_id + and ofi.offer_id = oi.latest_revision + and oo.object_id = oi.item_id + and oo.package_id = :package_id + and p.customer_id = oz.organization_id + and not exists (select 1 + from iv_invoice_items ii, iv_invoices i + where ii.offer_item_id = ofi.offer_item_id + and i.invoice_id = ii.invoice_id + and i.cancelled_p = 'f') + group by oi.item_id, pr.revision_id, o.creation_date, p.customer_id, oz.name + ) sub, ( + select count(*) as count_total, oi.item_id + from cr_items oi, iv_offer_items ofi + where ofi.offer_id = oi.latest_revision + group by oi.item_id + ) total, ( + select count(i.invoice_id) as count_billed, oi.item_id + from cr_items oi, iv_offer_items ofi + left outer join iv_invoice_items ii + on (ii.offer_item_id = ofi.offer_item_id) + left outer join iv_invoices i + on (ii.invoice_id = i.invoice_id + and i.cancelled_p = 'f') + where ofi.offer_id = oi.latest_revision + group by oi.item_id + ) billed, cr_revisions r + where r.revision_id = sub.revision_id + and total.item_id = sub.offer_id + and billed.item_id = sub.offer_id + [template::list::filter_where_clauses -and -name projects] + + + + + Index: openacs-4/packages/invoices-portlet/www/invoices-list-portlet.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices-portlet/www/invoices-list-portlet.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/invoices-portlet/www/invoices-list-portlet.adp 16 Aug 2005 20:14:55 -0000 1.1 +++ openacs-4/packages/invoices-portlet/www/invoices-list-portlet.adp 31 Aug 2005 17:05:21 -0000 1.2 @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file Index: openacs-4/packages/invoices-portlet/www/invoices-offers-portlet.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices-portlet/www/invoices-offers-portlet.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/invoices-portlet/www/invoices-offers-portlet.adp 16 Aug 2005 20:14:55 -0000 1.1 +++ openacs-4/packages/invoices-portlet/www/invoices-offers-portlet.adp 31 Aug 2005 17:05:21 -0000 1.2 @@ -1,2 +1 @@ - - \ No newline at end of file + \ No newline at end of file Index: openacs-4/packages/invoices-portlet/www/invoices-portlet.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices-portlet/www/invoices-portlet.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/invoices-portlet/www/invoices-portlet.adp 16 Aug 2005 20:14:55 -0000 1.1 +++ openacs-4/packages/invoices-portlet/www/invoices-portlet.adp 31 Aug 2005 17:05:21 -0000 1.2 @@ -1,2 +1,2 @@ - +