diff --git a/SL/AA.pm b/SL/AA.pm index e1385a644..076e8be2d 100644 --- a/SL/AA.pm +++ b/SL/AA.pm @@ -21,9 +21,7 @@ sub post_transaction { my $disconnect = ($dbh) ? 0 : 1; # connect to database - if (! $dbh) { - $dbh = $form->dbconnect_noauto($myconfig); - } + $dbh = $form->dbconnect_noauto($myconfig) unless $dbh; my $query; my $sth; @@ -254,6 +252,10 @@ sub post_transaction { $form->{amount} = $invamount; # need for vr batch + + ($paymentaccno) = split /--/, $form->{"$form->{ARAP}_paid_$form->{paidaccounts}"}; + ($null, $paymentmethod_id) = split /--/, $form->{"paymentmethod_$form->{paidaccounts}"}; + $paymentmethod_id *= 1; if ($form->{vc} eq 'customer') { # dcn @@ -269,10 +271,6 @@ sub post_transaction { for my $dcn (qw(dcn rvc)) { $form->{$dcn} = $form->format_dcn($form->{$dcn}) } } - ($paymentaccno) = split /--/, $form->{"$form->{ARAP}_paid_$form->{paidaccounts}"}; - ($null, $paymentmethod_id) = split /--/, $form->{"paymentmethod_$form->{paidaccounts}"}; - $paymentmethod_id *= 1; - $query = qq|UPDATE $table SET invnumber = |.$dbh->quote($form->{invnumber}).qq|, @@ -1260,7 +1258,7 @@ sub company_details { my $disconnect = ($dbh) ? 0 : 1; # connect to database - $dbh = $form->dbconnect($myconfig); + $dbh = $form->dbconnect($myconfig) unless $dbh; # get rest for the customer/vendor my $query = qq|SELECT ct.$form->{vc}number, ct.name, ad.address1, ad.address2, @@ -1343,35 +1341,35 @@ sub ship_to { # connect to database my $dbh = $form->dbconnect($myconfig); - AA->company_details($myconfig, $form, $dbh); - - my $table = ($form->{vc} eq 'customer') ? 'ar' : 'ap'; - - my $query = qq|SELECT - s.shiptoname, s.shiptoaddress1, s.shiptoaddress2, - s.shiptocity, s.shiptostate, s.shiptozipcode, - s.shiptocountry, s.shiptocontact, s.shiptophone, - s.shiptofax, s.shiptoemail - FROM shipto s - WHERE trans_id = $form->{"$form->{vc}_id"} - UNION - SELECT - s.shiptoname, s.shiptoaddress1, s.shiptoaddress2, - s.shiptocity, s.shiptostate, s.shiptozipcode, - s.shiptocountry, s.shiptocontact, s.shiptophone, - s.shiptofax, s.shiptoemail - FROM shipto s - JOIN oe o ON (o.id = s.trans_id) - WHERE o.$form->{vc}_id = $form->{"$form->{vc}_id"} - UNION - SELECT - s.shiptoname, s.shiptoaddress1, s.shiptoaddress2, - s.shiptocity, s.shiptostate, s.shiptozipcode, - s.shiptocountry, s.shiptocontact, s.shiptophone, - s.shiptofax, s.shiptoemail - FROM shipto s - JOIN $table a ON (a.id = s.trans_id) - WHERE a.$form->{vc}_id = $form->{"$form->{vc}_id"}|; + AA->company_details($myconfig, $form, $dbh); + + my $table = ($form->{vc} eq 'customer') ? 'ar' : 'ap'; + + my $query = qq|SELECT + s.shiptoname, s.shiptoaddress1, s.shiptoaddress2, + s.shiptocity, s.shiptostate, s.shiptozipcode, + s.shiptocountry, s.shiptocontact, s.shiptophone, + s.shiptofax, s.shiptoemail + FROM shipto s + WHERE trans_id = $form->{"$form->{vc}_id"} + UNION + SELECT + s.shiptoname, s.shiptoaddress1, s.shiptoaddress2, + s.shiptocity, s.shiptostate, s.shiptozipcode, + s.shiptocountry, s.shiptocontact, s.shiptophone, + s.shiptofax, s.shiptoemail + FROM shipto s + JOIN oe o ON (o.id = s.trans_id) + WHERE o.$form->{vc}_id = $form->{"$form->{vc}_id"} + UNION + SELECT + s.shiptoname, s.shiptoaddress1, s.shiptoaddress2, + s.shiptocity, s.shiptostate, s.shiptozipcode, + s.shiptocountry, s.shiptocontact, s.shiptophone, + s.shiptofax, s.shiptoemail + FROM shipto s + JOIN $table a ON (a.id = s.trans_id) + WHERE a.$form->{vc}_id = $form->{"$form->{vc}_id"}|; if ($form->{id}) { $query .= qq| diff --git a/SL/Form.pm b/SL/Form.pm index f18c40890..49331bf7c 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -78,7 +78,7 @@ sub new { $self->{menubar} = 1 if $self->{path} =~ /lynx/i; - $self->{version} = "2.8.23"; + $self->{version} = "2.8.24"; $self->{dbversion} = "2.8.9"; bless $self, $type; @@ -1099,11 +1099,11 @@ sub format_line { @a = reverse @a; } - $i = $n - 1; + my $j = $n - 1; $newstr = ""; foreach $str (@a) { - $i++; - if (! ($i % $n)) { + $j++; + if (! ($j % $n)) { $newstr .= " $str"; } else { $newstr .= $str; @@ -1142,6 +1142,13 @@ sub format_dcn { my @e; my $i; + my $d; + my @n; + my $n; + my $w; + my $cd; + my $lr; + for (0 .. $#m) { @{ $m{$_} } = @m; $m = shift @m; @@ -1155,7 +1162,7 @@ sub format_dcn { $param = $1; $str = $param; - ($var, $padl) = split / /, $1; + ($var, $padl) = split / /, $param; $padl *= 1; if ($var eq 'membernumber') { @@ -1185,19 +1192,55 @@ sub format_dcn { while (/\x01(modulo.+?)\x01/) { $param = $1; - + + @e = split //, $modulo; + if ($param eq 'modulo10') { - @e = split //, $modulo; $e = 0; - for (@e) { - $e = $m{$e}[$_]; + for $n (@e) { + $e = $m{$e}[$n]; } $str = substr(10 - $e, -1); } - /\x01modulo.+?\x01(.+?)\x01modulo.+?\x01/; - $modulo = $1; + if ($param =~ /modulo(1\d+)?_/) { + ($n, $w, $lr) = split /_/, $param; + $cd = 0; + $m = $1; + + if ($lr eq 'right') { + @e = reverse @e; + } + + if ($w eq '12' || $w eq '21') { + @n = split //, $w; + + for $i (0 .. $#e) { + $n = $i % 2; + if (($d = $e[$i] * $n[$n]) > 9) { + for $n (split //, $d) { + $cd += $n; + } + } else { + $cd += $d; + } + } + } else { + @n = split //, $w; + for $i (0 .. $#e) { + $n = $i % 2; + $cd += $e[$i] * $n[$n]; + } + } + + $str = $cd % $m; + if ($m eq '10') { + if ($str > 0) { + $str = $m - $str; + } + } + } s/\x01$param\x01/$str/; diff --git a/SL/IS.pm b/SL/IS.pm index d07d3e9b5..2a98ade81 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -475,13 +475,12 @@ sub invoice_details { } } - my ($paymentaccno) = split /--/, $form->{"AR_paid_1"}; + my ($paymentaccno) = split /--/, $form->{"AR_paid_$form->{paidaccounts}"}; for $i (1 .. $form->{paidaccounts}) { if ($form->{"paid_$i"}) { push(@{ $form->{payment} }, $form->{"paid_$i"}); my ($accno, $description) = split /--/, $form->{"AR_paid_$i"}; - $paymentaccno = $accno; push(@{ $form->{paymentaccount} }, $description); push(@{ $form->{paymentdate} }, $form->{"datepaid_$i"}); push(@{ $form->{paymentsource} }, $form->{"source_$i"}); diff --git a/SL/RC.pm b/SL/RC.pm index 695224b8c..1d6fa1001 100644 --- a/SL/RC.pm +++ b/SL/RC.pm @@ -189,7 +189,7 @@ sub payment_transactions { $fx_transaction $transdate $cleared - UNION + UNION ALL SELECT ac.transdate, ac.source, ac.fx_transaction, ac.amount, ac.cleared, a.id, n.name FROM acc_trans ac @@ -201,7 +201,7 @@ sub payment_transactions { $fx_transaction $transdate $cleared - UNION + UNION ALL SELECT ac.transdate, ac.source, ac.fx_transaction, ac.amount, ac.cleared, a.id, n.name FROM acc_trans ac diff --git a/SL/RP.pm b/SL/RP.pm index b3096ab42..3079caa62 100644 --- a/SL/RP.pm +++ b/SL/RP.pm @@ -1512,6 +1512,7 @@ sub aging { c.contact, c.email, c.phone as $form->{vc}phone, c.fax as $form->{vc}fax, c.$form->{vc}number, c.taxnumber as $form->{vc}taxnumber, + a.description AS invdescription, a.invnumber, a.transdate, a.till, a.ordnumber, a.ponumber, a.notes, $c{$_}{flds}, a.duedate, a.invoice, a.id, a.curr, @@ -1581,6 +1582,194 @@ sub aging { } +sub reminder { + my ($self, $myconfig, $form) = @_; + + # connect to database + my $dbh = $form->dbconnect($myconfig); + + my $query; + + my $item; + my $curr; + + my @a = qw(company address businessnumber tel fax precision); + my %defaults = $form->get_defaults($dbh, \@a); + for (keys %defaults) { $form->{$_} = $defaults{$_} } + + $form->{currencies} = $form->get_currencies($dbh, $myconfig); + + my $where = "a.approved = '1'"; + my $name; + my $null; + my $ref; + + if ($form->{"$form->{vc}_id"}) { + $where .= qq| AND vc.id = $form->{"$form->{vc}_id"}|; + } else { + if ($form->{$form->{vc}} ne "") { + $name = $form->like(lc $form->{$form->{vc}}); + $where .= qq| AND lower(vc.name) LIKE '$name'|; + } + if ($form->{"$form->{vc}number"} ne "") { + $name = $form->like(lc $form->{"$form->{vc}number"}); + $where .= qq| AND lower(vc.$form->{vc}number) LIKE '$name'|; + } + } + + if ($form->{department}) { + ($null, $department_id) = split /--/, $form->{department}; + $where .= qq| AND a.department_id = $department_id|; + } + + $form->{sort} =~ s/;//g; + my $sortorder = ($form->{sort}) ? "vc.$form->{sort}" : "vc.name"; + + # select outstanding customers + $query = qq|SELECT DISTINCT vc.id, vc.name, vc.$form->{vc}number, + vc.language_code + FROM $form->{vc} vc + JOIN ar a ON (a.$form->{vc}_id = vc.id) + WHERE $where + AND a.paid != a.amount + ORDER BY $sortorder|; + my $sth = $dbh->prepare($query); + $sth->execute || $form->dberror; + + my @ot = (); + while ($ref = $sth->fetchrow_hashref(NAME_lc)) { + push @ot, $ref; + } + $sth->finish; + + $query = qq|SELECT s.formname + FROM status s + JOIN ar a ON (a.id = s.trans_id) + WHERE s.formname LIKE 'reminder_' + AND s.trans_id = ? + AND a.curr = ? + ORDER BY s.formname DESC|; + my $rth = $dbh->prepare($query); + + # for each company that has some stuff outstanding + $form->{currencies} ||= ":"; + + $where = qq| + a.paid != a.amount + AND a.approved = '1' + AND c.id = ? + AND a.curr = ?|; + + if ($department_id) { + $where .= qq| AND a.department_id = $department_id|; + } + + $query = qq|SELECT c.id AS vc_id, c.$form->{vc}number, c.name, c.terms, + ad.address1, ad.address2, ad.city, ad.state, ad.zipcode, ad.country, + c.contact, c.email, + c.phone as $form->{vc}phone, c.fax as $form->{vc}fax, + c.$form->{vc}number, c.taxnumber as $form->{vc}taxnumber, + a.description AS invdescription, + a.invnumber, a.transdate, a.till, a.ordnumber, a.ponumber, a.notes, + a.amount - a.paid AS due, + a.duedate, a.invoice, a.id, a.curr, + (SELECT exchangerate FROM exchangerate e + WHERE a.curr = e.curr + AND e.transdate = a.transdate) AS exchangerate, + ct.firstname, ct.lastname, ct.salutation, ct.typeofcontact, + s.* + FROM ar a + JOIN $form->{vc} c ON (a.$form->{vc}_id = c.id) + JOIN address ad ON (ad.trans_id = c.id) + LEFT JOIN contact ct ON (ct.trans_id = c.id) + LEFT JOIN shipto s ON (a.id = s.trans_id) + WHERE (a.transdate < (current_date - c.terms)) + AND $where + ORDER BY vc_id, transdate, invnumber|; + $sth = $dbh->prepare($query) || $form->dberror($query); + + $form->{AG} = (); + + for $curr (split /:/, $form->{currencies}) { + + for $item (@ot) { + + $sth->execute($item->{id}, $curr); + + while ($ref = $sth->fetchrow_hashref(NAME_lc)) { + $ref->{module} = ($ref->{invoice}) ? 'is' : 'ar'; + $ref->{module} = 'ps' if $ref->{till}; + $ref->{exchangerate} ||= 1; + $ref->{language_code} = $item->{language_code}; + + $rth->execute($ref->{id}, $curr); + $found = 0; + while (($reminder) = $rth->fetchrow_array) { + $ref->{level} = substr($reminder, -1); + $ref->{level}++; + push @{ $form->{AG} }, $ref; + $found = 1; + } + $rth->finish; + + if (! $found) { + $ref->{level}++; + push @{ $form->{AG} }, $ref; + } + } + $sth->finish; + + } + } + + # get language + $form->all_languages($myconfig, $dbh); + + # disconnect + $dbh->disconnect; + +} + + +sub save_level { + my ($self, $myconfig, $form) = @_; + + # connect to database + my $dbh = $form->dbconnect_noauto($myconfig); + + my $query; + + $query = qq|DELETE FROM status + WHERE trans_id = ? + AND formname LIKE 'reminder_'|; + my $dth = $dbh->prepare($query) || $form->dberror($query); + + $query = qq|INSERT INTO status (trans_id, formname) + VALUES (?,?)|; + my $ath = $dbh->prepare($query) || $form->dberror($query); + + for (split / /, $form->{ids}) { + if ($form->{"ndx_$_"}) { + + $dth->execute($_) || $form->dberror; + $dth->finish; + + if ($form->{"level_$_"} *= 1) { + $ath->execute($_, qq|reminder$form->{"level_$_"}|) || $form->dberror; + $ath->finish; + } + } + } + + my $rc = $dbh->commit; + + $dbh->disconnect; + + $rc; + +} + + sub get_customer { my ($self, $myconfig, $form) = @_; diff --git a/VERSION b/VERSION index 37c6fdb60..0668896a2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.8.23 +2.8.24 diff --git a/bin/lynx/aa.pl b/bin/lynx/aa.pl index 008b7f0b3..31c811d93 100644 --- a/bin/lynx/aa.pl +++ b/bin/lynx/aa.pl @@ -484,7 +484,7 @@ sub form_header { -|; +| . $form->hide_form("$form->{vc}number"); } else { $vc .= qq| diff --git a/bin/lynx/admin.pl b/bin/lynx/admin.pl index 17462ddeb..d17ddb175 100644 --- a/bin/lynx/admin.pl +++ b/bin/lynx/admin.pl @@ -185,7 +185,7 @@ sub add_user { } $myconfig->{vclimit} = 1000; $myconfig->{menuwidth} = 155; - $myconfig->{timeout} = 3600; + $myconfig->{timeout} = 10800; &form_header; &form_footer; diff --git a/bin/lynx/am.pl b/bin/lynx/am.pl index 24fe1a273..97f4771e5 100644 --- a/bin/lynx/am.pl +++ b/bin/lynx/am.pl @@ -1869,7 +1869,7 @@ sub taxes { my $i = 0; foreach my $ref (@{ $form->{taxrates} }) { $i++; - $form->{"taxrate_$i"} = $form->format_amount(\%myconfig, $ref->{rate}); + $form->{"taxrate_$i"} = $ref->{rate}; $form->{"taxdescription_$i"} = $ref->{description}; for (qw(taxnumber validto)) { $form->{"${_}_$i"} = $ref->{$_} } diff --git a/bin/lynx/ct.pl b/bin/lynx/ct.pl index 2e8ed6e7b..b22c9c826 100644 --- a/bin/lynx/ct.pl +++ b/bin/lynx/ct.pl @@ -1024,16 +1024,16 @@ sub list_names { } $i = 1; - if ($myconfig{acs} !~ /AR--AR/) { + if ($myconfig{acs} !~ /Customers--/) { if ($form->{db} eq 'customer') { - $button{'AR--Customers--Add Customer'}{code} = qq| |; - $button{'AR--Customers--Add Customer'}{order} = $i++; + $button{'Customers--Add Customer'}{code} = qq| |; + $button{'Customers--Add Customer'}{order} = $i++; } } - if ($myconfig{acs} !~ /AP--AP/) { + if ($myconfig{acs} !~ /Vendors--/) { if ($form->{db} eq 'vendor') { - $button{'AP--Vendors--Add Vendor'}{code} = qq| |; - $button{'AP--Vendors--Add Vendor'}{order} = $i++; + $button{'Vendors--Add Vendor'}{code} = qq| |; + $button{'Vendors--Add Vendor'}{order} = $i++; } } @@ -1934,7 +1934,7 @@ sub form_footer { %a = (); if ($form->{db} eq 'customer') { - if ($myconfig{acs} !~ /AR--Customers--Add Customer/) { + if ($myconfig{acs} !~ /Customers--Add Customer/) { $a{'Save'} = 1; $a{'New Number'} = 1; $a{'Shipping Address'} = 1; @@ -1977,7 +1977,7 @@ sub form_footer { } if ($form->{db} eq 'vendor') { - if ($myconfig{acs} !~ /AP--Vendors--Add Vendor/) { + if ($myconfig{acs} !~ /Vendors--Add Vendor/) { $a{'Save'} = 1; $a{'Shipping Address'} = 1; $a{'Update'} = 1; @@ -1994,7 +1994,7 @@ sub form_footer { if ($myconfig{acs} !~ /AP--Add Transaction/) { $a{'AP Transaction'} = 1; } - if ($myconfig{acs} !~ /AP--Vendor Invoice/) { + if ($myconfig{acs} !~ /Vendor Invoice/) { $a{'Vendor Invoice'} = 1; } if ($myconfig{acs} !~ /AP--Debit Invoice/) { diff --git a/bin/lynx/ic.pl b/bin/lynx/ic.pl index 1a8aaac62..47fdea429 100644 --- a/bin/lynx/ic.pl +++ b/bin/lynx/ic.pl @@ -3211,6 +3211,7 @@ sub save { $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"}); for (qw(partnumber description bin unit listprice sellprice partsgroup)) { $form->{"${_}_$i"} = $newform{$_} } + $form->{"itemnotes_$i"} = $newform{notes}; for (qw(inventory income expense)) { $form->{"${_}_accno_id_$i"} = $newform{"IC_$_"}; $form->{"${_}_accno_id_$i"} =~ s/--.*//; diff --git a/bin/lynx/ir.pl b/bin/lynx/ir.pl index 30039002a..0680bdfc9 100644 --- a/bin/lynx/ir.pl +++ b/bin/lynx/ir.pl @@ -324,7 +324,7 @@ sub form_header { -|; +| . $form->hide_form("$form->{vc}number"); } else { $vc .= qq| diff --git a/bin/lynx/is.pl b/bin/lynx/is.pl index de9f273a8..62fdac8d8 100644 --- a/bin/lynx/is.pl +++ b/bin/lynx/is.pl @@ -331,7 +331,7 @@ sub form_header { -|; +| . $form->hide_form("$form->{vc}number"); } else { $vc .= qq| diff --git a/bin/lynx/rp.pl b/bin/lynx/rp.pl index 7298bc035..36fbf0afd 100644 --- a/bin/lynx/rp.pl +++ b/bin/lynx/rp.pl @@ -75,10 +75,13 @@ sub report { receipts => { title => 'Receipts', vc => 'customer' }, payments => { title => 'Payments' }, projects => { title => 'Project Transactions' }, + reminder => { title => 'Reminder', vc => 'customer' }, ); $form->{title} = $locale->text($report{$form->{report}}->{title}); + $form->{nextsub} = "generate_$form->{report}"; + $gifi = qq| |.$locale->text('Accounts').qq| @@ -225,7 +228,6 @@ sub report { |; if ($form->{report} eq "projects") { - $form->{nextsub} = "generate_projects"; print qq| $project @@ -249,7 +251,6 @@ sub report { } if ($form->{report} eq "income_statement") { - $form->{nextsub} = "generate_income_statement"; print qq| $project @@ -324,7 +325,6 @@ sub report { if ($form->{report} eq "balance_sheet") { - $form->{nextsub} = "generate_balance_sheet"; print qq| @@ -384,7 +384,6 @@ sub report { if ($form->{report} eq "trial_balance") { - $form->{nextsub} = "generate_trial_balance"; print qq| @@ -488,7 +487,7 @@ sub report { } -print qq| + print qq| $method @@ -618,8 +617,6 @@ sub report { } $form->{sort} = ($form->{namesbynumber}) ? "$form->{vc}number" : "name"; - $form->{nextsub} = "generate_$form->{report}"; - $form->{type} = "statement"; $form->{format} ||= $myconfig{outputformat}; $form->{media} ||= $myconfig{printer}; @@ -697,6 +694,58 @@ sub report { } + if ($form->{report} eq 'reminder') { + $gifi = ""; + + $vclabel = $locale->text('Customer'); + $vcnumber = $locale->text('Customer Number'); + $form->{vc} = 'customer'; + $form->{sort} = "customernumber" if $form->{namesbynumber}; + $form->{sort} = ($form->{namesbynumber}) ? "$form->{vc}number" : "name"; + + $form->{type} = "reminder"; + $form->{format} ||= $myconfig{outputformat}; + $form->{media} ||= $myconfig{printer}; + + # setup vc selection + $form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP", undef, undef, undef, 1); + + if (@{ $form->{"all_$form->{vc}"} }) { + $vc = qq| + + $vclabel + + + +|; + } else { + $vc = qq| + + $vclabel + {vc} size=35> + + + + $vcnumber + + + +|; + } + + print qq| + $vc + +|; + + $form->hide_form(qw(type format media sort)); + + } + # above action can be removed if there is more than one input field @@ -1614,7 +1663,7 @@ sub aging { if ($form->{arap} eq 'ar') { - $form->hide_form(qw(todate title summary overdue callback arap vc department path login)); + $form->hide_form(qw(todate title summary overdue callback arap vc department path login type report)); $form->hide_form(@c, "$form->{vc}"); %button = ('Select all' => { ndx => 1, key => 'A', value => $locale->text('Select all') }, @@ -1648,7 +1697,9 @@ sub aging { } -sub select_all { +sub select_all { &{ "select_all_$form->{type}" } } + +sub select_all_statement { RP->aging(\%myconfig, \%$form); @@ -1661,7 +1712,22 @@ sub select_all { } -sub deselect_all { +sub select_all_reminder { + + RP->reminder(\%myconfig, \%$form); + + for (@{ $form->{AG} }) { $form->{"ndx_$_->{id}"} = "checked" } + $form->{allbox} = "checked"; + $form->{deselect} = 1; + + &reminder; + +} + + +sub deselect_all { &{ "deselect_all_$form->{type}" } } + +sub deselect_all_statement { RP->aging(\%myconfig, \%$form); @@ -1673,6 +1739,293 @@ sub deselect_all { } +sub deselect_all_reminder { + + RP->reminder(\%myconfig, \%$form); + + for (@{ $form->{AG} }) { $_->{checked} = "" } + $form->{allbox} = ""; + + &reminder; + +} + + +sub generate_reminder { + + # split customer + ($form->{customer}) = split(/--/, $form->{customer}); + + $form->{vc} = "customer"; + $form->{arap} = "ar"; + + $form->{initcallback} = qq|$form->{script}?action=generate_reminder|; + + RP->reminder(\%myconfig, \%$form); + + &reminder; + +} + + +sub reminder { + + $form->{callback} = $form->{initcallback}; + for (qw(path login type format)) { $form->{callback} .= "&$_=$form->{$_}" } + for (qw(title media report)) { $form->{callback} .= qq|&$_=|.$form->escape($form->{$_},1) } + $form->{callback} .= qq|&$form->{vc}=|.$form->escape($form->{"$form->{vc}"},1); + + $vcnumber = $locale->text('Customer Number'); + + $form->{allbox} = ($form->{allbox}) ? "checked" : ""; + $action = ($form->{deselect}) ? "deselect_all" : "select_all"; + $column_header{ndx} = qq|{allbox} onChange="CheckAll(); javascript:document.forms[0].submit()">|; + $column_header{vc} = qq||.$locale->text(ucfirst $form->{vc}).qq||; + $column_header{"$form->{vc}number"} = qq|$vcnumber|; + $column_header{level} = qq||.$locale->text('Level').qq||; + $column_header{language} = qq||.$locale->text('Language').qq||; + $column_header{invnumber} = qq||.$locale->text('Invoice').qq||; + $column_header{ordnumber} = qq||.$locale->text('Order').qq||; + $column_header{transdate} = qq||.$locale->text('Date').qq||; + $column_header{duedate} = qq||.$locale->text('Due Date').qq||; + $column_header{due} = qq||.$locale->text('Due').qq||; + + @column_index = qw(ndx vc); + push @column_index, "$form->{vc}number"; + push @column_index, "level"; + + $form->{selectlevel} = "\n1\n2\n3"; + + if (@{ $form->{all_language} }) { + push @column_index, "language"; + $form->{selectlanguage} = qq|\n|; + $form->{language_code} ||= ""; + + for (@{ $form->{all_language} }) { $form->{selectlanguage} .= qq|$_->{code}--$_->{description}\n| } + } + + push @column_index, qw(invnumber ordnumber transdate duedate due); + + if ($form->{department}) { + $option .= "\n
" if $option; + ($department) = split /--/, $form->{department}; + $option .= $locale->text('Department')." : $department"; + $department = $form->escape($form->{department},1); + $form->{callback} .= "&department=$department"; + } + + if ($form->{customer}) { + $option .= "\n
" if $option; + $option .= $form->{customer}; + } + + $title = "$form->{title} / $form->{company}"; + + $form->header; + + print qq| + + + + +
{script}> + + + + + + + + + + + + + + + + + + + +
$title
$option
+ +|; + + $curr = ""; + $form->{ids} = ""; + + $callback = $form->escape($form->{callback},1); + + for $ref (@{ $form->{AG} }) { + + if ($curr ne $ref->{curr}) { + + for (@column_index) { $column_data{$_} = qq|| } + + if ($curr) { + + print qq| + +|; + + for (@column_index) { print "$column_data{$_}\n" } + + print qq| + +|; + } + + print qq| + + + + + + +|; + + for (@column_index) { print "$column_header{$_}\n" } + + print qq| + +|; + } + + $curr = $ref->{curr}; + + $column_data{vc} = qq| + |; + + $column_data{"$form->{vc}number"} = qq||; + + if (exists $form->{"level_$ref->{id}"}) { + $ref->{level} = $form->{"level_$ref->{id}"}; + } + $column_data{level} = qq||; + + if ($form->{selectlanguage}) { + if (exists $form->{"language_code_$ref->{id}"}) { + $ref->{language_code} = $form->{"language_code_$ref->{id}"}; + } + + $column_data{language} = qq||; + } + + $checked = ($form->{"ndx_$ref->{id}"}) ? "checked" : ""; + $column_data{ndx} = qq||; + + $form->{ids} .= "$ref->{id} "; + + $href = qq|$ref->{module}.pl?path=$form->{path}&action=edit&id=$ref->{id}&login=$form->{login}&callback=|.$form->escape($form->{callback}); + + $column_data{invnumber} = qq||; + $column_data{ordnumber} = qq||; + for (qw(transdate duedate)) { $column_data{$_} = qq|| } + + $column_data{due} = qq||; + + $j++; $j %= 2; + print qq| + +|; + + for (@column_index) { print "$column_data{$_}\n" } + + print qq| + +|; + + for (qw(vc ndx language level)) { $column_data{$_} = qq|| } + $column_data{"$form->{vc}number"} = qq||; + + } + + print qq| + + +|; + + for (@column_index) { $column_data{$_} = qq|| } + for (@column_index) { print "$column_data{$_}\n" } + + print qq| + +
 
$ref->{curr}
{path}&login=$form->{login}&action=edit&id=$ref->{vc_id}&db=$form->{vc}&callback=$callback>$ref->{name}$ref->{"$form->{vc}number"}$ref->{invnumber}$ref->{ordnumber}$ref->{$_}|.$form->format_amount(\%myconfig, $ref->{due} / $ref->{exchangerate}, $form->{precision}).qq|
  
 
+
+|; + + &print_options; + + print qq| +

+|; + + chop $form->{ids}; + + $form->hide_form(qw(title initcallback callback vc department path login ids)); + $form->hide_form($form->{vc}); + $form->hide_form(qw(type report)); + + %button = ('Select all' => { ndx => 1, key => 'A', value => $locale->text('Select all') }, + 'Deselect all' => { ndx => 2, key => 'A', value => $locale->text('Deselect all') }, + 'Preview' => { ndx => 3, key => 'V', value => $locale->text('Preview') }, + 'Print' => { ndx => 4, key => 'P', value => $locale->text('Print') }, + 'E-mail' => { ndx => 5, key => 'E', value => $locale->text('E-mail') }, + 'Save Level' => { ndx => 6, key => 'L', value => $locale->text('Save Level') }, + ); + + if ($form->{deselect}) { + delete $button{'Select all'}; + } else { + delete $button{'Deselect all'}; + } + + for (sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button) { $form->print_button(\%button, $_) } + + if ($form->{menubar}) { + require "$form->{path}/menu.pl"; + &menubar; + } + + print qq| +
+ + + +|; + +} + + +sub save_level { + + if (RP->save_level(\%myconfig, \%$form)) { + $form->redirect; + } + + $form->error($locale->text('Could not save reminder level!')); + +} + + sub print_options { $form->{copies} ||= 1; @@ -1709,9 +2062,13 @@ sub print_options { $format = qq| -