[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[2787] trunk/LedgerSMB/PE.pm



Revision: 2787
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2787&view=rev
Author:   einhverfr
Date:     2009-11-09 19:59:19 +0000 (Mon, 09 Nov 2009)

Log Message:
-----------
Correcting errors on project reports

Modified Paths:
--------------
    trunk/LedgerSMB/PE.pm

Modified: trunk/LedgerSMB/PE.pm
===================================================================
--- trunk/LedgerSMB/PE.pm	2009-11-06 23:28:47 UTC (rev 2786)
+++ trunk/LedgerSMB/PE.pm	2009-11-09 19:59:19 UTC (rev 2787)
@@ -89,9 +89,10 @@
     my $where = "WHERE 1=1";
 
     $query = qq|
-		   SELECT pr.*, c.name 
+		   SELECT pr.*, e.name 
 		     FROM project pr
-		LEFT JOIN customer c ON (c.id = pr.customer_id)|;
+		LEFT JOIN entity_credit_account c ON (c.id = pr.credit_id)
+		LEFT JOIN entity e ON (c.entity_id = e.id)|;
 
     if ( $form->{type} eq 'job' ) {
         $where .= qq| AND pr.id NOT IN (SELECT DISTINCT id
@@ -196,9 +197,11 @@
     if ( $form->{id} ) {
 
         $query = qq|
-			   SELECT pr.*, c.name AS customer
+			   SELECT pr.*, e.name AS customer
 			     FROM project pr
-			LEFT JOIN customer c ON (c.id = pr.customer_id)
+			LEFT JOIN entity_credit_account c 
+                                  ON (c.id = pr.customer_id)
+			LEFT JOIN entity e ON (c.entity_id = e.id)
 			    WHERE pr.id = ?|;
         $sth = $dbh->prepare($query);
         $sth->execute( $form->{id} ) || $form->dberror($query);
@@ -281,7 +284,7 @@
 			       description = ?,
 			       startdate = ?,
 			       enddate = ?,
-			       customer_id = ?
+			       credit_id = ?
 			 WHERE id = | . $dbh->quote( $form->{id} );
     }
     else {
@@ -391,10 +394,11 @@
     my $sortorder = $form->sort_order( ..hidden.., \%ordinal );
 
     my $query = qq|
-		   SELECT pr.*, p.partnumber, p.onhand, c.name
+		   SELECT pr.*, p.partnumber, p.onhand, e.name
 		     FROM project pr
 		     JOIN parts p ON (p.id = pr.parts_id)
-		LEFT JOIN customer c ON (c.id = pr.customer_id)
+		LEFT JOIN entity_credit_account c ON (c.id = pr.credit_id)
+		LEFT JOIN entity e ON (e.id = c.entity_id)
 		    WHERE 1=1|;
 
     if ( $form->{projectnumber} ne "" ) {
@@ -487,12 +491,14 @@
 			          p.weight, p.notes, p.bin, p.partsgroup_id,
 			          ch.accno AS income_accno, 
 			          ch.description AS income_description, 
-			          pr.customer_id, c.name AS customer, 
+			          pr.credit_id, e.name AS customer, 
 			          pg.partsgroup
 			     FROM project pr
 			LEFT JOIN parts p ON (p.id = pr.parts_id)
 			LEFT JOIN chart ch ON (ch.id = p.income_accno_id)
-			LEFT JOIN customer c ON (c.id = pr.customer_id)
+			LEFT JOIN entity_credit_account c ON 
+                                                   (c.id = pr.credit_id)
+			LEFT JOIN entity e ON (e.id = c.entity_id
 			LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id)
 			    WHERE pr.id = | . $dbh->quote( $form->{id} );
     }
@@ -711,7 +717,7 @@
 		       enddate = ?,
 		       parts_id = ?
 		       production = ?,
-		       customer_id = ?
+		       credit_id = ?
 		 WHERE id = ?|;
     $sth = $dbh->prepare($query);
     $sth->execute(


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.