Index: openacs-4/packages/invoices/www/invoice-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-ae.tcl,v diff -u -r1.27 -r1.28 --- openacs-4/packages/invoices/www/invoice-ae.tcl 15 Mar 2006 17:05:06 -0000 1.27 +++ openacs-4/packages/invoices/www/invoice-ae.tcl 2 Apr 2006 22:08:02 -0000 1.28 @@ -68,6 +68,7 @@ } } +set current_url "[ad_conn url]?[ad_conn query]" set package_id [ad_conn package_id] set user_id [auth::require_login] set date_format "YYYY-MM-DD" @@ -148,13 +149,46 @@ set contact_options $recipient_options } else { # normal invoice: get recipients from projects - # We only want to offer invoice recipients that have actually been assigned in the project - # The other query would show all of them. - set contact_options [db_list_of_lists contacts {}] + # We want to mark invoice recipients that have actually been assigned in the project + set project_contacts [db_list contacts {}] + set contact_id [lindex $project_contacts 0] + set contact_options {} + + # add all invoice-recipients of customer to recipient list + # mark project recipients as bold + set project_recipients [db_list recipients {}] + set recipient_id [lindex $project_recipients 0] + set recipients [db_list invoice_recipients {}] set recipient_options {} - db_foreach recipients {} { - lappend recipient_options [list [contact::name -party_id $rec_id -reverse_order] $rec_id] + + foreach recipient $recipients { + set recipient_name [contact::name -party_id $recipient -reverse_order] + if {[lsearch -exact $project_recipients $recipient] == -1 || $mode == "display"} { + lappend recipient_options [list $recipient_name $recipient] + } else { + lappend recipient_options [list "* $recipient_name *" $recipient] + } } + + # add all employees of customer to recipient-list + foreach employee_id [contact::util::get_employees -organization_id $organization_id] { + if {[lsearch -exact $recipients $employee_id] == -1} { + set employee_name [contact::name -party_id $employee_id -reverse_order] + if {[lsearch -exact $project_recipients $employee_id] == -1 || $mode == "display"} { + lappend recipient_options [list $employee_name $employee_id] + } else { + lappend recipient_options [list "* $employee_name *" $employee_id] + } + } + + if {[lsearch -exact $project_contacts $employee_id] == -1 || $mode == "display"} { + lappend contact_options [list $employee_name $employee_id] + } else { + lappend contact_options [list "* $employee_name *" $employee_id] + } + } + + set contact_options [lsort -dictionary $contact_options] set recipient_options [lsort -dictionary $recipient_options] } @@ -170,7 +204,7 @@ {contact_id:integer(select),optional {label "[_ invoices.iv_invoice_contact]"} {options $contact_options} {help_text "[_ invoices.iv_invoice_contact_help]"}} {recipient_id:integer(select),optional {label "[_ invoices.iv_invoice_recipient]"} {options $recipient_options} {help_text "[_ invoices.iv_invoice_recipient_help]"}} {title:text(inform) {label "[_ invoices.iv_invoice_Title]"} {html {size 80 maxlength 1000}} {help_text "[_ invoices.iv_invoice_Title_help]"}} - {description:text(textarea),optional {label "[_ invoices.iv_invoice_Description]"} {html {rows 5 cols 80}} {help_text "[_ invoices.iv_invoice_Description_help]"}} + {description:text(inform),optional {label "[_ invoices.iv_invoice_Description]"} {html {rows 5 cols 80}} {help_text "[_ invoices.iv_invoice_Description_help]"}} } if {![empty_string_p [category_tree::get_mapped_trees $container_objects(invoice_id)]]} { @@ -238,7 +272,7 @@ } ad_form -extend -name iv_invoice_form -form { - {payment_days:integer,optional {label "[_ invoices.iv_invoice_payment_days]"} {html {size 5 maxlength 5}} {help_text "[_ invoices.iv_invoice_payment_days_help]"}} + {payment_days:integer(inform),optional {label "[_ invoices.iv_invoice_payment_days]"} {html {size 5 maxlength 5}} {help_text "[_ invoices.iv_invoice_payment_days_help]"}} } if {!$has_submit} { @@ -261,8 +295,30 @@ if {!$_invoice_id} { # adding a new invoice if {![empty_string_p $project_id]} { - + + # get all subprojects marked for no invoice to display warning + foreach main_project_id $project_id { + set subprojects [wieners::process::subprojects -project_id $main_project_id] + + db_foreach not_invoiceable_subprojects {} { + set offer_url [export_vars -base offer-ae {offer_id {mode display}}] + lappend no_invoice($main_project_id) "$offer_title" + } + } + + set project_title 0 db_foreach offer_items {} -column_array offer { + + # check if project changed in loop over offer-items + # show warning of subprojects without invoice if necessary + if {$project_title != $offer(project_title) && $project_title != "0" && [exists_and_not_null no_invoice($old_project_id)]} { + ad_form -extend -name iv_invoice_form -form \ + [list [list "no_invoice.${old_project_id}:text(inform),optional" \ + [list label "\#invoices.iv_invoice_no_invoice\#"] \ + [list value "