X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=sql-ledger%2Fbin%2Fmozilla%2Fct.pl;h=988422b9daef65b2b91b6ce22e27d9c411171552;hp=3dbb5656a9c55002f6068c2da976616f9618bab2;hb=32306b5f8ffe4ce594409aa6e89626740b225a39;hpb=52072fcd26f2faf57923f598c358e7f47c4e2643
diff --git a/sql-ledger/bin/mozilla/ct.pl b/sql-ledger/bin/mozilla/ct.pl
index 3dbb5656a..988422b9d 100644
--- a/sql-ledger/bin/mozilla/ct.pl
+++ b/sql-ledger/bin/mozilla/ct.pl
@@ -1,6 +1,6 @@
#=====================================================================
# SQL-Ledger Accounting
-# Copyright (c) 1998-2002
+# Copyright (c) 2001
#
# Author: Dieter Simader
# Email: dsimader@sql-ledger.org
@@ -26,9 +26,6 @@
#
#======================================================================
-# $locale->text('Customers')
-# $locale->text('Vendors')
-
use SL::CT;
1;
@@ -39,10 +36,12 @@ use SL::CT;
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};
+ $form->{callback} = "$form->{script}?action=add&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback};
- CT->taxaccounts(\%myconfig, \%$form);
+ CT->create_links(\%myconfig, \%$form);
&form_header;
&form_footer;
@@ -50,10 +49,316 @@ sub add {
}
+sub history {
+
+# $locale->text('Customer History')
+# $locale->text('Vendor History')
+
+ $history = 1;
+ $label = ucfirst $form->{db};
+ $label .= " History";
+
+ if ($form->{db} eq 'customer') {
+ $invlabel = $locale->text('Sales Invoices');
+ $ordlabel = $locale->text('Sales Orders');
+ $quolabel = $locale->text('Quotations');
+ } else {
+ $invlabel = $locale->text('Vendor Invoices');
+ $ordlabel = $locale->text('Purchase Orders');
+ $quolabel = $locale->text('Request for Quotations');
+ }
+
+ $form->{title} = $locale->text($label);
+
+ $form->{nextsub} = "list_history";
+
+ $transactions = qq|
+
+ |
+
+
+ |
+
+|;
+
+ $include = qq|
+
+ |.$locale->text('Include in Report').qq| |
+
+
+ |
+
+|;
+
+ &search_name;
+
+}
+
+
+sub transactions {
+
+ if ($form->{db} eq 'customer') {
+ $translabel = $locale->text('AR Transactions');
+ $invlabel = $locale->text('Sales Invoices');
+ $ordlabel = $locale->text('Sales Orders');
+ $quolabel = $locale->text('Quotations');
+ } else {
+ $translabel = $locale->text('AP Transactions');
+ $invlabel = $locale->text('Vendor Invoices');
+ $ordlabel = $locale->text('Purchase Orders');
+ $quolabel = $locale->text('Request for Quotations');
+ }
+
+
+ $transactions = qq|
+
+ |
+
+
+ |
+
+|;
+
+}
+
+
+sub include_in_report {
+
+ $label = ucfirst $form->{db};
+
+ if ($myconfig{role} =~ /(admin|manager)/) {
+ $bcc = qq|
+ |.$locale->text('Bcc').qq| |
+|;
+ }
+
+ if ($form->{db} eq 'customer') {
+ $employee = qq|
+ |.$locale->text('Salesperson').qq| |
+|;
+
+ $pricegroup = qq|
+ |.$locale->text('Pricegroup').qq| |
+|;
+
+ } else {
+ $employee = qq|
+ |.$locale->text('Employee').qq| |
+|;
+ }
+
+ $employee .= qq|
+ |.$locale->text('Manager').qq| |
+|;
+
+ $include = qq|
+
+ |.$locale->text('Include in Report').qq| |
+
+
+ |
+
+|;
+
+}
+
+
sub search {
+# $locale->text('Customers')
+# $locale->text('Vendors')
+
+ $form->{title} = $locale->text('Search') unless $form->{title};
+
+ map { $form->{"l_$_"} = 'checked' } qw(name contact phone email);
+
+ $form->{nextsub} = "list_names";
+
+ $orphan = qq|
+
+ |
+ |.$locale->text('All').qq|
+ |.$locale->text('Orphaned').qq| |
+
+|;
+
+ if ($form->{db} eq 'vendor') {
+ $gifi = qq|
+ |.$locale->text('GIFI').qq| |
+|;
+ }
+
+ &transactions;
+ &include_in_report;
+ &search_name;
+
+}
+
+
+sub search_name {
+
$label = ucfirst $form->{db};
- $form->{title} = $locale->text($label."s");
+
$form->header;
@@ -73,52 +378,65 @@ sub search {
|
+
|
-
+{nextsub}>
{path}>
{login}>
-{password}>
+{sessionid}>
@@ -131,13 +449,44 @@ sub search {
sub list_names {
-
+
CT->search(\%myconfig, \%$form);
- $callback = "$form->{script}?action=list_names&db=$form->{db}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
- $href = $callback;
+ $href = "$form->{script}?action=list_names&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&status=$form->{status}&l_subtotal=$form->{l_subtotal}";
+
+ $form->sort_order();
- @columns = $form->sort_columns(name, "$form->{db}number", address, contact, phone, fax, email, cc);
+ $callback = "$form->{script}?action=list_names&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&status=$form->{status}&l_subtotal=$form->{l_subtotal}";
+
+ @columns = $form->sort_columns(id, name, "$form->{db}number", address,
+ city, state, zipcode, country, contact,
+ phone, fax, email, cc, bcc, employee,
+ manager, notes, discount,
+ taxnumber, gifi_accno, sic_code, business,
+ pricegroup, language, iban, bic,
+ startdate, enddate,
+ invnumber, invamount, invtax, invtotal,
+ ordnumber, ordamount, ordtax, ordtotal,
+ quonumber, quoamount, quotax, quototal);
+
+ foreach $item (qw(inv ord quo)) {
+ if ($form->{"l_${item}number"}) {
+ map { $form->{"l_$item$_"} = $form->{"l_$_"} } qw(amount tax total);
+ $removeemployee = 1;
+ $openclosed = 1;
+ }
+ }
+ $form->{open} = $form->{closed} = "" if !$openclosed;
+
+ if ($form->{l_transnumber}) {
+ map { $form->{"l_inv$_"} = $form->{"l_$_"} } qw(amount tax total);
+ $removeemployee = 1;
+ }
+
+ if ($removeemployee) {
+ @columns = grep !/(employee|manager)/, @columns;
+ }
+
foreach $item (@columns) {
if ($form->{"l_$item"} eq "Y") {
@@ -149,6 +498,14 @@ sub list_names {
}
}
+ foreach $item (qw(amount tax total transnumber)) {
+ if ($form->{"l_$item"} eq "Y") {
+ $callback .= "&l_$item=Y";
+ $href .= "&l_$item=Y";
+ }
+ }
+
+
if ($form->{status} eq 'all') {
$option = $locale->text('All');
}
@@ -156,40 +513,153 @@ sub list_names {
$option .= $locale->text('Orphaned');
}
if ($form->{name}) {
- $callback .= "&name=$form->{name}";
+ $callback .= "&name=".$form->escape($form->{name},1);
$href .= "&name=".$form->escape($form->{name});
$option .= "\n
".$locale->text('Name')." : $form->{name}";
}
+ if ($form->{address}) {
+ $callback .= "&address=".$form->escape($form->{address},1);
+ $href .= "&address=".$form->escape($form->{address});
+ $option .= "\n
".$locale->text('Address')." : $form->{address}";
+ }
+ if ($form->{city}) {
+ $callback .= "&city=".$form->escape($form->{city},1);
+ $href .= "&city=".$form->escape($form->{city});
+ $option .= "\n
".$locale->text('City')." : $form->{city}";
+ }
+ if ($form->{state}) {
+ $callback .= "&state=".$form->escape($form->{state},1);
+ $href .= "&state=".$form->escape($form->{state});
+ $option .= "\n
".$locale->text('State')." : $form->{state}";
+ }
+ if ($form->{zipcode}) {
+ $callback .= "&zipcode=".$form->escape($form->{zipcode},1);
+ $href .= "&zipcode=".$form->escape($form->{zipcode});
+ $option .= "\n
".$locale->text('Zip/Postal Code')." : $form->{zipcode}";
+ }
+ if ($form->{country}) {
+ $callback .= "&country=".$form->escape($form->{country},1);
+ $href .= "&country=".$form->escape($form->{country});
+ $option .= "\n
".$locale->text('Country')." : $form->{country}";
+ }
if ($form->{contact}) {
- $callback .= "&contact=$form->{contact}";
+ $callback .= "&contact=".$form->escape($form->{contact},1);
$href .= "&contact=".$form->escape($form->{contact});
$option .= "\n
".$locale->text('Contact')." : $form->{contact}";
}
+ if ($form->{notes}) {
+ $callback .= "¬es=".$form->escape($form->{notes},1);
+ $href .= "¬es=".$form->escape($form->{notes});
+ $option .= "\n
".$locale->text('Notes')." : $form->{notes}";
+ }
if ($form->{"$form->{db}number"}) {
- $callback .= qq|&$form->{db}number=$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
".$locale->text('Number').qq| : $form->{"$form->{db}number"}|;
}
if ($form->{email}) {
- $callback .= "&email=$form->{email}";
+ $callback .= "&email=".$form->escape($form->{email},1);
$href .= "&email=".$form->escape($form->{email});
$option .= "\n
".$locale->text('E-mail')." : $form->{email}";
}
+ if ($form->{transdatefrom}) {
+ $callback .= "&transdatefrom=$form->{transdatefrom}";
+ $href .= "&transdatefrom=$form->{transdatefrom}";
+ $option .= "\n
" if ($option);
+ $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{transdatefrom}, 1);
+ }
+ if ($form->{transdateto}) {
+ $callback .= "&transdateto=$form->{transdateto}";
+ $href .= "&transdateto=$form->{transdateto}";
+ if ($form->{transdatefrom}) {
+ $option .= " ";
+ } else {
+ $option .= "\n
" if ($option);
+ }
+ $option .= $locale->text('To')." ".$locale->date(\%myconfig, $form->{transdateto}, 1);
+ }
+ if ($form->{open}) {
+ $callback .= "&open=$form->{open}";
+ $href .= "&open=$form->{open}";
+ $option .= "\n
" if ($option);
+ $option .= $locale->text('Open');
+ }
+ if ($form->{closed}) {
+ $callback .= "&closed=$form->{closed}";
+ $href .= "&closed=$form->{closed}";
+ $option .= "\n
" if ($option);
+ $option .= $locale->text('Closed');
+ }
+
$form->{callback} = "$callback&sort=$form->{sort}";
$callback = $form->escape($form->{callback});
+ $column_header{id} = qq||.$locale->text('ID').qq| | |;
$column_header{"$form->{db}number"} = qq|{db}number>|.$locale->text('Number').qq| | |;
$column_header{name} = qq||.$locale->text('Name').qq| | |;
- $column_header{address} = qq||.$locale->text('Address').qq| | |;
+ $column_header{address} = qq||.$locale->text('Address').qq| | |;
+ $column_header{city} = qq||.$locale->text('City').qq| | |;
+ $column_header{state} = qq||.$locale->text('State/Province').qq| | |;
+ $column_header{zipcode} = qq||.$locale->text('Zip/Postal Code').qq| | |;
+ $column_header{country} = qq||.$locale->text('Country').qq| | |;
$column_header{contact} = qq||.$locale->text('Contact').qq| | |;
$column_header{phone} = qq||.$locale->text('Phone').qq| | |;
$column_header{fax} = qq||.$locale->text('Fax').qq| | |;
$column_header{email} = qq||.$locale->text('E-mail').qq| | |;
$column_header{cc} = qq||.$locale->text('Cc').qq| | |;
+ $column_header{bcc} = qq||.$locale->text('Bcc').qq| | |;
+ $column_header{notes} = qq||.$locale->text('Notes').qq| | |;
+ $column_header{discount} = qq|% | |;
- $label = ucfirst $form->{db}."s";
- $form->{title} = $locale->text($label);
+ $column_header{taxnumber} = qq||.$locale->text('Tax Number').qq| | |;
+ $column_header{gifi_accno} = qq||.$locale->text('GIFI').qq| | |;
+ $column_header{sic_code} = qq||.$locale->text('SIC').qq| | |;
+ $column_header{business} = qq||.$locale->text('Type of Business').qq| | |;
+ $column_header{iban} = qq||.$locale->text('IBAN').qq| | |;
+ $column_header{bic} = qq||.$locale->text('BIC').qq| | |;
+ $column_header{startdate} = qq||.$locale->text('Startdate').qq| | |;
+ $column_header{enddate} = qq||.$locale->text('Enddate').qq| | |;
+
+ $column_header{invnumber} = qq||.$locale->text('Invoice').qq| | |;
+ $column_header{ordnumber} = qq||.$locale->text('Order').qq| | |;
+ $column_header{quonumber} = qq||.$locale->text('Quotation').qq| | |;
+
+ if ($form->{db} eq 'customer') {
+ $column_header{employee} = qq||.$locale->text('Salesperson').qq| | |;
+ } else {
+ $column_header{employee} = qq||.$locale->text('Employee').qq| | |;
+ }
+ $column_header{manager} = qq||.$locale->text('Manager').qq| | |;
+
+ $column_header{pricegroup} = qq||.$locale->text('Pricegroup').qq| | |;
+ $column_header{language} = qq||.$locale->text('Language').qq| | |;
+
+
+ $amount = $locale->text('Amount');
+ $tax = $locale->text('Tax');
+ $total = $locale->text('Total');
+
+ $column_header{invamount} = qq|$amount | |;
+ $column_header{ordamount} = qq|$amount | |;
+ $column_header{quoamount} = qq|$amount | |;
+
+ $column_header{invtax} = qq|$tax | |;
+ $column_header{ordtax} = qq|$tax | |;
+ $column_header{quotax} = qq|$tax | |;
+
+ $column_header{invtotal} = qq|$total | |;
+ $column_header{ordtotal} = qq|$total | |;
+ $column_header{quototal} = qq|$total | |;
+
+
+ if ($form->{status}) {
+ $label = ucfirst $form->{db}."s";
+ $form->{title} = $locale->text($label);
+ } else {
+ $label = ucfirst $form->{db};
+ $form->{title} = $locale->text($label ." Transactions");
+ }
$form->header;
@@ -211,20 +681,97 @@ sub list_names {
|;
map { print "$column_header{$_}\n" } @column_index;
-
+
print qq|
|;
+ $ordertype = ($form->{db} eq 'customer') ? 'sales_order' : 'purchase_order';
+ $quotationtype = ($form->{db} eq 'customer') ? 'sales_quotation' : 'request_quotation';
+ $subtotal = 0;
+
foreach $ref (@{ $form->{CT} }) {
- map { $column_data{$_} = "$ref->{$_} | " } ("$form->{db}number", address, contact, phone, fax);
-
- $column_data{name} = "{script}?action=edit&id=$ref->{id}&db=$form->{db}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}&callback=$callback>$ref->{name} | ";
+ if ("$ref->{$form->{sort}}$ref->{id}" ne $sameitem && $form->{l_subtotal}) {
+ # print subtotal
+ if ($subtotal) {
+ map { $column_data{$_} = " | " } @column_index;
+ &list_subtotal;
+ }
+ }
+
+ if ("$ref->{$form->{sort}}$ref->{id}" eq $sameitem && $form->{sort} eq 'name') {
+ map { $column_data{$_} = " | " } @column_index;
+ } else {
+
+ map { $column_data{$_} = "$ref->{$_} | " } @column_index;
+ $column_data{$form->{sort}} = " | " if $ref->{$form->{sort}} eq $sameitem && $form->{l_subtotal};
+
+ $column_data{address} = "$ref->{address1} $ref->{address2} | ";
+ $column_data{name} = "{script}?action=edit&id=$ref->{id}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&status=$form->{status}&callback=$callback>$ref->{name} | ";
+
+ $email = "";
+ if ($form->{sort} =~ /(email|cc)/) {
+ if ("$ref->{$form->{sort}}$ref->{id}" ne $sameitem) {
+ $email = 1;
+ }
+ } else {
+ $email = 1;
+ }
+
+ if ($email) {
+ foreach $item (qw(email cc bcc)) {
+ if ($ref->{$item}) {
+ $email = $ref->{$item};
+ $email =~ s/\</;
+ $email =~ s/>/\>/;
+
+ $column_data{$item} = qq|$email | |;
+ }
+ }
+ }
+ }
- $column_data{email} = ($ref->{email}) ? qq|$ref->{email} | | : " | ";
- $column_data{cc} = ($ref->{cc}) ? qq|$ref->{cc} | | : " | ";
+ if ($ref->{formtype} eq 'invoice') {
+ $column_data{invnumber} = "{module}.pl?action=edit&id=$ref->{invid}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{invnumber} | ";
+
+ $column_data{invamount} = "".$form->format_amount(\%myconfig, $ref->{netamount}, 2, " ")." | ";
+ $column_data{invtax} = "".$form->format_amount(\%myconfig, $ref->{amount} - $ref->{netamount}, 2, " ")." | ";
+ $column_data{invtotal} = "".$form->format_amount(\%myconfig, $ref->{amount}, 2, " ")." | ";
+
+ $invamountsubtotal += $ref->{netamount};
+ $invtaxsubtotal += ($ref->{amount} - $ref->{netamount});
+ $invtotalsubtotal += $ref->{amount};
+ }
+
+ if ($ref->{formtype} eq 'order') {
+ $column_data{ordnumber} = "{module}.pl?action=edit&id=$ref->{invid}&type=$ordertype&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{ordnumber} | ";
+
+ $column_data{ordamount} = "".$form->format_amount(\%myconfig, $ref->{netamount}, 2, " ")." | ";
+ $column_data{ordtax} = "".$form->format_amount(\%myconfig, $ref->{amount} - $ref->{netamount}, 2, " ")." | ";
+ $column_data{ordtotal} = "".$form->format_amount(\%myconfig, $ref->{amount}, 2, " ")." | ";
+
+ $ordamountsubtotal += $ref->{netamount};
+ $ordtaxsubtotal += ($ref->{amount} - $ref->{netamount});
+ $ordtotalsubtotal += $ref->{amount};
+ }
+
+ if ($ref->{formtype} eq 'quotation') {
+ $column_data{quonumber} = "{module}.pl?action=edit&id=$ref->{invid}&type=$quotationtype&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{quonumber} | ";
+
+ $column_data{quoamount} = "".$form->format_amount(\%myconfig, $ref->{netamount}, 2, " ")." | ";
+ $column_data{quotax} = "".$form->format_amount(\%myconfig, $ref->{amount} - $ref->{netamount}, 2, " ")." | ";
+ $column_data{quototal} = "".$form->format_amount(\%myconfig, $ref->{amount}, 2, " ")." | ";
+
+ $quoamountsubtotal += $ref->{netamount};
+ $quotaxsubtotal += ($ref->{amount} - $ref->{netamount});
+ $quototalsubtotal += $ref->{amount};
+ }
+ if ($form->{l_discount}) {
+ $column_data{discount} = "".$form->format_amount(\%myconfig, $ref->{discount} * 100, "", " ")." | ";
+ }
+
$i++; $i %= 2;
print "
@@ -236,8 +783,34 @@ sub list_names {
|;
+ $sameitem = "$ref->{$form->{sort}}$ref->{id}";
+ $subtotal = 1;
+
}
+ if ($form->{l_subtotal}) {
+ map { $column_data{$_} = " | " } @column_index;
+ &list_subtotal;
+ }
+
+ $i = 1;
+ if ($myconfig{acs} !~ /AR--AR/) {
+ if ($form->{db} eq 'customer') {
+ $button{'AR--Customers-Add Customer'}{code} = 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| |;
+ $button{'AP--Vendors--Add Vendor'}{order} = $i++;
+ }
+ }
+
+ foreach $item (split /;/, $myconfig{acs}) {
+ delete $button{$item};
+ }
+
print qq|
@@ -255,11 +828,22 @@ sub list_names {
{path}>
{login}>
-{password}>
+{sessionid}>
+|;
+
+ if ($form->{status}) {
+ foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
+ print $item->{code};
+ }
+ }
-
+ if ($form->{menubar}) {
+ require "$form->{path}/menu.pl";
+ &menubar;
+ }
-
+ print qq|
+