[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Misc patches for a bunch of little issues with 1.3
- Subject: [PATCH] Misc patches for a bunch of little issues with 1.3
- From: John Locke <..hidden..>
- Date: Tue, 12 Oct 2010 09:14:48 -0700
---
LedgerSMB/HR.pm | 40 ++++++++++++++++++++--------------------
LedgerSMB/PriceMatrix.pm | 8 ++++----
LedgerSMB/Setting.pm | 2 +-
UI/payments/payment2.html | 4 ++--
sql/Pg-database.sql | 6 +++++-
sql/modules/Account.sql | 2 +-
6 files changed, 33 insertions(+), 29 deletions(-)
diff --git a/LedgerSMB/HR.pm b/LedgerSMB/HR.pm
index 2fbd297..54a5a09 100644
--- a/LedgerSMB/HR.pm
+++ b/LedgerSMB/HR.pm
@@ -44,7 +44,7 @@ sub get_employee {
my $notid = "";
if ( $form->{id} ) {
- $query = qq|SELECT e.* FROM employee e WHERE e.id = ?|;
+ $query = qq|SELECT e.* FROM employee e WHERE e.employeenumber = ?|;
$sth = $dbh->prepare($query);
$sth->execute( $form->{id} )
|| $form->dberror( __FILE__ . ':' . __LINE__ . ':' . $query );
@@ -61,10 +61,10 @@ sub get_employee {
$sth->finish;
# get manager
- $form->{managerid} *= 1;
+ $form->{manager_id} *= 1;
- $sth = $dbh->prepare("SELECT name FROM employee WHERE id = ?");
- $sth->execute( $form->{managerid} );
+ $sth = $dbh->prepare("SELECT first_name FROM employee WHERE
entity_id = ?");
+ $sth->execute( $form->{manager_id} );
( $form->{manager} ) = $sth->fetchrow_array;
$notid = qq|AND id != | . $dbh->quote( $form->{id} );
@@ -78,7 +78,7 @@ sub get_employee {
# get managers
$query = qq|
- SELECT id, name
+ SELECT entity_id, first_name
FROM employee
WHERE sales = '1'
AND role = 'manager'
@@ -110,11 +110,11 @@ sub save_employee {
my $uid = localtime;
$uid .= "$$";
- $query = qq|INSERT INTO employee (name) VALUES ('$uid')|;
+ $query = qq|INSERT INTO employee (first_name) VALUES ('$uid')|;
$dbh->do($query)
|| $form->dberror( __FILE__ . ':' . __LINE__ . ':' . $query );
- $query = qq|SELECT id FROM employee WHERE name = '$uid'|;
+ $query = qq|SELECT entity_id FROM employee WHERE first_name =
'$uid'|;
$sth = $dbh->prepare($query);
$sth->execute
|| $form->dberror( __FILE__ . ':' . __LINE__ . ':' . $query );
@@ -123,15 +123,15 @@ sub save_employee {
$sth->finish;
}
- my ( $null, $managerid ) = split /--/, $form->{manager};
- $managerid *= 1;
+ my ( $null, $manager_id ) = split /--/, $form->{manager};
+ $manager_id *= 1;
$form->{sales} *= 1;
$query = qq|
UPDATE employee SET employeenumber = ?,
- name = ?,
+ first_name = ?,
address1 = ?,
address2 = ?,
city = ?,
@@ -150,20 +150,20 @@ sub save_employee {
dob = ?,
iban = ?,
bic = ?,
- managerid = ?
+ manager_id = ?
WHERE id = ?|;
$sth = $dbh->prepare($query);
$form->{dob} ||= undef;
$form->{startdate} ||= undef;
$form->{enddate} ||= undef;
$sth->execute(
- $form->{employeenumber}, $form->{name}, $form->{address1},
+ $form->{employeenumber}, $form->{first_name},
$form->{address1},
$form->{address2}, $form->{city}, $form->{state},
$form->{zipcode}, $form->{country}, $form->{workphone},
$form->{homephone}, $form->{startdate}, $form->{enddate},
$form->{notes}, $form->{role}, $form->{sales},
$form->{email}, $form->{ssn}, $form->{dob},
- $form->{iban}, $form->{bic}, $managerid,
+ $form->{iban}, $form->{bic}, $manager_id,
$form->{id}
) || $form->dberror( __FILE__ . ':' . __LINE__ . ':' . $query );
@@ -196,8 +196,8 @@ sub employees {
my $dbh = $form->{dbh};
my $where = "1 = 1";
- $form->{sort} = ( $form->{sort} ) ? $form->{sort} : "name";
- my @a = qw(name);
+ $form->{sort} = ( $form->{sort} ) ? $form->{sort} : "first_name";
+ my @a = qw(first_name);
my $sortorder = $form->sort_order( \@a );
my $var;
@@ -209,9 +209,9 @@ sub employees {
if ( $form->{startdateto} ) {
$where .= " AND e.startddate <= " . $dbh->quote(
$form->{startdateto} );
}
- if ( $form->{name} ne "" ) {
- $var = $dbh->quote( $form->like( lc $form->{name} ) );
- $where .= " AND lower(e.name) LIKE $var";
+ if ( $form->{first_name} ne "" ) {
+ $var = $dbh->quote( $form->like( lc $form->{first_name} ) );
+ $where .= " AND lower(e.first_name) LIKE $var";
}
if ( $form->{notes} ne "" ) {
$var = $dbh->quote( $form->like( lc $form->{notes} ) );
@@ -231,9 +231,9 @@ sub employees {
}
my $query = qq|
- SELECT e.*, m.name AS manager
+ SELECT e.*, m.first_name AS manager
FROM employee e
- LEFT JOIN employee m ON (m.id = e.managerid)
+ LEFT JOIN employee m ON (m.entity_id = e.manager_id)
WHERE $where
ORDER BY $sortorder|;
diff --git a/LedgerSMB/PriceMatrix.pm b/LedgerSMB/PriceMatrix.pm
index 2538fa0..f2afb4b 100644
--- a/LedgerSMB/PriceMatrix.pm
+++ b/LedgerSMB/PriceMatrix.pm
@@ -47,7 +47,7 @@ sub price_matrix_query {
if ( $form->{customer_id} ) {
my $defaultcurrency = $form->{dbh}->quote(
$form->{defaultcurrency} );
$query = qq|
- SELECT p.parts_id, p.customer_id AS entity_id, + SELECT
p.parts_id, p.credit_id AS entity_id, NULL AS pricegroup_id,
p.pricebreak, p.sellprice, p.validfrom,
p.validto, p.curr, NULL AS pricegroup, @@ -58,11 +58,11 @@ sub
price_matrix_query {
$transdate
AND coalesce(p.validto, $transdate) >= $transdate
- AND p.customer_id = $entity_id
+ AND p.credit_id = $entity_id
UNION
- SELECT p.parts_id, p.customer_id AS entity_id, + SELECT
p.parts_id, p.credit_id AS entity_id, p.pricegroup_id,
p.pricebreak, p.sellprice, p.validfrom,
p.validto, p.curr, g.pricegroup, 2 AS priority
@@ -78,7 +78,7 @@ sub price_matrix_query {
UNION
- SELECT p.parts_id, p.customer_id AS entity_id, + SELECT
p.parts_id, p.credit_id AS entity_id, p.pricegroup_id,
p.pricebreak, p.sellprice, p.validfrom,
p.validto, p.curr, g.pricegroup, 3 AS priority
diff --git a/LedgerSMB/Setting.pm b/LedgerSMB/Setting.pm
index 5bc56aa..a65fe0f 100644
--- a/LedgerSMB/Setting.pm
+++ b/LedgerSMB/Setting.pm
@@ -168,6 +168,6 @@ sub get_currencies {
my $self = shift;
my @data = $self->exec_method(funcname => 'setting__get_currencies');
$self->{currencies} = $data[0]->{setting__get_currencies};
- return @{$self->{currencies}};
+ return split /,/, $self->{currencies};
}
diff --git a/UI/payments/payment2.html
b/UI/payments/payment2.html
index b000d07..b485673 100644
--- a/UI/payments/payment2.html
+++ b/UI/payments/payment2.html
@@ -302,7 +302,7 @@ onLoad="maximize_minimize_on_load('div_topay_state',
'UI/payments/img/down.gif',
<td align="center">
<input name="overpayment_topay_<?lsmb overpayment_item -?>"
- id="overpayment_topay_<?lsmboverpayment_item ?>"
+ id="overpayment_topay_<?lsmb overpayment_item -?>"
value="<?lsmb IF unhandled_overpayment.value > 0 -?>
<?lsmb unhandled_overpayment.value -?>
<?lsmb END -?>" @@ -357,4 +357,4 @@
onLoad="maximize_minimize_on_load('div_topay_state',
'UI/payments/img/down.gif',
</div> </form>
</body>
-</html>
\ No newline at end of file
+</html>
diff --git a/sql/Pg-database.sql b/sql/Pg-database.sql
index f119cf8..1285b5d 100644
--- a/sql/Pg-database.sql
+++ b/sql/Pg-database.sql
@@ -928,6 +928,7 @@ CREATE VIEW employee AS
CREATE VIEW customer AS SELECT c.id,
+ e.name,
emd.entity_id, emd.entity_class, emd.discount,
@@ -950,11 +951,13 @@ CREATE VIEW customer AS
join entity_bank_account eba on emd.entity_id = eba.entity_id
Left join entity_note ein on ein.ref_key = emd.entity_id
join company c on c.entity_id = emd.entity_id
+ join entity e on c.entity_id = e.id
where emd.entity_class = 2;
CREATE VIEW vendor AS SELECT - c.id, + c.id,
+ e.name,
emd.entity_id, emd.entity_class, emd.discount,
@@ -977,6 +980,7 @@ CREATE VIEW vendor AS
LEFT join entity_bank_account eba on emd.entity_id = eba.entity_id
left join entity_note ein on ein.ref_key = emd.entity_id
join company c on c.entity_id = emd.entity_id
+ join entity e on c.entity_id = e.id
where emd.entity_class = 1;
COMMENT ON TABLE entity_credit_account IS $$ This is a metadata table
for ALL entities in LSMB; it deprecates the use of customer and vendor
specific tables (which were nearly identical and largely redundant), and
replaces it with a single point of metadata. $$;
diff --git a/sql/modules/Account.sql b/sql/modules/Account.sql
index 74d040d..1237fa1 100644
--- a/sql/modules/Account.sql
+++ b/sql/modules/Account.sql
@@ -159,7 +159,7 @@ RETURNS void AS $BODY$
IF NOT FOUND THEN
-- This is a new account. Insert the relevant data.
- SELECT chart_id INTO v_chart_id FROM charts WHERE accno =
in_accno;
+ SELECT id INTO v_chart_id FROM chart WHERE accno = in_accno;
INSERT INTO cr_coa_to_account (chart_id, account) VALUES
(v_chart_id, in_accno||'--'||in_description);
END IF;
-- Already found, no need to do anything. =) -- 1.5.4.3
--
John Locke
"Open Source Solutions for Small Business Problems"
published by Charles River Media, June 2004
Follow me on Twitter: http://twitter.com/freelock
http://www.freelock.com