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

SF.net SVN: ledger-smb: [1313] trunk



Revision: 1313
          http://svn.sourceforge.net/ledger-smb/?rev=1313&view=rev
Author:   einhverfr
Date:     2007-06-23 08:05:53 -0700 (Sat, 23 Jun 2007)

Log Message:
-----------
Correcting POD on LedgerSMB.pm, changing db_init to _db_init and calling it from the constructor.

Modified Paths:
--------------
    trunk/LedgerSMB/AM.pm
    trunk/LedgerSMB/CT.pm
    trunk/LedgerSMB/Form.pm
    trunk/LedgerSMB/HR.pm
    trunk/LedgerSMB/IC.pm
    trunk/LedgerSMB/IS.pm
    trunk/LedgerSMB/JC.pm
    trunk/LedgerSMB/OE.pm
    trunk/LedgerSMB/PE.pm
    trunk/LedgerSMB/RP.pm
    trunk/LedgerSMB.pm

Modified: trunk/LedgerSMB/AM.pm
===================================================================
--- trunk/LedgerSMB/AM.pm	2007-06-22 22:04:57 UTC (rev 1312)
+++ trunk/LedgerSMB/AM.pm	2007-06-23 15:05:53 UTC (rev 1313)
@@ -1314,7 +1314,7 @@
     my @queryargs;
     my $query = qq|
 		SELECT login
-		  FROM employees
+		  FROM employee 
 		 WHERE login = ?|;
     @queryargs = ( $form->{login} );
     my $sth = $dbh->prepare($query);
@@ -1326,7 +1326,7 @@
 
     # update name
     $query = qq|
-		UPDATE employees
+		UPDATE employee 
 		   SET name = ?
 		 WHERE login = ?|;
 
@@ -1756,7 +1756,7 @@
 
     $query = qq|
 		INSERT INTO gl (reference, employee_id)
-		     VALUES (?, (SELECT id FROM employees
+		     VALUES (?, (SELECT id FROM employee
 		                  WHERE login = ?))|;
 
     $dbh->prepare($query)->execute( $uid, $form->{login} )

Modified: trunk/LedgerSMB/CT.pm
===================================================================
--- trunk/LedgerSMB/CT.pm	2007-06-22 22:04:57 UTC (rev 1312)
+++ trunk/LedgerSMB/CT.pm	2007-06-23 15:05:53 UTC (rev 1313)
@@ -54,7 +54,7 @@
 			      FROM $form->{db} ct
 			 LEFT JOIN business b ON (ct.business_id = b.id)
 			 LEFT JOIN shipto s ON (ct.id = s.trans_id)
-			 LEFT JOIN employees e ON (ct.employee_id = e.id)
+			 LEFT JOIN employee e ON (ct.employee_id = e.id)
 			 LEFT JOIN pricegroup g ON (g.id = ct.pricegroup_id)
 			 LEFT JOIN language l ON (l.code = ct.language_code)
 			     WHERE ct.id = ?|;
@@ -519,8 +519,8 @@
 		          l.description AS language, m.name AS manager
 		     FROM $form->{db} ct
 		LEFT JOIN business b ON (ct.business_id = b.id)
-		LEFT JOIN employees e ON (ct.employee_id = e.id)
-		LEFT JOIN employees m ON (m.id = e.managerid)
+		LEFT JOIN employee e ON (ct.employee_id = e.id)
+		LEFT JOIN employee m ON (m.id = e.managerid)
 		LEFT JOIN pricegroup g ON (ct.pricegroup_id = g.id)
 		LEFT JOIN language l ON (l.code = ct.language_code)
 		    WHERE $where|;
@@ -577,8 +577,8 @@
 				      FROM $form->{db} ct
 				      JOIN $ar a ON (a.$form->{db}_id = ct.id)
 				 LEFT JOIN business b ON (ct.business_id = b.id)
-				 LEFT JOIN employees e ON (a.employee_id = e.id)
-				 LEFT JOIN employees m ON (m.id = e.managerid)
+				 LEFT JOIN employee e ON (a.employee_id = e.id)
+				 LEFT JOIN employee m ON (m.id = e.managerid)
 				     WHERE $where
 				           AND a.invoice = '0'
 				           $transwhere
@@ -613,8 +613,8 @@
 				     FROM $form->{db} ct
 				     JOIN $ar a ON (a.$form->{db}_id = ct.id)
 				LEFT JOIN business b ON (ct.business_id = b.id)
-				LEFT JOIN employees e ON (a.employee_id = e.id)
-				LEFT JOIN employees m ON (m.id = e.managerid)
+				LEFT JOIN employee e ON (a.employee_id = e.id)
+				LEFT JOIN employee m ON (m.id = e.managerid)
 				    WHERE $where
 				          AND a.invoice = '1'
 				          $transwhere
@@ -645,8 +645,8 @@
 				     FROM $form->{db} ct
 				     JOIN oe o ON (o.$form->{db}_id = ct.id)
 				LEFT JOIN business b ON (ct.business_id = b.id)
-				LEFT JOIN employees e ON (o.employee_id = e.id)
-				LEFT JOIN employees m ON (m.id = e.managerid)
+				LEFT JOIN employee e ON (o.employee_id = e.id)
+				LEFT JOIN employee m ON (m.id = e.managerid)
 				    WHERE $where
 				      AND o.quotation = '0'
 				          $transwhere
@@ -678,8 +678,8 @@
 				     FROM $form->{db} ct
 				     JOIN oe o ON (o.$form->{db}_id = ct.id)
 				LEFT JOIN business b ON (ct.business_id = b.id)
-				LEFT JOIN employees e ON (o.employee_id = e.id)
-				LEFT JOIN employees m ON (m.id = e.managerid)
+				LEFT JOIN employee e ON (o.employee_id = e.id)
+				LEFT JOIN employee m ON (m.id = e.managerid)
 				    WHERE $where
 				          AND o.quotation = '1'
 				          $transwhere
@@ -890,7 +890,7 @@
 		          $invjoin
 		     JOIN parts p ON (p.id = i.parts_id)
 		LEFT JOIN project pr ON (pr.id = i.project_id)
-		LEFT JOIN employees e ON (e.id = a.employee_id)
+		LEFT JOIN employee e ON (e.id = a.employee_id)
 				 WHERE $where
 			  ORDER BY $sortorder|;
 

Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm	2007-06-22 22:04:57 UTC (rev 1312)
+++ trunk/LedgerSMB/Form.pm	2007-06-23 15:05:53 UTC (rev 1313)
@@ -2322,53 +2322,42 @@
 
         $sth->finish;
 
-        for (qw(curr closedto revtrans)) {
-            $query = qq|
-				SELECT value FROM defaults 
-				 WHERE setting_key = '$_'|;
 
-            $sth = $dbh->prepare($query);
-            $sth->execute || $self->dberror($query);
-
-            ($val) = $sth->fetchrow_array();
-            if ( $_ eq 'curr' ) {
-                $self->{currencies} = $val;
-            }
-            else {
-                $self->{$_} = $val;
-            }
-            $sth->finish;
-        }
-	$self->{transdate} = $self->current_date;
-
     }
     else {
 
-        for (qw(current_date curr closedto revtrans)) {
+        if ( !$self->{"$self->{vc}_id"} ) {
+            $self->lastname_used( $myconfig, $dbh, $vc, $module );
+        }
+    }
+    for (qw(current_date curr closedto revtrans)) {
+        if ($_ eq 'closedto'){
             $query = qq|
+				SELECT value::date FROM defaults
+				 WHERE setting_key = '$_'|;
+        } elsif ($_ eq 'current_date') {
+            $query = qq| select $_|;
+        } else {
+            $query = qq|
 				SELECT value FROM defaults 
 				 WHERE setting_key = '$_'|;
+        }
 
-            $sth = $dbh->prepare($query);
-            $sth->execute || $self->dberror($query);
+        $sth = $dbh->prepare($query);
+        $sth->execute || $self->dberror($query);
 
-            ($val) = $sth->fetchrow_array();
-            if ( $_ eq 'curr' ) {
-                $self->{currencies} = $val;
-            }
-            elsif ( $_ eq 'current_date' ) {
-                $self->{transdate} = $val;
-            }
-            else {
-                $self->{$_} = $val;
-            }
-            $sth->finish;
+        ($val) = $sth->fetchrow_array();
+        if ( $_ eq 'curr' ) {
+            $self->{currencies} = $val;
         }
-
-        if ( !$self->{"$self->{vc}_id"} ) {
-            $self->lastname_used( $myconfig, $dbh, $vc, $module );
+        else {
+            $self->{$_} = $val;
         }
+        $sth->finish;
     }
+    if (!$self->{id}){
+        $self->{transdate} = $self->{current_date};
+    }
 
     $self->all_vc( $myconfig, $vc, $module, $dbh, $self->{transdate}, $job );
     $self->{dbh}->commit;

Modified: trunk/LedgerSMB/HR.pm
===================================================================
--- trunk/LedgerSMB/HR.pm	2007-06-22 22:04:57 UTC (rev 1312)
+++ trunk/LedgerSMB/HR.pm	2007-06-23 15:05:53 UTC (rev 1313)
@@ -44,7 +44,7 @@
     my $notid = "";
 
     if ( $form->{id} ) {
-        $query = qq|SELECT e.* FROM employees e WHERE e.id = ?|;
+        $query = qq|SELECT e.* FROM employee e WHERE e.id = ?|;
         $sth   = $dbh->prepare($query);
         $sth->execute( $form->{id} )
           || $form->dberror( __FILE__ . ':' . __LINE__ . ':' . $query );
@@ -63,7 +63,7 @@
         # get manager
         $form->{managerid} *= 1;
 
-        $sth = $dbh->prepare("SELECT name FROM employees WHERE id = ?");
+        $sth = $dbh->prepare("SELECT name FROM employee WHERE id = ?");
         $sth->execute( $form->{managerid} );
         ( $form->{manager} ) = $sth->fetchrow_array;
 
@@ -79,7 +79,7 @@
     # get managers
     $query = qq|
 		  SELECT id, name
-		    FROM employees
+		    FROM employee
 		   WHERE sales = '1'
 		         AND role = 'manager'
 		         $notid
@@ -107,11 +107,11 @@
         my $uid = localtime;
         $uid .= "$$";
 
-        $query = qq|INSERT INTO employees (name) VALUES ('$uid')|;
+        $query = qq|INSERT INTO employee (name) VALUES ('$uid')|;
         $dbh->do($query)
           || $form->dberror( __FILE__ . ':' . __LINE__ . ':' . $query );
 
-        $query = qq|SELECT id FROM employees WHERE name = '$uid'|;
+        $query = qq|SELECT id FROM employee WHERE name = '$uid'|;
         $sth   = $dbh->prepare($query);
         $sth->execute
           || $form->dberror( __FILE__ . ':' . __LINE__ . ':' . $query );
@@ -129,7 +129,7 @@
       if !$form->{employeenumber};
 
     $query = qq|
-		UPDATE employees 
+		UPDATE employee 
 		   SET employeenumber = ?,
 		       name = ?,
 		       address1 = ?,
@@ -180,7 +180,7 @@
     # delete employee
 
     my $query = qq|
-		DELETE FROM employees 
+		DELETE FROM employee 
 		      WHERE id = | . $dbh->quote( $form->{id} );
     $dbh->do($query)
       || $form->dberror( __FILE__ . ':' . __LINE__ . ':' . $query );
@@ -232,8 +232,8 @@
 
     my $query = qq|
 		   SELECT e.*, m.name AS manager
-		     FROM employees e
-		LEFT JOIN employees m ON (m.id = e.managerid)
+		     FROM employee e
+		LEFT JOIN employee m ON (m.id = e.managerid)
 		    WHERE $where
 		 ORDER BY $sortorder|;
 

Modified: trunk/LedgerSMB/IC.pm
===================================================================
--- trunk/LedgerSMB/IC.pm	2007-06-22 22:04:57 UTC (rev 1312)
+++ trunk/LedgerSMB/IC.pm	2007-06-23 15:05:53 UTC (rev 1313)
@@ -1215,7 +1215,7 @@
 					          ON (a.vendor_id = ct.id)
 					LEFT JOIN partsgroup pg 
 					          ON (p.partsgroup_id = pg.id)
-					LEFT JOIN employees e 
+					LEFT JOIN employee e 
 					          ON (a.employee_id = e.id)
 					$makemodeljoin
 					    WHERE $invwhere|;
@@ -1242,7 +1242,7 @@
 					          USING (entity_id)
 					LEFT JOIN partsgroup pg 
 					          ON (p.partsgroup_id = pg.id)
-					LEFT JOIN employees e 
+					LEFT JOIN employee e 
 					          ON (a.person_id = e.entity_id)
 					$makemodeljoin
 					    WHERE $invwhere|;
@@ -1308,7 +1308,7 @@
 					          USING (entity_id)
 					LEFT JOIN partsgroup pg 
 					          ON (p.partsgroup_id = pg.id)
-					LEFT JOIN employees e 
+					LEFT JOIN employee e 
 					          ON (a.employee_id = e.id)
 					$makemodeljoin
 					    WHERE $ordwhere 
@@ -1348,7 +1348,7 @@
 					          ON (a.vendor_id = ct.id)
 					LEFT JOIN partsgroup pg 
 					          ON (p.partsgroup_id = pg.id)
-					LEFT JOIN employees e 
+					LEFT JOIN employee e 
 					          ON (a.employee_id = e.id)
 					$makemodeljoin
 					    WHERE $ordwhere
@@ -1414,7 +1414,7 @@
 					          USING (entity_id)
 					LEFT JOIN partsgroup pg 
 					          ON (p.partsgroup_id = pg.id)
-					LEFT JOIN employees e 
+					LEFT JOIN employee e 
 					          ON (a.employee_id = e.id)
 					$makemodeljoin
 					    WHERE $quowhere
@@ -1454,7 +1454,7 @@
 					          ON (a.vendor_id = ct.id)
 					LEFT JOIN partsgroup pg 
 					          ON (p.partsgroup_id = pg.id)
-					LEFT JOIN employees e 
+					LEFT JOIN employee e 
 					          ON (a.employee_id = e.id)
 					$makemodeljoin
 					    WHERE $quowhere

Modified: trunk/LedgerSMB/IS.pm
===================================================================
--- trunk/LedgerSMB/IS.pm	2007-06-22 22:04:57 UTC (rev 1312)
+++ trunk/LedgerSMB/IS.pm	2007-06-23 15:05:53 UTC (rev 1313)
@@ -1761,7 +1761,7 @@
 			          a.entity_id,
 			          a.language_code, a.ponumber
 			     FROM ar a
-			LEFT JOIN employees e ON (e.entity_id = a.employee_id)
+			LEFT JOIN employee e ON (e.entity_id = a.employee_id)
 			    WHERE a.id = ?|;
 
         $sth = $dbh->prepare($query);

Modified: trunk/LedgerSMB/JC.pm
===================================================================
--- trunk/LedgerSMB/JC.pm	2007-06-22 22:04:57 UTC (rev 1312)
+++ trunk/LedgerSMB/JC.pm	2007-06-23 15:05:53 UTC (rev 1313)
@@ -67,7 +67,7 @@
 			       pr.production, pr.completed, 
 			       pr.parts_id AS project
 			  FROM jcitems j
-			  JOIN employees e ON (e.id = j.employee_id)
+			  JOIN employee e ON (e.id = j.employee_id)
 			  JOIN parts p ON (p.id = j.parts_id)
 			  JOIN project pr ON (pr.id = j.project_id)
 			 WHERE j.id = ?|;
@@ -480,7 +480,7 @@
 		  FROM jcitems j
 		  JOIN parts p ON (p.id = j.parts_id)
 		  JOIN project pr ON (pr.id = j.project_id)
-		  JOIN employees e ON (e.id = j.employee_id)
+		  JOIN employee e ON (e.id = j.employee_id)
 		 WHERE $where
 		ORDER BY employee, employeenumber, $sortorder|;
 

Modified: trunk/LedgerSMB/OE.pm
===================================================================
--- trunk/LedgerSMB/OE.pm	2007-06-22 22:04:57 UTC (rev 1312)
+++ trunk/LedgerSMB/OE.pm	2007-06-23 15:05:53 UTC (rev 1313)
@@ -83,8 +83,8 @@
 			m.name AS manager, o.curr, o.ponumber
 		FROM oe o
 		JOIN $form->{vc} ct ON (o.$form->{vc}_id = ct.id)
-		LEFT JOIN employees e ON (o.employee_id = e.id)
-		LEFT JOIN employees m ON (e.managerid = m.id)
+		LEFT JOIN employee e ON (o.employee_id = e.id)
+		LEFT JOIN employee m ON (e.managerid = m.id)
 		LEFT JOIN exchangerate ex 
 			ON (ex.curr = o.curr AND ex.transdate = o.transdate)
 		WHERE o.quotation = ?
@@ -138,7 +138,7 @@
         }
 
         $query .= qq|
-			LEFT JOIN employees e ON (o.employee_id = e.id)
+			LEFT JOIN employee e ON (o.employee_id = e.id)
 			LEFT JOIN exchangerate ex 
 				ON (ex.curr = o.curr 
 					AND ex.transdate = o.transdate)
@@ -765,7 +765,7 @@
 				o.ponumber
 			FROM oe o
 			JOIN $form->{vc} vc ON (o.$form->{vc}_id = vc.id)
-			LEFT JOIN employees e ON (o.employee_id = e.id)
+			LEFT JOIN employee e ON (o.employee_id = e.id)
 			LEFT JOIN department d ON (o.department_id = d.id)
 			WHERE o.id = ?|;
         $sth = $dbh->prepare($query);

Modified: trunk/LedgerSMB/PE.pm
===================================================================
--- trunk/LedgerSMB/PE.pm	2007-06-22 22:04:57 UTC (rev 1312)
+++ trunk/LedgerSMB/PE.pm	2007-06-23 15:05:53 UTC (rev 1313)
@@ -1490,7 +1490,7 @@
 		          p.partnumber
 		     FROM jcitems j
 		     JOIN project pr ON (pr.id = j.project_id)
-		     JOIN employees e ON (e.id = j.employee_id)
+		     JOIN employee e ON (e.id = j.employee_id)
 		     JOIN parts p ON (p.id = j.parts_id)
 		LEFT JOIN $form->{vc} c ON (c.id = pr.$form->{vc}_id)
 		    WHERE pr.parts_id IS NULL

Modified: trunk/LedgerSMB/RP.pm
===================================================================
--- trunk/LedgerSMB/RP.pm	2007-06-22 22:04:57 UTC (rev 1312)
+++ trunk/LedgerSMB/RP.pm	2007-06-23 15:05:53 UTC (rev 1313)
@@ -2337,7 +2337,7 @@
 			     FROM acc_trans ac
 			     JOIN $form->{db} a ON (ac.trans_id = a.id)
 			     JOIN $table c ON (c.id = a.${table}_id)
-			LEFT JOIN employees e ON (a.employee_id = e.id)
+			LEFT JOIN employee e ON (a.employee_id = e.id)
 			          $dpt_join
 			    WHERE ac.chart_id = $ref->{id} $where|;
 
@@ -2364,7 +2364,7 @@
 				  FROM acc_trans ac
 				  JOIN gl g ON (g.id = ac.trans_id)
 				  LEFT 
-				  JOIN employees e ON (g.employee_id = e.id)
+				  JOIN employee e ON (g.employee_id = e.id)
 				       $dpt_join
 				 WHERE ac.chart_id = $ref->{id} $glwhere
 				       AND (ac.amount * $ml) > 0

Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm	2007-06-22 22:04:57 UTC (rev 1312)
+++ trunk/LedgerSMB.pm	2007-06-23 15:05:53 UTC (rev 1313)
@@ -14,8 +14,9 @@
 
 =item new ()
 
-This method creates a new base request instance. In any mode but CLI, it also
-validates the session/user credentials.
+This method creates a new base request instance. It also validates the 
+session/user credentials, as appropriate for the run mode.  Finally, it sets up 
+the database connections for the user.
 
 =item date_to_number (user => $LedgerSMB::User, date => $string);
 
@@ -205,6 +206,7 @@
             exit;
         }
     }
+    $self->_db_init;
 
     $self;
 
@@ -604,7 +606,6 @@
 
         $self->{msg}    = $msg;
         $self->{format} = "html";
-        $self->format_string('msg');
 
         delete $self->{pre};
 
@@ -628,10 +629,10 @@
 }
 # Database routines used throughout
 
-sub db_init {
+sub _db_init {
     my $self     = shift @_;
     my %args     = @_;
-    my $myconfig = $args{user};
+    my $myconfig = $self->{_user};
 
     my $dbh = DBI->connect(
         $myconfig->{dbconnect}, $myconfig->{dbuser},


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