Index: openacs-4/packages/contacts/tcl/contact-message-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-message-procs.tcl,v diff -u -r1.13 -r1.14 --- openacs-4/packages/contacts/tcl/contact-message-procs.tcl 27 Dec 2005 16:37:24 -0000 1.13 +++ openacs-4/packages/contacts/tcl/contact-message-procs.tcl 27 Dec 2005 20:19:02 -0000 1.14 @@ -282,36 +282,105 @@ @param parent_id Needed to set the parent of this object @return revision_id of the revision that contains the file } { - # This exec command is missing all the good things about openacs # Add the parameter to whatever package you put this procedure in. - set oowriter_bin [parameter::get -parameter "OOWriterBin" -default "/usr/local/bin/oowriter2"] - exec $oowriter_bin -invisible -pt $printer_name $oo_file + set oowriter_bin [parameter::get -parameter "OOWriterBin" -default "/opt/openoffice.org2.0/program/swriter"] + + set status [catch {exec -- /bin/sh [acs_package_root_dir contacts]/bin/convert.sh $oo_file } result] + + if { $status == 0 } { + + # The command succeeded, and wrote nothing to stderr. + # $result contains what it wrote to stdout, unless you + # redirected it + + } elseif { [string equal $::errorCode NONE] } { + + # The command exited with a normal status, but wrote something + # to stderr, which is included in $result. + + } else { + + switch -exact -- [lindex $::errorCode 0] { + + CHILDKILLED { + foreach { - pid sigName msg } $::errorCode break + + # A child process, whose process ID was $pid, + # died on a signal named $sigName. A human- + # readable message appears in $msg. + + } + + CHILDSTATUS { + + foreach { - pid code } $::errorCode break + + # A child process, whose process ID was $pid, + # exited with a non-zero exit status, $code. + + } + + CHILDSUSP { + + foreach { - pid sigName msg } $::errorCode break + + # A child process, whose process ID was $pid, + # has been suspended because of a signal named + # $sigName. A human-readable description of the + # signal appears in $msg. + + } + + POSIX { + + foreach { - errName msg } $::errorCode break + + # One of the kernel calls to launch the command + # failed. The error code is in $errName, and a + # human-readable message is in $msg. + + } + + } + } # Strip the extension. set pdf_filename "[file rootname $oo_file].pdf" + if {![file exists $pdf_filename]} { + set pdf_filename $oo_file + } set pdf_filesize [file size $pdf_filename] set mime_type "application/pdf" if {[exists_and_not_null $item_id]} { set parent_id [get_parent -item_id $item_id] - } - - # cr_import_content checks the item_id switch. If present, it creates a new revision of the item, else it creates a new item and assigns it the name specified in the object_name parameter (last parameter). - set revision_id [cr_import_content \ - -item_id $item_id \ - $parent_id \ - $pdf_filename \ - $pdf_filesize \ - $mime_type \ - $pdf_filename ] + + set revision_id [cr_import_content \ + -title $title \ + -item_id $item_id \ + $parent_id \ + $pdf_filename \ + $pdf_filesize \ + $mime_type \ + $pdf_filename ] + } else { + set revision_id [cr_import_content \ + -title $title \ + $parent_id \ + $pdf_filename \ + $pdf_filesize \ + $mime_type \ + $pdf_filename ] + } + content::item::set_live_revision -revision_id $revision_id - return revision_id + return [content::revision::item_id -revision_id $revision_id] } ad_proc -public contact::oo::change_content { -path:required -document_filename:required - -contents:requried + -contents:required } { Takes the provided contents and places them in the content.xml file of the sxw file, effectivly changing the content of the file. @@ -341,8 +410,19 @@ # The zip command should replace the content.xml in the zipfile which # happens to be the OpenOffice File. foreach filename [array names content_array] { - exec zip "${dir}/$document_filename" "${dir}/$filename" + exec zip -j "${dir}/$document_filename" "${dir}/$filename" } - return "${dir}/$document_filename" + # copy odt file + set new_file "[ns_tmpnam].odt" + ns_cp "${dir}/$document_filename" $new_file + + # delete other tmpfiles + ns_unlink "${dir}/$document_filename" + foreach filename [array names content_array] { + ns_unlink "${dir}/$filename" + } + ns_rmdir $dir + + return $new_file } Index: openacs-4/packages/invoices/tcl/invoice-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/tcl/invoice-procs.tcl,v diff -u -r1.11 -r1.12 --- openacs-4/packages/invoices/tcl/invoice-procs.tcl 27 Dec 2005 18:26:10 -0000 1.11 +++ openacs-4/packages/invoices/tcl/invoice-procs.tcl 27 Dec 2005 20:17:40 -0000 1.12 @@ -190,8 +190,8 @@ # Get the invoice data db_1row get_data {} -column_array data - set locale [lang::user::site_wide_locale -user_id $recipient_id] - set contact_locale [lang::user::site_wide_locale -user_id $contact_id] + set locale [lang::user::site_wide_locale -user_id $data(recipient_id)] + set contact_locale [lang::user::site_wide_locale -user_id $data(contact_id)] set rec_locale $locale set data(creator_name) "$data(first_names) $data(last_name)" set data(amount_diff) [format "%.2f" [expr $data(total_amount) - $data(amount_sum)]] @@ -207,7 +207,7 @@ set data(creation_date) [lc_time_fmt $data(creation_date) $time_format] set data(due_date) [lc_time_fmt $data(due_date) $time_format] - set name [contact::name -party_id $recipient_id] + set name [contact::name -party_id $data(recipient_id)] set data(rep_first_names) [lindex $name 1] set data(rep_last_name) [string trim [lindex $name 0] ,] set data(recipient_name) "$data(rep_first_names) $data(rep_last_name)" @@ -216,30 +216,30 @@ set rec_orga_revision_id [content::item::get_best_revision -item_id $rec_organization_id] set contact_client_id [ams::value -attribute_name "client_id" -object_id $orga_revision_id -locale $contact_locale] set rec_client_id [ams::value -attribute_name "client_id" -object_id $rec_orga_revision_id -locale $rec_locale] - set rec_revision_id [content::item::get_best_revision -item_id $recipient_id] + set rec_revision_id [content::item::get_best_revision -item_id $data(recipient_id)] # invoice contact data - contact::employee::get -employee_id $contact_id -array contact_data + contact::employee::get -employee_id $data(contact_id) -array contact_data foreach attribute {name company_name_ext address town_line country country_code salutation salutation_letter} { set data(contact_$attribute) [value_if_exists contact_data($attribute)] } # invoice recipient data - if {[contact::organization_p -party_id $recipient_id]} { + if {[contact::organization_p -party_id $data(recipient_id)]} { # recipient is organization - set data(rec_name) [ams::value -object_id $recipient_id -attribute_name name] - set data(rec_company_name_ext) [ams::value -object_id $recipient_id -attribute_name company_name_ext] - set data(rec_salutation) [contact::salutation -party_id $recipient_id -type salutation] + set data(rec_name) [ams::value -object_id $data(recipient_id) -attribute_name name] + set data(rec_company_name_ext) [ams::value -object_id $data(recipient_id) -attribute_name company_name_ext] + set data(rec_salutation) [contact::salutation -party_id $data(recipient_id) -type salutation] set data(rec_salutation_letter) "" - contacts::postal_address::get -attribute_name "company_address" -party_id $recipient_id -array address_array + contacts::postal_address::get -attribute_name "company_address" -party_id $data(recipient_id) -array address_array set data(rec_address) [value_if_exists address_array(delivery_address)] set data(rec_country_code) [value_if_exists address_array(country_code)] set data(rec_country) [value_if_exists address_array(country)] set data(rec_town_line) [value_if_exists address_array(town_line)] } else { # recipient is person - contact::employee::get -employee_id $recipient_id -array recipient_data + contact::employee::get -employee_id $data(recipient_id) -array recipient_data foreach attribute {name company_name_ext address town_line country country_code salutation salutation_letter} { set data(rec_$attribute) [value_if_exists recipient_data($attribute)] } @@ -296,7 +296,7 @@ eval [template::adp_compile -string $styles] set styles_compiled $__adp_output - lappend final_content [contact::oo::change_content -path $template_path -document_filename "document.odt" -contents [list "content.xml" $content_compiled "styles.xml" $styles_compiled]] + lappend final_content [contact::oo::change_content -path "[acs_root_dir]/$template_path" -document_filename "document.odt" -contents [list "content.xml" $content_compiled "styles.xml" $styles_compiled]] } return $final_content Index: openacs-4/packages/invoices/tcl/invoices-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/tcl/invoices-callback-procs.tcl,v diff -u -r1.11 -r1.12 --- openacs-4/packages/invoices/tcl/invoices-callback-procs.tcl 15 Dec 2005 18:58:43 -0000 1.11 +++ openacs-4/packages/invoices/tcl/invoices-callback-procs.tcl 27 Dec 2005 20:17:40 -0000 1.12 @@ -127,7 +127,6 @@ ad_proc -public -callback iv::offer_accepted { {-offer_id:required} - {-party_id:required} } { } Index: openacs-4/packages/invoices/tcl/offer-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/tcl/offer-procs.tcl,v diff -u -r1.13 -r1.14 --- openacs-4/packages/invoices/tcl/offer-procs.tcl 27 Dec 2005 18:26:10 -0000 1.13 +++ openacs-4/packages/invoices/tcl/offer-procs.tcl 27 Dec 2005 20:17:40 -0000 1.14 @@ -198,37 +198,36 @@ # Get the offer data db_1row get_data {} -column_array data - set locale [lang::user::site_wide_locale -user_id $contact_id] + set locale [lang::user::site_wide_locale -user_id $data(contact_id)] set contact_locale $locale set data(creator_name) "$data(first_names) $data(last_name)" set data(amount_diff) [lc_numeric [format "%.2f" [expr $data(amount_total) - $data(amount_sum)]] "" $locale] set data(final_amount) [lc_numeric [format "%.2f" [expr $data(amount_total)+$data(vat)]] "" $locale] set data(vat_percent) [lc_numeric [format "%.1f" $data(vat_percent)] "" $locale] set data(vat) [lc_numeric [format "%.2f" $data(vat)] "" $locale] set data(amount_sum) [lc_numeric [format "%.2f" $data(amount_sum)] "" $locale] - set data(amount_total) [lc_numeric [format "%.2f" $data(amount_total)] "" $locale] + set data(total_amount) [lc_numeric [format "%.2f" $data(amount_total)] "" $locale] set orga_revision_id [content::item::get_best_revision -item_id $data(organization_id)] - set contact_revision_id [content::item::get_best_revision -item_id $contact_id] + set contact_revision_id [content::item::get_best_revision -item_id $data(contact_id)] set rec_client_id [ams::value -attribute_name "client_id" -object_id $orga_revision_id -locale $locale] # offer contact data - contact::employee::get -employee_id $contact_id -array contact_data + contact::employee::get -employee_id $data(contact_id) -array contact_data foreach attribute {name company_name_ext address town_line country country_code salutation salutation_letter} { set data(contact_$attribute) [value_if_exists contact_data($attribute)] } - set data(document_type) $type + set document_type $type set time_format "[lc_get -locale $locale d_fmt] [lc_get -locale $locale t_fmt]" set data(finish_date) [lc_time_fmt $data(finish_date) $time_format] set data(creation_date) [lc_time_fmt $data(creation_date) $time_format] set data(accepted_date) [lc_time_fmt $data(accepted_date) $time_format] - set data(recipient_id) $recipient_id - set data(name) [contact::name -party_id $recipient_id] + set data(name) [contact::name -party_id $data(contact_id)] set data(rep_first_names) [lindex $data(name) 1] set data(rep_last_name) [string trim [lindex $data(name) 0] ,] set data(recipient_name) "$data(rep_first_names) $data(rep_last_name)" - set rec_organization_id [contact::util::get_employee_organization -employee_id $data(recipient_id)] + set rec_organization_id [contact::util::get_employee_organization -employee_id $data(contact_id)] # data of offer items db_multirow -local -extend {amount_sum amount_total category} items offer_items {} { @@ -258,7 +257,7 @@ eval [template::adp_compile -string $styles] set styles_compiled $__adp_output - lappend final_content [contact::oo::change_content -path $template_path -document_filename "document.odt" -contents [list "content.xml" $content_compiled "styles.xml" $styles_compiled]] + lappend final_content [contact::oo::change_content -path "[acs_root_dir]/$template_path" -document_filename "document.odt" -contents [list "content.xml" $content_compiled "styles.xml" $styles_compiled]] return $final_content } Index: openacs-4/packages/invoices/www/invoice-send.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-send.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/invoices/www/invoice-send.tcl 27 Dec 2005 18:28:16 -0000 1.10 +++ openacs-4/packages/invoices/www/invoice-send.tcl 27 Dec 2005 20:17:41 -0000 1.11 @@ -29,27 +29,24 @@ if {$total_amount > 0} { # send invoice - set invoice_text "{#invoices.iv_invoice_email#}" + set invoice_text "#invoices.iv_invoice_email#" set subject [lang::util::localize "#invoices.iv_invoice_email_subject#" $locale] - set template "InvoiceTemplate" set invoice_title [lang::util::localize "#invoices.file_invoice#_${invoice_nr}.pdf" $locale] if {$invoice_p} { lappend document_types invoice } } elseif {[empty_string_p $parent_invoice_id]} { # send credit - set invoice_text "{#invoices.iv_invoice_credit_email#}" + set invoice_text "#invoices.iv_invoice_credit_email#" set subject [lang::util::localize "#invoices.iv_invoice_credit_email_subject#" $locale] - set template "CreditTemplate" set invoice_title [lang::util::localize "#invoices.file_invoice_credit#_${invoice_nr}.pdf" $locale] if {$invoice_p} { lappend document_types credit } } else { # send cancellation - set invoice_text "{#invoices.iv_invoice_cancel_email#}" + set invoice_text "#invoices.iv_invoice_cancel_email#" set subject [lang::util::localize "#invoices.iv_invoice_cancel_email_subject#" $locale] - set template "CancelTemplate" set invoice_title [lang::util::localize "#invoices.file_invoice_cancel#_${invoice_nr}.pdf" $locale] if {$invoice_p} { lappend document_types cancel Index: openacs-4/packages/invoices/www/offer-accept-2.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/offer-accept-2.adp,v diff -u -r1.5 -r1.6 --- openacs-4/packages/invoices/www/offer-accept-2.adp 26 Oct 2005 12:00:38 -0000 1.5 +++ openacs-4/packages/invoices/www/offer-accept-2.adp 27 Dec 2005 20:17:41 -0000 1.6 @@ -6,6 +6,4 @@ party_ids="@contact_id@" content="@offer_text;noquote@" mime_type="text/html" subject="@subject@" export_vars="offer_id" return_url="@return_url;noquote@" - cancel_url="@cancel_url@" file_ids="@file_ids@" - template_type="offer_accepted" template_object="@offer_id@" - template_locale="@locale@" template_package_id="@contacts_package_id@"> + cancel_url="@cancel_url@" file_ids="@file_ids@"> Index: openacs-4/packages/invoices/www/offer-accept-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/offer-accept-2.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/invoices/www/offer-accept-2.tcl 27 Dec 2005 18:45:40 -0000 1.10 +++ openacs-4/packages/invoices/www/offer-accept-2.tcl 27 Dec 2005 20:17:41 -0000 1.11 @@ -25,7 +25,7 @@ set context [list [list [export_vars -base offer-list {organization_id}] "[_ invoices.iv_offer_2]"] [list [export_vars -base offer-ae {offer_id}] "[_ invoices.iv_offer_View]"] $page_title] -set offer_text "{#invoices.iv_offer_accepted_email#}" +set offer_text "#invoices.iv_offer_accepted_email#" set subject [lang::util::localize "#invoices.iv_offer_accepted_email_subject#" $locale] set file_title [lang::util::localize "#invoices.file_offer_accepted#_${offer_nr}.pdf" $locale] @@ -45,12 +45,8 @@ # content::item::set_live_revision -revision_id $file_ids db_dml set_publish_status {} -} - -if {[llength $file_ids] > 0} { + ns_log notice "\#\#\# $file_ids" set return_url [export_vars -base offer-pdf {offer_id {file_id $file_ids}}] -} else { - set return_url "" } if {[empty_string_p [cc_email_from_party $contact_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.15 -r1.16 --- openacs-4/packages/invoices/www/offer-send.tcl 27 Dec 2005 18:45:40 -0000 1.15 +++ openacs-4/packages/invoices/www/offer-send.tcl 27 Dec 2005 20:17:41 -0000 1.16 @@ -27,14 +27,14 @@ if {[empty_string_p $accepted_date]} { # send pending offer - set offer_text "{#invoices.iv_offer_email#}" + set offer_text "#invoices.iv_offer_email#" set subject [lang::util::localize "#invoices.iv_offer_email_subject#" $locale] set template "OfferTemplate" set document_type "offer" 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 offer_text "#invoices.iv_offer_accepted_email#" set subject [lang::util::localize "#invoices.iv_offer_accepted_email_subject#" $locale] set template "OfferAcceptedTemplate" set document_type "accepted"