summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LedgerSMB/AA.pm21
-rw-r--r--LedgerSMB/CT.pm38
-rw-r--r--LedgerSMB/Form.pm9
-rw-r--r--LedgerSMB/IR.pm39
-rw-r--r--LedgerSMB/IS.pm42
-rw-r--r--bin/aa.pl10
-rw-r--r--bin/ir.pl25
-rw-r--r--bin/is.pl28
8 files changed, 182 insertions, 30 deletions
diff --git a/LedgerSMB/AA.pm b/LedgerSMB/AA.pm
index 8c4c4ad9..5a523cd0 100644
--- a/LedgerSMB/AA.pm
+++ b/LedgerSMB/AA.pm
@@ -886,6 +886,25 @@ sub transactions {
WHERE lower(description)
LIKE '$var'))|;
}
+
+ if ($form->{invoice_type}) {
+
+ if ( $form->{invoice_type} == 2 ) {
+
+ $where .= qq|
+ AND a.on_hold = 'f'
+ |;
+ }
+
+ if ($form->{invoice_type} == 3) {
+
+ $where .= qq|
+ AND a.on_hold = 't'
+ |;
+ }
+ }
+
+ # the third state, all invoices, sets no explicit toggles. It just selects them all, as normal.
$query .= "WHERE $where
ORDER BY $sortorder";
@@ -972,7 +991,7 @@ sub get_name {
FROM $form->{vc} c
JOIN entity ON (entity.id = c.entity_id)
LEFT JOIN business b ON (b.id = c.business_id)
- WHERE c.id = ?|;
+ WHERE c.entity_id = ?|;
# TODO: Add location join
@queryargs = ( $form->{"$form->{vc}_id"} );
diff --git a/LedgerSMB/CT.pm b/LedgerSMB/CT.pm
index 785d2dc3..6aa07459 100644
--- a/LedgerSMB/CT.pm
+++ b/LedgerSMB/CT.pm
@@ -264,42 +264,46 @@ sub _save_vc {
}
if (!$updated){
# Creating Entity
- $query = qq|INSERT INTO entity (name, entity_class) VALUES (?, ?)|;
+ ($form->{entity_id}) = $dbh->selectrow_array("SELECT nextval('entity_id_seq')");
+ $query = qq|INSERT INTO entity (id, name, entity_class) VALUES (?, ?)|;
$sth = $dbh->prepare($query);
- $sth->execute($form->{name}, $form->{entity_class});
+ $sth->execute($form->{entity_id}, $form->{name}, $form->{entity_class});
$sth->finish;
- ($form->{entity_id}) =
- $dbh->selectrow_array("SELECT currval('entity_id_seq')");
+
# Creating LOCATION
+ ($form->{location_id}) =
+ $dbh->selectrow_array("SELECT nextval('location_id_seq')");
$query = qq|
INSERT INTO location
- (line_one, line_two, city_province, mail_code,
- country_id)
+ (id, line_one, line_two, city_province, mail_code,
+ country_id, location_class,created)
VALUES
(?, ?, ?, ?,
(SELECT id FROM country
- WHERE short_name = ? OR name = ?))
- |;
+ WHERE short_name = ? OR name = ?),
+ 1, current_date)
+ |; # location class 1 is Billing. This is a sensible default.
$sth = $dbh->prepare($query);
- $sth->execute($form->{address1}, $form->{address2},
+ $sth->execute($form->{location_id}, $form->{address1}, $form->{address2},
"$form->{city}, $form->{state}", $form->{zipcode},
$form->{country}, $form->{country}
) || $form->dberror($query);
- ($form->{location_id}) =
- $dbh->selectrow_array("SELECT currval('location_id_seq')");
+
#Creating company
+ # Removed entity_class_id ~Aurynn
+ # removed primary_location_id ~Aurynn
$query = qq|
INSERT INTO company
- (entity_id, entity_class_id, legal_name,
- primary_location_id, tax_id)
+ (entity_id, legal_name, tax_id)
VALUES
- (?, ?, ?, ?, ?)
+ (?, ?, ?)
|;
$sth = $dbh->prepare($query) || $form->dberror($query);
- $sth->execute($form->{entity_id}, $form->{entity_class},
+ $sth->execute($form->{entity_id}, # $form->{entity_class}, # removed entity_class_id ~Aurynn
$form->{name},
- $form->{location_id}, $form->{taxnumber});
+ # $form->{location_id}, # removed by ~aurynn
+ $form->{taxnumber});
#Creating customer record
$query = qq|
INSERT INTO customer
@@ -331,7 +335,7 @@ sub save_customer {
my ( $self, $myconfig, $form ) = @_;
- # connect to database
+ # connect to databaseĀµ
my $dbh = $form->{dbh};
my $query;
my $sth;
diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm
index 4a2d0a65..7d263fdd 100644
--- a/LedgerSMB/Form.pm
+++ b/LedgerSMB/Form.pm
@@ -1201,10 +1201,11 @@ sub get_name {
my $name = $self->like( lc $self->{$table} );
my $query = qq|
- SELECT * FROM $table
- WHERE (lower(name) LIKE ? OR ${table}number LIKE ?)
+ SELECT * FROM $table t
+ JOIN entity e ON t.entity_id = e.id
+ WHERE (lower(e.name) LIKE ? OR t.${table}number LIKE ?)
$where
- ORDER BY name|;
+ ORDER BY e.name|;
unshift( @queryargs, $name, $name );
my $sth = $self->{dbh}->prepare($query);
@@ -1726,7 +1727,7 @@ sub lastname_used {
$where = "AND $where " if $where;
$inv_notes = "ct.invoice_notes," if $vc eq 'customer';
my $query = qq|
- SELECT entity.name, ct.curr AS currency, ct.id AS ${vc}_id,
+ SELECT entity.name, ct.curr AS currency, entity_id AS ${vc}_id,
current_date + ct.terms AS duedate,
$inv_notes
ct.curr AS currency
diff --git a/LedgerSMB/IR.pm b/LedgerSMB/IR.pm
index d651a520..ff0b2704 100644
--- a/LedgerSMB/IR.pm
+++ b/LedgerSMB/IR.pm
@@ -1044,7 +1044,8 @@ sub retrieve_invoice {
SELECT a.invnumber, a.transdate, a.duedate,
a.ordnumber, a.quonumber, a.paid, a.taxincluded,
a.notes, a.intnotes, a.curr AS currency,
- a.vendor_id, a.language_code, a.ponumber
+ a.vendor_id, a.language_code, a.ponumber,
+ a.on_hold
FROM ap a
WHERE id = ?|;
$sth = $dbh->prepare($query);
@@ -1375,5 +1376,39 @@ sub item_links {
$sth->finish;
}
-1;
+sub toggle_on_hold {
+
+ my $self = shift @_;
+ my $form = shift @_;
+
+ if ($form->{id}) { # it's an existing (.. probably) invoice.
+
+ my $dbh = $form->{dbh};
+ my $sth = $dbh->prepare("SELECT on_hold from ar where ar.id = ?");
+ $sth->execute($form->{id});
+ my $state = $sth->fetchrow_array;
+ my $sth;
+ my $n_s; # new state
+ if ($state[0] == 't') {
+
+ # Turn it off
+ $n_s = 'f';
+
+ } else {
+ $n_s = 't';
+ }
+
+ my $sth = $dbh->prepare("update ar set on_hold = ?::boolean where ar.id = ?");
+ my $code = $dbh->execute($ns, $form->{id});
+
+ return 1;
+
+ } else { # This shouldn't even be possible, but check for it anyway.
+
+ # Definitely, DEFINITELY check it.
+ # happily return 0. Find out about proper error states.
+ return 0;
+ }
+}
+1; \ No newline at end of file
diff --git a/LedgerSMB/IS.pm b/LedgerSMB/IS.pm
index 42fb5a2b..3ffbc1ed 100644
--- a/LedgerSMB/IS.pm
+++ b/LedgerSMB/IS.pm
@@ -1759,7 +1759,8 @@ sub retrieve_invoice {
a.duedate, a.taxincluded, a.curr AS currency,
a.employee_id, e.name AS employee, a.till,
a.entity_id,
- a.language_code, a.ponumber
+ a.language_code, a.ponumber,
+ a.on_hold
FROM ar a
LEFT JOIN employee e ON (e.entity_id = a.employee_id)
WHERE a.id = ?|;
@@ -2039,5 +2040,44 @@ sub exchangerate_defaults {
}
+=pod
+
+=cut
+
+sub toggle_on_hold {
+
+ my $self = shift @_;
+ my $form = shift @_;
+
+ if ($form->{id}) { # it's an existing (.. probably) invoice.
+
+ my $dbh = $form->{dbh};
+ my $sth = $dbh->prepare("SELECT on_hold from ar where ar.id = ?");
+ $sth->execute($form->{id});
+ my $state = $sth->fetchrow_array;
+ my $sth;
+ my $n_s; # new state
+ if ($state[0] == 't') {
+
+ # Turn it off
+ $n_s = 'f';
+
+ } else {
+ $n_s = 't';
+ }
+
+ my $sth = $dbh->prepare("update ar set on_hold = ?::boolean where ar.id = ?");
+ my $code = $dbh->execute($ns, $form->{id});
+
+ return 1;
+
+ } else { # This shouldn't even be possible, but check for it anyway.
+
+ # Definitely, DEFINITELY check it.
+ # happily return 0. Find out about proper error states.
+ return 0;
+ }
+}
+
1;
diff --git a/bin/aa.pl b/bin/aa.pl
index fc398b81..73550101 100644
--- a/bin/aa.pl
+++ b/bin/aa.pl
@@ -1424,6 +1424,16 @@ qq|<input name="l_transdate" class=checkbox type=checkbox value=Y checked> |
</table>
</td>
</tr>
+
+ <tr>
+ <td>
+ |.$locale->text('All Invoices').qq|: <input type="radio" name="invoice_type" checked value="1">
+ |.$locale->text('Active').qq|: <input type="radio" name="invoice_type" value="2">
+ |.$locale->text('On Hold').qq|: <input type="radio" name="invoice_type" value="3">
+ <br/>
+ </td>
+ </tr>
+
<tr>
<td>
<table>
diff --git a/bin/ir.pl b/bin/ir.pl
index 50c7c51f..ed646c00 100644
--- a/bin/ir.pl
+++ b/bin/ir.pl
@@ -519,13 +519,22 @@ qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</texta
$form->{oldinvtotal} = $form->{invtotal};
$form->{invtotal} =
- $form->format_amount( \%myconfig, $form->{invtotal}, 2, 0 );
+ $form->format_amount( \%myconfig, $form->{invtotal}, 2, 0 );
+
+ my $hold;
+
+ if ($form->{on_hold}) {
+
+ $hold = qq| <font size="17"><b> This invoice is On Hold </b></font> |;
+ }
print qq|
<tr>
<td>
<table width=100%>
<tr valign=bottom>
+ | . $hold . qq|
+
<td>
<table>
<tr>
@@ -681,12 +690,14 @@ qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></t
{ ndx => 7, key => 'H', value => $locale->text('Schedule') },
'delete' =>
{ ndx => 8, key => 'D', value => $locale->text('Delete') },
+ 'on_hold' =>
+ { ndx => 9, key=> 'O', value => $locale->text('On Hold') },
);
if ( $form->{id} ) {
if ( $form->{locked} ) {
- for ( "post", "delete" ) { delete $button{$_} }
+ for ( "post", "delete", 'on_hold' ) { delete $button{$_} }
}
}
@@ -1119,3 +1130,13 @@ sub yes {
}
+sub on_hold {
+
+ if ($form->{id}) {
+
+ my $toggled = IS->toggle_on_old($form);
+
+ #&invoice_links(); # is that it?
+ &edit(); # it was already IN edit for this to be reached.
+ }
+} \ No newline at end of file
diff --git a/bin/is.pl b/bin/is.pl
index 3f8f6daa..a940fa7a 100644
--- a/bin/is.pl
+++ b/bin/is.pl
@@ -568,13 +568,21 @@ qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</texta
$form->{oldinvtotal} = $form->{invtotal};
$form->{invtotal} =
- $form->format_amount( \%myconfig, $form->{invtotal}, 2, 0 );
+ $form->format_amount( \%myconfig, $form->{invtotal}, 2, 0 );
+
+ my $hold;
+
+ if ($form->{on_hold}) {
+
+ $hold = qq| <font size="17"><b> This invoice is On Hold </b></font> |;
+ }
print qq|
<tr>
<td>
<table width=100%>
<tr valign=bottom>
+ | . $hold . qq|
<td>
<table>
<tr>
@@ -723,6 +731,8 @@ qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></t
# type=submit $locale->text('Sales Order')
if ( !$form->{readonly} ) {
+
+ # changes by Aurynn to add an On Hold button
%button = (
'update' =>
@@ -752,6 +762,8 @@ qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></t
{ ndx => 10, key => 'H', value => $locale->text('Schedule') },
'delete' =>
{ ndx => 11, key => 'D', value => $locale->text('Delete') },
+ 'on_hold' =>
+ { ndx => 12, key => 'O', value => $locale->text('On Hold') },
);
if ( $form->{id} ) {
@@ -772,9 +784,9 @@ qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></t
else {
if ( $transdate > $closedto ) {
-
+ # Added on_hold, by Aurynn.
for ( "update", "ship_to", "print", "e_mail", "post",
- "schedule" )
+ "schedule", "on_hold" )
{
$allowed{$_} = 1;
}
@@ -1177,3 +1189,13 @@ sub yes {
}
+sub on_hold {
+
+ if ($form->{id}) {
+
+ my $toggled = IS->toggle_on_old($form);
+
+ #&invoice_links(); # is that it?
+ &edit(); # it was already IN edit for this to be reached.
+ }
+} \ No newline at end of file