X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fct.pl;h=e5ba1ddf8ff48d4fe44667b360a374b20a20699b;hb=f5ab83507b71d551147835d84ec8317afd2842e9;hp=95c6e3315ba1843ca2a5cdf8be286bc859064498;hpb=4dbb09950c9f5596646537c12d991c99086fe7c1;p=kivitendo-erp.git diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl index 95c6e3315..e5ba1ddf8 100644 --- a/bin/mozilla/ct.pl +++ b/bin/mozilla/ct.pl @@ -38,44 +38,66 @@ # $locale->text('Add Vendor') use SL::CT; +use CGI::Ajax; +use CGI; +use Data::Dumper; -1; -# end of main +require "bin/mozilla/common.pl"; +1; +# end of main sub add { $lxdebug->enter_sub(); - $form->{title} = "Add"; - $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}&login=$form->{login}&password=$form->{password}" + unless $form->{callback}; + + CT->populate_drop_down_boxes(\%myconfig, \%$form); - CT->taxaccounts(\%myconfig, \%$form); - &form_header; &form_footer; - + $lxdebug->leave_sub(); } - sub search { $lxdebug->enter_sub(); + my $vc_business_type = $form->{db} eq "customer" ? + $locale->text("Customer type") : $locale->text("Vendor type"); - $label = ucfirst $form->{db}; - $form->{title} = $locale->text($label."s"); + $form->get_lists("business_types" => "ALL_BUSINESS_TYPES"); + my (%labels, @values); - if ($form->{db} eq 'vendor') { - $gifi = qq| - |.$locale->text('GIFI').qq| + my $business_types; + if (scalar(@{ $form->{ALL_BUSINESS_TYPES} }) != 0) { + push(@values, undef); + foreach my $item (@{ $form->{ALL_BUSINESS_TYPES} }) { + push(@values, $item->{id}); + $labels{$item->{id}} = $item->{description}; + } + + $business_types = + qq| + ${vc_business_type} + | + . NTI($cgi->popup_menu('-name' => 'business_id', '-values' => \@values, + '-labels' => \%labels)) + . qq| + |; } - + + $label = ucfirst $form->{db}; + $form->{title} = $locale->text($label . "s"); + $form->header; - + print qq| @@ -92,52 +114,77 @@ sub search { - + - + - + - + + $business_types + + + + - + - + @@ -152,12 +199,12 @@ sub search { -{path}> {login}> {password}>
- + @@ -166,16 +213,137 @@ sub search { $lxdebug->leave_sub(); } +sub search_delivery { + $lxdebug->enter_sub(); + + $label = ucfirst $form->{db}; + $form->{title} = $locale->text($label . "s"); + + $form->header; + + print qq| + + +{script}> + +{db}> + +
|.$locale->text($label . ' Number').qq|| . $locale->text($label . ' Number') . qq| {db}number size=35>
|.$locale->text('Company Name').qq|| . $locale->text('Company Name') . qq|
|.$locale->text('Contact').qq|| . $locale->text('Contact') . qq|
|.$locale->text('E-mail').qq|| . $locale->text('E-mail') . qq|
 | + . $locale->text('All') . qq| +  | + . $locale->text('Orphaned') . qq|
 |.$locale->text('All').qq| -  |.$locale->text('Orphaned').qq| | + . $locale->text('All') . qq| +  | + . $locale->text('Obsolete') . qq| +  | + . $locale->text('Not obsolete') . qq|
|.$locale->text('Include in Report').qq|| . $locale->text('Include in Report') . qq| - - - - + + + + - - - - + + + + - - $gifi - - + + + - - - + + +
|.$locale->text('ID').qq| |.$locale->text($label . ' Number').qq| |.$locale->text('Company Name').qq| |.$locale->text('Address').qq| | + . $locale->text('ID') . qq| | + . $locale->text($label . ' Number') . qq| | + . $locale->text('Company Name') . qq| | + . $locale->text('Address') . qq|
|.$locale->text('Contact').qq| |.$locale->text('Phone').qq| |.$locale->text('Fax').qq| |.$locale->text('E-mail').qq| | + . $locale->text('Contact') . qq| | + . $locale->text('Phone') . qq| | + . $locale->text('Fax') . qq| | + . $locale->text('E-mail') . qq|
|.$locale->text('Tax Number').qq| |.$locale->text('SIC').qq| |.$locale->text('Type of Business').qq| | + . $locale->text('Tax Number') . qq| | + . $locale->text('SIC') . qq| | + . $vc_business_type . qq|
|.$locale->text('Invoices').qq| |.$locale->text('Orders').qq| |.$locale->text('Quotations').qq| | + . $locale->text('Invoices') . qq| | + . $locale->text('Orders') . qq| | + . $locale->text('Quotations') . qq|
+ + + + + + + + + + +
$form->{title}
+ + + + + + + + + + + + + + + + + + + + + + + + + +
| . $locale->text($label . ' Number') . qq|{db}number size=35>
| . $locale->text('Company Name') . qq|
| . $locale->text('Contact') . qq|
| . $locale->text('E-mail') . qq|
 | + . $locale->text('All') . qq| +  | + . $locale->text('Orphaned') . qq|
| . $locale->text('Include in Report') . qq| + + + + + + + + + + + + + + + + + + + + + + + +
| + . $locale->text('ID') . qq| | + . $locale->text($label . ' Number') . qq| | + . $locale->text('Company Name') . qq| | + . $locale->text('Address') . qq|
| + . $locale->text('Contact') . qq| | + . $locale->text('Phone') . qq| | + . $locale->text('Fax') . qq| | + . $locale->text('E-mail') . qq|
| + . $locale->text('Tax Number') . qq| | + . $locale->text('SIC') . qq| | + . $locale->text('Type of Business') . qq|
| + . $locale->text('Invoices') . qq| | + . $locale->text('Orders') . qq| | + . $locale->text('Quotations') . qq|
+
+

+ + + +{login}> +{password}> + +
+ + + + + +|; + $lxdebug->leave_sub(); +} sub list_names { $lxdebug->enter_sub(); 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}"; + + $callback = + "$form->{script}?action=list_names&db=$form->{db}&login=$form->{login}&password=$form->{password}&status=$form->{status}&obsolete=$form->{obsolete}"; $href = $callback; - - @columns = $form->sort_columns(id, name, "$form->{db}number", address, contact, phone, fax, email, taxnumber, gifi_accno, sic_code, business, invnumber, ordnumber, quonumber); + + @columns = + $form->sort_columns(id, name, + "$form->{db}number", address, + contact, phone, + fax, email, + taxnumber, + sic_code, business, + invnumber, ordnumber, + quonumber); foreach $item (@columns) { if ($form->{"l_$item"} eq "Y") { @@ -183,11 +351,14 @@ sub list_names { # add column to href and callback $callback .= "&l_$item=Y"; - $href .= "&l_$item=Y"; + $href .= "&l_$item=Y"; } } - $number = ($form->{db} eq "customer") ? $locale->text('Customer Number') : $locale->text('Vendor Number') ; - + $number = + ($form->{db} eq "customer") + ? $locale->text('Customer Number') + : $locale->text('Vendor Number'); + if ($form->{status} eq 'all') { $option = $locale->text('All'); } @@ -195,50 +366,92 @@ sub list_names { $option .= $locale->text('Orphaned'); } if ($form->{name}) { - $callback .= "&name=".$form->escape($form->{name},1); - $href .= "&name=".$form->escape($form->{name}); - $option .= "\n
".$locale->text('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->{contact}) { - $callback .= "&contact=".$form->escape($form->{contact},1); - $href .= "&contact=".$form->escape($form->{contact}); - $option .= "\n
".$locale->text('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->{"$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"}|; + $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}"; + $callback .= "&email=" . $form->escape($form->{email}, 1); + $href .= "&email=" . $form->escape($form->{email}); + $option .= "\n
" . $locale->text('E-mail') . " : $form->{email}"; } $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>$number|; - $column_header{name} = qq||.$locale->text('Name').qq||; - $column_header{address} = qq||.$locale->text('Address').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{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{invnumber} = qq||.$locale->text('Invoice').qq||; - $column_header{ordnumber} = qq||.$locale->text('Order').qq||; - $column_header{quonumber} = qq||.$locale->text('Quotation').qq||; - - $label = ucfirst $form->{db}."s"; + $column_header{id} = + qq|| . $locale->text('ID') . qq||; + $column_header{"$form->{db}number"} = + qq|{db}number>$number|; + $column_header{name} = + qq|| + . $locale->text('Name') + . qq||; + $column_header{address} = + qq|| + . $locale->text('Address') + . 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{taxnumber} = + qq|| + . $locale->text('Tax Number') + . qq||; + $column_header{sic_code} = + qq|| + . $locale->text('SIC') + . qq||; + $column_header{business} = + qq|| + . $locale->text('Type of Business') + . 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||; + + $label = ucfirst $form->{db} . "s"; $form->{title} = $locale->text($label); $form->header; @@ -261,14 +474,15 @@ 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'; - + $quotationtype = + ($form->{db} eq 'customer') ? 'sales_quotation' : 'request_quotation'; + foreach $ref (@{ $form->{CT} }) { if ($ref->{id} eq $sameid) { @@ -276,35 +490,40 @@ sub list_names { } else { map { $column_data{$_} = "$ref->{$_} " } @column_index; - map { $column_data{$_} = "$ref->{$_} " } (invnumber, ordnumber, quonumber); - - $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} "; + map { $column_data{$_} = "$ref->{$_} " } + (invnumber, ordnumber, quonumber); + + $column_data{name} = + "{script}?action=edit&id=$ref->{id}&db=$form->{db}&login=$form->{login}&password=$form->{password}&status=$form->{status}&callback=$callback>$ref->{name} "; if ($ref->{email}) { - $email = $ref->{email}; - $email =~ s//\>/; - - $column_data{email} = qq|$email|; + $email = $ref->{email}; + $email =~ s//\>/; + + $column_data{email} = + qq|$email|; } - + } - - + if ($ref->{formtype} eq 'invoice') { - $column_data{invnumber} = "{module}.pl?action=edit&id=$ref->{invid}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{invnumber} "; + $column_data{invnumber} = + "{module}.pl?action=edit&id=$ref->{invid}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{invnumber} "; } - + if ($ref->{formtype} eq 'order') { - $column_data{ordnumber} = "{module}.pl?action=edit&id=$ref->{invid}&type=$ordertype&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{ordnumber} "; + $column_data{ordnumber} = + "{module}.pl?action=edit&id=$ref->{invid}&type=$ordertype&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{ordnumber} "; } if ($ref->{formtype} eq 'quotation') { - $column_data{quonumber} = "{module}.pl?action=edit&id=$ref->{invid}&type=$quotationtype&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{quonumber} "; + $column_data{quonumber} = + "{module}.pl?action=edit&id=$ref->{invid}&type=$quotationtype&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{quonumber} "; } - - - $i++; $i %= 2; + + $i++; + $i %= 2; print " "; @@ -314,7 +533,7 @@ sub list_names { print qq| |; - + $sameid = $ref->{id}; } @@ -334,36 +553,33 @@ sub list_names { {db}> -{path}> {login}> {password}> -|; + - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print qq| |; - + $lxdebug->leave_sub(); } - sub edit { $lxdebug->enter_sub(); - -# $locale->text('Edit Customer') -# $locale->text('Edit Vendor') + # show history button + $form->{javascript} = qq||; + #/show hhistory button + + # $locale->text('Edit Customer') + # $locale->text('Edit Vendor') CT->get_tuple(\%myconfig, \%$form); + CT->populate_drop_down_boxes(\%myconfig, \%$form); # format " into " map { $form->{$_} =~ s/\"/"/g } keys %$form; @@ -372,257 +588,550 @@ sub edit { # format discount $form->{discount} *= 100; - + &form_header; &form_footer; $lxdebug->leave_sub(); } - sub form_header { $lxdebug->enter_sub(); - + $form->get_lists("employees" => "ALL_SALESMEN", + "taxzones" => "ALL_TAXZONES"); + $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : ""; - $form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0); + $form->{creditlimit} = + $form->format_amount(\%myconfig, $form->{creditlimit}, 0); + $form->{discount} = $form->format_amount(\%myconfig, $form->{discount}); if ($myconfig{role} eq 'admin') { $bcc = qq| - |.$locale->text('Bcc').qq| + | . $locale->text('Bcc') . qq| |; } - $form->{obsolete} = "checked" if $form->{obsolete}; - %langs = (de=>"deutsch", en=>"englisch", fr=>"französisch"); + $form->{obsolete} = "checked" if $form->{obsolete}; + $lang = qq||; - foreach $item (keys %langs) { - if ($form->{language} eq $item) { - $lang .= qq||; + foreach $item (@{ $form->{languages} }) { + if ($form->{language_id} eq $item->{id}) { + $lang .= qq||; } else { - $lang .= qq||; + $lang .= qq||; } } - - foreach $item (split / /, $form->{taxaccounts}) { - if (($form->{tax}{$item}{taxable}) || !($form->{id})) { - $taxable .= qq|  $form->{tax}{$item}{description}|; + + $payment = qq||; + foreach $item (@{ $form->{payment_terms} }) { + if ($form->{payment_id} eq $item->{id}) { + $payment .= qq||; } else { - $taxable .= qq|  $form->{tax}{$item}{description}|; + $payment .= qq||; } } -##LINET - $taxable=""; + if (!$form->{id}) { + if ($form->{db} eq "customer") { + $form->{taxzone_id} = 0; + } else { + $form->{taxzone_id} = 0; + } + } - if ($taxable) { - $tax = qq| - - |.$locale->text('Taxable').qq| - - - - - - - -
$taxable{taxincluded}>|.$locale->text('Tax Included').qq|
- - + %labels = (); + @values = (); + foreach my $item (@{ $form->{"ALL_TAXZONES"} }) { + push(@values, $item->{"id"}); + $labels{$item->{"id"}} = $item->{"description"}; + } + + $taxzone = qq| + | . $locale->text('Steuersatz') . qq| + | . + NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"}, + '-values' => \@values, '-labels' => \%labels)) . qq| + |; + + $get_contact_url = + "$form->{script}?login=$form->{login}&password=$form->{password}&action=get_contact"; + + my $pjx = new CGI::Ajax( 'get_contact' => $get_contact_url ); + $form->{selectcontact} = ""; + if (@{ $form->{CONTACTS} }) { + foreach $item (@{ $form->{CONTACTS} }) { + if ($item->{cp_id} == $form->{cp_id}) { + $form->{selectcontact} .= + qq|\n|; + } else { + $form->{selectcontact} .= + qq|\n|; + } + + } + } + push(@ { $form->{AJAX} }, $pjx); + $ansprechpartner = qq| + + | . $locale->text('Ansprechpartner') . qq| + + + |; + $get_shipto_url = + "$form->{script}?login=$form->{login}&password=$form->{password}&action=get_shipto"; + + my $pjy = new CGI::Ajax( 'get_shipto' => $get_shipto_url ); + $form->{selectshipto} = ""; + $form->{selectshipto} .= ""; + if (@{ $form->{SHIPTO} }) { + foreach $item (@{ $form->{SHIPTO} }) { + if ($item->{shipto_id} == $form->{shipto_id}) { + $form->{selectshipto} .= + "|; + map( + { $select_greeting .= qq||; } @{ $form->{GREETINGS} }); $select_greeting .= qq||; + + $select_company_greeting = + qq| |; + + $select_department = + qq| |; ## /LINET -# $locale->text('Customer Number') -# $locale->text('Vendor Number') - $form->{fokus} = "ct.name"; + if ($form->{db} eq 'customer') { + + #get pricegroup and form it + $form->get_pricegroup(\%myconfig, { all => 1 }); + + $form->{pricegroup} = "$form->{klass}"; + $form->{pricegroup_id} = "$form->{klass}"; + + if (@{ $form->{all_pricegroup} }) { + + $form->{selectpricegroup} = qq|
{script}> - - -
$form->{title}
+
+ + +{script} onKeyUp="highlight(event)" onClick="highlight(event)"> + + + +
+ +
+ +
+ - - - - - $business_salesman - + + + + + + + + + - - - + + - - - - + + + + + + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + +
|.$locale->text('Billing Address').qq||.$locale->text('Shipping Address').qq|
|.$locale->text($label .' Number').qq|| . $locale->text($label . ' Number') . qq| {db}number"}">
| . $locale->text('Greeting') . qq|  + $select_company_greeting
| . $locale->text('Company Name') . qq|
|.$locale->text('Company Name').qq|| . $locale->text('Abteilung') . qq| +
|.$locale->text('Abteilung').qq| - -
| . $locale->text('Street') . qq|
| + . $locale->text('Zipcode') . "/" . $locale->text('City') . qq| +
|.$locale->text('Street').qq|| . $locale->text('Country') . qq|
|.$locale->text('Zipcode')."/".$locale->text('City').qq| - - | . $locale->text('Contact') . qq|
|.$locale->text('Country').qq|| . $locale->text('Phone') . qq|
|.$locale->text('Contact').qq|| . $locale->text('Fax') . qq|
|.$locale->text('Phone').qq|| . $locale->text('E-mail') . qq|
|.$locale->text('Fax').qq|| . $locale->text('Homepage') . qq|
+ - - - + + + + + + + - - + + + + + $customer - |; + + + + + + + + + $business + + |; + + if ($form->{db} eq 'customer') { + + print qq| + + |; + } + print qq| + + + + + + $taxzone + $salesman + +
|.$locale->text('E-mail').qq|| . $locale->text('Credit Limit') . qq|| . $locale->text('Payment Terms') . qq|| . $locale->text('Discount') . qq| + %
|.$locale->text('Homepage').qq|| . $locale->text('Tax Number / SSN') . qq|| . $locale->text('USt-IdNr.') . qq|
| . $locale->text('Account Number') . qq|| . $locale->text('Bank Code Number') . qq|| . $locale->text('Bank') . qq|
| . $locale->text('Language') . qq|| . $locale->text('Preisklasse') . qq|$pricegroup
| . $locale->text('Obsolete') . qq|{obsolete}>
+ + + + + + + + +
| . $locale->text('Notes') . qq|
+ + + +
|; + +print qq| +
+ + +$shipto + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
| . $locale->text('Company Name') . qq|
| . $locale->text('Abteilung') . qq| +
| . $locale->text('Street') . qq|
| + . $locale->text('Zipcode') . "/" . $locale->text('City') . qq| +
| . $locale->text('Country') . qq|
| . $locale->text('Contact') . qq|
| . $locale->text('Phone') . qq|
| . $locale->text('Fax') . qq|
| . $locale->text('E-mail') . qq|
 
 
+
|; + + ##LINET - added fields for contact person - print qq| + print qq| +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{cp_id}> + $ansprechpartner - + + - - - - - + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + - - - - - -
|.$locale->text('Contact Person').qq|| . $locale->text('Greeting') . qq|  + $select_greeting
|.$locale->text('Greeting').qq|  - $select_greeting|.$locale->text('Title').qq|  + | . $locale->text('Title') . qq|  $select_title
|.$locale->text('Given Name').qq||.$locale->text('Name').qq|| . $locale->text('Department') . qq|  + $select_department
| + . $locale->text('Given Name') . qq|
| . $locale->text('Name') . qq|
| . $locale->text('Phone1') . qq|
| . $locale->text('Phone2') . qq|
| . $locale->text('Fax') . qq|
| . $locale->text('Mobile1') . qq|
|.$locale->text('Phone1').qq||.$locale->text('Phone2').qq|| . $locale->text('Mobile2') . qq|
|.$locale->text('E-mail').qq|
+
| . $locale->text('Sat. Phone') . qq|
| . $locale->text('Sat. Fax') . qq|
| . $locale->text('Project') . qq|
| . $locale->text('E-mail') . qq|
| . $locale->text('Private Phone') . qq|
| . $locale->text('Private E-mail') . qq|
| . $locale->text('Birthday') . qq|
|; -##/LINET +##/LINET print qq| $bcc $tax @@ -630,115 +1139,104 @@ sub form_header { - - - - - - - - - - - - - - - $customer - - - - - - - - - - - $business - - |; - - print qq| - - - - -
|.$locale->text('Credit Limit').qq||.$locale->text('Terms: Net').qq||.$locale->text('days').qq||.$locale->text('Discount').qq| - %
|.$locale->text('Tax Number / SSN').qq||.$locale->text('USt-IdNr.').qq|
|.$locale->text('Account Number').qq||.$locale->text('Bank Code Number').qq||.$locale->text('Bank').qq|
|.$locale->text('Language').qq|
|.$locale->text('Obsolete').qq|{obsolete}>
- - - - |.$locale->text('Notes').qq| - - - - - -
- - -|; + +
+
+ + $delivery + + + + + + + + + +
| . $locale->text('From') . qq| + | . $locale->text('To (time)') . qq| +
+
+
+
+
+ +
+ +| . $form->write_trigger(\%myconfig, 2, "fromB", "BL", "trigger_from", + "toB", "BL", "trigger_to"); $lxdebug->leave_sub(); } - - sub form_footer { $lxdebug->enter_sub(); - - $label = ucfirst $form->{db}; - $quotation = ($form->{db} eq 'customer') ? $locale->text('Save and Quotation') : $locale->text('Save and RFQ'); - $arap = ($form->{db} eq 'customer') ? $locale->text('Save and AR Transaction') : $locale->text('Save and AP Transaction'); - if ($vertreter) { - $update_button = qq||; - } else { - $update_button = ""; - } - + $label = ucfirst $form->{db}; + $quotation = + ($form->{db} eq 'customer') + ? $locale->text('Save and Quotation') + : $locale->text('Save and RFQ'); + $arap = + ($form->{db} eq 'customer') + ? $locale->text('Save and AR Transaction') + : $locale->text('Save and AP Transaction'); + ## ## ## ## print qq| -{id}> - +{id}> -{path}> {login}> {password}> -{db}> +{db}> + +
-$update_button - + + - - + + |; if ($form->{id} && $form->{status} eq 'orphaned') { - print qq|\n|; + print qq|\n|; } - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; + # button for saving history + if($form->{id} ne "") { + print qq| + {id} + . qq|); name=history id=history value=| + . $locale->text('history') + . qq|>|; } + # /button for saving history print qq| - -
+ + |; @@ -746,131 +1244,216 @@ $update_button $lxdebug->leave_sub(); } - sub add_transaction { $lxdebug->enter_sub(); +# # saving the history +# if(!exists $form->{addition}) { +# $form->{addition} = "ADD TRANSACTION"; +# $form->save_history($form->dbconnect(\%myconfig)); +# } +# # /saving the history $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); + if ($form->{"db"} eq "customer") { + CT->save_customer(\%myconfig, \%$form); + } else { + CT->save_vendor(\%myconfig, \%$form); + } - $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->{callback} = $form->escape($form->{callback}, 1); + $name = $form->escape("$form->{name}", 1); + $form->{callback} = + "$form->{script}?login=$form->{login}&password=$form->{password}&action=add&vc=$form->{db}&$form->{db}_id=$form->{id}&$form->{db}=$name&type=$form->{type}&callback=$form->{callback}"; $form->redirect; - + $lxdebug->leave_sub(); } sub save_and_ap_transaction { $lxdebug->enter_sub(); - $form->{script} = "ap.pl"; + # saving the history + if(!exists $form->{addition}) { + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; + $form->{addition} = "SAVED"; + $form->save_history($form->dbconnect(\%myconfig)); + } + # /saving the history &add_transaction; - $lxdebug->leave_sub(); } - sub save_and_ar_transaction { $lxdebug->enter_sub(); - $form->{script} = "ar.pl"; + # saving the history + if(!exists $form->{addition}) { + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; + $form->{addition} = "SAVED"; + $form->save_history($form->dbconnect(\%myconfig)); + } + # /saving the history &add_transaction; - $lxdebug->leave_sub(); } - sub save_and_invoice { $lxdebug->enter_sub(); - $form->{script} = ($form->{db} eq 'customer') ? "is.pl" : "ir.pl"; $form->{type} = "invoice"; + # saving the history + if(!exists $form->{addition}) { + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; + $form->{addition} = "SAVED"; + $form->save_history($form->dbconnect(\%myconfig)); + } + # /saving the history &add_transaction; - $lxdebug->leave_sub(); } - sub save_and_rfq { $lxdebug->enter_sub(); - $form->{script} = "oe.pl"; - $form->{type} = "request_quotation"; + $form->{type} = "request_quotation"; + # saving the history + if(!exists $form->{addition}) { + $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; + $form->{addition} = "SAVED"; + $form->save_history($form->dbconnect(\%myconfig)); + } + # /saving the history &add_transaction; - $lxdebug->leave_sub(); } - sub save_and_quotation { $lxdebug->enter_sub(); - $form->{script} = "oe.pl"; - $form->{type} = "sales_quotation"; + $form->{type} = "sales_quotation"; + # saving the history + if(!exists $form->{addition}) { + $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; + $form->{addition} = "SAVED"; + $form->save_history($form->dbconnect(\%myconfig)); + } + # /saving the history &add_transaction; - $lxdebug->leave_sub(); } - sub save_and_order { $lxdebug->enter_sub(); - $form->{script} = "oe.pl"; - $form->{type} = ($form->{db} eq 'customer') ? "sales_order" : "purchase_order"; + $form->{type} = + ($form->{db} eq 'customer') ? "sales_order" : "purchase_order"; + # saving the history + if(!exists $form->{addition}) { + $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; + $form->{addition} = "SAVED"; + $form->save_history($form->dbconnect(\%myconfig)); + } + # /saving the history &add_transaction; - $lxdebug->leave_sub(); } - -sub save { +sub save_and_close { $lxdebug->enter_sub(); - -# $locale->text('Customer saved!') -# $locale->text('Vendor saved!') + # $locale->text('Customer saved!') + # $locale->text('Vendor saved!') $msg = ucfirst $form->{db}; $imsg .= " saved!"; - + $form->isblank("name", $locale->text("Name missing!")); - if ($vertreter && $form->{db} eq "customer") { - $form->isblank("salesman_id", $locale->text("Salesman missing!")); + if ($form->{"db"} eq "customer") { + $rc = CT->save_customer(\%myconfig, \%$form); + } else { + $rc = CT->save_vendor(\%myconfig, \%$form); } - &{ "CT::save_$form->{db}" }("", \%myconfig, \%$form); - + if ($rc == 3) { + $form->error($locale->text('customernumber not unique!')); + } + # saving the history + if(!exists $form->{addition}) { + $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber}); + $form->{addition} = "SAVED"; + $form->save_history($form->dbconnect(\%myconfig)); + } + # /saving the history $form->redirect($locale->text($msg)); - + $lxdebug->leave_sub(); } +sub save { + $lxdebug->enter_sub(); + + # $locale->text('Customer saved!') + # $locale->text('Vendor saved!') + + $msg = ucfirst $form->{db}; + $imsg .= " saved!"; + + $form->isblank("name", $locale->text("Name missing!")); + + my $res; + if ($form->{"db"} eq "customer") { + $res = CT->save_customer(\%myconfig, \%$form); + } else { + $res = CT->save_vendor(\%myconfig, \%$form); + } + + if (3 == $res) { + if ($form->{"db"} eq "customer") { + $form->error($locale->text('This customer number is already in use.')); + } else { + $form->error($locale->text('This vendor number is already in use.')); + } + } + # saving the history + if(!exists $form->{addition}) { + $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber}); + $form->{addition} = "SAVED"; + $form->save_history($form->dbconnect(\%myconfig)); + } + # /saving the history + &edit; + exit; + $lxdebug->leave_sub(); +} sub delete { $lxdebug->enter_sub(); - -# $locale->text('Customer deleted!') -# $locale->text('Cannot delete customer!') -# $locale->text('Vendor deleted!') -# $locale->text('Cannot delete vendor!') + # $locale->text('Customer deleted!') + # $locale->text('Cannot delete customer!') + # $locale->text('Vendor deleted!') + # $locale->text('Cannot delete vendor!') CT->delete(\%myconfig, \%$form); - + $msg = ucfirst $form->{db}; $msg .= " deleted!"; + # saving the history + if(!exists $form->{addition}) { + $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber}); + $form->{addition} = "DELETED"; + $form->save_history($form->dbconnect(\%myconfig)); + } + # /saving the history $form->redirect($locale->text($msg)); - + $msg = "Cannot delete $form->{db}"; $form->error($locale->text($msg)); @@ -889,179 +1472,119 @@ sub display { sub update { $lxdebug->enter_sub(); - &check_salesman($form->{salesman}); -# $form->get_salesman(\%myconfig, $form->{salesman}); &display(); $lxdebug->leave_sub(); } -sub check_salesman { +sub get_contact { $lxdebug->enter_sub(); - my ($name) = @_; - - my ($new_name, $new_id) = split /--/, $form->{$name}; - my $i = 0; - - # check name, combine name and id - if ($form->{"oldsalesman"} ne$ form->{"salesman"} ) { - - # return one name or a list of names in $form->{name_list} - if (($i = $form->get_salesman(\%myconfig, $name)) > 1) { - &select_salesman($name); - exit; - } - - if ($i == 1) { - # we got one name - $form->{"salesman_id"} = $form->{salesman_list}[0]->{id}; - $form->{salesman} = $form->{salesman_list}[0]->{name}; - $form->{"oldsalesman"} = $form->{salesman}; - - } else { - # name is not on file - # $locale->text('Customer not on file!') - # $locale->text('Vendor not on file!') - $msg = ucfirst $name . " not on file or locked!"; - $form->error($locale->text($msg)); - } - } - + CT->get_contact(\%myconfig, \%$form); + my $q = new CGI; + $result = "$form->{cp_name}"; + map { $result .= "__pjx__" . $form->{$_} } qw(cp_greeting cp_title cp_givenname cp_phone1 cp_phone2 cp_email cp_abteilung cp_fax cp_mobile1 cp_mobile2 cp_satphone cp_satfax cp_project cp_privatphone cp_privatemail cp_birthday); + print $q->header(); + print $result; $lxdebug->leave_sub(); - return $i; } - - - -sub select_salesman { +sub get_shipto { $lxdebug->enter_sub(); - my ($table) = @_; - - @column_index = qw(ndx name); + CT->get_shipto(\%myconfig, \%$form); - $label = ucfirst $table; - $column_data{ndx} = qq| |; - $column_data{name} = qq||.$locale->text($label).qq||; - - # list items with radio button on a form - $form->header; + my $q = new CGI; + $result = "$form->{shiptoname}"; + map { $result .= "__pjx__" . $form->{$_} } qw(shiptodepartment_1 shiptodepartment_2 shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail); + print $q->header(); + print $result; + $lxdebug->leave_sub(); - $title = $locale->text('Select from one of the names below'); +} - print qq| - +sub get_delivery { + $lxdebug->enter_sub(); -
{script}> + CT->get_delivery(\%myconfig, \%$form ); + + @column_index = + $form->sort_columns(shiptoname, + invnumber, + ordnumber, + transdate, + description, + qty, + unit); + + + + $column_header{shiptoname} = + qq|| . $locale->text('Shipping Address') . qq||; + $column_header{invnumber} = + qq||. $locale->text('Invoice'). qq||; + $column_header{ordnumber} = + qq||. $locale->text('Order'). qq||; + $column_header{transdate} = + qq|| . $locale->text('Invdate') . qq||; + $column_header{description} = + qq|| . $locale->text('Description') . qq||; + $column_header{qty} = + qq|| . $locale->text('Qty') . qq||; + $column_header{unit} = + qq|| . $locale->text('Unit') . qq||; + $result .= qq| - - - - - - - - -
$title
- |; - - map { print "\n$column_data{$_}" } @column_index; - - print qq| - + |; - my $i = 0; - foreach $ref (@{ $form->{salesman_list} }) { - $checked = ($i++) ? "" : "checked"; - - $ref->{name} =~ s/\"/"/g; - - $column_data{ndx} = qq||; - $column_data{name} = qq||; - - $j++; $j %= 2; - print qq| - |; - - map { print "\n$column_data{$_}" } @column_index; - - print qq| - - -{id}> + map { $result .= "$column_header{$_}\n" } @column_index; + $result .= qq| + |; - } - - print qq| -
$ref->{name}
-

- + foreach $ref (@{ $form->{DELIVERY} }) { -|; - - # delete variables - map { delete $form->{$_} } qw(action name_list header); - - # save all other form variables - foreach $key (keys %${form}) { - $form->{$key} =~ s/\"/"/g; - print qq|\n|; - } + if ($ref->{shiptoname} eq $sameshiptoname) { + map { $column_data{$_} = "$ref->{$_} " } @column_index; + $column_data{shiptoname} = " "; + } else { + map { $column_data{$_} = "$ref->{$_} " } @column_index; + } - print qq| - + $i++; + $i %= 2; + $result .= " + +"; - -
- -
+ map { $result .= "$column_data{$_}\n" } @column_index; - - + $result .= qq| + |; - $lxdebug->leave_sub(); -} - + $sameshiptoname = $ref->{shiptoname}; - -sub salesman_selected { - $lxdebug->enter_sub(); - - - # replace the variable with the one checked - - # index for new item - $i = $form->{ndx}; - - $form->{salesman} = $form->{"new_name_$i"}; - $form->{"salesman_id"} = $form->{"new_id_$i"}; - $form->{"oldsalesman"} = $form->{salesman}; - - # delete all the new_ variables - for $i (1 .. $form->{lastndx}) { - map { delete $form->{"new_${_}_$i"} } (id, name); } - - map { delete $form->{$_} } qw(ndx lastndx nextsub); - &update(1); - - $lxdebug->leave_sub(); -} + $result .= qq| + +|; -sub continue { &{ $form->{nextsub} } }; + my $q = new CGI; + print $q->header(); + print $result; + $lxdebug->leave_sub(); +} +sub continue { call_sub($form->{nextsub}); }