#===================================================================== # LedgerSMB Small Medium Business Accounting # Copyright (c) 2001 # # Author: DWS Systems Inc. # Web: http://sourceforge.net/projects/ledger-smb/ # # Contributors: Reed White # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #====================================================================== # # customer/vendor module # #====================================================================== use SL::CT; 1; # end of main 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}&sessionid=$form->{sessionid}" unless $form->{callback}; CT->create_links(\%myconfig, \%$form); &form_header; &form_footer; } 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|
$invlabel
$ordlabel
$quolabel
|.$locale->text('From').qq| |.$locale->text('To').qq|
 |.$locale->text('Open').qq|  |.$locale->text('Closed').qq|
|; $include = qq| |.$locale->text('Include in Report').qq|
|.$locale->text('Summary').qq| |.$locale->text('Detail').qq|
 |.$locale->text('Part Number').qq|  |.$locale->text('Description').qq|  |.$locale->text('Sell Price').qq|  |.$locale->text('Currency').qq|
 |.$locale->text('Qty').qq|  |.$locale->text('Unit').qq|  |.$locale->text('Discount').qq|
 |.$locale->text('Delivery Date').qq|  |.$locale->text('Project Number').qq|  |.$locale->text('Serial Number').qq|
|; &search_name; if ($form->{menubar}) { require "$form->{path}/menu.pl"; &menubar; } print qq| |; } 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|
$translabel
$invlabel
$ordlabel
$quolabel
|.$locale->text('From').qq| |.$locale->text('To').qq|
 |.$locale->text('Open').qq|  |.$locale->text('Closed').qq|
 |.$locale->text('Amount').qq|  |.$locale->text('Tax').qq|  |.$locale->text('Total').qq|  |.$locale->text('Subtotal').qq|
|; } sub include_in_report { $label = ucfirst $form->{db}; @a = (); push @a, qq| |.$locale->text('No.'); push @a, qq| |.$locale->text('ID'); push @a, qq| |.$locale->text($label . ' Number'); push @a, qq|{l_name}> |.$locale->text('Company Name'); push @a, qq|{l_contact}> |.$locale->text('Contact'); push @a, qq|{l_email}> |.$locale->text('E-mail'); push @a, qq| |.$locale->text('Address'); push @a, qq| |.$locale->text('City'); push @a, qq| |.$locale->text('State/Province'); push @a, qq| |.$locale->text('Zip/Postal Code'); push @a, qq| |.$locale->text('Country'); push @a, qq|{l_phone}> |.$locale->text('Phone'); push @a, qq| |.$locale->text('Fax'); push @a, qq| |.$locale->text('Cc'); if ($myconfig{role} =~ /(admin|manager)/) { push @a, qq| |.$locale->text('Bcc'); } push @a, qq| |.$locale->text('Notes'); push @a, qq| |.$locale->text('Discount'); push @a, qq| |.$locale->text('Tax Account'); push @a, qq| |.$locale->text('Tax Number'); if ($form->{db} eq 'customer') { push @a, qq| |.$locale->text('Salesperson'); push @a, qq| |.$locale->text('Manager'); push @a, qq| |.$locale->text('Pricegroup'); } else { push @a, qq| |.$locale->text('Employee'); push @a, qq| |.$locale->text('Manager'); push @a, qq| |.$locale->text('GIFI'); } push @a, qq| |.$locale->text('SIC'); push @a, qq| |.$locale->text('IBAN'); push @a, qq| |.$locale->text('BIC'); push @a, qq| |.$locale->text('Type of Business'); push @a, qq| |.$locale->text('Terms'); push @a, qq| |.$locale->text('Language'); push @a, qq| |.$locale->text('Startdate'); push @a, qq| |.$locale->text('Enddate'); $include = qq| |.$locale->text('Include in Report').qq| |; while (@a) { $include .= qq|\n|; for (1 .. 5) { $include .= qq|\n|; } $include .= qq|\n|; } $include .= qq|
|. shift @a; $include .= qq|
|; } sub search { # $locale->text('Customers') # $locale->text('Vendors') $form->{title} = $locale->text('Search') unless $form->{title}; for (qw(name contact phone email)) { $form->{"l_$_"} = 'checked' } $form->{nextsub} = "list_names"; $orphan = qq|  |.$locale->text('All').qq|  |.$locale->text('Active').qq|  |.$locale->text('Inactive').qq|  |.$locale->text('Orphaned').qq| |; &transactions; &include_in_report; &search_name; if ($form->{menubar}) { require "$form->{path}/menu.pl"; &menubar; } print qq| |; } sub search_name { $label = ucfirst $form->{db}; if ($form->{db} eq 'customer') { $employee = qq| |.$locale->text('Salesperson').qq| |; } if ($form->{db} eq 'vendor') { $employee = qq| |.$locale->text('Employee').qq| |; } $form->header; print qq|
{script}> {db}>
$form->{title}
$employee
|.$locale->text('Company Name').qq|
|.$locale->text('Contact').qq|
|.$locale->text('E-mail').qq|
|.$locale->text('Phone').qq|
|.$locale->text('Notes').qq|
|.$locale->text($label . ' Number').qq| {db}number size=32>
|.$locale->text('Address').qq|
|.$locale->text('City').qq|
|.$locale->text('State/Province').qq|
|.$locale->text('Zip/Postal Code').qq|
|.$locale->text('Country').qq|
|.$locale->text('Startdate').qq| |.$locale->text('From').qq| |.$locale->text('To').qq|
$orphan $transactions $include

{nextsub}> {path}> {login}> {sessionid}>
|; } sub list_names { CT->search(\%myconfig, \%$form); $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(); $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, terms, taxaccount, taxnumber, gifi_accno, sic_code, business, pricegroup, language, iban, bic, startdate, enddate, invnumber, invamount, invtax, invtotal, ordnumber, ordamount, ordtax, ordtotal, quonumber, quoamount, quotax, quototal); unshift @columns, "ndx"; $form->{l_invnumber} = "Y" if $form->{l_transnumber}; foreach $item (qw(inv ord quo)) { if ($form->{"l_${item}number"}) { for (qw(amount tax total)) { $form->{"l_$item$_"} = $form->{"l_$_"} } $removeemployee = 1; $openclosed = 1; } } $form->{open} = $form->{closed} = "" if !$openclosed; 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"; } } 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'); } if ($form->{status} eq 'orphaned') { $option = $locale->text('Orphaned'); } if ($form->{status} eq 'active') { $option = $locale->text('Active'); } if ($form->{status} eq 'inactive') { $option = $locale->text('Inactive'); } if ($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->escape($form->{contact},1); $href .= "&contact=".$form->escape($form->{contact}); $option .= "\n
".$locale->text('Contact')." : $form->{contact}"; } if ($form->{employee}) { $callback .= "&employee=".$form->escape($form->{employee},1); $href .= "&employee=".$form->escape($form->{employee}); $option .= "\n
"; if ($form->{db} eq 'customer') { $option .= $locale->text('Salesperson'); } if ($form->{db} eq 'vendor') { $option .= $locale->text('Employee'); } $option .= " : $form->{employee}"; } $fromdate = ""; $todate = ""; if ($form->{startdatefrom}) { $callback .= "&startdatefrom=$form->{startdatefrom}"; $href .= "&startdatefrom=$form->{startdatefrom}"; $fromdate = $locale->date(\%myconfig, $form->{startdatefrom}, 1); } if ($form->{startdateto}) { $callback .= "&startdateto=$form->{startdateto}"; $href .= "&startdateto=$form->{startdateto}"; $todate = $locale->date(\%myconfig, $form->{startdateto}, 1); } if ($fromdate || $todate) { $option .= "\n
".$locale->text('Startdate')." $fromdate - $todate"; } 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->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->{phone}) { $callback .= "&phone=".$form->escape($form->{phone},1); $href .= "&phone=".$form->escape($form->{phone}); $option .= "\n
".$locale->text('Phone')." : $form->{phone}"; } if ($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{ndx} = qq| |; $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{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|%|; $column_header{terms} = qq||.$locale->text('Terms').qq||; $column_header{taxnumber} = qq||.$locale->text('Tax Number').qq||; $column_header{taxaccount} = qq||.$locale->text('Tax Account').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; print qq|
$form->{title}
$option
|; for (@column_index) { print "$column_header{$_}\n" } print qq| |; $ordertype = ($form->{db} eq 'customer') ? 'sales_order' : 'purchase_order'; $quotationtype = ($form->{db} eq 'customer') ? 'sales_quotation' : 'request_quotation'; $subtotal = 0; $i = 0; foreach $ref (@{ $form->{CT} }) { if ($ref->{$form->{sort}} ne $sameitem && $form->{l_subtotal}) { # print subtotal if ($subtotal) { for (@column_index) { $column_data{$_} = "" } &list_subtotal; } } if ($ref->{id} eq $sameid) { for (@column_index) { $column_data{$_} = "" } } else { $i++; $ref->{notes} =~ s/\r?\n/
/g; for (@column_index) { $column_data{$_} = "" } $column_data{ndx} = ""; if ($ref->{$form->{sort}} eq $sameitem) { $column_data{$form->{sort}} = ""; } $column_data{address} = ""; $column_data{name} = ""; $email = ""; if ($form->{sort} =~ /(email|cc)/) { if ($ref->{$form->{sort}} ne $sameitem) { $email = 1; } } else { $email = 1; } if ($email) { foreach $item (qw(email cc bcc)) { if ($ref->{$item}) { $email = $ref->{$item}; $email =~ s//\>/; $column_data{$item} = qq||; } } } } if ($ref->{formtype} eq 'invoice') { $column_data{invnumber} = ""; $column_data{invamount} = ""; $column_data{invtax} = ""; $column_data{invtotal} = ""; $invamountsubtotal += $ref->{netamount}; $invtaxsubtotal += ($ref->{amount} - $ref->{netamount}); $invtotalsubtotal += $ref->{amount}; $subtotal = 1; } if ($ref->{formtype} eq 'order') { $column_data{ordnumber} = ""; $column_data{ordamount} = ""; $column_data{ordtax} = ""; $column_data{ordtotal} = ""; $ordamountsubtotal += $ref->{netamount}; $ordtaxsubtotal += ($ref->{amount} - $ref->{netamount}); $ordtotalsubtotal += $ref->{amount}; $subtotal = 1; } if ($ref->{formtype} eq 'quotation') { $column_data{quonumber} = ""; $column_data{quoamount} = ""; $column_data{quotax} = ""; $column_data{quototal} = ""; $quoamountsubtotal += $ref->{netamount}; $quotaxsubtotal += ($ref->{amount} - $ref->{netamount}); $quototalsubtotal += $ref->{amount}; $subtotal = 1; } if ($sameid ne "$ref->{id}") { if ($form->{l_discount}) { $column_data{discount} = ""; } if ($form->{l_terms}) { $column_data{terms} = ""; } } $j++; $j %= 2; print " "; for (@column_index) { print "$column_data{$_}\n" } print qq| |; $sameitem = "$ref->{$form->{sort}}"; $sameid = $ref->{id}; } if ($form->{l_subtotal} && $subtotal) { for (@column_index) { $column_data{$_} = "" } &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|
  $ref->{$_} $i $ref->{address1} $ref->{address2} {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{module}.pl?action=edit&id=$ref->{invid}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{invnumber} ".$form->format_amount(\%myconfig, $ref->{netamount}, 2, " ")."".$form->format_amount(\%myconfig, $ref->{amount} - $ref->{netamount}, 2, " ")."".$form->format_amount(\%myconfig, $ref->{amount}, 2, " ")."{module}.pl?action=edit&id=$ref->{invid}&type=$ordertype&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{ordnumber} ".$form->format_amount(\%myconfig, $ref->{netamount}, 2, " ")."".$form->format_amount(\%myconfig, $ref->{amount} - $ref->{netamount}, 2, " ")."".$form->format_amount(\%myconfig, $ref->{amount}, 2, " ")."{module}.pl?action=edit&id=$ref->{invid}&type=$quotationtype&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{quonumber} ".$form->format_amount(\%myconfig, $ref->{netamount}, 2, " ")."".$form->format_amount(\%myconfig, $ref->{amount} - $ref->{netamount}, 2, " ")."".$form->format_amount(\%myconfig, $ref->{amount}, 2, " ")."".$form->format_amount(\%myconfig, $ref->{discount} * 100, "", " ")."".$form->format_amount(\%myconfig, $ref->{terms}, "", " ")."
 


{script}> |; $form->hide_form(qw(callback db path login 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|
|; } sub list_subtotal { $column_data{invamount} = "".$form->format_amount(\%myconfig, $invamountsubtotal, 2, " ").""; $column_data{invtax} = "".$form->format_amount(\%myconfig, $invtaxsubtotal, 2, " ").""; $column_data{invtotal} = "".$form->format_amount(\%myconfig, $invtotalsubtotal, 2, " ").""; $invamountsubtotal = 0; $invtaxsubtotal = 0; $invtotalsubtotal = 0; $column_data{ordamount} = "".$form->format_amount(\%myconfig, $ordamountsubtotal, 2, " ").""; $column_data{ordtax} = "".$form->format_amount(\%myconfig, $ordtaxsubtotal, 2, " ").""; $column_data{ordtotal} = "".$form->format_amount(\%myconfig, $ordtotalsubtotal, 2, " ").""; $ordamountsubtotal = 0; $ordtaxsubtotal = 0; $ordtotalsubtotal = 0; $column_data{quoamount} = "".$form->format_amount(\%myconfig, $quoamountsubtotal, 2, " ").""; $column_data{quotax} = "".$form->format_amount(\%myconfig, $quotaxsubtotal, 2, " ").""; $column_data{quototal} = "".$form->format_amount(\%myconfig, $quototalsubtotal, 2, " ").""; $quoamountsubtotal = 0; $quotaxsubtotal = 0; $quototalsubtotal = 0; print " "; for (@column_index) { print "$column_data{$_}\n" } print qq| |; } sub list_history { CT->get_history(\%myconfig, \%$form); $href = "$form->{script}?action=list_history&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&history=$form->{history}"; $form->sort_order(); $callback = "$form->{script}?action=list_history&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&history=$form->{history}"; $form->{l_fxsellprice} = $form->{l_curr}; @columns = $form->sort_columns(partnumber, description, qty, unit, sellprice, fxsellprice, curr, discount, deliverydate, projectnumber, serialnumber); if ($form->{history} eq 'summary') { @columns = $form->sort_columns(partnumber, description, qty, unit, sellprice, curr); } 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
".$locale->text('Name')." : $form->{name}"; } if ($form->{contact}) { $callback .= "&contact=".$form->escape($form->{contact},1); $href .= "&contact=".$form->escape($form->{contact}); $option .= "\n
".$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
".$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
".$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{partnumber} = qq||.$locale->text('Part Number').qq||; $column_header{description} = qq||.$locale->text('Description').qq||; if ($form->{history} eq 'summary') { $column_header{sellprice} = qq||.$locale->text('Total').qq||; } else { $column_header{sellprice} = qq||.$locale->text('Sell Price').qq||; } $column_header{fxsellprice} = qq| |; $column_header{curr} = qq||.$locale->text('Curr').qq||; $column_header{discount} = qq||.$locale->text('Discount').qq||; $column_header{qty} = qq||.$locale->text('Qty').qq||; $column_header{unit} = qq||.$locale->text('Unit').qq||; $column_header{deliverydate} = qq||.$locale->text('Delivery Date').qq||; $column_header{projectnumber} = qq||.$locale->text('Project Number').qq||; $column_header{serialnumber} = qq||.$locale->text('Serial Number').qq||; # $locale->text('Customer History') # $locale->text('Vendor History') $label = ucfirst $form->{db}; $form->{title} = $locale->text($label." History"); $colspan = $#column_index + 1; $form->header; print qq|
$form->{title}
$option
|; for (@column_index) { print "$column_header{$_}\n" } print qq| |; $module = 'oe'; if ($form->{db} eq 'customer') { $invlabel = $locale->text('Sales Invoice'); $ordlabel = $locale->text('Sales Order'); $quolabel = $locale->text('Quotation'); $ordertype = 'sales_order'; $quotationtype = 'sales_quotation'; if ($form->{type} eq 'invoice') { $module = 'is'; } } else { $invlabel = $locale->text('Vendor Invoice'); $ordlabel = $locale->text('Purchase Order'); $quolabel = $locale->text('RFQ'); $ordertype = 'purchase_order'; $quotationtype = 'request_quotation'; if ($form->{type} eq 'invoice') { $module = 'ir'; } } $ml = ($form->{db} eq 'vendor') ? -1 : 1; foreach $ref (@{ $form->{CT} }) { if ($ref->{id} ne $sameid) { # print the header print qq| |; } if ($form->{type} ne 'invoice') { $ref->{fxsellprice} = $ref->{sellprice}; $ref->{sellprice} *= $ref->{exchangerate}; } if ($form->{history} eq 'detail' and $ref->{invid} ne $sameinvid) { # print inv, ord, quo number $i++; $i %= 2; print qq| |; if ($form->{type} eq 'invoice') { print qq||; } if ($form->{type} eq 'order') { print qq||; } if ($form->{type} eq 'quotation') { print qq||; } print qq| |; } for (@column_index) { $column_data{$_} = "" } if ($form->{l_curr}) { $column_data{fxsellprice} = qq|"; } $column_data{sellprice} = qq|"; $column_data{qty} = qq|"; $column_data{discount} = qq|"; $column_data{partnumber} = qq||; $i++; $i %= 2; print qq| |; for (@column_index) { print "$column_data{$_}\n" } print qq| |; $sameid = $ref->{id}; $sameinvid = $ref->{invid}; } print qq|
{script}?action=edit&id=$ref->{ctid}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{name} $ref->{address}
{invid}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$invlabel $ref->{invnumber} / $ref->{employee}{invid}&type=$ordertype&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ordlabel $ref->{ordnumber} / $ref->{employee}{invid}&type=$quotationtype&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$quolabel $ref->{quonumber} / $ref->{employee}
$ref->{$_} |.$form->format_amount(\%myconfig, $ref->{fxsellprice}, 2)."|.$form->format_amount(\%myconfig, $ref->{sellprice}, 2)."|.$form->format_amount(\%myconfig, $ref->{qty} * $ml)."|.$form->format_amount(\%myconfig, $ref->{discount} * 100, "", " ")."{pid}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{partnumber}

|; if ($form->{menubar}) { require "$form->{path}/menu.pl"; &menubar; } print qq| |; } sub edit { # $locale->text('Edit Customer') # $locale->text('Edit Vendor') CT->create_links(\%myconfig, \%$form); for (keys %$form) { $form->{$_} = $form->quote($form->{$_}) } $form->{title} = "Edit"; # format discount $form->{discount} *= 100; &form_header; &form_footer; } sub form_header { $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : ""; $form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0); $form->{discount} = $form->format_amount(\%myconfig, $form->{discount}, ""); $form->{terms} = $form->format_amount(\%myconfig, $form->{terms}, ""); if ($myconfig{role} =~ /(admin|manager)/) { $bcc = qq| |.$locale->text('Bcc').qq| |; } if ($form->{currencies}) { # currencies for (split /:/, $form->{currencies}) { $form->{selectcurrency} .= "