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

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



Revision: 1907
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1907&view=rev
Author:   einhverfr
Date:     2007-11-25 14:49:51 -0800 (Sun, 25 Nov 2007)

Log Message:
-----------
Adding employee workflow scripts

Modified Paths:
--------------
    trunk/ledgersmb-httpd.conf
    trunk/old-handler.pl
    trunk/scripts/vendor.pl

Added Paths:
-----------
    trunk/scripts/employee.pl

Removed Paths:
-------------
    trunk/scripts/employees.pl

Modified: trunk/ledgersmb-httpd.conf
===================================================================
--- trunk/ledgersmb-httpd.conf	2007-11-25 21:31:56 UTC (rev 1906)
+++ trunk/ledgersmb-httpd.conf	2007-11-25 22:49:51 UTC (rev 1907)
@@ -19,6 +19,7 @@
   # passwords.
   Order Deny,Allow
   Allow from 127.0.0.1
+  Allow from localhost
   Deny from All
 
   # The rest of this file just tightens up security.

Modified: trunk/old-handler.pl
===================================================================
--- trunk/old-handler.pl	2007-11-25 21:31:56 UTC (rev 1906)
+++ trunk/old-handler.pl	2007-11-25 22:49:51 UTC (rev 1907)
@@ -85,8 +85,8 @@
 $SIG{__WARN__} = sub { $form->info( $_[0] ) };
 
 # send errors to browser
-$SIG{__DIE__} =
-  sub { $form->error( __FILE__ . ':' . __LINE__ . ': ' . $_[0] ) };
+#$SIG{__DIE__} =
+#  sub { print STDERR  __FILE__ . ':' . __LINE__ . ': ' . $_[0]; };
 
 ## did sysadmin lock us out
 #if (-f "${LedgerSMB::Sysconfig::userspath}/nologin") {

Copied: trunk/scripts/employee.pl (from rev 1903, trunk/scripts/vendor.pl)
===================================================================
--- trunk/scripts/employee.pl	                        (rev 0)
+++ trunk/scripts/employee.pl	2007-11-25 22:49:51 UTC (rev 1907)
@@ -0,0 +1,205 @@
+#!/usr/bin/perl
+
+=pod
+
+=head1 NAME
+
+LedgerSMB::Scripts::employee - LedgerSMB class defining the Controller
+functions, template instantiation and rendering for employee editing and display.
+
+=head1 SYOPSIS
+
+This module is the UI controller for the employee DB access; it provides the 
+View interface, as well as defines the Save employee. 
+Save employee will update or create as needed.
+
+
+=head1 METHODS
+
+=cut
+
+package LedgerSMB::Scripts::employee;
+
+use LedgerSMB::Template;
+use LedgerSMB::DBObject::Employee;
+
+require 'lsmb-request.pl';
+
+=pod
+
+=over
+
+=item get($self, $request, $user)
+
+Requires form var: id
+
+Extracts a single employee from the database, using its company ID as the primary
+point of uniqueness. Shows (appropriate to user privileges) and allows editing
+of the employee informations.
+
+=back
+
+=cut
+
+
+sub get {
+    
+    my ($request) = @_;
+    my $employee = LedgerSMB::DBObject::Employee->new(base => $request, copy => 'all');
+    
+    $employee->set( entity_class=> '1' );
+    my $result = $employee->get();
+    
+    my $template = LedgerSMB::Template->new( user => $user, 
+	template => 'contact', language => $user->{language}, 
+	path => 'UI/Contact',
+        format => 'HTML');
+    $template->render($results);
+        
+}
+
+
+sub add_location {
+    my ($request) = @_;
+    my $employee= LedgerSMB::DBObject::Employee->new({base => $request, copy => 'all'});
+    $employee->set( entity_class=> '1' );
+    $employee->save_location();
+    $employee->get();
+
+    
+    $employee->get_metadata();
+
+    _render_main_screen($employee);
+	
+}
+
+=pod
+
+=over
+
+=item add
+
+This method creates a blank screen for entering a employee's information.
+
+=back
+
+=cut 
+
+sub add {
+    my ($request) = @_;
+    my $employee= LedgerSMB::DBObject::Employee->new(base => $request, copy => 'all');
+    $employee->set( entity_class=> '1' );
+    _render_main_screen($employee);
+}
+
+=pod
+
+=over
+
+=item search($self, $request, $user)
+
+Requires form var: search_pattern
+
+Directly calls the database function search, and returns a set of all employees
+found that match the search parameters. Search parameters search over address 
+as well as employee/Company name.
+
+=back
+
+=cut
+
+sub search {
+    my ($request) = @_;
+    
+    if ($request->type() eq 'POST') {
+        # assume it's asking us to do the search, now
+        
+        my $employee = LedgerSMB::DBObject::Employee->new(base => $request, copy => 'all');
+        $employee->set(entity_class=>1);
+        my $results = $employee->search($employee->{search_pattern});
+
+        my $template = LedgerSMB::Template->new( user => $user, 
+    	template => 'Contact/employee', language => $user->{language}, 
+            format => 'HTML');
+        $template->render($results);
+        
+    }
+    else {
+        
+        # grab the happy search page out.
+        
+        my $template = LedgerSMB::Template->new( 
+		user => $user,
+		path => 'UI/Contact' ,
+    		template => 'employee_search', 
+		locale => $request->{_locale}, 
+		format => 'HTML');
+            
+        $template->render();
+    }
+}
+
+=pod
+
+=over
+
+=item save($self, $request, $user)
+
+Saves a employee to the database. The function will update or insert a new 
+employee as needed, and will generate a new Company ID for the employee if needed.
+
+=back
+
+=cut
+
+sub save {
+    
+    my ($request) = @_;
+
+    my $employee = LedgerSMB::DBObject::Employee->new({base => $request});
+    $employee->save();
+    _render_main_screen($employee);
+}
+
+sub edit{
+    my $request = shift @_;
+    my $employee = LedgerSMB::DBObject::Employee->new({base => $request});
+    $employee->get();
+    _render_main_screen($employee);
+}
+
+sub _render_main_screen{
+    my $employee = shift @_;
+    $employee->get_metadata();
+
+    $employee->{creditlimit} = "$employee->{creditlimit}"; 
+    $employee->{discount} = "$employee->{discount}"; 
+    $employee->{script} = "employee.pl";
+
+    my $template = LedgerSMB::Template->new( 
+	user => $employee->{_user}, 
+    	template => 'contact', 
+	locale => $employee->{_locale},
+	path => 'UI/Contact',
+        format => 'HTML'
+    );
+    $template->render($employee);
+}
+
+sub save_contact {
+    my ($request) = @_;
+    my $employee = LedgerSMB::DBObject::Employee->new({base => $request});
+    $employee->save_contact();
+    $employee->get;
+    _render_main_screen($employee );
+}
+
+sub save_bank_account {
+    my ($request) = @_;
+    my $employee = LedgerSMB::DBObject::Employee->new({base => $request});
+    $employee->save_bank_account();
+    $employee->get;
+    _render_main_screen($employee);
+}
+
+1;

Deleted: trunk/scripts/employees.pl
===================================================================
--- trunk/scripts/employees.pl	2007-11-25 21:31:56 UTC (rev 1906)
+++ trunk/scripts/employees.pl	2007-11-25 22:49:51 UTC (rev 1907)
@@ -1,43 +0,0 @@
-# The handler, prior to handing the execution off to this script will create a
-# $request object from the LedgerSMB namespace.  This object contains the http
-# request parameters, db connections, and the like.  A $user object is also 
-# created
-#
-# Entrence points are functions which do not begin with an underscore (_)
-use LedgerSMB::Template;
-
-sub save {
-    my $employee = LedgerSMB::Employee->new(base => $request, copy => 'all');
-    $employee->save();
-    &_display;
-}
-
-sub search {
-    my $search = LedgerSMB::Employee->new(base => $request, copy => 'all');
-    $employee->{search_results} = $employee->search();
-    my $template = LedgerSMB::Template->new( user => $user, 
-	template => 'employee_search.html', language => $user->{language}, 
-        format => 'html');
-    $template->render($employee);
-}
-
-sub add {
-    my $employee = LedgerSMB::Employee->new(base => $request, copy => 'all');
-    &_display;
-}
-
-sub edit {
-    my $employee = LedgerSMB::Employee->new(base => $request, copy => 'all');
-    $employee->get();
-    &_display;
-}
-
-sub _display {
-    my $template = LedgerSMB::Template->new( user => $user, 
-	template => 'employee.html', language => $user->{language}, 
-        format => 'html');
-    $template->render($employee);
-
-}
-
-1;

Modified: trunk/scripts/vendor.pl
===================================================================
--- trunk/scripts/vendor.pl	2007-11-25 21:31:56 UTC (rev 1906)
+++ trunk/scripts/vendor.pl	2007-11-25 22:49:51 UTC (rev 1907)
@@ -189,16 +189,16 @@
 sub save_contact {
     my ($request) = @_;
     my $vendor = LedgerSMB::DBObject::Vendor->new({base => $request});
-    $vendor ->save_contact();
-    $vendor ->get;
+    $vendor->save_contact();
+    $vendor->get;
     _render_main_screen($vendor );
 }
 
 sub save_bank_account {
     my ($request) = @_;
     my $vendor = LedgerSMB::DBObject::Vendor->new({base => $request});
-    $vendor ->save_bank_account();
-    $vendor ->get;
+    $vendor->save_bank_account();
+    $vendor->get;
     _render_main_screen($vendor );
 }
 


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