diff options
-rw-r--r-- | LedgerSMB/DBObject/Customer.pm | 4 | ||||
-rwxr-xr-x | LedgerSMB/Template/HTML.pm | 2 | ||||
-rw-r--r-- | UI/Customer/customer.html | 127 | ||||
-rw-r--r-- | UI/lib/ui-header.html | 9 | ||||
-rw-r--r-- | scripts/customer.pl | 39 | ||||
-rw-r--r-- | scripts/payment.pl | 4 | ||||
-rw-r--r-- | sql/Pg-database.sql | 3 | ||||
-rw-r--r-- | sql/modules/Location.sql | 8 | ||||
-rw-r--r-- | sql/modules/Roles.sql | 1 | ||||
-rw-r--r-- | sql/modules/Vendor.sql | 60 |
10 files changed, 121 insertions, 136 deletions
diff --git a/LedgerSMB/DBObject/Customer.pm b/LedgerSMB/DBObject/Customer.pm index 36b4ed62..09f8e3dd 100644 --- a/LedgerSMB/DBObject/Customer.pm +++ b/LedgerSMB/DBObject/Customer.pm @@ -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 @@ sub search { } -1;
\ No newline at end of file +1; diff --git a/LedgerSMB/Template/HTML.pm b/LedgerSMB/Template/HTML.pm index 9159098e..ca748dd3 100755 --- a/LedgerSMB/Template/HTML.pm +++ b/LedgerSMB/Template/HTML.pm @@ -97,7 +97,7 @@ sub process { $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 => ';', diff --git a/UI/Customer/customer.html b/UI/Customer/customer.html index 23bb064b..88020d1d 100644 --- a/UI/Customer/customer.html +++ b/UI/Customer/customer.html @@ -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 - </td> - <td> - <label for="discount"><?lsmb text('Discount %:') ?></label> - <input id="discount" name="discount" type="textarea" - value="<?lsmb customer.discount ?>"> + <input id="terms" name="terms" type="text" + value="<?lsmb terms ?>"> days </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,21 +104,22 @@ <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" @@ -133,8 +127,6 @@ 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> diff --git a/UI/lib/ui-header.html b/UI/lib/ui-header.html index 5a429866..af703b32 100644 --- a/UI/lib/ui-header.html +++ b/UI/lib/ui-header.html @@ -6,7 +6,16 @@ <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" /> diff --git a/scripts/customer.pl b/scripts/customer.pl index 7fc238da..76fa8a56 100644 --- a/scripts/customer.pl +++ b/scripts/customer.pl @@ -44,14 +44,14 @@ of the customer informations. 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 @@ This method creates a blank screen for entering a customer's information. 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 @@ sub search { 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 @@ sub search { # 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 @@ sub save { 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 { diff --git a/scripts/payment.pl b/scripts/payment.pl index 01e32fc7..b6dd87d4 100644 --- a/scripts/payment.pl +++ b/scripts/payment.pl @@ -157,8 +157,8 @@ my $template; $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 :) diff --git a/sql/Pg-database.sql b/sql/Pg-database.sql index 67dc0a5a..9737b474 100644 --- a/sql/Pg-database.sql +++ b/sql/Pg-database.sql @@ -130,7 +130,6 @@ SELECT SETVAL('location_class_id_seq',4); 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 @@ COMMENT ON COLUMN company.tax_id IS $$ In the US this would be a EIN. $$; 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 entity_employee ( 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)); diff --git a/sql/modules/Location.sql b/sql/modules/Location.sql index fb93cf82..d4f8f9f5 100644 --- a/sql/modules/Location.sql +++ b/sql/modules/Location.sql @@ -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 @@ DECLARE 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 diff --git a/sql/modules/Roles.sql b/sql/modules/Roles.sql index a44ebcf4..864fb4e7 100644 --- a/sql/modules/Roles.sql +++ b/sql/modules/Roles.sql @@ -1376,3 +1376,4 @@ GRANT SELECT ON user_preference TO public; 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; diff --git a/sql/modules/Vendor.sql b/sql/modules/Vendor.sql index d075b62e..e18f88a5 100644 --- a/sql/modules/Vendor.sql +++ b/sql/modules/Vendor.sql @@ -170,9 +170,9 @@ $$ language 'plpgsql'; 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 @@ create or replace function _entity_location_save( 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'; |