[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[3325] trunk
- Subject: SF.net SVN: ledger-smb:[3325] trunk
- From: ..hidden..
- Date: Sat, 25 Jun 2011 04:52:20 +0000
Revision: 3325
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3325&view=rev
Author: einhverfr
Date: 2011-06-25 04:52:20 +0000 (Sat, 25 Jun 2011)
Log Message:
-----------
Correcting div visibility when editing contacts, addresses, etc
Modified Paths:
--------------
trunk/LedgerSMB/RP.pm
trunk/UI/Contact/contact.html
trunk/sql/Pg-database.sql
Modified: trunk/LedgerSMB/RP.pm
===================================================================
--- trunk/LedgerSMB/RP.pm 2011-06-24 14:52:19 UTC (rev 3324)
+++ trunk/LedgerSMB/RP.pm 2011-06-25 04:52:20 UTC (rev 3325)
@@ -2505,5 +2505,82 @@
}
+sub inventory_accounts {
+ my ( $self, $myconfig, $form ) = @_;
+ my $dbh = $form->{dbh};
+ my $query = qq|
+ SELECT id, accno, description FROM chart
+ WHERE link = 'IC'
+ ORDER BY accno|;
+ my $sth = $dbh->prepare($query);
+ $sth->execute || $form->dberror($query);
+ while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+ push @{ $form->{selectIC} }, $ref;
+ }
+ $sth->finish;
+ $dbh->{dbh};
+}
+
+sub inventory {
+ my ( $self, $myconfig, $form ) = @_;
+ my $dbh = $form->{dbh};
+ my $where_date = '';
+ my $where_date = '';
+ my $where_date_acc = '';
+ my $where_product = '';
+ my $where_chart = '';
+ if($form->{fromdate}) {
+ $where_date.=" AND a.transdate>='".$form->{fromdate}."' ";
+ $where_date_acc.=" AND acc.transdate>='".$form->{fromdate}."' ";
+ }
+ if($form->{todate}) {
+ $where_date.=" AND a.transdate<='".$form->{todate}."' ";
+ $where_date_acc.=" AND acc.transdate<='".$form->{todate}."' ";
+ }
+
+ if($form->{partnumber}) {
+ $where_product.= " AND partnumber LIKE '%".$form->{partnumber}."%' ";
+ }
+ if($form->{description}) {
+ $where_product.= " AND description LIKE '%".$form->{description}."%' ";
+ }
+ if($form->{inventory_account}) {
+ $where_chart .= " AND p.inventory_accno_id = ".$form->{inventory_account}." ";
+ }
+
+ my $query = qq|
+ SELECT id, description, partnumber, sum(qty) as qty, sum(exited) as exited, sum(entered) as entered, sum(entered)-sum(exited) as value FROM
+ (
+ SELECT p.id, p.description, p.partnumber, -sum(i.qty) as qty, 0 as exited, 0 as entered
+ FROM invoice i
+ JOIN ar a ON (a.id=i.trans_id $where_date)
+ JOIN parts p ON (i.parts_id=p.id AND p.inventory_accno_id>0 $where_chart)
+ GROUP BY p.id, p.description, p.partnumber
+
+ UNION ALL
+
+ SELECT p.id, p.description, p.partnumber, 0, sum(acc.amount) as exited, 0 as entered
+ FROM acc_trans acc
+ JOIN parts p ON (p.inventory_accno_id=acc.chart_id AND p.inventory_accno_id>0 $where_chart)
+ JOIN invoice i ON (i.id=acc.invoice_id AND i.parts_id=p.id)
+ WHERE acc.trans_id NOT IN (SELECT id FROM ap) $where_date_acc
+ GROUP BY p.id, p.description, p.partnumber
+
+ UNION ALL
+
+ SELECT p.id, p.description, p.partnumber, -sum(i.qty) as qty, 0 as exited, -sum(i.qty*i.sellprice) as entered
+ FROM invoice i
+ JOIN ap a ON (a.id=i.trans_id $where_date)
+ JOIN parts p ON (i.parts_id=p.id AND p.inventory_accno_id>0 $where_chart)
+ GROUP BY p.id, p.description, p.partnumber
+ ) AS temp WHERE 1=1 $where_product GROUP BY id, description, partnumber HAVING sum(entered)-sum(exited)!=0 OR sum(qty)!=0 ORDER BY description;|;
+
+ my $sth = $dbh->prepare($query);
+ $sth->execute || $form->dberror($query);
+ while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+ push @{ $form->{inventory} }, $ref;
+ }
+ $sth->finish;
+ $dbh->{dbh};
+}
1;
-
Modified: trunk/UI/Contact/contact.html
===================================================================
--- trunk/UI/Contact/contact.html 2011-06-24 14:52:19 UTC (rev 3324)
+++ trunk/UI/Contact/contact.html 2011-06-25 04:52:20 UTC (rev 3325)
@@ -29,8 +29,6 @@
target_div = 'bank_div';
ELSIF action== 'save_notes';
target_div = 'notes_div';
-ELSE;
- target_div = '';
END ?>
<body onload="init('<?lsmb target_div ?>')">
<?lsmb IF name ?>
@@ -76,8 +74,8 @@
<form name="hr" action="<?lsmb script ?>" method="post">
<?lsmb PROCESS input element_data = {
type = "hidden"
- name = "entity_id"
- value = entity_id
+ name = "target_div"
+ value = 'hr_div'
} ?>
<?lsmb PROCESS input element_data = {
type = "hidden"
@@ -218,6 +216,11 @@
?><?lsmb END ?>
<div class="listtop"><strong><?lsmb text("$operation $entity_classname") ?></strong></div>
<form name="customer" method="post" action="<?lsmb script ?>">
+<?lsmb PROCESS input element_data = {
+ type = "hidden"
+ name = "target_div"
+ value = 'company_div'
+ } ?>
<?lsmb PROCESS input element_data = {
type = "hidden"
name = "entity_id"
@@ -648,6 +651,11 @@
name = "form_id"
value = form_id
} ?>
+<?lsmb PROCESS input element_data = {
+ type = "hidden"
+ name = "target_div"
+ value = 'location_div'
+ } ?>
<?lsmb PROCESS input element_data = {
type="hidden"
name="entity_id"
@@ -685,10 +693,11 @@
<!-- TODO: Automate links with AJAX -->
<a href="<?lsmb script ?>?action=edit&entity_id=<?lsmb entity_id
?>&location_id=<?lsmb loc.id ?>&credit_id=<?lsmb
- credit_id ?>">[edit]</a>
+ credit_id ?>&target_div=location_div">[edit]</a>
<a href="<?lsmb script ?>?action=delete_location&entity_id=<?lsmb
entity_id ?>&location_id=<?lsmb loc.id
- ?>&credit_id = <?lsmb credit_id ?>">[delete]</a>
+ ?>&credit_id = <?lsmb credit_id
+ ?>&target_div=location_div">[delete]</a>
</td>
</tr>
<?lsmb END ?>
@@ -807,13 +816,13 @@
?>&contact_class=<?lsmb tt_url(ct.class_id)
?>&description=<?lsmb tt_url(ct.description)
?>&action=edit&credit_id=<?lsmb
- tt_url(credit_id) ?>"
+ tt_url(credit_id) ?>&target_div=contact_div"
>[<?lsmb text('Edit'); ?>]</a>
<a href="<?lsmb tt_url(script)
?>?entity_id=<?lsmb tt_url(entity_id)
?>&contact_id=<?lsmb tt_url(ct.id)
?>&action=delete_contact&credit_id=<?lsmb
- tt_url(credit_id) ?>"
+ tt_url(credit_id) ?>&target_div=contact_div"
>[<?lsmb text('Delete'); ?>]</a>
</td>
</tr>
@@ -825,6 +834,11 @@
name = "form_id"
value = form_id
} ?>
+<?lsmb PROCESS input element_data = {
+ type = "hidden"
+ name = "target_div"
+ value = 'contact_div'
+ } ?>
<?lsmb PROCESS input element_data = {
type="hidden"
name="entity_id"
@@ -910,10 +924,12 @@
<td class="iban"><?lsmb ba.iban ?></td>
<td class="actions">
<a href="<?lsmb script ?>?action=edit_bank_acct&entity_id=<?lsmb
- entity_id ?>&bank_account_id=<?lsmb ba.id ?>"
+ entity_id ?>&bank_account_id=<?lsmb ba.id
+ ?>&target_div=bank_div"
>[Edit]</a>
<a href="<?lsmb script ?>?action=delete_bank_acct&entity_id=<?lsmb
- entity_id ?>&bank_account_id=<?lsmb ba.id ?>"
+ entity_id ?>&bank_account_id=<?lsmb ba.id
+ ?>&target_div=bank_div"
>[Delete]</a>
</td>
</tr>
@@ -925,6 +941,11 @@
name = "form_id"
value = form_id
} ?>
+<?lsmb PROCESS input element_data = {
+ type = "hidden"
+ name = "target_div"
+ value = 'bank_div'
+ } ?>
<?lsmb PROCESS input element_data = {
type="hidden"
name="entity_id"
@@ -972,6 +993,11 @@
<form action="<?lsmb script ?>" method="post">
<?lsmb PROCESS input element_data = {
type = "hidden"
+ name = "target_div"
+ value = 'notes_div'
+ } ?>
+<?lsmb PROCESS input element_data = {
+ type = "hidden"
name = "form_id"
value = form_id
} ?>
Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql 2011-06-24 14:52:19 UTC (rev 3324)
+++ trunk/sql/Pg-database.sql 2011-06-25 04:52:20 UTC (rev 3325)
@@ -1822,23 +1822,26 @@
field_datatype ALIAS FOR $3;
BEGIN
- EXECUTE ''SELECT TABLE_ID FROM custom_table_catalog
- WHERE extends = '''''' || table_name || '''''' '';
+ perform TABLE_ID FROM custom_table_catalog
+ WHERE extends = table_name;
IF NOT FOUND THEN
BEGIN
INSERT INTO custom_table_catalog (extends)
VALUES (table_name);
- EXECUTE ''CREATE TABLE custom_''||table_name ||
+ EXECUTE ''CREATE TABLE '' ||
+ quote_ident(''custom_'' ||table_name) ||
'' (row_id INT PRIMARY KEY)'';
EXCEPTION WHEN duplicate_table THEN
-- do nothing
END;
END IF;
- EXECUTE ''INSERT INTO custom_field_catalog (field_name, table_id)
- VALUES ( '''''' || new_field_name ||'''''', (SELECT table_id FROM custom_table_catalog
- WHERE extends = ''''''|| table_name || ''''''))'';
- EXECUTE ''ALTER TABLE custom_''||table_name || '' ADD COLUMN ''
- || new_field_name || '' '' || field_datatype;
+ INSERT INTO custom_field_catalog (field_name, table_id)
+ values (new_field_name, (SELECT table_id
+ FROM custom_table_catalog
+ WHERE extends = table_name));
+ EXECUTE ''ALTER TABLE ''|| quote_ident(''custom_''||table_name) ||
+ '' ADD COLUMN '' || quote_ident(new_field_name) || '' '' ||
+ quote_ident(field_datatype);
RETURN TRUE;
END;
' LANGUAGE PLPGSQL;
@@ -1855,8 +1858,8 @@
WHERE field_name = custom_field_name AND
table_id = (SELECT table_id FROM custom_table_catalog
WHERE extends = table_name);
- EXECUTE ''ALTER TABLE custom_'' || table_name ||
- '' DROP COLUMN '' || custom_field_name;
+ EXECUTE ''ALTER TABLE '' || quote_ident(''custom_'' || table_name) ||
+ '' DROP COLUMN '' || quote_ident(custom_field_name);
RETURN TRUE;
END;
' LANGUAGE PLPGSQL;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.