From 6d56df13627da83f9125c4716d64a45446a8e7cd Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Tue, 10 Oct 2006 18:14:31 +0000 Subject: [PATCH] Added SQLReport download and Product AddToGroup handler --- docs/changelog/7.x.x.txt | 5 + .../templates-7.1.0/SQLReport-Download.tmpl | 129 ++++++++++ docs/upgrades/templates-7.1.0/SQLReport.tmpl | 161 ++++++++++++ docs/upgrades/upgrade_7.0.9-7.1.0.pl | 16 ++ lib/WebGUI/Asset/Wobject/SQLReport.pm | 229 +++++++++++++++++- lib/WebGUI/Commerce/Item/Product.pm | 32 ++- lib/WebGUI/Group.pm | 2 +- lib/WebGUI/Operation/Commerce.pm | 2 +- lib/WebGUI/Operation/ProductManager.pm | 71 ++++-- lib/WebGUI/Text.pm | 148 +++++++++++ lib/WebGUI/i18n/English/Asset_SQLReport.pm | 53 ++++ lib/WebGUI/i18n/English/ProductManager.pm | 62 +++++ .../wobject/SQLReport/editFormDownload.js | 64 +++++ 13 files changed, 946 insertions(+), 28 deletions(-) create mode 100644 docs/upgrades/templates-7.1.0/SQLReport-Download.tmpl create mode 100644 docs/upgrades/templates-7.1.0/SQLReport.tmpl mode change 100644 => 100755 docs/upgrades/upgrade_7.0.9-7.1.0.pl create mode 100644 lib/WebGUI/Text.pm create mode 100755 www/extras/wobject/SQLReport/editFormDownload.js diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 4a2e3ddb1..490a270ea 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -12,6 +12,11 @@ - fix: Events Calendar: error in "big" template (Martin Kamerbeek / Procolix) - fix: PM task editor not preserving duration - fix: PM project completion percentage updates not working right + - Added ability to download an SQLReport in either CSV or as a template. + - Added ability for Products to add a user to a group when purchased. + - Changed the ?op=editProduct form to a TabForm. + - fixed a small error in WebGUI::Group documentation. + - Added WebGUI::Text with some CSV functions. 7.0.9 - Removed the need for DateTime::Cron::Simple, which also added the ability diff --git a/docs/upgrades/templates-7.1.0/SQLReport-Download.tmpl b/docs/upgrades/templates-7.1.0/SQLReport-Download.tmpl new file mode 100644 index 000000000..c726c0ecb --- /dev/null +++ b/docs/upgrades/templates-7.1.0/SQLReport-Download.tmpl @@ -0,0 +1,129 @@ +#SQLReportDownload0001 +#namespace:SQLReport/Download +#title:SQLReport Download Default Template + + + + + + + + + + + + + + + + + + + +
+ + + + + +
  + + + + + + + + + + + + + + + + + + + +
+ + + + + +
  + + + + + + + + + + + + + + + + + + + +
+ + + + + +
  + + + + + + + + + + + + + + + + + + + +
+ + + + + +
  + + + + + + + + + + + + + +
+
+
+
+
+
+
+
+
diff --git a/docs/upgrades/templates-7.1.0/SQLReport.tmpl b/docs/upgrades/templates-7.1.0/SQLReport.tmpl new file mode 100644 index 000000000..4372dac7a --- /dev/null +++ b/docs/upgrades/templates-7.1.0/SQLReport.tmpl @@ -0,0 +1,161 @@ +#PBtmpl0000000000000059 + + + +

+
+ + +

+
+ + + +

+ + + + Download this data + + + +

    + +
  • +
    +
+
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + +
  + + + + + + + + + + + + + + + + + + + +
+ + + + + +
  + + + + + + + + + + + + + + + + + + + +
+ + + + + +
  + + + + + + + + + + + + + + + + + + + +
+ + + + + +
  + + + + + + + + + + + + + +
+
+
+
+
+
+
+
+
+ + + + + diff --git a/docs/upgrades/upgrade_7.0.9-7.1.0.pl b/docs/upgrades/upgrade_7.0.9-7.1.0.pl old mode 100644 new mode 100755 index 123c5f61b..c96e19f09 --- a/docs/upgrades/upgrade_7.0.9-7.1.0.pl +++ b/docs/upgrades/upgrade_7.0.9-7.1.0.pl @@ -20,6 +20,8 @@ my $quiet; # this line required my $session = start(); # this line required recalculateProjectCompletion($session); +updateSqlReportTable($session); +updateProductsTable($session); finish($session); # this line required @@ -38,6 +40,20 @@ sub recalculateProjectCompletion { } } + +sub updateSqlReportTable { + my $session = shift; + print "\tUpdating SQLReport table structure.\n" unless ($quiet); + $session->db->write("alter table `SQLReport` ADD COLUMN ( downloadType varchar(255), downloadFilename varchar(255), downloadTemplateId varchar(22), downloadMimeType varchar(255), downloadUserGroup varchar(22))"); +} + + +sub updateProductsTable { + my $session = shift; + print "\tUpdating products table structure.\n" unless ($quiet); + $session->db->write("alter table products add column (groupId varchar(22), groupExpiresOffset varchar(16))"); +} + # ---- DO NOT EDIT BELOW THIS LINE ---- #------------------------------------------------- diff --git a/lib/WebGUI/Asset/Wobject/SQLReport.pm b/lib/WebGUI/Asset/Wobject/SQLReport.pm index afd33e3a8..90f023a54 100644 --- a/lib/WebGUI/Asset/Wobject/SQLReport.pm +++ b/lib/WebGUI/Asset/Wobject/SQLReport.pm @@ -19,6 +19,7 @@ use WebGUI::SQL; use WebGUI::Utility; use WebGUI::Asset::Wobject; use WebGUI::Cache; +use WebGUI::Text qw(:csv); our @ISA = qw(WebGUI::Asset::Wobject); @@ -153,6 +154,30 @@ sub definition { fieldType=>"yesNo", defaultValue=>0 }, + + # download + downloadType=>{ + fieldType=>"text", + defaultValue=>"", + }, + downloadFilename=>{ + fieldType=>"text", + defaultValue=>"", + }, + downloadTemplateId=>{ + fieldType=>"template", + defaultValue=>'SQLReportDownload0001', + }, + downloadMimeType=>{ + fieldType=>"text", + defaultValue=>"text/html", + }, + downloadUserGroup=>{ + fieldType=>"group", + defaultValue=>"text/html", + }, + + } }); return $class->SUPER::definition($session, $definition); @@ -182,7 +207,79 @@ sub getEditForm { -uiLevel => 8, -value=>$self->getValue("cacheTimeout") ); + + + ### Download + # Download Type + my %downloadTypes; + tie %downloadTypes, 'Tie::IxHash', + "none" => "No Download", + "csv" => "CSV", + "template" => "Template", + ; + + $tabform->getTab("properties")->radioList( + -name=>"downloadType", # ID is downloadType_formId + -label=>$i18n->get("download type"), + -hoverHelp=>$i18n->get("download type description"), + -vertical=>1, + -options=> \%downloadTypes, + -defaultValue=>"none", + -value=>$self->getValue("downloadType"), + -extras=> "onclick='changeDownloadType(this)'" + ); + + # Download Filename + $tabform->getTab("properties")->text( + -name=>"downloadFilename", # ID is downloadFilename_formId + -label=>$i18n->get("download filename"), + -hoverHelp=>$i18n->get("download filename description"), + -value=>$self->getValue("downloadFilename"), + ); + + # Download template (if necessary) + $tabform->getTab("properties")->template( + -name=>"downloadTemplateId", # ID is downloadTemplateId_formId + -label=>$i18n->get("download template"), + -hoverHelp=>$i18n->get("download template description"), + -value=>$self->getValue("downloadTemplateId"), + -namespace=>"SQLReport/Download", + ); + + # Download mimeType (if necessary) + my %downloadMimeType; + tie %downloadMimeType, 'Tie::IxHash', + "application/octet-stream" => "application/octet-stream", + "application/xml" => "application/xml", + "application/csv" => "application/csv", + "text/html" => "text/html", + "text/plain" => "text/plain", + ; + $tabform->getTab("properties")->selectBox( + -name=>"downloadMimeType", + -label=>$i18n->get("download mimetype"), + -hoverHelp=>$i18n->get("download mimetype description"), + -options=> \%downloadMimeType, + -value=>$self->getValue("downloadMimeType"), + -defaultValue=>"application/octet-stream", + ); + + # Download UserGroup + $tabform->getTab("security")->group( + -name=>"downloadUserGroup", + -label=>$i18n->get("download usergroup"), + -hoverHelp=>$i18n->get("download usergroup description"), + -value=>$self->getValue("downloadUserGroup"), + -defaultValue=>$self->getValue("groupIdView"), + ); + + # javascript + $self->session->style->setScript("/extras/wobject/SQLReport/editFormDownload.js"); + + ### /DOWNLOAD + + # Add toggleQuery javascript $tabform->getTab("properties")->raw(qq|