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

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



Revision: 1879
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1879&view=rev
Author:   einhverfr
Date:     2007-11-18 12:35:31 -0800 (Sun, 18 Nov 2007)

Log Message:
-----------
More customer/vendor screen/stored proc fixes.  Note that since locations are mapped many<->many with companies and persons, I have moved the location class foreign key into the mapping tables.

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Customer.pm
    trunk/LedgerSMB/Template/HTML.pm
    trunk/UI/Customer/customer.html
    trunk/UI/lib/ui-header.html
    trunk/scripts/customer.pl
    trunk/scripts/payment.pl
    trunk/sql/Pg-database.sql
    trunk/sql/modules/Location.sql
    trunk/sql/modules/Roles.sql
    trunk/sql/modules/Vendor.sql

Modified: trunk/LedgerSMB/DBObject/Customer.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Customer.pm	2007-11-18 18:19:52 UTC (rev 1878)
+++ trunk/LedgerSMB/DBObject/Customer.pm	2007-11-18 20:35:31 UTC (rev 1879)
@@ -1,6 +1,6 @@
 package LedgerSMB::DBObject::Customer;
 
-use base qw(LedgerSMB::DBObject::Company);
+use base qw(LedgerSMB::DBObject);
 use LedgerSMB::DBObject;
 use LedgerSMB::Entity;
 
@@ -44,4 +44,4 @@
     
     
 }
-1;
\ No newline at end of file
+1;

Modified: trunk/LedgerSMB/Template/HTML.pm
===================================================================
--- trunk/LedgerSMB/Template/HTML.pm	2007-11-18 18:19:52 UTC (rev 1878)
+++ trunk/LedgerSMB/Template/HTML.pm	2007-11-18 20:35:31 UTC (rev 1879)
@@ -97,7 +97,7 @@
 		$source = get_template($parent->{template});
 	}
 	$template = Template->new({
-		INCLUDE_PATH => $parent->{include_path},
+		INCLUDE_PATH => [$parent->{include_path}, 'UI/lib'],
 		START_TAG => quotemeta('<?lsmb'),
 		END_TAG => quotemeta('?>'),
 		DELIMITER => ';',

Modified: trunk/UI/Customer/customer.html
===================================================================
--- trunk/UI/Customer/customer.html	2007-11-18 18:19:52 UTC (rev 1878)
+++ trunk/UI/Customer/customer.html	2007-11-18 20:35:31 UTC (rev 1879)
@@ -1,109 +1,102 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
-		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
-<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
-<head>
-	<title><?lsmb form.titlebar ?></title>
-	<meta http-equiv="Pragma" content="no-cache" />
-	<meta http-equiv="Expires" content="-1" />
-	<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
-	<link rel="stylesheet" href="css/<?lsmb form.stylesheet ?>" type="text/css" title="LedgerSMB stylesheet" />
-
-	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
-	<meta name="robots" content="noindex,nofollow" />
-        
-</head>
+<?lsmb PROCESS 'ui-header.html' ?>
+<body>
+<div class="listtop"><strong><?lsmb text('Add/Edit Customer') ?></strong></div>
 <div class="customer">
-    
-    <font size="17"><?lsmb customer.name?></font>
-    
+    <?lsmb IF name ?> 
+    <font size="17"><?lsmb name?></font>
+    <?lsmb END ?>
 <form name="customer" method="POST" action="vendor.pl">
+	<label for="name"><?lsmb text('Name:') ?></label>
+	<input name="name" id="name" type="text" value="<?lsmb name ?>"><br/>
         <table>
-        
+       <?lsmb IF ordered ?> 
         <tr>
             <td><b><?lsmb text('Shipping Address') ?></b></td>
             
             <td><b><?lsmb text('Billing Address (if different)') ?></p></td>
             
         </tr>
+	<?lsmb END ?>
         
-        <hr/>
         
-        <?lsmb FOREACH entry = customer.ordered  ?>
+        <?lsmb FOREACH entry = ordered  ?>
         <tr>
             <td>
                 <label for="shipping_<?lsmb entry ?>"><?lsmb text(entry) ?>:
 		</label>
-                <input id="shipping_<?lsmb entry ?>" type="textarea" 
+                <input id="shipping_<?lsmb entry ?>" type="text" 
 			name="shipping_<?lsmb entry ?>" 
-			value="<?lsmb customer.entry ?>">
+			value="<?lsmb entry ?>">
             </td>
             <td>
-                <input type="textarea" name="billing_<?lsmb entry ?>" 
-			value="<?lsmb customer.entry ?>">
+                <input type="text" name="billing_<?lsmb entry ?>" 
+			value="<?lsmb entry ?>">
             </td>            
         </tr>
         <?lsmb END ?>
         <tr>
             <td>
                 <label for="startdate"><?lsmb text('Starting Date:') ?></label>
-                    <input id="startdate" type="textarea" name="startdate" 
-			value="<?lsmb customer.startdate ?>">
+                    <input id="startdate" type="text" name="startdate" 
+			class="date" value="<?lsmb startdate ?>">
             </td>
             <td>
                 <label for="enddate"><?lsmb('End date:') ?></label>
-                    <input id="enddate" type="textarea" name="startdate" 
-			value="<?lsmb customer.enddate ?>">
+                    <input id="enddate" type="text" name="startdate" 
+			class="date" value="<?lsmb enddate ?>">
             </td>
         </tr>
         <tr>
             <td>
                 <label for"creditlimit"><?lsmb text('Credit Limit:') ?></label>
-                <input id="creditlimit" name="creditlimit" type="textarea" 
-			value="<?lsmb customer.creditlimit ?>">
+                <input id="creditlimit" name="creditlimit" type="text" 
+			value="<?lsmb creditlimit ?>">
             </td>
             <td>
                 <label for="terms"><?lsmb text('Terms:') ?></label>
-                <input id="terms" name="terms" type="textarea" 
-			value="<?lsmb customer.terms ?>"> days
+                <input id="terms" name="terms" type="text" 
+			value="<?lsmb terms ?>"> days
             </td>
-            <td>
-                <label for="discount"><?lsmb text('Discount %:') ?></label>
-                <input id="discount" name="discount" type="textarea" 
-			value="<?lsmb customer.discount ?>">                
-            </td>
         </tr>
         <tr>
             
             <td>
                 <label for="taxnumber"><?lsmb text('Tax Number/SSN:') ?></label>
-                <input id="taxnumber" name="taxnumber" type="textarea" 
-			value="<?lsmb customer.taxnumber ?>">                
+                <input id="taxnumber" name="taxnumber" type="text" 
+			value="<?lsmb taxnumber ?>">                
             </td>
             <td>
                 <label for"gifi_accno"><?lsmb text('Subcontract GIFI:') ?>
 		</label>
-                <input id="gifi_accno" name="gifi_accno" type="textarea" 
-			value="<?lsmb customer.gifi_accno ?>">
+                <input id="gifi_accno" name="gifi_accno" type="text" 
+			value="<?lsmb gifi_accno ?>">
             </td>
+        </tr>
+	<tr>
             <td>
+                <label for="discount"><?lsmb text('Discount %:') ?></label>
+                <input id="discount" name="discount" type="text" size="3" 
+			maxlength="3" value="<?lsmb discount ?>">/
+		<input id="discountdays" name="discountdays" type="text" 
+		size="3" value="<?lsmb discount_days ?>">  
+            </td>
+            <td>
                 <label for"sic_code"><?lsmb text('SIC Code:') ?></label>
-                <input id="sic_code" name="sic_code" type="textarea" 
-			value="<?lsmb customer.sic_code ?>">
+                <input id="sic_code" name="sic_code" type="text" 
+			value="<?lsmb sic_code ?>">
             </td>
         </tr>
-        
         <tr>
             
-            <td></td>
             <td>
                 <label for"bic"><?lsmb text('BIC:') ?></label>
-                <input id="bic" name="bic" type="textarea" 
-			value="<?lsmb customer.bic ?>">
+                <input id="bic" name="bic" type="text" 
+			value="<?lsmb bic ?>">
             </td>
             <td>
                 <label for="iban"><?lsmb text('IBAN:') ?></label>
-                <input id="iban" name="iban" type="textarea" 
-			value="<?lsmb customer.iban ?>">
+                <input id="iban" name="iban" type="text" 
+			value="<?lsmb iban ?>">
             </td>
         </tr>
         
@@ -111,30 +104,29 @@
             <td>
                 <label for="notes"><?lsmb text('Notes:') ?></label><br/>
                 <textarea name="notes" rows="3" cols="40" id="notes"><?lsmb 
-			customer.notes
+			notes
 		?></textarea>
 		<!-- The prior funny whitespace may look funny but it prevents
 		additional whitespace from being added to the data every time 
 		it is saved -->
             </td>
         </tr>
+    </table>
 
-        <tr>
             <hr/>
-            <br/>
-            <td>
-                <button class="submit" type="submit" name="action" value="save" accesskey="S" title="Save [Alt-S]"><?lsmb text('Save') ?></button>
-                </td>
-            <td>
                 <button class="submit" 
+			type="submit" 
+			name="action" 
+			value="save" 
+			accesskey="S" 
+			title="Save [Alt-S]"><?lsmb text('Save') ?></button>
+                <button class="submit" 
                         type="submit" 
                         name="action" 
                         value="ap_transaction" 
                         accesskey="A" 
                         title="AP Transaction [Alt-A]">
 			<?lsmb text('AP Transaction') ?></button>
-                </td>
-            <td>
                 <button class="submit" 
                         type="submit" 
                         name="action" 
@@ -142,8 +134,6 @@
                         accesskey="I" 
                         title="customer Invoice [Alt-I]">
 			<?lsmb text('Customer Invoice') ?></button>
-            </td>
-            <td>
                 <button class="submit" 
                         type="submit" 
                         name="action" 
@@ -151,16 +141,12 @@
                         accesskey="O" 
                         title="Purchase Order [Alt-O]">
 			<?lsmb text('Purchase Order') ?></button>
-            </td>
-            <td>
                 <button class="submit" 
                         type="submit" 
                         name="action" 
                         value="rfq" 
                         accesskey="Q" 
                         title="RFQ [Alt-Q]"><?lsmb text('RFQ') ?></button>
-            </td>
-            <td>
                 <button class="submit" 
                         type="submit" 
                         name="action" 
@@ -168,8 +154,15 @@
                         accesskey="P" 
                         title="Pricelist [Alt-P]">
 			<?lsmb text('Pricelist') ?></button>
-            </td>
-        </tr>        
-    </table>
     </form>
 </div>
+<div id="locations">
+    <div class="listtop"><?lsmb text('Locations') ?></div>
+	<!-- This entire form should probably be optionaly automated with AJAX
+	in oder to prevent user confusion -->
+    <form id="location_form" action="vendor.pl">
+	<!-- todo, add location management! -->
+    </form>
+</div>
+</body>
+</html>

Modified: trunk/UI/lib/ui-header.html
===================================================================
--- trunk/UI/lib/ui-header.html	2007-11-18 18:19:52 UTC (rev 1878)
+++ trunk/UI/lib/ui-header.html	2007-11-18 20:35:31 UTC (rev 1879)
@@ -6,8 +6,17 @@
 	<meta http-equiv="Pragma" content="no-cache" />
 	<meta http-equiv="Expires" content="-1" />
 	<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
+	<?lsmb IF form.stylesheet ?>
 	<link rel="stylesheet" href="css/<?lsmb form.stylesheet ?>" type="text/css" title="LedgerSMB stylesheet" />
+	<?lsmb ELSE ?>
+	<link rel="stylesheet" href="css/<?lsmb stylesheet ?>" type="text/css" title="LedgerSMB stylesheet" />
+	<?lsmb END ?>
+	<?lsmb IF script ?>
+	<link rel="stylesheet" href="css/<?lsmb script ?>.css" type="text/css" title="LedgerSMB stylesheet" />
+	<?lsmb END ?>
+	
 
+
 	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
 	<meta name="robots" content="noindex,nofollow" />
         

Modified: trunk/scripts/customer.pl
===================================================================
--- trunk/scripts/customer.pl	2007-11-18 18:19:52 UTC (rev 1878)
+++ trunk/scripts/customer.pl	2007-11-18 20:35:31 UTC (rev 1879)
@@ -44,14 +44,14 @@
 sub get {
     
     my ($request) = @_;
-    my $customer = LedgerSMB::DBObject::Company->new(base => $request, copy => 'all');
+    my $customer = LedgerSMB::DBObject::Customer->new(base => $request, copy => 'all');
     
     $customer->set( entity_class=> '2' );
     my $result = $customer->get();
     
     my $template = LedgerSMB::Template->new( user => $user, 
-	template => 'Customer/customer.html', language => $user->{language}, 
-        format => 'html');
+	template => 'Customer/customer', language => $user->{language}, 
+        format => 'HTML');
     $template->render($results);
         
 }
@@ -70,12 +70,16 @@
 
 sub add {
     my ($request) = @_;
-    my $customer = LedgerSMB::DBObject::Company->new(base => $request, copy => 'all');
+    my $customer = LedgerSMB::DBObject::Customer->new(base => $request, copy => 'all');
     $customer->set(entity_class=>2);
-    my $template = LedgerSMB::Template->new( user => $user, 
-	template => 'Customer/customer.html', language => $user->{language}, 
-        format => 'html');
-    $template->render($results);
+    my $template = LedgerSMB::Template->new( 
+	user => $user, 
+	template => 'customer', 
+	path => 'UI/Customer',
+	locale => $request->{_locale}, 
+        format => 'HTML');
+    $request->{script} = 'Customer/customer';
+    $template->render($request);
 }
 
 =pod
@@ -100,13 +104,13 @@
     if ($request->type() eq 'POST') {
         # assume it's asking us to do the search, now
         
-        my $customer = LedgerSMB::DBObject::Company->new(base => $request, copy => 'all');
+        my $customer = LedgerSMB::DBObject::Customer->new(base => $request, copy => 'all');
         $customer->set(entity_class=>2);
         my $results = $customer->search($customer->{search_pattern});
 
         my $template = LedgerSMB::Template->new( user => $user, 
-    	template => 'Customer/customer.html', language => $user->{language}, 
-            format => 'html');
+    	template => 'Customer/customer', language => $user->{language}, 
+            format => 'HTML');
         $template->render($results);
         
     }
@@ -114,9 +118,12 @@
         
         # grab the happy search page out.
         
-        my $template = LedgerSMB::Template->new( user => $user, 
-    	template => 'Customer/customer_search.html', language => $user->{language}, 
-            format => 'html');
+        my $template = LedgerSMB::Template->new( 
+		user => $user,
+		path => 'UI/Customer' ,
+    		template => 'customer_search', 
+		locale => $request->{_locale}, 
+		format => 'HTML');
             
         $template->render();
     }
@@ -151,8 +158,8 @@
         my $result = $customer->save();
 
         my $template = LedgerSMB::Template->new( user => $user, 
-    	template => 'Customer/customer.html', language => $user->{language}, 
-            format => 'html');
+    	template => 'Customer/customer', language => $user->{language}, 
+            format => 'HTML');
         $template->render($result);
     } 
     else {

Modified: trunk/scripts/payment.pl
===================================================================
--- trunk/scripts/payment.pl	2007-11-18 18:19:52 UTC (rev 1878)
+++ trunk/scripts/payment.pl	2007-11-18 20:35:31 UTC (rev 1879)
@@ -157,8 +157,8 @@
   $template = LedgerSMB::Template->new(
   user     => $request->{_user},
   locale   => $request->{_locale},
-#  path     => 'UI/payments',
-  path     => 'UI',
+  path     => 'UI/payments',
+#  path     => 'UI',
   template => 'payment1',
   format => 'HTML', );
 $template->render($select);# And finally, Lets print the screen :)

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2007-11-18 18:19:52 UTC (rev 1878)
+++ trunk/sql/Pg-database.sql	2007-11-18 20:35:31 UTC (rev 1879)
@@ -130,7 +130,6 @@
   
 CREATE TABLE location (
   id serial PRIMARY KEY,
-  location_class integer not null references location_class(id),
   line_one text check (line_one ~ '[[:alnum:]_]') NOT NULL,
   line_two text,
   line_three text,
@@ -156,6 +155,7 @@
 
 CREATE TABLE company_to_location (
   location_id integer references location(id) not null,
+  location_class integer not null references location_class(id),
   company_id integer not null references company(id) ON DELETE CASCADE,
   PRIMARY KEY(location_id,company_id));
 
@@ -201,6 +201,7 @@
 
 CREATE TABLE person_to_location (
   location_id integer not null references location(id),
+  location_class integer not null references location_class(id),
   person_id integer not null references person(id) ON DELETE CASCADE,
   PRIMARY KEY (location_id,person_id));
 

Modified: trunk/sql/modules/Location.sql
===================================================================
--- trunk/sql/modules/Location.sql	2007-11-18 18:19:52 UTC (rev 1878)
+++ trunk/sql/modules/Location.sql	2007-11-18 20:35:31 UTC (rev 1879)
@@ -1,6 +1,6 @@
 -- VERSION 1.3.0
 CREATE OR REPLACE FUNCTION location_save
-(in_companyname text, in_address1 text, in_address2 text, 
+(in_address1 text, in_address2 text, in_address3 text,
 	in_city text, in_state text, in_zipcode text, in_country text) 
 returns integer AS
 $$
@@ -10,9 +10,9 @@
 BEGIN
 	
 	SELECT * INTO location_row FROM location
-	WHERE companyname = in_companyname AND
-		address1 = in_address1 AND
-		address2 = in_address2 AND
+	WHERE line_one = in_address1 AND
+		line_two = in_address2 AND
+		line_three = in_address3 AND
 		city = in_city AND
 		state = in_state AND
 		zipcode = in_zipcode AND

Modified: trunk/sql/modules/Roles.sql
===================================================================
--- trunk/sql/modules/Roles.sql	2007-11-18 18:19:52 UTC (rev 1878)
+++ trunk/sql/modules/Roles.sql	2007-11-18 20:35:31 UTC (rev 1879)
@@ -1376,3 +1376,4 @@
 GRANT SELECT ON custom_table_catalog TO PUBLIC;
 GRANT SELECT ON custom_field_catalog TO PUBLIC;
 grant select on menu_node, menu_attribute, menu_acl to public;
+GRANT select on chart, gifi to public;

Modified: trunk/sql/modules/Vendor.sql
===================================================================
--- trunk/sql/modules/Vendor.sql	2007-11-18 18:19:52 UTC (rev 1878)
+++ trunk/sql/modules/Vendor.sql	2007-11-18 20:35:31 UTC (rev 1879)
@@ -170,9 +170,9 @@
 
 
 create or replace function _entity_location_save(
-    in_company_id int,
-    in_location_class int, in_line_one text, in_line_two text, 
-    in_city_province TEXT, in_mail_code text, in_country_code int,
+    in_company_id int, in_location_id int,
+    in_location_class int, in_line_one text, in_line_two text,
+    in_city TEXT, in_state TEXT, in_mail_code text, in_country_code int,
     in_created date
 ) returns int AS $$
 
@@ -180,46 +180,20 @@
         l_row location;
         l_id INT;
     BEGIN
-    
-        SELECT l.* INTO l_row FROM location l 
-        JOIN company_to_location ctl ON ctl.location_id = l.id
-        JOIN company c on ctl.company_id = c.id
-        where c.id = in_company_id;
-        
-        IF NOT FOUND THEN
-        
-            l_id := nextval('location_id_seq');
-            
-            INSERT INTO location (id, location_class, line_one, line_two, 
-                 city_province, country_id, mail_code, created)
-            VALUES (
-                l_id,
-                in_location_class,
-                in_line_one,
-                in_line_two,
-                in_city_province,
-                in_country_code,
-                in_mail_code,
-                in_created
-            );
-            
-            INSERT INTO company_to_location (location_id, company_id)
-            VALUES (l_id, in_company_id);
-        
-        ELSIF FOUND THEN
-        
-            l_id := l.id;
-            update location SET
-                location_class = in_location_class,
-                line_one = in_line_one,
-                line_two = in_line_two,
-                city_province = in_city_province,
-                country_id = in_country_code,
-                mail_code = in_mail_code
-            WHERE id = l_id;        
-        
-        END IF;
-        return l_id;
+	DELETE FROM company_to_location
+	WHERE company_id = in_company_id
+		AND location_class = in_location_class
+		AND location_id = in_location_id;
+
+	SELECT location_save(in_line_one, in_line_two, NULL, in_city,
+		in_state, in_mail_code, in_mail_code, in_country_code) 
+	INTO l_id;
+
+	INSERT INTO company_to_location 
+		(company_id, location_class, location_id)
+	VALUES  (in_company_id, in_location_class, l_id);
+
+	RETURN l_id;    
     END;
 
 $$ language 'plpgsql';


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