- fix Mason profiling to pass-through images (for graph/)
authorivan <ivan>
Fri, 8 Aug 2003 02:02:41 +0000 (02:02 +0000)
committerivan <ivan>
Fri, 8 Aug 2003 02:02:41 +0000 (02:02 +0000)
- fix graph/money-time.cgi use of $m interfering with Mason
- fix graph/money-time-graph.cgi to set content-type in a Mason/ASP-independant
  fashion
- (beginning of) includes!
- (beginning of) moving SQL search to including generic elements/search.html
- fix global.asa typo
- fix masonize to not prepend an extraneous blank line (breaking
  graph/money-time-graph.cgi)

bin/masonize
htetc/global.asa
httemplate/autohandler
httemplate/graph/money_time-graph.cgi
httemplate/graph/money_time.cgi
httemplate/search/elements/search.html [new file with mode: 0644]
httemplate/search/sql.html [new file with mode: 0644]

index 475c9a6..def0115 100755 (executable)
@@ -8,6 +8,7 @@ foreach $file ( split(/\n/, `find . -depth -print | grep cgi\$`) ) {
   system("chmod u+w $file");
   open(W,">$file") or die "can't open $file for writing: $!";
   select W; $| = 1; select STDOUT;
   system("chmod u+w $file");
   open(W,">$file") or die "can't open $file for writing: $!";
   select W; $| = 1; select STDOUT;
+  $newline = ''; #avoid prepending extraneous newlines
   $all = join('',@file);
 
   $mode = 'html';
   $all = join('',@file);
 
   $mode = 'html';
@@ -26,7 +27,7 @@ foreach $file ( split(/\n/, `find . -depth -print | grep cgi\$`) ) {
         #die;
         next;
       } elsif ( $all =~ /^<%(.*)$/s ) {
         #die;
         next;
       } elsif ( $all =~ /^<%(.*)$/s ) {
-        print W "\n";
+        print W $newline; $newline = "\n";
         $all = $1;
         $mode = 'perlc';
         next;
         $all = $1;
         $mode = 'perlc';
         next;
index c7056fc..5b0ac49 100644 (file)
@@ -73,7 +73,7 @@ sub Script_OnStart {
   $p = popurl(2);
   #print $cgi->header( '-expires' => 'now' );
   #dbh->{'private_profile'} = {} if dbh->can('sprintProfile');
   $p = popurl(2);
   #print $cgi->header( '-expires' => 'now' );
   #dbh->{'private_profile'} = {} if dbh->can('sprintProfile');
-  dbh->{'private_profile'} = {} if UNIVERSAL::can(dbh, 'sprintProfile') );
+  dbh->{'private_profile'} = {} if UNIVERSAL::can(dbh, 'sprintProfile');
 
   #really should check for FS::Profiler or something
     # Devel::AutoProfiler _our_ VERSION?  thanks a fucking lot
 
   #really should check for FS::Profiler or something
     # Devel::AutoProfiler _our_ VERSION?  thanks a fucking lot
@@ -191,5 +191,9 @@ sub sprintAutoProfile {
 
 }
 
 
 }
 
+sub include {
+  $Response->Include(@_);
+}
+
 1;
 
 1;
 
index e6e50d5..2bd3adf 100644 (file)
@@ -1,20 +1,18 @@
 % $m->call_next;
 % $m->call_next;
-
 <%init>
   dbh->{'private_profile'} = {} if UNIVERSAL::can(dbh, 'sprintProfile');
 </%init>
 <%init>
   dbh->{'private_profile'} = {} if UNIVERSAL::can(dbh, 'sprintProfile');
 </%init>
-
 <%filter>
 
 my $profile = '';
 if ( UNIVERSAL::can(dbh, 'sprintProfile') ) {
 
 <%filter>
 
 my $profile = '';
 if ( UNIVERSAL::can(dbh, 'sprintProfile') ) {
 
-  #if contenttype is text/html!!  **FIXME**
+  if ( lc($r->content_type) eq 'text/html' ) {
 
     $profile = '<PRE>'. ("\n"x4096). encode_entities(dbh->sprintProfile()).
                #"\n\n". &sprintAutoProfile(). '</PRE>';
                "\n\n".                        '</PRE>';
 
     $profile = '<PRE>'. ("\n"x4096). encode_entities(dbh->sprintProfile()).
                #"\n\n". &sprintAutoProfile(). '</PRE>';
                "\n\n".                        '</PRE>';
-  #endif
+  } 
 
   dbh->{'private_profile'} = {};
 }
 
   dbh->{'private_profile'} = {};
 }
index 944019a..76f1bd7 100755 (executable)
@@ -62,14 +62,14 @@ while ( $syear < $eyear || ( $syear == $eyear && $smonth < $emonth ) ) {
   my $refunded = $refunded_sth->fetchrow_arrayref->[0] || 0;
 
     #horrible local kludge that doesn't even really work right
   my $refunded = $refunded_sth->fetchrow_arrayref->[0] || 0;
 
     #horrible local kludge that doesn't even really work right
-    my $expenses_sql = "SELECT SUM(cust_bill_pay.amount) FROM cust_bill_pay, cust_bill WHERE cust_bill_pay.invnum = cust_bill.invnum AND cust_bill_pay._date >= $speriod AND cust_bill_pay._date < $eperiod AND 0 < ( select count(*) from cust_bill_pkg, cust_pkg, part_pkg WHERE cust_bill.invnum = cust_bill_pkg.invnum AND cust_pkg.pkgnum = cust_bill_pkg.pkgnum AND cust_pkg.pkgpart = part_pkg.pkgpart AND LOWER(part_pkg.pkg) LIKE 'expense _%' )";
+    my $expenses_sql2 = "SELECT SUM(cust_bill_pay.amount) FROM cust_bill_pay, cust_bill WHERE cust_bill_pay.invnum = cust_bill.invnum AND cust_bill_pay._date >= $speriod AND cust_bill_pay._date < $eperiod AND 0 < ( select count(*) from cust_bill_pkg, cust_pkg, part_pkg WHERE cust_bill.invnum = cust_bill_pkg.invnum AND cust_pkg.pkgnum = cust_bill_pkg.pkgnum AND cust_pkg.pkgpart = part_pkg.pkgpart AND LOWER(part_pkg.pkg) LIKE 'expense _%' )";
 
 
-#    my $expenses_sql = "SELECT SUM(cust_bill_pay.amount) FROM cust_bill_pay, cust_bill_pkg, cust_bill, cust_pkg, part_pkg WHERE cust_bill_pay.invnum = cust_bill.invnum AND cust_bill.invnum = cust_bill_pkg.invnum AND cust_bill_pay._date >= $speriod AND cust_bill_pay._date < $eperiod AND cust_pkg.pkgnum = cust_bill_pkg.pkgnum AND cust_pkg.pkgpart = part_pkg.pkgpart AND LOWER(part_pkg.pkg) LIKE 'expense _%'";
-    my $expenses_sth = dbh->prepare($expenses_sql) or die dbh->errstr;
-    $expenses_sth->execute or die $expenses_sth->errstr;
-    my $expenses = $expenses_sth->fetchrow_arrayref->[0] || 0;
+#    my $expenses_sql2 = "SELECT SUM(cust_bill_pay.amount) FROM cust_bill_pay, cust_bill_pkg, cust_bill, cust_pkg, part_pkg WHERE cust_bill_pay.invnum = cust_bill.invnum AND cust_bill.invnum = cust_bill_pkg.invnum AND cust_bill_pay._date >= $speriod AND cust_bill_pay._date < $eperiod AND cust_pkg.pkgnum = cust_bill_pkg.pkgnum AND cust_pkg.pkgpart = part_pkg.pkgpart AND LOWER(part_pkg.pkg) LIKE 'expense _%'";
+    my $expenses_sth2 = dbh->prepare($expenses_sql2) or die dbh->errstr;
+    $expenses_sth2->execute or die $expenses_sth2->errstr;
+    my $expenses2 = $expenses_sth2->fetchrow_arrayref->[0] || 0;
 
 
-  push @{$data{cash}}, $paid-$refunded-$expenses;
+  push @{$data{cash}}, $paid-$refunded-$expenses2;
 
 }
 
 
 }
 
@@ -101,7 +101,7 @@ my @data = ( \@labels,
 #$chart->cgi_png(\@data);
 
 http_header('Content-Type' => 'image/png' );
 #$chart->cgi_png(\@data);
 
 http_header('Content-Type' => 'image/png' );
-$Response->{ContentType} = 'image/png';
+#$Response->{ContentType} = 'image/png';
 
 $chart->_set_colors();
 
 
 $chart->_set_colors();
 
index e24157c..de8f6ee 100644 (file)
@@ -1,4 +1,4 @@
-<!-- mason kludge %>
+<!-- mason kludge -->
 <%
 
 #my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
 <%
 
 #my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
@@ -32,9 +32,9 @@ my $emonth = $cgi->param('emonth') || $curmon+1;
   Cashflow (payments - refunds)<BR>
 <BR>
 From <SELECT NAME="smonth">
   Cashflow (payments - refunds)<BR>
 <BR>
 From <SELECT NAME="smonth">
-<% my @m = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
-   foreach my $m ( 1..12 ) { %>
-<OPTION VALUE="<%= $m %>"<%= $m == $smonth ? ' SELECTED' : '' %>><%= $m[$m-1] %>
+<% my @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); %>
+<% foreach my $mon ( 1..12 ) { %>
+<OPTION VALUE="<%= $mon %>"<%= $mon == $smonth ? ' SELECTED' : '' %>><%= $mon[$mon-1] %>
 <% } %>
 </SELECT>
 <SELECT NAME="syear">
 <% } %>
 </SELECT>
 <SELECT NAME="syear">
@@ -43,8 +43,8 @@ From <SELECT NAME="smonth">
 <% } %>
 </SELECT>
  to <SELECT NAME="emonth">
 <% } %>
 </SELECT>
  to <SELECT NAME="emonth">
-<% foreach my $m ( 1..12 ) { %>
-<OPTION VALUE="<%= $m %>"<%= $m == $emonth ? ' SELECTED' : '' %>><%= $m[$m-1] %>
+<% foreach my $mon ( 1..12 ) { %>
+<OPTION VALUE="<%= $mon %>"<%= $mon == $emonth ? ' SELECTED' : '' %>><%= $mon[$mon-1] %>
 <% } %>
 </SELECT>
 <SELECT NAME="eyear">
 <% } %>
 </SELECT>
 <SELECT NAME="eyear">
diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html
new file mode 100644 (file)
index 0000000..fba8ee8
--- /dev/null
@@ -0,0 +1,8 @@
+<%
+
+my $conf = new FS::Conf;
+my $maxrecords = $conf->config('maxsearchrecordsperpage');
+
+my $limit = $maxrecords ? "LIMIT $maxrecords" : '';
+
+%>
diff --git a/httemplate/search/sql.html b/httemplate/search/sql.html
new file mode 100644 (file)
index 0000000..e61ce15
--- /dev/null
@@ -0,0 +1,8 @@
+<%= include( '/elements/header', 'Query Results',
+               include( '/elements/menubar', 'Main Menu' => $p )
+%>
+<%= include( 'elements/search.html',
+               'name' => 'rows',
+             
+%>
+