Index: openacs-4/packages/invoices/www/offer-pdf.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/offer-pdf.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/invoices/www/offer-pdf.tcl 19 Dec 2005 20:10:04 -0000 1.1 @@ -0,0 +1,40 @@ +ad_page_contract { + add offer-pdf to offer / accepted offer folder + + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2005-10-05 +} { + offer_id:integer + file_id:integer +} + +set user_id [auth::require_login] +db_1row offer_data {} + +set project_id [lindex [application_data_link::get_linked -from_object_id $offer_id -to_object_type content_item] 0] +if {![empty_string_p $project_id]} { + acs_object::get -object_id $project_id -array project + set pm_url [lindex [site_node::get_url_from_object_id -object_id $project(package_id)] 0] + set return_url [export_vars -base "${pm_url}one" {{project_item_id $project_id}}] +} else { + set return_url [export_vars -base offer-list {organization_id}] +} + +set root_folder_id [lindex [application_data_link::get_linked -from_object_id $organization_id -to_object_type content_folder] 0] + +if {$status == "new"} { + # this is an unaccepted offer + set offer_folder_id [fs::get_folder -name "offers_${root_folder_id}" -parent_id $root_folder_id] +} else { + # this is an accapted offer + set offer_folder_id [fs::get_folder -name "accepted_${root_folder_id}" -parent_id $root_folder_id] +} + +db_transaction { + # move file to offer /accepted offer folder + set file_item_id [content::revision::item_id -revision_id $file_id] + content::item::move -item_id $file_item_id -target_folder_id $offer_folder_id + application_data_link::new -this_object_id $offer_id -target_object_id $file_id +} + +ad_returnredirect $return_url Index: openacs-4/packages/invoices/www/offer-pdf.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/offer-pdf.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/invoices/www/offer-pdf.xql 19 Dec 2005 20:10:04 -0000 1.1 @@ -0,0 +1,15 @@ + + + + + + + select o.organization_id, o.status + from iv_offers o, cr_items oi + where oi.latest_revision = o.offer_id + and oi.item_id = :offer_id + + + + + Index: openacs-4/packages/invoices/www/offer-send.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/offer-send.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/invoices/www/offer-send.tcl 24 Oct 2005 13:49:59 -0000 1.10 +++ openacs-4/packages/invoices/www/offer-send.tcl 19 Dec 2005 20:10:04 -0000 1.11 @@ -30,19 +30,22 @@ # set offer_text "{[_ invoices.iv_offer_email]}" set subject [lang::util::localize "#invoices.iv_offer_email_subject#" $locale] set template "OfferTemplate" + set file_title [lang::util::localize "#invoices.file_offer#_${offer_nr}.pdf" $locale] } else { # send accepted offer # set offer_text "{[_ invoices.iv_offer_accepted_email]}" set subject [lang::util::localize "#invoices.iv_offer_accepted_email_subject#" $locale] set template "OfferAcceptedTemplate" + set file_title [lang::util::localize "#invoices.file_offer_accepted#_${offer_nr}.pdf" $locale] } set offer_text [iv::offer::parse_data -offer_id $offer_id -recipient_id $contact_id -template $template -locale $locale -accept_link $accept_link] set pdf_file [text_templates::create_pdf_from_html -html_content "$offer_text"] if {![empty_string_p $pdf_file]} { set file_size [file size $pdf_file] - set file_ids [cr_import_content -title "Offer_${offer_id}.pdf" -description "PDF version of this offer" $offer_id $pdf_file $file_size application/pdf "[clock seconds]-[expr round([ns_rand]*100000)]"] + set file_ids [cr_import_content -title $file_title -description "PDF version of this offer" $offer_id $pdf_file $file_size application/pdf "[clock seconds]-[expr round([ns_rand]*100000)]"] + set return_url [export_vars -base offer-pdf {offer_id {file_id $file_ids}}] } else { set file_ids "" } @@ -77,7 +80,7 @@ # Create a task for the saved offer set task_id [tasks::task::new \ -title "Nachfassen Angebot" \ - -description "Angebot Nr. $offer_id" \ + -description "Angebot Nr. $offer_nr" \ -mime_type "text/plain" \ -party_id $contact_id \ -due_date ${due_date} \