Subversion Repositories sql-ledger-old

Compare Revisions

Ignore whitespace Rev 112 → Rev 113

/trunk/sql-ledger.conf.default
1,4 → 1,4
use vars qw($userspath $memberfile $templates $sendmail $language $sid);
use vars qw($userspath $memberfile $templates $sendmail $language $sid $latex);
 
# path to user configuration files
# you may use an absolute path i.e. /var/tmp
29,5 → 29,9
# on mac os X using Fink's Perl libs, add the path
$ENV{PERL5LIB} .= ":/sw/lib/perl5";
 
# DB2, Default dataset is expected to be LEDGER
$ENV{DB2INSTANCE} = "db2inst1";
$ENV{DB2_HOME} = "/opt/IBM/db2/V8.1/";
 
 
1;
/trunk/am.pl
75,12 → 75,9
 
 
$myconfig{dbpasswd} = unpack 'u', $myconfig{dbpasswd};
map { $form->{$_} = $myconfig{$_} } qw(stylesheet charset) unless (($form->{action} eq "save") && ($form->{type} eq 'preferences'));
 
if ($form->{action} ne "save_preferences") {
map { $form->{$_} = $myconfig{$_} } qw(stylesheet charset);
}
 
 
# locale messages
$locale = new Locale "$myconfig{countrycode}", "$script";
 
95,7 → 92,7
}
 
# did sysadmin lock us out
if (-e "$userspath/nologin") {
if (-f "$userspath/nologin") {
$form->error($locale->text('System currently down for maintenance!'));
}
 
119,7 → 116,11
# window title bar, user info
$form->{titlebar} = "SQL-Ledger ".$locale->text('Version'). " $form->{version} - $myconfig{name} - $myconfig{dbname}";
 
&{ $locale->findsub($form->{action}) };
if (substr($form->{action}, 0, 1) eq ' ') {
&{ $form->{nextsub} };
} else {
&{ $locale->findsub($form->{action}) };
}
} else {
$form->error($locale->text('action= not defined!'));
}
/trunk/bin/mozilla/ca.pl
223,8 → 223,13
# construct href
$href = "$form->{script}?path=$form->{path}&action=list_transactions&accno=$form->{accno}&login=$form->{login}&password=$form->{password}&fromdate=$form->{fromdate}&todate=$form->{todate}&description=$description&accounttype=$form->{accounttype}&gifi_accno=$form->{gifi_accno}&gifi_description=$gifi_description&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}";
 
 
$description = $form->escape($form->{description},1);
$gifi_description = $form->escape($form->{gifi_description},1);
# construct callback
$callback = "rp.pl?path=$form->{path}&action=generate_trial_balance&login=$form->{login}&password=$form->{password}&fromdate=$form->{fromdate}&todate=$form->{todate}&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}&accounttype=$form->{accounttype}";
$callback = "$form->{script}?path=$form->{path}&action=list_transactions&accno=$form->{accno}&login=$form->{login}&password=$form->{password}&fromdate=$form->{fromdate}&todate=$form->{todate}&description=$description&accounttype=$form->{accounttype}&gifi_accno=$form->{gifi_accno}&gifi_description=$gifi_description&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}";
 
# figure out which column comes first
$column_header{transdate} = qq|<th><a class=listheading href=$href&sort=transdate>|.$locale->text('Date').qq|</a></th>|;
233,8 → 238,13
$column_header{debit} = qq|<th class=listheading>|.$locale->text('Debit').qq|</th>|;
$column_header{credit} = qq|<th class=listheading>|.$locale->text('Credit').qq|</th>|;
$column_header{balance} = qq|<th class=listheading>|.$locale->text('Balance').qq|</th>|;
$column_header{cleared} = qq|<th class=listheading>|.$locale->text('R').qq|</th>|;
 
@column_index = $form->sort_columns(qw(transdate reference description debit credit));
 
if ($form->{link} =~ /_paid/) {
@column_index = $form->sort_columns(qw(transdate reference description cleared debit credit));
}
if ($form->{accounttype} eq 'gifi') {
map { $form->{$_} = $form->{"gifi_$_"} } qw(accno description);
338,6 → 348,8
$column_data{transdate} = qq|<td>$ca->{transdate}</td>|;
$column_data{reference} = qq|<td>$href</td>|;
$column_data{description} = qq|<td>$ca->{description}</td>|;
 
$column_data{cleared} = ($ca->{cleared}) ? qq|<td>*</td>| : qq|<td>&nbsp;</td>|;
$i++; $i %= 2;
print qq|
/trunk/bin/mozilla/am.pl
247,7 → 247,7
<input type=submit class=submit name=action value="|.$locale->text('Save').qq|">
|;
 
if ($form->{id}) {
if ($form->{id} && $form->{orphaned}) {
print qq|<input type=submit class=submit name=action value="|.$locale->text('Delete').qq|">|;
}
 
267,7 → 267,18
 
$form->isblank("accno", $locale->text('Account Number missing!'));
$form->isblank("category", $locale->text('Account Type missing!'));
 
# check for conflicting accounts
if ($form->{AR} || $form->{AP} || $form->{IC}) {
map { $a .= $form->{$_} } qw(AR AP IC);
$form->error($locale->text('Cannot set account for more than one of AR, AP or IC')) if length $a > 2;
foreach $item (qw(AR_amount AR_tax AR_paid AP_amount AP_tax AP_paid IC_sale IC_cogs IC_taxpart IC_income IC_expense IC_taxservice)) {
$form->error("$form->{AR}$form->{AP}$form->{IC} ". $locale->text('account cannot be set to any other type of account')) if $form->{$item};
}
}
$form->redirect($locale->text('Account saved!')) if (AM->save_account(\%myconfig, \%$form));
$form->error($locale->text('Cannot save account!'));
 
624,14 → 635,12
 
# if it is anything but html
if ($form->{file} !~ /\.html$/) {
$form->{body} = "<pre>\n$form->{body}\n</pre>";
$form->{pre} = "<pre>";
}
$form->header;
 
print qq|
<body>
 
$form->{body}
 
<form method=post action=$form->{script}>
712,7 → 721,7
$dateformat .= ($item eq $myconfig{dateformat}) ? "<option selected>$item\n" : "<option>$item\n";
}
 
foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00 1'000.00)) {
$numberformat .= ($item eq $myconfig{numberformat}) ? "<option selected>$item\n" : "<option>$item\n";
}
 
726,10 → 735,16
 
%countrycodes = User->country_codes;
$countrycodes = '';
$gb = $countrycodes{en_GB};
delete $countrycodes{en_GB};
foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) {
$countrycodes .= ($myconfig{countrycode} eq $key) ? "<option selected value=$key>$countrycodes{$key}\n" : "<option value=$key>$countrycodes{$key}\n";
}
$countrycodes = "<option>English\n$countrycodes";
if ($gb) {
$countrycodes = ($myconfig{countrycode} eq 'en_GB') ? qq|<option selected value="en_GB">English (GB)\n$countrycodes| : qq|<option value="en_GB">English (GB)\n$countrycodes|;
}
$countrycodes = qq|<option value="">English (US)\n$countrycodes|;
 
foreach $key (keys %{ $form->{IC} }) {
foreach $accno (sort keys %{ $form->{IC}{$key} }) {
760,7 → 775,7
</tr>
<tr>
<th align=right>|.$locale->text('Password').qq|</th>
<td><input type=password name=password size=10 value=$myconfig{password}></td>
<td><input type=password name=new_password size=10 value=$myconfig{password}></td>
</tr>
<tr>
<th align=right>|.$locale->text('E-mail').qq|</th>
827,7 → 842,7
<table width=100%>
<tr>
<th align=right>|.$locale->text('Year End').qq| (mm/dd)</th>
<td><input name=yearend size=5 maxsize=5 value=$form->{defaults}{yearend}></td>
<td><input name=yearend size=5 maxlength=5 value=$form->{defaults}{yearend}></td>
<th align=right>|.$locale->text('Weight Unit').qq|</th>
<td><input name=weightunit size=5 value="$form->{defaults}{weightunit}"></td>
</tr>
955,6 → 970,7
 
}
$SIG{INT} = 'IGNORE';
AM->backup(\%myconfig, \%$form, $userspath);
 
if ($form->{media} eq 'email') {
/trunk/bin/mozilla/ap.pl
101,11 → 101,14
 
$taxincluded = $form->{taxincluded};
$duedate = $form->{duedate};
$notes = $form->{notes};
IR->get_vendor(\%myconfig, \%$form);
$form->{duedate} = $duedate;
$form->{notes} = $notes;
$form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}";
$form->{oldinvdate} = $form->{invdate};
# build the popup menus
 
121,6 → 124,12
$form->{vendor} = qq|$form->{vendor}--$form->{vendor_id}|;
map { $form->{selectvendor} .= "<option>$_->{name}--$_->{id}\n" } (@{ $form->{all_vendor} });
}
 
# projects
if (@{ $form->{all_project} }) {
$form->{selectprojectnumber} = "<option>\n";
map { $form->{selectprojectnumber} .= "<option>$_->{projectnumber}\n" } (@{ $form->{all_project} });
}
 
# forex
164,10 → 173,10
$form->{"${akey}_$i"} *= -1;
$totalamount += $form->{"${akey}_$i"};
$form->{rowcount}++;
 
$form->{"projectnumber_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}";
}
$form->{"${key}_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
$form->{"oldprojectnumber_$i"} = $form->{"projectnumber_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}";
$form->{"project_id_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{project_id}";
}
}
}
176,7 → 185,7
$form->{taxincluded} = $taxincluded if ($form->{id});
$form->{paidaccounts} = 1 if not defined $form->{paidaccounts};
 
if ($form->{taxincluded}) {
if ($form->{taxincluded} && $totalamount) {
# add tax to amounts and invtotal
for $i (1 .. $form->{rowcount}) {
$taxamount = $totaltax * $form->{"amount_$i"} / $totalamount;
188,12 → 197,16
}
$form->{invtotal} = $totalamount + $totaltax;
$form->{rowcount}++;
$form->{rowcount}++ if $form->{id};
$form->{AP} = $form->{AP_1};
$form->{rowcount} = 1 if ! $form->{amount_1};
 
$form->{locked} = ($form->datetonum($form->{transdate}, \%myconfig) <= $form->datetonum($form->{closedto}, \%myconfig));
$form->{locked} = ($form->{revtrans}) ? '1' : ($form->datetonum($form->{transdate}, \%myconfig) <= $form->datetonum($form->{closedto}, \%myconfig));
 
# readonly
$form->{readonly} = 1 if $myconfig{acs} =~ /AP--Add Transaction/;
 
}
 
 
223,17 → 236,13
if ($form->{currency} ne $form->{defaultcurrency}) {
if ($form->{forex}) {
$exchangerate .= qq|
<tr>
<th align=right>|.$locale->text('Exchangerate').qq|</th>
<th align=right>|.$locale->text('Exchange Rate').qq|</th>
<td><input type=hidden name=exchangerate value=$form->{exchangerate}>$form->{exchangerate}</td>
</tr>
|;
} else {
$exchangerate .= qq|
<tr>
<th align=right>|.$locale->text('Exchangerate').qq|</th>
<th align=right>|.$locale->text('Exchange Rate').qq|</th>
<td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
</tr>
|;
}
}
254,10 → 263,10
}
$notes = qq|<textarea name=notes rows=$rows cols=50 wrap=soft>$form->{notes}</textarea>|;
$vendor = ($form->{selectvendor}) ? qq|<select name=vendor>$form->{selectvendor}</select>| : qq|<input name=vendor value="$form->{vendor}" size=35>|;
 
$form->header;
 
$vendor = ($form->{selectvendor}) ? qq|<select name=vendor>$form->{selectvendor}</select>| : qq|<input name=vendor value="$form->{vendor}" size=35>|;
print qq|
<body>
270,6 → 279,8
<input type=hidden name=locked value=$form->{locked}>
<input type=hidden name=title value="$title">
 
<input type=hidden name=oldinvdate value=$form->{oldinvdate}>
 
<table width=100%>
<tr class=listtop>
<th class=listtop>$form->{title}</th>
283,7 → 294,7
<table>
<tr>
<th align=right nowrap>|.$locale->text('Vendor').qq|</th>
<td>$vendor</td>
<td colspan=3>$vendor</td>
<input type=hidden name=selectvendor value="$form->{selectvendor}">
<input type=hidden name=oldvendor value="$form->{oldvendor}">
<input type=hidden name=vendor_id value="$form->{vendor_id}">
298,8 → 309,8
<input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
<input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
<input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
$exchangerate
</tr>
$exchangerate
</table>
</td>
<td align=right>
327,6 → 338,7
</td>
</tr>
<input type=hidden name=selectAP_amount value="$form->{selectAP_amount}">
<input type=hidden name=selectprojectnumber value="$form->{selectprojectnumber}">
<input type=hidden name=rowcount value=$form->{rowcount}>
<tr>
<td>
334,29 → 346,30
|;
 
$amount = $locale->text('Amount');
$project = $locale->text('Project');
for $i (1 .. $form->{rowcount}) {
 
$form->{"selectAP_amount"} =~ s/ selected//;
$form->{"selectAP_amount"} =~ s/option>\Q$form->{"AP_amount_$i"}\E/option selected>$form->{"AP_amount_$i"}/;
foreach $item (qw(AP_amount projectnumber)) {
$form->{"select$item"} =~ s/ selected//;
$form->{"select$item"} =~ s/option>\Q$form->{"${item}_$i"}\E/option selected>$form->{"${item}_$i"}/;
}
 
# format amounts
$form->{"amount_$i"} = $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
 
$project = qq|
<td align=right><select name="projectnumber_$i">$form->{selectprojectnumber}</select></td>
| if $form->{selectprojectnumber};
print qq|
<tr>
<th align=right nowrap>$amount</th>
<td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td>
<th>$project</th>
<td><input name="projectnumber_$i" size=20 value="$form->{"projectnumber_$i"}">
<input type=hidden name="project_id_$i" value=$form->{"project_id_$i"}>
<input type=hidden name="oldprojectnumber_$i" value="$form->{"oldprojectnumber_$i"}"></td>
<td width=50%><select name="AP_amount_$i">$form->{selectAP_amount}</select></td>
<td><select name="AP_amount_$i">$form->{selectAP_amount}</select></td>
$project
</tr>
|;
$amount = "";
$project = "";
}
 
$taxlabel = ($form->{taxincluded}) ? $locale->text('Tax Included') : $locale->text('Tax');
370,7 → 383,6
<tr>
<th align=right nowrap>${taxlabel}</th>
<td><input name="tax_$item" size=10 value=$form->{"tax_$item"}></td>
<td colspan=2></td>
<td><select name=AP_tax_$item>$form->{"selectAP_tax_$item"}</select></td>
</tr>
<input type=hidden name="${item}_rate" value="$form->{"${item}_rate"}">
384,8 → 396,7
print qq|
<tr>
<th align=right nowrap>|.$locale->text('Total').qq|</th>
<td>$form->{invtotal}</td>
<td colspan=2></td>
<th align=left>$form->{invtotal}</th>
<td><select name=AP>$form->{selectAP}</select></td>
<input type=hidden name=selectAP value="$form->{selectAP}">
<input type=hidden name=taxaccounts value="$form->{taxaccounts}">
406,7 → 417,11
|;
 
 
@column_index = qw(datepaid source paid exchangerate AP_paid);
if ($form->{currency} eq $form->{defaultcurrency}) {
@column_index = qw(datepaid source paid AP_paid);
} else {
@column_index = qw(datepaid source paid exchangerate AP_paid);
}
 
$column_data{datepaid} = "<th>".$locale->text('Date')."</th>";
$column_data{paid} = "<th>".$locale->text('Amount')."</th>";
448,11 → 463,11
<input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
|;
 
$column_data{"paid_$i"} = qq|<td><input name="paid_$i" size=10 value=$form->{"paid_$i"}></td>|;
$column_data{"AP_paid_$i"} = qq|<td><select name="AP_paid_$i">$form->{"selectAP_paid_$i"}</select></td>|;
$column_data{"exchangerate_$i"} = qq|<td>$exchangerate</td>|;
$column_data{"datepaid_$i"} = qq|<td><input name="datepaid_$i" size=11 title="($myconfig{'dateformat'})" value=$form->{"datepaid_$i"}></td>|;
$column_data{"source_$i"} = qq|<td><input name="source_$i" size=10 value="$form->{"source_$i"}"></td>|;
$column_data{"paid_$i"} = qq|<td align=center><input name="paid_$i" size=10 value=$form->{"paid_$i"}></td>|;
$column_data{"AP_paid_$i"} = qq|<td align=center><select name="AP_paid_$i">$form->{"selectAP_paid_$i"}</select></td>|;
$column_data{"exchangerate_$i"} = qq|<td align=center>$exchangerate</td>|;
$column_data{"datepaid_$i"} = qq|<td align=center><input name="datepaid_$i" size=11 title="($myconfig{'dateformat'})" value=$form->{"datepaid_$i"}></td>|;
$column_data{"source_$i"} = qq|<td align=center><input name="source_$i" size=10 value="$form->{"source_$i"}"></td>|;
 
map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
 
493,29 → 508,28
$transdate = $form->datetonum($form->{transdate}, \%myconfig);
$closedto = $form->datetonum($form->{closedto}, \%myconfig);
if ($form->{id}) {
print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
if (! $form->{readonly}) {
if ($form->{id}) {
print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
|;
 
if (!$form->{revtrans}) {
if (!$form->{locked}) {
print qq|
<input class=submit type=submit name=action value="|.$locale->text('Post').qq|">
<input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">
|;
}
}
 
if ($transdate > $closedto) {
print qq|
<input class=submit type=submit name=action value="|.$locale->text('Post as new').qq|">
<input class=submit type=submit name=action value="|.$locale->text('Post as new').qq|">
|;
}
 
} else {
if ($transdate > $closedto) {
print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
<input class=submit type=submit name=action value="|.$locale->text('Post').qq|">|;
} else {
if ($transdate > $closedto) {
print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
<input class=submit type=submit name=action value="|.$locale->text('Post').qq|">|;
}
}
}
 
530,12 → 544,17
 
 
sub update {
my $display = shift;
 
$invtotal = 0;
if ($display) {
goto TAXCALC;
}
 
$form->{invtotal} = 0;
$form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate});
 
@flds = qw(amount AP_amount projectnumber oldprojectnumber project_id);
@flds = qw(amount AP_amount projectnumber);
$count = 0;
for $i (1 .. $form->{rowcount}) {
$form->{"amount_$i"} = $form->parse_amount(\%myconfig, $form->{"amount_$i"});
549,15 → 568,21
$form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
$form->{rowcount} = $count + 1;
map { $invtotal += $form->{"amount_$_"} } (1 .. $form->{rowcount});
map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
$form->{exchangerate} = $exchangerate if ($form->{forex} = ($exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, 'sell')));
 
$form->{invdate} = $form->{transdate};
&check_name(vendor);
 
&check_project;
if ($form->{invdate} ne $form->{oldinvdate}) {
$form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
$form->{oldinvdate} = $form->{invdate};
}
 
 
 
TAXCALC:
# recalculate taxes
if ($form->{taxincluded}) {
$taxrate = 0;
565,7 → 590,7
map { $taxrate += $form->{"${_}_rate"} } split / /, $form->{taxaccounts};
 
foreach $item (split / /, $form->{taxaccounts}) {
$amount = ($invtotal * (1 - 1 / (1 + $taxrate)) * $form->{"${item}_rate"} / $taxrate) if $taxrate;
$amount = ($form->{invtotal} * (1 - 1 / (1 + $taxrate)) * $form->{"${item}_rate"} / $taxrate) if $taxrate;
$form->{"tax_$item"} = $form->round_amount($amount, 2);
$taxdiff += ($amount - $form->{"tax_$item"});
if (abs $taxdiff >= 0.005) {
577,13 → 602,13
}
} else {
foreach $item (split / /, $form->{taxaccounts}) {
$form->{"tax_$item"} = $form->round_amount($invtotal * $form->{"${item}_rate"}, 2);
$form->{"tax_$item"} = $form->round_amount($form->{invtotal} * $form->{"${item}_rate"}, 2);
$form->{"selectAP_tax_$item"} = qq|<option>$item--$form->{"${item}_description"}|;
$totaltax += $form->{"tax_$item"};
}
}
 
$form->{invtotal} = ($form->{taxincluded}) ? $invtotal : $invtotal + $totaltax;
$form->{invtotal} = ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
for $i (1 .. $form->{paidaccounts}) {
if ($form->{"paid_$i"}) {
596,8 → 621,8
&display_form;
 
}
 
sub post {
 
# check if there is an invoice number, invoice and due date
612,7 → 637,7
 
$form->error($locale->text('Cannot post transaction for a closed period!')) if ($transdate <= $closedto);
 
$form->isblank("exchangerate", $locale->text('Exchangerate missing!')) if ($form->{currency} ne $form->{defaultcurrency});
$form->isblank("exchangerate", $locale->text('Exchange rate missing!')) if ($form->{currency} ne $form->{defaultcurrency});
 
for $i (1 .. $form->{paidaccounts}) {
if ($form->{"paid_$i"}) {
624,7 → 649,7
 
if ($form->{currency} ne $form->{defaultcurrency}) {
$form->{"exchangerate_$i"} = $form->{exchangerate} if ($transdate == $datepaid);
$form->isblank("exchangerate_$i", $locale->text('Exchangerate for payment missing!'));
$form->isblank("exchangerate_$i", $locale->text('Exchange rate for payment missing!'));
}
}
695,19 → 720,53
 
 
sub search {
# setup vendor selection
$form->all_vc(\%myconfig, "vendor");
 
$form->create_links("AP", \%myconfig, "vendor");
 
$form->{selectAP} = "<option>\n";
map { $form->{selectAP} .= "<option>$_->{accno}--$_->{description}\n" } @{ $form->{AP_links}{AP} };
 
 
if (@{ $form->{all_vendor} }) {
map { $vendor .= "<option>$_->{name}--$_->{id}\n" } @{ $form->{all_vendor} };
$vendor = qq|<select name=vendor><option>\n$vendor\n</select>|;
} else {
$vendor = qq|<input name=vendor size=35>|;
}
$form->{title} = $locale->text('AP Transactions');
$form->{title} = $locale->text('AP Transactions');
 
$invnumber = qq|
<tr>
<th align=right nowrap>|.$locale->text('Invoice Number').qq|</th>
<td colspan=3><input name=invnumber size=20></td>
</tr>
<tr>
<th align=right nowrap>|.$locale->text('Order Number').qq|</th>
<td colspan=3><input name=ordnumber size=20></td>
</tr>
<tr>
<th align=right nowrap>|.$locale->text('Notes').qq|</th>
<td colspan=3><input name=notes size=40></td>
</tr>
|;
$openclosed = qq|
<tr>
<td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
<td nowrap>|.$locale->text('Open').qq|</td>
<td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
<td nowrap>|.$locale->text('Closed').qq|</td>
</tr>
|;
 
if ($form->{outstanding}) {
$form->{title} = $locale->text('AP Outstanding');
$invnumber = "";
$openclosed = "";
}
 
 
$form->header;
 
print qq|
715,6 → 774,9
 
<form method=post action=$form->{script}>
 
<input type=hidden name=title value="$form->{title}">
<input type=hidden name=outstanding value=$form->{outstanding}>
 
<table width=100%>
<tr>
<th class=listtop>$form->{title}</th>
723,23 → 785,16
<tr>
<td>
<table>
<tr>
<th align=right>|.$locale->text('Account').qq|</th>
<td colspan=3><select name=AP>$form->{selectAP}</select></td>
</tr>
<tr>
<th align=right>|.$locale->text('Vendor').qq|</th>
<td colspan=3>$vendor</td>
</tr>
$invnumber
<tr>
<th align=right nowrap>|.$locale->text('Invoice Number').qq|</th>
<td colspan=3><input name=invnumber size=20></td>
</tr>
<tr>
<th align=right nowrap>|.$locale->text('Order Number').qq|</th>
<td colspan=3><input name=ordnumber size=20></td>
</tr>
<tr>
<th align=right nowrap>|.$locale->text('Notes').qq|</th>
<td colspan=3><input name=notes size=40></td>
</tr>
<tr>
<th align=right nowrap>|.$locale->text('From').qq|</th>
<td><input name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
<th align=right>|.$locale->text('to').qq|</th>
756,13 → 811,8
<th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
<td>
<table width=100%>
$openclosed
<tr>
<td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
<td nowrap>|.$locale->text('Open').qq|</td>
<td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
<td nowrap>|.$locale->text('Closed').qq|</td>
</tr>
<tr>
<td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
<td nowrap>|.$locale->text('ID').qq|</td>
<td align=right><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
817,6 → 867,7
 
<br>
<input type=hidden name=nextsub value=$form->{nextsub}>
 
<input type=hidden name=path value=$form->{path}>
<input type=hidden name=login value=$form->{login}>
<input type=hidden name=password value=$form->{password}>
833,34 → 884,46
 
sub ap_transactions {
 
$form->{vendor} = $form->unescape($form->{vendor});
($form->{vendor}, $form->{vendor_id}) = split(/--/, $form->{vendor});
if ($form->{vendor}) {
$form->{vendor} = $form->unescape($form->{vendor});
($form->{vendor}, $form->{vendor_id}) = split(/--/, $form->{vendor});
}
 
AP->ap_transactions(\%myconfig, \%$form);
 
$callback = "$form->{script}?action=ap_transactions&path=$form->{path}&login=$form->{login}&password=$form->{password}";
$callback = "$form->{script}?action=ap_transactions&outstanding=$form->{outstanding}&path=$form->{path}&login=$form->{login}&password=$form->{password}";
$href = $callback;
 
$callback .= "&title=".$form->escape($form->{title},1);
$href .= "&title=".$form->escape($form->{title});
 
if ($form->{AP}) {
$callback .= "&AP=".$form->escape($form->{AP},1);
$href .= "&AP=".$form->escape($form->{AP});
$form->{AP} =~ s/--/ /;
$option = $locale->text('Account')." : $form->{AP}";
}
if ($form->{vendor}) {
$callback .= "&vendor=".$form->escape($form->{vendor});
$href .= "&vendor=".$form->escape($form->{vendor});
$callback .= "&vendor=".$form->escape($form->{vendor},1)."--$form->{vendor_id}";
$href .= "&vendor=".$form->escape($form->{vendor})."--$form->{vendor_id}";
$option .= "\n<br>" if ($option);
$option .= $locale->text('Vendor')." : $form->{vendor}";
}
if ($form->{invnumber}) {
$callback .= "&invnumber=$form->{invnumber}";
$callback .= "&invnumber=".$form->escape($form->{invnumber},1);
$href .= "&invnumber=".$form->escape($form->{invnumber});
$option .= "\n<br>" if ($option);
$option .= $locale->text('Invoice Number')." : $form->{invnumber}";
}
if ($form->{ordnumber}) {
$callback .= "&ordnumber=$form->{ordnumber}";
$callback .= "&ordnumber=".$form->escape($form->{ordnumber},1);
$href .= "&ordnumber=".$form->escape($form->{ordnumber});
$option .= "\n<br>" if ($option);
$option .= $locale->text('Order Number')." : $form->{ordnumber}";
}
if ($form->{notes}) {
$callback .= "&notes=$form->{notes}";
$callback .= "&notes=".$form->escape($form->{notes},1);
$href .= "&notes=".$form->escape($form->{notes});
$option .= "\n<br>" if $option;
$option .= $locale->text('Notes')." : $form->{notes}";
891,7 → 954,7
$option .= $locale->text('Closed');
}
 
@columns = $form->sort_columns(qw(transdate id invnumber ordnumber name netamount tax amount paid datepaid due duedate notes employee));
@columns = $form->sort_columns(qw(transdate id invnumber ordnumber name netamount tax amount paid due datepaid duedate notes employee));
 
foreach $item (@columns) {
if ($form->{"l_$item"} eq "Y") {
925,7 → 988,7
$column_header{employee} = "<th><a class=listheading href=$href&sort=employee>".$locale->text('Employee')."</th>";
 
$form->{title} = $locale->text('AP Transactions');
$form->{title} = ($form->{title}) ? $form->{title} : $locale->text('AP Transactions');
 
$form->header;
956,13 → 1019,13
$form->{callback} = "$callback&sort=$form->{sort}";
$callback = $form->escape($form->{callback});
 
if (@{ $form->{AP} }) {
$sameitem = $form->{AP}->[0]->{$form->{sort}};
if (@{ $form->{transactions} }) {
$sameitem = $form->{transactions}->[0]->{$form->{sort}};
}
# sums and tax on reports by Antonio Gallardo
#
foreach $ap (@{ $form->{AP} }) {
foreach $ap (@{ $form->{transactions} }) {
 
if ($form->{l_subtotal} eq 'Y') {
if ($sameitem ne $ap->{$form->{sort}}) {
1034,6 → 1097,19
 
map { print "$column_data{$_}\n" } @column_index;
 
if ($myconfig{acs} !~ /AP--AP/) {
$i = 1;
$button{'AP--Add Transaction'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('AP Transaction').qq|"> |;
$button{'AP--Add Transaction'}{order} = $i++;
$button{'AP--Vendor Invoice'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Vendor Invoice').qq|"> |;
$button{'AP--Vendor Invoice'}{order} = $i++;
 
foreach $item (split /;/, $myconfig{acs}) {
delete $button{$item};
}
}
 
print qq|
</tr>
</table>
1052,11 → 1128,13
<input type=hidden name=path value=$form->{path}>
<input type=hidden name=login value=$form->{login}>
<input type=hidden name=password value=$form->{password}>
<input class=submit type=submit name=action value="|.$locale->text('AP Transaction').qq|">
|;
 
<input class=submit type=submit name=action value="|.$locale->text('Purchase Invoice').qq|">
foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
print $item->{code};
}
 
print qq|
</form>
 
</body>
/trunk/bin/mozilla/ar.pl
97,13 → 97,16
 
$form->create_links("AR", \%myconfig, "customer");
$duedate = $form->{duedate};
$notes = $form->{notes};
$taxincluded = $form->{taxincluded};
IS->get_customer(\%myconfig, \%$form);
 
$form->{duedate} = $duedate;
$form->{notes} = $notes if $form->{id};
$form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
$form->{oldinvdate} = $form->{invdate};
 
# currencies
@curr = split /:/, $form->{currencies};
117,7 → 120,14
$form->{customer} = "$form->{customer}--$form->{customer_id}";
map { $form->{selectcustomer} .= "<option>$_->{name}--$_->{id}\n" } (@{ $form->{all_customer} });
}
 
# projects
if (@{ $form->{all_project} }) {
$form->{selectprojectnumber} = "<option>\n";
map { $form->{selectprojectnumber} .= "<option>$_->{projectnumber}\n" } (@{ $form->{all_project} });
}
 
 
# forex
$form->{forex} = $form->{exchangerate};
$exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
159,10 → 169,10
if ($akey eq 'amount') {
$form->{rowcount}++;
$totalamount += $form->{"${akey}_$i"};
 
$form->{"projectnumber_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}";
}
$form->{"${key}_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
$form->{"oldprojectnumber_$i"} = $form->{"projectnumber_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}";
$form->{"project_id_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{project_id}";
}
}
}
171,7 → 181,7
$form->{taxincluded} = $taxincluded if ($form->{id});
$form->{paidaccounts} = 1 if not defined $form->{paidaccounts};
 
if ($form->{taxincluded}) {
if ($form->{taxincluded} && $totalamount) {
# add tax to amounts and invtotal
for $i (1 .. $form->{rowcount}) {
$taxamount = $totaltax * $form->{"amount_$i"} / $totalamount;
183,12 → 193,16
}
 
$form->{invtotal} = $totalamount + $totaltax;
$form->{rowcount}++;
$form->{rowcount}++ if $form->{id};
$form->{AR} = $form->{AR_1};
$form->{rowcount} = 1 if ! $form->{amount_1};
$form->{locked} = ($form->datetonum($form->{transdate}, \%myconfig) <= $form->datetonum($form->{closedto}, \%myconfig));
$form->{locked} = ($form->{revtrans}) ? '1' : ($form->datetonum($form->{transdate}, \%myconfig) <= $form->datetonum($form->{closedto}, \%myconfig));
 
# readonly
$form->{readonly} = 1 if $myconfig{acs} =~ /AR--Add Transaction/;
 
}
 
 
220,17 → 234,13
if ($form->{currency} ne $form->{defaultcurrency}) {
if ($form->{forex}) {
$exchangerate .= qq|
<tr>
<th align=right>|.$locale->text('Exchangerate').qq|</th>
<th align=right>|.$locale->text('Exchange Rate').qq|</th>
<td><input type=hidden name=exchangerate value=$form->{exchangerate}>$form->{exchangerate}</td>
</tr>
|;
} else {
$exchangerate .= qq|
<tr>
<th align=right>|.$locale->text('Exchangerate').qq|</th>
<th align=right>|.$locale->text('Exchange Rate').qq|</th>
<td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
</tr>
|;
}
}
269,6 → 279,8
<input type=hidden name=locked value=$form->{locked}>
<input type=hidden name=title value="$title">
 
<input type=hidden name=oldinvdate value=$form->{oldinvdate}>
 
<table width=100%>
<tr>
<th class=listtop>$form->{title}</th>
282,7 → 294,7
<table>
<tr>
<th align="right" nowrap>|.$locale->text('Customer').qq|</th>
<td>$customer</td>
<td colspan=3>$customer</td>
<input type=hidden name=selectcustomer value="$form->{selectcustomer}">
<input type=hidden name=oldcustomer value="$form->{oldcustomer}">
<input type=hidden name=customer_id value="$form->{customer_id}">
290,7 → 302,7
</tr>
<tr>
<td></td>
<td>
<td colspan=3>
<table width=100%>
<tr>
<th align=left nowrap>|.$locale->text('Credit Limit').qq|</th>
311,8 → 323,8
<input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
<input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
<input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
$exchangerate
</tr>
$exchangerate
</table>
</td>
<td align=right>
339,50 → 351,56
</table>
</td>
</tr>
 
<input type=hidden name=selectAR_amount value="$form->{selectAR_amount}">
<input type=hidden name=selectprojectnumber value="$form->{selectprojectnumber}">
<input type=hidden name=rowcount value=$form->{rowcount}>
<tr>
<td>
<table width=100%>
<input type=hidden name=selectAR_amount value="$form->{selectAR_amount}">
<input type=hidden name=rowcount value=$form->{rowcount}>
|;
 
$amount = $locale->text('Amount');
$project = $locale->text('Project');
for $i (1 .. $form->{rowcount}) {
$form->{"selectAR_amount"} =~ s/ selected//;
$form->{"selectAR_amount"} =~ s/option>\Q$form->{"AR_amount_$i"}\E/option selected>$form->{"AR_amount_$i"}/;
foreach $item (qw(AR_amount projectnumber)) {
$form->{"select$item"} =~ s/ selected//;
$form->{"select$item"} =~ s/option>\Q$form->{"${item}_$i"}\E/option selected>$form->{"${item}_$i"}/;
}
 
# format amounts
$form->{"amount_$i"} = $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
 
$project = qq|
<td align=right><select name="projectnumber_$i">$form->{selectprojectnumber}</select></td>
| if $form->{selectprojectnumber};
 
print qq|
<tr>
<th align=right>$amount</th>
<td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td>
<th>$project</th>
<td><input name="projectnumber_$i" size=20 value="$form->{"projectnumber_$i"}">
<input type=hidden name="project_id_$i" value=$form->{"project_id_$i"}>
<input type=hidden name="oldprojectnumber_$i" value="$form->{"oldprojectnumber_$i"}"></td>
<td width=50%><select name="AR_amount_$i">$form->{"selectAR_amount"}</select></td>
<td><select name="AR_amount_$i">$form->{selectAR_amount}</select></td>
$project
</tr>
|;
$amount = "";
$project = "";
}
 
 
$taxlabel = ($form->{taxincluded}) ? $locale->text('Tax Included') : $locale->text('Tax');
foreach $item (split / /, $form->{taxaccounts}) {
 
$form->{"tax_$item"} = $form->format_amount(\%myconfig, $form->{"tax_$item"}, 2);
 
print qq|
<tr>
<th align=right nowrap>$taxlabel</th>
<td><input name="tax_$item" size=10 value=$form->{"tax_$item"}></td>
<td colspan=2></td>
<td><select name="AR_tax_$item">$form->{"selectAR_tax_$item"}</select></td>
</tr>
<input type=hidden name="${item}_rate" value="$form->{"${item}_rate"}">
399,15 → 417,12
 
<th align=right>|.$locale->text('Total').qq|</th>
<th align=left>$form->{invtotal}</th>
 
<td><select name=AR>$form->{selectAR}</select></td>
<input type=hidden name=selectAR value="$form->{selectAR}">
<input type=hidden name=taxaccounts value="$form->{taxaccounts}">
<input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
<input type=hidden name=oldtotalpaid value=$form->{oldtotalpaid}>
 
<input type=hidden name=taxaccounts value="$form->{taxaccounts}">
 
<td colspan=2></td>
<td><select name=AR>$form->{selectAR}</select></td>
<input type=hidden name=selectAR value="$form->{selectAR}">
</tr>
<tr>
426,7 → 441,11
|;
 
 
@column_index = qw(datepaid source paid exchangerate AR_paid);
if ($form->{currency} eq $form->{defaultcurrency}) {
@column_index = qw(datepaid source paid AR_paid);
} else {
@column_index = qw(datepaid source paid exchangerate AR_paid);
}
 
$column_data{datepaid} = "<th>".$locale->text('Date')."</th>";
$column_data{paid} = "<th>".$locale->text('Amount')."</th>";
468,11 → 487,11
<input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
|;
 
$column_data{"paid_$i"} = qq|<td><input name="paid_$i" size=10 value=$form->{"paid_$i"}></td>|;
$column_data{"AR_paid_$i"} = qq|<td><select name="AR_paid_$i">$form->{"selectAR_paid_$i"}</select></td>|;
$column_data{"exchangerate_$i"} = qq|<td>$exchangerate</td>|;
$column_data{"datepaid_$i"} = qq|<td><input name="datepaid_$i" size=11 value=$form->{"datepaid_$i"}></td>|;
$column_data{"source_$i"} = qq|<td><input name="source_$i" size=10 value="$form->{"source_$i"}"></td>|;
$column_data{"paid_$i"} = qq|<td align=center><input name="paid_$i" size=10 value=$form->{"paid_$i"}></td>|;
$column_data{"AR_paid_$i"} = qq|<td align=center><select name="AR_paid_$i">$form->{"selectAR_paid_$i"}</select></td>|;
$column_data{"exchangerate_$i"} = qq|<td align=center>$exchangerate</td>|;
$column_data{"datepaid_$i"} = qq|<td align=center><input name="datepaid_$i" size=11 value=$form->{"datepaid_$i"}></td>|;
$column_data{"source_$i"} = qq|<td align=center><input name="source_$i" size=10 value="$form->{"source_$i"}"></td>|;
 
map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
482,6 → 501,7
}
print qq|
 
<input type=hidden name=paidaccounts value=$form->{paidaccounts}>
<input type=hidden name=selectAR_paid value="$form->{selectAR_paid}">
 
513,30 → 533,29
$transdate = $form->datetonum($form->{transdate}, \%myconfig);
$closedto = $form->datetonum($form->{closedto}, \%myconfig);
if ($form->{id}) {
if (! $form->{readonly}) {
print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
if ($form->{id}) {
print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
|;
 
if (!$form->{revtrans}) {
if (!$form->{locked}) {
print qq|
<input class=submit type=submit name=action value="|.$locale->text('Post').qq|">
<input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">
<input class=submit type=submit name=action value="|.$locale->text('Post').qq|">
<input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">
|;
}
}
 
if ($transdate > $closedto) {
print qq|
<input class=submit type=submit name=action value="|.$locale->text('Post as new').qq|">
|;
}
 
} else {
if ($transdate > $closedto) {
print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
} else {
if ($transdate > $closedto) {
print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
<input class=submit type=submit name=action value="|.$locale->text('Post').qq|">|;
}
}
}
 
551,12 → 570,17
 
 
sub update {
my $display = shift;
 
$invtotal = 0;
if ($display) {
goto TAXCALC;
}
 
$form->{invtotal} = 0;
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining);
 
@flds = qw(amount AR_amount projectnumber oldprojectnumber project_id);
@flds = qw(amount AR_amount projectnumber);
$count = 0;
@a = ();
for $i (1 .. $form->{rowcount}) {
571,9 → 595,9
}
 
$form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
$form->{rowcount} = $count;
$form->{rowcount} = $count + 1;
 
map { $invtotal += $form->{"amount_$_"} } (1 .. $form->{rowcount});
map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
 
$form->{exchangerate} = $exchangerate if ($form->{forex} = ($exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, 'buy')));
 
581,8 → 605,14
$form->{invdate} = $form->{transdate};
&check_name(customer);
 
&check_project;
if ($form->{invdate} ne $form->{oldinvdate}) {
$form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
$form->{oldinvdate} = $form->{invdate};
}
 
 
 
TAXCALC:
# recalculate taxes
if ($form->{taxincluded}) {
$taxrate = 0;
590,7 → 620,7
map { $taxrate += $form->{"${_}_rate"} } split / /, $form->{taxaccounts};
 
foreach $item (split / /, $form->{taxaccounts}) {
$amount = ($invtotal * (1 - 1 / (1 + $taxrate)) * $form->{"${item}_rate"} / $taxrate) if $taxrate;
$amount = ($form->{invtotal} * (1 - 1 / (1 + $taxrate)) * $form->{"${item}_rate"} / $taxrate) if $taxrate;
$form->{"tax_$item"} = $form->round_amount($amount, 2);
$taxdiff += ($amount - $form->{"tax_$item"});
if (abs $taxdiff >= 0.005) {
602,13 → 632,13
}
} else {
foreach $item (split / /, $form->{taxaccounts}) {
$form->{"tax_$item"} = $form->round_amount($invtotal * $form->{"${item}_rate"}, 2);
$form->{"tax_$item"} = $form->round_amount($form->{invtotal} * $form->{"${item}_rate"}, 2);
$form->{"selectAR_tax_$item"} = qq|<option>$item--$form->{"${item}_description"}|;
$totaltax += $form->{"tax_$item"};
}
}
 
$form->{invtotal} = ($form->{taxincluded}) ? $invtotal : $invtotal + $totaltax;
$form->{invtotal} = ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
 
for $i (1 .. $form->{paidaccounts}) {
if ($form->{"paid_$i"}) {
624,9 → 654,6
$form->{oldinvtotal} = $form->{invtotal};
$form->{oldtotalpaid} = $totalpaid;
# add a new row
$form->{rowcount}++;
 
&display_form;
}
645,7 → 672,7
$form->error($locale->text('Cannot post transaction for a closed period!')) if ($transdate <= $closedto);
 
$form->isblank("exchangerate", $locale->text('Exchangerate missing!')) if ($form->{currency} ne $form->{defaultcurrency});
$form->isblank("exchangerate", $locale->text('Exchange rate missing!')) if ($form->{currency} ne $form->{defaultcurrency});
for $i (1 .. $form->{paidaccounts}) {
if ($form->{"paid_$i"}) {
657,7 → 684,7
 
if ($form->{currency} ne $form->{defaultcurrency}) {
$form->{"exchangerate_$i"} = $form->{exchangerate} if ($transdate == $datepaid);
$form->isblank("exchangerate_$i", $locale->text('Exchangerate for payment missing!'));
$form->isblank("exchangerate_$i", $locale->text('Exchange rate for payment missing!'));
}
}
}
727,18 → 754,53
 
sub search {
 
# setup customer selection
$form->all_vc(\%myconfig, "customer");
$form->create_links("AR", \%myconfig, "customer");
$form->{selectAR} = "<option>\n";
map { $form->{selectAR} .= "<option>$_->{accno}--$_->{description}\n" } @{ $form->{AR_links}{AR} };
 
 
if (@{ $form->{all_customer} }) {
map { $customer .= "<option>$_->{name}--$_->{id}\n" } @{ $form->{all_customer} };
$customer = qq|<select name=customer><option>\n$customer</select>|;
} else {
$customer = qq|<input name=customer size=35>|;
}
 
 
$form->{title} = $locale->text('AR Transactions');
$invnumber = qq|
<tr>
<th align=right nowrap>|.$locale->text('Invoice Number').qq|</th>
<td colspan=3><input name=invnumber size=20></td>
</tr>
<tr>
<th align=right nowrap>|.$locale->text('Order Number').qq|</th>
<td colspan=3><input name=ordnumber size=20></td>
</tr>
<tr>
<th align=right nowrap>|.$locale->text('Notes').qq|</th>
<td colspan=3><input name=notes size=40></td>
</tr>
|;
 
$openclosed = qq|
<tr>
<td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
<td nowrap>|.$locale->text('Open').qq|</td>
<td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
<td nowrap>|.$locale->text('Closed').qq|</td>
</tr>
|;
 
if ($form->{outstanding}) {
$form->{title} = $locale->text('AR Outstanding');
$invnumber = "";
$openclosed = "";
}
 
$form->header;
print qq|
746,29 → 808,25
 
<form method=post action=$form->{script}>
 
<input type=hidden name=title value="$form->{title}">
<input type=hidden name=outstanding value=$form->{outstanding}>
 
<table width=100%>
<tr><th class=listtop>$form->{title}</th></tr>
<tr height="5"></tr>
<tr>
<td>
<table>
<tr>
<th align=right>|.$locale->text('Account').qq|</th>
<td colspan=3><select name=AR>$form->{selectAR}</select></td>
</tr>
<tr>
<th align=right>|.$locale->text('Customer').qq|</th>
<td colspan=3>$customer</td>
</tr>
$invnumber
<tr>
<th align=right nowrap>|.$locale->text('Invoice Number').qq|</th>
<td colspan=3><input name=invnumber size=20></td>
</tr>
<tr>
<th align=right nowrap>|.$locale->text('Order Number').qq|</th>
<td colspan=3><input name=ordnumber size=20></td>
</tr>
<tr>
<th align=right nowrap>|.$locale->text('Notes').qq|</th>
<td colspan=3><input name=notes size=40></td>
</tr>
<tr>
<th align=right nowrap>|.$locale->text('From').qq|</th>
<td><input name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
<th align=right>|.$locale->text('to').qq|</th>
785,13 → 843,8
<th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
<td>
<table width=100%>
$openclosed
<tr>
<td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
<td nowrap>|.$locale->text('Open').qq|</td>
<td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
<td nowrap>|.$locale->text('Closed').qq|</td>
</tr>
<tr>
<td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
<td nowrap>|.$locale->text('ID').qq|</td>
<td align=right><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
824,8 → 877,12
<tr>
<td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
<td nowrap>|.$locale->text('Notes').qq|</td>
<td align=right><input name="l_till" class=checkbox type=checkbox value=Y></td>
<td nowrap>|.$locale->text('Till').qq|</td>
<td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
<td nowrap>|.$locale->text('Employee').qq|</td>
<td nowrap>|.$locale->text('Salesperson').qq|</td>
<td align=right><input name="l_shippingpoint" class=checkbox type=checkbox value=Y></td>
<td nowrap>|.$locale->text('Ship via').qq|</td>
</tr>
<tr>
<td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
862,33 → 919,46
 
sub ar_transactions {
 
$form->{customer} = $form->unescape($form->{customer});
($form->{customer}, $form->{customer_id}) = split(/--/, $form->{customer});
if ($form->{customer}) {
$form->{customer} = $form->unescape($form->{customer});
($form->{customer}, $form->{customer_id}) = split /--/, $form->{customer};
}
 
AR->ar_transactions(\%myconfig, \%$form);
 
$callback = "$form->{script}?action=ar_transactions&path=$form->{path}&login=$form->{login}&password=$form->{password}";
$callback = "$form->{script}?action=ar_transactions&till=$form->{till}&outstanding=$form->{outstanding}&path=$form->{path}&login=$form->{login}&password=$form->{password}";
$href = $callback;
 
$callback .= "&title=".$form->escape($form->{title},1);
$href .= "&title=".$form->escape($form->{title});
 
if ($form->{AR}) {
$callback .= "&AR=".$form->escape($form->{AR},1);
$href .= "&AR=".$form->escape($form->{AR});
$form->{AR} =~ s/--/ /;
$option = $locale->text('Account')." : $form->{AR}";
}
 
if ($form->{customer}) {
$callback .= "&customer=".$form->escape($form->{customer});
$href .= "&customer=".$form->escape($form->{customer});
$option = $locale->text('Customer')." : $form->{customer}";
$callback .= "&customer=".$form->escape($form->{customer},1)."--$form->{customer_id}";
$href .= "&customer=".$form->escape($form->{customer})."--$form->{customer_id}";
$option .= "\n<br>" if ($option);
$option .= $locale->text('Customer')." : $form->{customer}";
}
if ($form->{invnumber}) {
$callback .= "&invnumber=$form->{invnumber}";
$callback .= "&invnumber=".$form->escape($form->{invnumber},1);
$href .= "&invnumber=".$form->escape($form->{invnumber});
$option .= "\n<br>" if ($option);
$option .= $locale->text('Invoice Number')." : $form->{invnumber}";
}
if ($form->{ordnumber}) {
$callback .= "&ordnumber=$form->{ordnumber}";
$callback .= "&ordnumber=".$form->escape($form->{ordnumber},1);
$href .= "&ordnumber=".$form->escape($form->{ordnumber});
$option .= "\n<br>" if ($option);
$option .= $locale->text('Order Number')." : $form->{ordnumber}";
}
if ($form->{notes}) {
$callback .= "&notes=$form->{notes}";
$callback .= "&notes=".$form->escape($form->{notes},1);
$href .= "&notes=".$form->escape($form->{notes});
$option .= "\n<br>" if $option;
$option .= $locale->text('Notes')." : $form->{notes}";
919,7 → 989,7
$option .= $locale->text('Closed');
}
 
@columns = $form->sort_columns(qw(transdate id invnumber ordnumber name netamount tax amount paid datepaid due duedate notes employee));
@columns = $form->sort_columns(qw(transdate id invnumber ordnumber name netamount tax amount paid due datepaid duedate notes till employee shippingpoint));
foreach $item (@columns) {
if ($form->{"l_$item"} eq "Y") {
950,11 → 1020,14
$column_header{datepaid} = "<th><a class=listheading href=$href&sort=datepaid>" . $locale->text('Date Paid') . "</a></th>";
$column_header{due} = "<th class=listheading>" . $locale->text('Amount Due') . "</th>";
$column_header{notes} = "<th class=listheading>".$locale->text('Notes')."</th>";
$column_header{employee} = "<th class=listheading><a class=listheading href=$href&sort=employee>".$locale->text('Employee')."</th>";
 
$column_header{employee} = "<th class=listheading><a class=listheading href=$href&sort=employee>".$locale->text('Salesperson')."</th>";
$column_header{till} = "<th class=listheading><a class=listheading href=$href&sort=till>".$locale->text('Till')."</th>";
 
$column_header{shippingpoint} = "<th class=listheading><a class=listheading href=$href&sort=shippingpoint>" . $locale->text('Ship via') . "</a></th>";
$form->{title} = ($form->{title}) ? $form->{title} : $locale->text('AR Transactions');
 
$form->{title} = $locale->text('AR Transactions');
 
$form->header;
 
print qq|
987,13 → 1060,13
# escape callback for href
$callback = $form->escape($callback);
if (@{ $form->{AR} }) {
$sameitem = $form->{AR}->[0]->{$form->{sort}};
if (@{ $form->{transactions} }) {
$sameitem = $form->{transactions}->[0]->{$form->{sort}};
}
# sums and tax on reports by Antonio Gallardo
#
foreach $ar (@{ $form->{AR} }) {
foreach $ar (@{ $form->{transactions} }) {
 
if ($form->{l_subtotal} eq 'Y') {
if ($sameitem ne $ar->{$form->{sort}}) {
1023,13 → 1096,17
$column_data{duedate} = "<td>$ar->{duedate}&nbsp;</td>";
 
$module = ($ar->{invoice}) ? "is.pl" : $form->{script};
$module = ($ar->{till}) ? "ps.pl" : $module;
 
$column_data{invnumber} = "<td><a href=$module?action=edit&id=$ar->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ar->{invnumber}</a></td>";
$column_data{ordnumber} = "<td>$ar->{ordnumber}&nbsp;</td>";
$column_data{name} = "<td>$ar->{name}</td>";
$ar->{notes} =~ s/\r\n/<br>/g;
$column_data{notes} = "<td>$ar->{notes}&nbsp;</td>";
$column_data{shippingpoint} = "<td>$ar->{shippingpoint}&nbsp;</td>";
 
$column_data{employee} = "<td>$ar->{employee}&nbsp;</td>";
$column_data{till} = "<td>$ar->{till}&nbsp;</td>";
 
$i++; $i %= 2;
print "
1064,6 → 1141,19
 
map { print "\n$column_data{$_}" } @column_index;
 
if ($myconfig{acs} !~ /AR--AR/) {
$i = 1;
$button{'AR--Add Transaction'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('AR Transaction').qq|"> |;
$button{'AR--Add Transaction'}{order} = $i++;
$button{'AR--Sales Invoice'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Sales Invoice').qq|"> |;
$button{'AR--Sales Invoice'}{order} = $i++;
 
foreach $item (split /;/, $myconfig{acs}) {
delete $button{$item};
}
}
 
print qq|
</tr>
</table>
1082,10 → 1172,15
<input type=hidden name=path value=$form->{path}>
<input type=hidden name=login value=$form->{login}>
<input type=hidden name=password value=$form->{password}>
|;
 
<input class=submit type=submit name=action value="|.$locale->text('AR Transaction').qq|">
<input class=submit type=submit name=action value="|.$locale->text('Sales Invoice').qq|">
if (! $form->{till}) {
foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
print $item->{code};
}
}
 
print qq|
</form>
 
</body>
/trunk/bin/mozilla/ct.pl
26,9 → 26,6
#
#======================================================================
 
# $locale->text('Customers')
# $locale->text('Vendors')
 
use SL::CT;
 
1;
39,6 → 36,8
sub add {
 
$form->{title} = "Add";
# $locale->text('Add Customer')
# $locale->text('Add Vendor')
 
$form->{callback} = "$form->{script}?action=add&db=$form->{db}&path=$form->{path}&login=$form->{login}&password=$form->{password}" unless $form->{callback};
 
50,10 → 49,165
}
 
 
sub history {
 
# $locale->text('Customer Transaction History')
# $locale->text('Vendor Transaction History')
 
$history = 1;
$label = ucfirst $form->{db};
$label .= " Transaction History";
$form->{title} = $locale->text($label);
 
if ($form->{db} eq 'customer') {
$invlabel = $locale->text('Sales Invoices');
$ordlabel = $locale->text('Sales Orders');
} else {
$invlabel = $locale->text('Vendor Invoices');
$ordlabel = $locale->text('Purchase Orders');
}
$form->{nextsub} = "list_history";
 
$transactions = qq|
<tr>
<td></td>
<td>
<table>
<tr>
<td>
<table>
<tr>
<td><input name=type type=radio class=radio value=invoice checked> $invlabel</td>
</tr>
<tr>
<td><input name=type type=radio class=radio value=order> $ordlabel</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<th>|.$locale->text('From').qq|</th>
<td><input name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
<th>|.$locale->text('To').qq|</th>
<td><input name=transdateto size=11 title="$myconfig{dateformat}"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
|;
 
$include = qq|
<tr>
<th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
<td>
<table>
<tr>
<td><input name=history type=radio class=radio value=summary checked> |.$locale->text('Summary').qq|</td>
<td><input name=history type=radio class=radio value=detail> |.$locale->text('Detail').qq|
</td>
</tr>
<tr>
<td>
<input name="l_partnumber" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Partnumber').qq|
</td>
<td>
<input name="l_description" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Description').qq|
</td>
<td>
<input name="l_sellprice" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Price').qq|
</td>
<td>
<input name="l_fxsellprice" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Foreign Price').qq|
</td>
</tr>
<tr>
<td>
<input name="l_curr" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Currency').qq|
</td>
<td>
<input name="l_qty" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Qty').qq|
</td>
<td>
<input name="l_unit" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Unit').qq|
</td>
<td>
<input name="l_discount" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Discount').qq|
</td>
<tr>
</tr>
<td>
<input name="l_deliverydate" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Delivery Date').qq|
</td>
<td>
<input name="l_projectnumber" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Project Number').qq|
</td>
</tr>
</table>
</td>
</tr>
|;
 
&search_name;
 
}
 
 
sub include_in_report {
$include = qq|
<tr>
<th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
<td>
<input name="l_$form->{db}number" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Number').qq|
<input name="l_name" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Name').qq|
<input name="l_address" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Address').qq|<br>
<input name="l_contact" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Contact').qq|
<input name="l_phone" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Phone').qq|
<input name="l_fax" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Fax').qq|
<input name="l_email" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('E-mail').qq|
<input name="l_cc" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Cc').qq|
</td>
</tr>
|;
 
}
 
 
sub search {
# $locale->text('Customers')
# $locale->text('Vendors')
 
$label = ucfirst $form->{db};
$form->{title} = $locale->text($label."s");
$label .= "s";
$form->{title} = $locale->text($label) unless $form->{title};
 
map { $form->{"l_$_"} = 'checked' } qw(name contact phone email);
 
$form->{nextsub} = "list_names";
 
$orphan = qq|
<tr>
<td></td>
<td><input name=status class=radio type=radio value=all checked>&nbsp;|.$locale->text('All').qq|
<input name=status class=radio type=radio value=orphaned>&nbsp;|.$locale->text('Orphaned').qq|</td>
</tr>
|;
 
&include_in_report;
&search_name;
 
}
 
 
sub search_name {
$form->header;
88,24 → 242,12
<th align=right nowrap>|.$locale->text('E-mail').qq|</th>
<td><input name=email size=35></td>
</tr>
<tr>
<td></td>
<td><input name=status class=radio type=radio value=all checked>&nbsp;|.$locale->text('All').qq|
<input name=status class=radio type=radio value=orphaned>&nbsp;|.$locale->text('Orphaned').qq|</td>
</tr>
<tr>
<th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
<td>
<input name="l_$form->{db}number" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Number').qq|
<input name="l_name" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Name').qq|
<input name="l_address" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Address').qq|<br>
<input name="l_contact" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Contact').qq|
<input name="l_phone" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Phone').qq|
<input name="l_fax" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Fax').qq|
<input name="l_email" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('E-mail').qq|
<input name="l_cc" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Cc').qq|
</td>
</tr>
 
$orphan
$transactions
$include
 
 
</table>
</td>
</tr>
114,7 → 256,7
</tr>
</table>
 
<input type=hidden name=nextsub value=list_names>
<input type=hidden name=nextsub value=$form->{nextsub}>
 
<input type=hidden name=path value=$form->{path}>
<input type=hidden name=login value=$form->{login}>
238,6 → 380,24
}
 
$i = 1;
if ($myconfig{acs} !~ /AR--AR/) {
if ($form->{db} eq 'customer') {
$button{'AR--Customers--Add Customer'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Add Customer').qq|"> |;
$button{'AR--Customers--Add Customer'}{order} = $i++;
}
}
if ($myconfig{acs} !~ /AP--AP/) {
if ($form->{db} eq 'vendor') {
$button{'AP--Vendors--Add Vendor'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Add Vendor').qq|"> |;
$button{'AP--Vendors--Add Vendor'}{order} = $i++;
}
}
 
foreach $item (split /;/, $myconfig{acs}) {
delete $button{$item};
}
print qq|
</table>
</td>
256,9 → 416,13
<input type=hidden name=path value=$form->{path}>
<input type=hidden name=login value=$form->{login}>
<input type=hidden name=password value=$form->{password}>
|;
 
<input class=submit type=submit name=action value="|.$locale->text('Add').qq|">
foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
print $item->{code};
}
 
print qq|
</form>
 
</body>
268,6 → 432,232
}
 
 
sub list_history {
CT->get_history(\%myconfig, \%$form);
$callback = "$form->{script}?action=list_history&db=$form->{db}&path=$form->{path}&login=$form->{login}&password=$form->{password}&type=$form->{type}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&history=$form->{history}";
$href = $callback;
@columns = $form->sort_columns(partnumber, description, qty, unit, sellprice, fxsellprice, curr, discount, deliverydate, projectnumber);
 
if ($form->{history} eq 'summary') {
@columns = $form->sort_columns(partnumber, description, qty, unit, sellprice, fxsellprice);
}
 
foreach $item (@columns) {
if ($form->{"l_$item"} eq "Y") {
push @column_index, $item;
 
# add column to href and callback
$callback .= "&l_$item=Y";
$href .= "&l_$item=Y";
}
}
if ($form->{history} eq 'detail') {
$option = $locale->text('Detail');
}
if ($form->{history} eq 'summary') {
$option .= $locale->text('Summary');
}
if ($form->{name}) {
$callback .= "&name=".$form->escape($form->{name},1);
$href .= "&name=".$form->escape($form->{name});
$option .= "\n<br>".$locale->text('Name')." : $form->{name}";
}
if ($form->{contact}) {
$callback .= "&contact=".$form->escape($form->{contact},1);
$href .= "&contact=".$form->escape($form->{contact});
$option .= "\n<br>".$locale->text('Contact')." : $form->{contact}";
}
if ($form->{"$form->{db}number"}) {
$callback .= qq|&$form->{db}number=|.$form->escape($form->{"$form->{db}number"},1);
$href .= "&$form->{db}number=".$form->escape($form->{"$form->{db}number"});
$option .= "\n<br>".$locale->text('Number').qq| : $form->{"$form->{db}number"}|;
}
if ($form->{email}) {
$callback .= "&email=".$form->escape($form->{email},1);
$href .= "&email=".$form->escape($form->{email});
$option .= "\n<br>".$locale->text('E-mail')." : $form->{email}";
}
if ($form->{transdatefrom}) {
$callback .= "&transdatefrom=$form->{transdatefrom}";
$href .= "&transdatefrom=$form->{transdatefrom}";
$option .= "\n<br>".$locale->text('From')."&nbsp;".$locale->date(\%myconfig, $form->{transdatefrom}, 1);
}
if ($form->{transdateto}) {
$callback .= "&transdateto=$form->{transdateto}";
$href .= "&transdateto=$form->{transdateto}";
if ($form->{transdatefrom}) {
$option .= " ";
} else {
$option .= "\n<br>";
}
$option .= $locale->text('to')."&nbsp;".$locale->date(\%myconfig, $form->{transdateto}, 1);
}
 
$form->{callback} = "$callback&sort=$form->{sort}";
$callback = $form->escape($form->{callback});
$column_header{partnumber} = qq|<th><a class=listheading href=$href&sort=partnumber>|.$locale->text('Partnumber').qq|</a></th>|;
$column_header{description} = qq|<th><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</a></th>|;
 
if ($form->{history} eq 'summary') {
$column_header{sellprice} = qq|<th class=listheading>|.$locale->text('Total').qq|</th>|;
} else {
$column_header{sellprice} = qq|<th class=listheading>|.$locale->text('Price').qq|</th>|;
}
$column_header{fxsellprice} = qq|<th class=listheading>|.$locale->text('Foreign Price').qq|</th>|;
$column_header{curr} = qq|<th class=listheading>|.$locale->text('Curr').qq|</th>|;
$column_header{discount} = qq|<th class=listheading>|.$locale->text('Disc').qq|</th>|;
$column_header{qty} = qq|<th class=listheading>|.$locale->text('Qty').qq|</th>|;
$column_header{unit} = qq|<th class=listheading>|.$locale->text('Unit').qq|</th>|;
$column_header{deliverydate} = qq|<th><a class=listheading href=$href&sort=deliverydate>|.$locale->text('Delivery Date').qq|</a></th>|;
$column_header{projectnumber} = qq|<th><a class=listheading href=$href&sort=projectnumber>|.$locale->text('Project Number').qq|</a></th>|;
 
# $locale->text('Customer Transaction History')
# $locale->text('Vendor Transaction History')
 
$label = ucfirst $form->{db};
$form->{title} = $locale->text($label." Transaction History");
 
$colspan = $#column_index + 1;
 
$form->header;
 
print qq|
<body>
 
<table width=100%>
<tr>
<th class=listtop>$form->{title}</th>
</tr>
<tr height="5"></tr>
<tr>
<td>$option</td>
</tr>
<tr>
<td>
<table width=100%>
<tr class=listheading>
|;
 
map { print "$column_header{$_}\n" } @column_index;
 
print qq|
</tr>
|;
 
$ml = 1;
$module = 'oe';
if ($form->{db} eq 'customer') {
if ($form->{type} eq 'invoice') {
$invlabel = $locale->text('Sales Invoice');
$module = 'is';
} else {
$ordertype = 'sales_order';
$invlabel = $locale->text('Sales Order');
}
} else {
if ($form->{type} eq 'invoice') {
$invlabel = $locale->text('Vendor Invoice');
$ml = -1;
$module = 'ir';
} else {
$ordertype = 'purchase_order';
$invlabel = $locale->text('Purchase Order');
}
}
 
foreach $ref (@{ $form->{CT} }) {
 
if ($ref->{id} ne $sameid) {
# print the header
print qq|
<tr class=listheading>
<th colspan=$colspan><a class=listheading href=$form->{script}?action=edit&id=$ref->{ctid}&db=$form->{db}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{name} $ref->{address}</a></th>
</tr>
|;
}
 
if ($form->{history} eq 'detail' and $ref->{invid} ne $sameinvid) {
# print inv, ord number
$i++; $i %= 2;
print qq|
<tr class=listrow$i>
|;
 
if ($form->{type} eq 'invoice') {
print qq|<th align=left colspan=$colspan><a href=${module}.pl?action=edit&id=$ref->{invid}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$invlabel $ref->{invnumber}</th>|;
}
if ($form->{type} eq 'order') {
print qq|<th align=left colspan=$colspan><a href=${module}.pl?action=edit&id=$ref->{invid}&type=$ordertype&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$invlabel $ref->{ordnumber}</th>|;
}
 
print qq|
</tr>
|;
}
 
map { $column_data{$_} = "<td>$ref->{$_}&nbsp;</td>" } @column_index;
 
map { $column_data{$_} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{$_}, 2)."</td>" } qw(sellprice fxsellprice);
$column_data{qty} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{qty} * $ml)."</td>";
$column_data{discount} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{discount} * 100)."</td>";
$column_data{partnumber} = qq|<td><a href=ic.pl?action=edit&id=$ref->{pid}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{partnumber}</td>|;
$i++; $i %= 2;
print "
<tr class=listrow$i>
";
 
map { print "$column_data{$_}\n" } @column_index;
 
print qq|
</tr>
|;
$sameid = $ref->{id};
$sameinvid = $ref->{invid};
 
}
 
print qq|
</table>
</td>
</tr>
<tr>
<td><hr size=3 noshade></td>
</tr>
</table>
 
<br>
<form method=post action=$form->{script}>
 
<input name=callback type=hidden value="$form->{callback}">
<input name=db type=hidden value=$form->{db}>
 
<input type=hidden name=path value=$form->{path}>
<input type=hidden name=login value=$form->{login}>
<input type=hidden name=password value=$form->{password}>
 
</form>
 
</body>
</html>
|;
}
 
 
sub edit {
 
# $locale->text('Edit Customer')
292,7 → 682,7
sub form_header {
 
foreach $item (split / /, $form->{taxaccounts}) {
if (($form->{tax}{$item}{taxable}) || !($form->{id})) {
if ($form->{tax}{$item}{taxable}) {
$taxable .= qq| <input name="tax_$item" value=1 class=checkbox type=checkbox checked>&nbsp;<b>$form->{tax}{$item}{description}</b>|;
} else {
$taxable .= qq| <input name="tax_$item" value=1 class=checkbox type=checkbox>&nbsp;<b>$form->{tax}{$item}{description}</b>|;
353,53 → 743,53
<td>
<table width=100%>
<tr class=listheading>
<th class=listheading colspan=2 width=50%">&nbsp;</th>
<th class=listheading width=50%">|.$locale->text('Ship to').qq|</th>
<th class=listheading colspan=2 width=50%>&nbsp;</th>
<th class=listheading width=50%>|.$locale->text('Ship to').qq|</th>
</tr>
<tr height="5"></tr>
<tr>
<th align=right nowrap>|.$locale->text('Number').qq|</th>
<td><input name="$form->{db}number" size=35 maxsize=35 value="$form->{"$form->{db}number"}"></td>
<td><input name="$form->{db}number" size=35 maxlength=35 value="$form->{"$form->{db}number"}"></td>
</tr>
<tr>
<th align=right nowrap>|.$locale->text('Name').qq|</th>
<td><input name=name size=35 maxsize=35 value="$form->{name}"></td>
<td><input name=shiptoname size=35 maxsize=35 value="$form->{shiptoname}"></td>
<td><input name=name size=35 maxlength=35 value="$form->{name}"></td>
<td><input name=shiptoname size=35 maxlength=35 value="$form->{shiptoname}"></td>
</tr>
<tr>
<th align=right nowrap>|.$locale->text('Address').qq|</th>
<td><input name=addr1 size=35 maxsize=35 value="$form->{addr1}"></td>
<td><input name=shiptoaddr1 size=35 maxsize=35 value="$form->{shiptoaddr1}"></td>
<td><input name=addr1 size=35 maxlength=35 value="$form->{addr1}"></td>
<td><input name=shiptoaddr1 size=35 maxlength=35 value="$form->{shiptoaddr1}"></td>
</tr>
<tr>
<th></th>
<td><input name=addr2 size=35 maxsize=35 value="$form->{addr2}"></td>
<td><input name=shiptoaddr2 size=35 maxsize=35 value="$form->{shiptoaddr2}"></td>
<td><input name=addr2 size=35 maxlength=35 value="$form->{addr2}"></td>
<td><input name=shiptoaddr2 size=35 maxlength=35 value="$form->{shiptoaddr2}"></td>
</tr>
<tr>
<th></th>
<td><input name=addr3 size=35 maxsize=35 value="$form->{addr3}"></td>
<td><input name=shiptoaddr3 size=35 maxsize=35 value="$form->{shiptoaddr3}"></td>
<td><input name=addr3 size=35 maxlength=35 value="$form->{addr3}"></td>
<td><input name=shiptoaddr3 size=35 maxlength=35 value="$form->{shiptoaddr3}"></td>
</tr>
<tr>
<th></th>
<td><input name=addr4 size=35 maxsize=35 value="$form->{addr4}"></td>
<td><input name=shiptoaddr4 size=35 maxsize=35 value="$form->{shiptoaddr4}"></td>
<td><input name=addr4 size=35 maxlength=35 value="$form->{addr4}"></td>
<td><input name=shiptoaddr4 size=35 maxlength=35 value="$form->{shiptoaddr4}"></td>
</tr>
<tr>
<th align=right nowrap>|.$locale->text('Contact').qq|</th>
<td><input name=contact size=35 maxsize=35 value="$form->{contact}"></td>
<td><input name=shiptocontact size=35 maxsize=35 value="$form->{shiptocontact}"></td>
<td><input name=contact size=35 maxlength=35 value="$form->{contact}"></td>
<td><input name=shiptocontact size=35 maxlength=35 value="$form->{shiptocontact}"></td>
</tr>
<tr>
<th align=right nowrap>|.$locale->text('Phone').qq|</th>
<td><input name=phone size=20 maxsize=20 value="$form->{phone}"></td>
<td><input name=shiptophone size=20 maxsize=20 value="$form->{shiptophone}"></td>
<td><input name=phone size=20 maxlength=20 value="$form->{phone}"></td>
<td><input name=shiptophone size=20 maxlength=20 value="$form->{shiptophone}"></td>
</tr>
<tr>
<th align=right nowrap>|.$locale->text('Fax').qq|</th>
<td><input name=fax size=20 maxsize=20 value="$form->{fax}"></td>
<td><input name=shiptofax size=20 maxsize=20 value="$form->{shiptofax}"></td>
<td><input name=fax size=20 maxlength=20 value="$form->{fax}"></td>
<td><input name=shiptofax size=20 maxlength=20 value="$form->{shiptofax}"></td>
</tr>
<tr>
<th align=right nowrap>|.$locale->text('E-mail').qq|</th>
447,6 → 837,36
 
sub form_footer {
 
$i = 1;
if ($form->{db} eq 'customer') {
if ($myconfig{acs} !~ /AR--AR/) {
$button{'AR--Add Transaction'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('AR Transaction').qq|"> |;
$button{'AR--Add Transaction'}{order} = $i++;
$button{'AR--Sales Invoice'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Invoice').qq|"> |;
$button{'AR--Sales Invoice'}{order} = $i++;
}
if ($myconfig{acs} !~ /Order Entry--Order Entry/) {
$button{'Order Entry--Sales Order'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Order').qq|"> |;
$button{'Order Entry--Sales Order'}{order} = $i++;
}
}
if ($form->{db} eq 'vendor') {
if ($myconfig{acs} !~ /AP--AP/) {
$button{'AP--Add Transaction'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('AP Transaction').qq|"> |;
$button{'AP--Add Transaction'}{order} = $i++;
$button{'AP--Vendor Invoice'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Invoice').qq|"> |;
$button{'AP--Vendor Invoice'}{order} = $i++;
}
if ($myconfig{acs} !~ /Order Entry--Order Entry/) {
$button{'Order Entry--Purchase Order'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Order').qq|"> |;
$button{'Order Entry--Purchase Order'}{order} = $i++;
}
}
 
foreach $item (split /;/, $myconfig{acs}) {
delete $button{$item};
}
$label = ucfirst $form->{db};
 
print qq|
461,16 → 881,30
<input type=hidden name=db value=$form->{db}>
 
<br>
|;
 
if ($form->{db} eq 'customer') {
$item = 'AR--Customers--Add Customer';
}
if ($form->{db} eq 'vendor') {
$item = 'AP--Vendors--Add Vendor';
}
if ($myconfig{acs} !~ /$item/) {
print qq|
<input class=submit type=submit name=action value="|.$locale->text("Save").qq|">
<input class=submit type=submit name=action value="|.$locale->text("Invoice").qq|">
<input class=submit type=submit name=action value="|.$locale->text('Order').qq|">
|;
 
if ($form->{id} && $form->{status} eq 'orphaned') {
print qq|<input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">\n|;
if ($form->{id} && $form->{status} eq 'orphaned') {
print qq|<input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">\n|;
}
 
}
 
foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
print $item->{code};
}
 
print qq|
</form>
482,6 → 916,37
}
 
 
sub add_transaction {
 
$form->isblank("name", $locale->text("Name missing!"));
&{ "CT::save_$form->{db}" }("", \%myconfig, \%$form);
 
$form->{callback} = $form->escape($form->{callback},1);
$name = $form->escape("$form->{name}",1);
 
$form->{callback} = "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=add&vc=$form->{db}&$form->{db}_id=$form->{id}&$form->{db}=$name&type=$form->{type}&callback=$form->{callback}";
 
$form->redirect;
 
}
 
 
sub ap_transaction {
 
$form->{script} = "ap.pl";
&add_transaction;
 
}
 
 
sub ar_transaction {
 
$form->{script} = "ar.pl";
&add_transaction;
 
}
 
 
sub invoice { &{ "$form->{db}_invoice" } };
 
sub customer_invoice {
628,4 → 1093,6
 
sub continue { &{ $form->{nextsub} } };
 
sub add_customer { &add };
sub add_vendor { &add };
 
/trunk/setup.pl
23,9 → 23,10
$tar = `tar --version 2>&1`; # tar archiver
$latex = `latex -version`;
 
@source = ( "http://unc.dl.sourceforge.net/sourceforge/sql-ledger",
"http://www.sql-ledger.org/source",
"http://abacus.sql-ledger.org/source" );
@source = ( "http://www.sql-ledger.org/source",
"http://www.sql-ledger.com/source",
"http://abacus.sql-ledger.org/source",
"http://pluto.sql-ledger.org/source" );
 
$userspath = "users"; # default for new installation
 
67,24 → 68,24
}
 
 
if ($newinstall) {
if ($httpd = `find /etc /usr/local/etc -type f -name 'httpd.conf'`) {
chomp $httpd;
$webowner = `grep "^User " $httpd`;
$webgroup = `grep "^Group " $httpd`;
$serverroot = `grep "^ServerRoot " $httpd`;
# is this windows? only used for downloading the right code
$windows = ($^O =~ /MS/) ? '/windows' : '';
 
chomp $webowner;
chomp $webgroup;
chomp $serverroot;
($null, $webowner) = split / /, $webowner;
($null, $webgroup) = split / /, $webgroup;
($null, $serverroot) = split / /, $serverroot;
 
$serverroot =~ s/"//g;
}
$webowner = $<;
$webgroup = $(;
 
if ($httpd = `find /etc /usr/local/etc -type f -name 'httpd.conf'`) {
chomp $httpd;
$webowner = `grep "^User " $httpd`;
$webgroup = `grep "^Group " $httpd`;
 
chomp $webowner;
chomp $webgroup;
($null, $webowner) = split / /, $webowner;
($null, $webgroup) = split / /, $webgroup;
 
}
 
system("tput clear");
103,7 → 104,7
}
 
if ($version && $latest_version) {
if (!$filename && $version ne $latest_version) {
if (!$filename && $version le $latest_version) {
if (substr($version, 0, rindex($version, ".")) eq substr($latest_version, 0, rindex($latest_version, "."))) {
$install .= "\n(u)pgrade to $latest_version\n";
}
118,7 → 119,7
print qq|
 
 
SQL-Ledger Accounting Software Installation
SQL-Ledger Accounting Installation
 
 
 
150,17 → 151,13
if ($a eq 'd') {
&download;
}
if ($a eq 'i') {
if ($a =~ /(i|u)/) {
&install;
}
if ($a eq 'r') {
$latest_version = $version;
&install;
}
if ($a eq 'u') {
&upgrade;
}
 
if ($a eq 'f') {
&install;
}
250,14 → 247,14
print "\nTrying $host .... ";
if ($lwp) {
$err = LWP::Simple::getstore("$source/$latest_version", "$latest_version");
$err = LWP::Simple::getstore("$source$windows/$latest_version", "$latest_version");
$err -= 200;
} else {
$ok = `lynx -dump -head $source/$latest_version`;
$ok = `lynx -dump -head $source$windows/$latest_version`;
$err = !($ok =~ s/HTTP.*?200 OK//);
 
if (!$err) {
$err = system("lynx -dump $source/$latest_version > $latest_version");
$err = system("lynx -dump $source$windows/$latest_version > $latest_version");
}
}
 
290,27 → 287,7
 
&decompress;
 
if ($upgrade) {
print qq|
 
Don't forget to upgrade the datasets!
 
Load the admin panel in your web browser
|;
}
 
if ($newinstall) {
# if this is not root, check if user is part of $webgroup
if ($>) {
if ($permset = ($) =~ getgrnam $webgroup)) {
`chown :$webgroup users templates`;
}
} else {
`chown $webowner:$webgroup users templates`;
}
chmod 0771, 'users', 'templates';
 
open(FH, "sql-ledger.conf.default");
@f = <FH>;
close(FH);
366,9 → 343,6
Copy $filename to $httpddir and add
|;
 
# strip serverroot off httpddir
$httpddir =~ s/$serverroot\///;
 
print qq|
Include $httpddir/$filename
 
382,7 → 356,7
WARNING: permissions for templates and users directory
could not be set. Login as root and set permissions
 
# chown $webowner:$webgroup users templates
# chown :$webgroup users templates
# chmod 771 users templates
 
|;
391,8 → 365,6
} else {
if (!(`grep "^# SQL-Ledger" $httpd`)) {
# append Include directive
$httpddir =~ s/$serverroot\///;
 
open(FH, ">>$httpd");
 
413,12 → 385,29
 
if (!$>) {
# send SIGHUP to httpd
$pid = `cat /var/run/httpd.pid`;
chomp $pid;
system("kill -s HUP $pid") if $pid;
if ($f = `find /var -type f -name 'httpd.pid'`) {
$pid = `cat $f`;
chomp $pid;
if ($pid) {
system("kill -s HUP $pid");
}
}
}
}
 
# if this is not root, check if user is part of $webgroup
if ($>) {
if ($permset = ($) =~ getgrnam $webgroup)) {
`chown :$webgroup users templates`;
chmod 0771, 'users', 'templates';
}
} else {
# root
`chown -hR 0:0 *`;
`chown $webowner:$webgroup users templates`;
chmod 0771, 'users', 'templates';
}
unlink "sql-ledger.conf.default";
 
&cleanup;
481,6 → 470,10
print "cleaning up ... ";
`rm -rf sql-ledger`;
print "done\n";
 
# replace shebang if this is windows
&shebang if $windows;
}
}
}
492,7 → 485,6
if (-d "$userspath") {
open(FH, ">$userspath/nologin");
close(FH);
$upgrade = 1;
}
}
511,64 → 503,28
sub remove_lockfile { unlink "$userspath/nologin" if (-f "$userspath/nologin") };
 
 
sub upgrade {
sub shebang {
 
$latest_version = &get_patch;
opendir DIR, ".";
@perlfiles = grep /\.pl/, readdir DIR;
closedir DIR;
 
&decompress;
&cleanup;
foreach $file (@perlfiles) {
open FH, "+<$file";
@file = <FH>;
 
}
seek(FH, 0, 0);
truncate(FH, 0);
 
$line = shift @file;
 
print FH "#!c:\\perl\\bin\\perl\n";
print FH @file;
 
sub get_patch {
close(FH);
 
$err = 0;
if ($version) {
# download the patch
$patchfile = "patch-${latest_version}.tar.gz";
print "Status\n";
print "Downloading $patchfile .... ";
foreach $source (@source) {
$host = $source;
$host =~ s/(\w\/).*/$1/g;
chop $host;
print "\nTrying $host .... ";
if ($lwp) {
$err = LWP::Simple::getstore("$source/$patchfile", "$patchfile");
$err -= 200;
} else {
$ok = `lynx -dump -head $source/$patchfile`;
$err = !($ok =~ /HTTP.*?200 OK/);
if (!$err) {
$err = system("lynx -dump $source/$patchfile > $patchfile");
}
}
 
last unless $err;
}
} else {
$err = -1;
}
if ($err) {
print "Cannot get $patchfile\n";
exit;
} else {
print "ok\n";
}
 
$patchfile;
 
}
 
 
/trunk/login.pl
44,14 → 44,6
 
eval { require "sql-ledger.conf"; };
 
if (-e "$userspath/nologin") {
print "
Login disabled!\n";
 
exit;
}
 
 
if ($ENV{CONTENT_LENGTH}) {
read(STDIN, $_, $ENV{CONTENT_LENGTH});
}
76,14 → 68,21
$script = substr($0, $pos + 1);
 
 
if (-f "$userspath/nologin" && $script ne 'admin.pl') {
print "Content-Type: text/html\n\n" if $ENV{HTTP_USER_AGENT};
print "\nLogin disabled!\n";
exit 1;
}
 
if ($form{path}) {
$form{path} =~ s/%2[fF]/\//g;
$form{path} =~ s/\.\.\///g;
 
if ($form{path} !~ /^bin\//) {
print "
Invalid path!\n";
die;
print "Content-Type: text/html\n\n" if $ENV{HTTP_USER_AGENT};
print "\nInvalid path!\n";
exit;
}
 
 
121,9 → 120,8
} else {
 
print qq|
Unknown terminal
|;
print "Content-Type: text/html\n\n" if $ENV{HTTP_USER_AGENT};
print qq"\nUnknown terminal\n";
}
 
}
/trunk/menu.ini
20,6 → 20,12
action=search
nextsub=ar_transactions
 
[AR--Reports--Outstanding]
module=ar.pl
action=search
outstanding=1
nextsub=ar_transactions
 
[AR--Reports--AR Aging]
module=rp.pl
action=report
42,17 → 48,43
db=customer
 
[AR--Customers--Reports]
module=menu.pl
action=acc_menu
target=acc_menu
submenu=1
 
[AR--Customers--Reports--Search]
module=ct.pl
action=search
db=customer
 
[AR--Customers--Reports--History]
module=ct.pl
action=history
db=customer
 
[POS]
 
[POS--Sale]
module=ps.pl
action=add
nextsub=openinvoices
 
[POS--Open]
module=ps.pl
action=openinvoices
 
[POS--Receipts]
module=ps.pl
action=receipts
 
[AP]
 
[AP--Add Transaction]
module=ap.pl
action=add
 
[AP--Purchase Invoice]
[AP--Vendor Invoice]
module=ir.pl
action=add
type=invoice
68,6 → 100,12
action=search
nextsub=ap_transactions
 
[AP--Reports--Outstanding]
module=ap.pl
action=search
outstanding=1
nextsub=ap_transactions
 
[AP--Reports--AP Aging]
module=rp.pl
action=report
90,10 → 128,21
db=vendor
 
[AP--Vendors--Reports]
module=menu.pl
action=acc_menu
target=acc_menu
submenu=1
 
[AP--Vendors--Reports--Search]
module=ct.pl
action=search
db=vendor
 
[AP--Vendors--Reports--History]
module=ct.pl
action=history
db=vendor
 
[Cash]
 
[Cash--Receipt]
106,6 → 155,11
action=payment
vc=vendor
 
[Cash--Transfer]
module=gl.pl
action=add
transfer=1
 
[Cash--Reports]
module=menu.pl
action=acc_menu
181,6 → 235,11
action=add
item=assembly
 
[Goods & Services--Add Group]
module=pe.pl
action=add
type=partsgroup
 
[Goods & Services--Stock Assembly]
module=ic.pl
action=stock_assembly
206,15 → 265,22
action=search
searchitems=assembly
 
[Goods & Services--Reports--Groups]
module=pe.pl
action=search
type=partsgroup
 
[Projects]
 
[Projects--Add Project]
module=pe.pl
action=add
type=project
 
[Projects--Reports]
module=pe.pl
action=search
type=project
 
[Reports]
 
343,6 → 409,17
action=display_form
file=templates=receipt.tex
 
[System--Text Templates]
module=menu.pl
action=acc_menu
target=acc_menu
submenu=1
 
[System--Text Templates--POS Invoice]
module=am.pl
action=display_form
file=templates=pos_invoice.txt
 
[System--Stylesheet]
module=am.pl
action=display_stylesheet
/trunk/VERSION
1,0 → 0,0
2.0.6
2.2.6