X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fct.pl;h=beefcc1fb7d014a518427c3bcd518cb40be3d406;hb=b39c8ce980f42154a4b7686de72a77789bfd1145;hp=aa8459d7d7e8c53b598e9fdd9e6e797edb3b3bb6;hpb=72539cb39a3d19f930a8e0e41e46bf41afe9a8f1;p=kivitendo-erp.git diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl index aa8459d7d..beefcc1fb 100644 --- a/bin/mozilla/ct.pl +++ b/bin/mozilla/ct.pl @@ -38,6 +38,9 @@ # $locale->text('Add Vendor') use SL::CT; +use CGI::Ajax; +use CGI; +use Data::Dumper; 1; @@ -182,6 +185,346 @@ sub search { $lxdebug->leave_sub(); } +sub search_delivery { + $lxdebug->enter_sub(); + + $label = ucfirst $form->{db}; + $form->{title} = $locale->text($label . "s"); + + if ($form->{db} eq 'vendor') { + $gifi = qq| + | + . $locale->text('GIFI') . qq| +|; + } + + $form->header; + + print qq| + + +
{script}> + +{db}> + + + + + + + + + + + + +
$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| + + + + + + + + + + + + + + + + $gifi + + + + + + + + +
| + . $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|
+
+

+ + + +{path}> +{login}> +{password}> + +
+ +
+ + + +|; + $lxdebug->leave_sub(); +} + +sub search_adr { + $lxdebug->enter_sub(); + + $form->{title} = $locale->text('ADR Report'); + + # use JavaScript Calendar or not + $form->{jsscript} = $jscalendar; + $jsscript = ""; + + if ($form->{jsscript}) { + + # with JavaScript Calendar + $button1 = qq| + {from}> + text('button') . qq|> + |; + $button2 = qq| + {to}> + text('button') . qq|> + |; + + + #write Trigger + $jsscript = + Form->write_trigger(\%myconfig, "2", + "from", "BL", + "trigger1", "to", + "BL", "trigger2"); + } else { + + # without JavaScript Calendar + $button1 = + qq|{from}>|; + $button2 = + qq|{to}>|; + } + + $form->header; + + print qq| + + +
{script}> + + + + + + + + + + + + + +
$form->{title}
+ + + + + + + $button1 + + + + $button2 + + + + + +
| . $locale->text('Year') . qq|{year}>
| . $locale->text('From') . qq|
| . $locale->text('Bis') . qq|
 | + . $locale->text('HTML') . qq| +  | + . $locale->text('CSV') . qq|
+

+$jsscript + + +{path}> +{login}> +{password}> + +
+ +
+ + + +|; + $lxdebug->leave_sub(); +} +sub adr_report { + $lxdebug->enter_sub(); + + CT->adr(\%myconfig, \%$form); + + $form->{title} = $locale->text('ADR Report'); + if ($form->{from} || $form->{to}) { + $option = "Für den Zeitraum $form->{from} bis $form->{to}"; + } elsif ($form->{year}) { + $option = "Für das Jahr $form->{year}"; + } + + if ($form->{format} eq "html") { + $form->header(); + print qq| + + + + + + + + + + +
$form->{title}
$option
|; + + + @column_index = + $form->sort_columns(adr_code, + adr_description, + sum, + unit); + + + + $column_header{adr_code} = + qq|| . $locale->text('ADR Code') . qq||; + $column_header{adr_description} = + qq||. $locale->text('ADR Description'). qq||; + $column_header{sum} = + qq||. $locale->text('Quantity'). qq||; + $column_header{unit} = + qq|| . $locale->text('Unit') . qq||; + + print qq| + + + + + + + + |; + + $get_contact_url = + "$form->{script}?login=$form->{login}&path=$form->{path}&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| + + + + + |; + $get_shipto_url = + "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=get_shipto"; + + my $pjy = new CGI::Ajax( 'get_shipto' => $get_shipto_url ); + $form->{selectshipto} = ""; + if (@{ $form->{SHIPTO} }) { + foreach $item (@{ $form->{SHIPTO} }) { + if ($item->{id} == $form->{shipto_id}) { + $form->{selectshipto} .= + " + + + + |; + + + $get_delivery_url = + "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=get_delivery"; + + my $pjz = new CGI::Ajax( 'get_delivery' => $get_delivery_url ); + + push(@ { $form->{AJAX} }, $pjz); + + $delivery = qq| + + + + |; foreach $item (split / /, $form->{taxaccounts}) { if (($form->{tax}{$item}{taxable}) || !($form->{id})) { @@ -524,7 +968,11 @@ sub form_header { s/|; } @{ $form->{GREETINGS} }); $select_greeting .= qq||; + + $select_company_greeting = + qq| |; + + $select_department = + qq| |; ## /LINET if ($form->{db} eq 'customer') { @@ -618,169 +1078,123 @@ sub form_header { # $locale->text('Customer Number') # $locale->text('Vendor Number') - $form->{fokus} = "ct.name"; + $form->{fokus} = "ct.greeting"; $form->header; print qq| -{script}> -
+ + +|; + + map { print "$column_header{$_}\n" } @column_index; + + print qq| + +|; + + + foreach $ref (@{ $form->{ADR} }) { + + map { $column_data{$_} = "" } @column_index; + + + $i++; + $i %= 2; + print " + +"; + + map { print "$column_data{$_}\n" } @column_index; + + print qq| + +|; + + + } + + print qq| +
$ref->{$_} 
+ + +|; + } else { + my $filename = "adr-report-$form->{from}-$form->{to}.csv"; + if ($form->{year}) { + $filename = "adr-report-$form->{year}.csv"; + } + @column_index = + $form->sort_columns(adr_code, + adr_description, + sum, + unit); + + $tmpfile = qq|ADR Code;ADR Beschreibung;Menge;Einheit\n|; + foreach $ref (@{ $form->{ADR} }) { + + map { $column_data{$_} = qq|"$ref->{$_}"| } @column_index; + + $line = ""; + map { $line .= "$column_data{$_};" } @column_index; + chomp($line); + $tmpfile .= qq|$line\n|;; + } + + my $size = length($tmpfile); + # launch application + print qq|Content-Type: application/csv +Content-Disposition: attachment; filename="$filename" +Content-Length: $size + +$tmpfile +|; + } + + $lxdebug->leave_sub(); +} + sub list_names { $lxdebug->enter_sub(); @@ -473,15 +816,116 @@ sub form_header { |; } $form->{obsolete} = "checked" if $form->{obsolete}; - %langs = (de => "deutsch", en => "englisch", fr => "französisch"); + $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||; + } + } + + $payment = qq||; + foreach $item (@{ $form->{payment_terms} }) { + if ($form->{payment_id} eq $item->{id}) { + $payment .= qq||; + } else { + $payment .= qq||; + } + } + + if (!$form->{id}) { + if ($form->{db} eq "customer") { + $form->{taxzone_id} = 0; } else { - $lang .= qq||; + $form->{taxzone_id} = 0; + } + } + + if (@{ $form->{TAXZONE} }) { + foreach $item (@{ $form->{TAXZONE} }) { + if ($item->{id} == $form->{taxzone_id}) { + $form->{selecttaxzone} .= + "
| . $locale->text('Steuersatz') . qq|
| . $locale->text('Ansprechpartner') . qq|
| . $locale->text('Shipping Address') . qq|
| . $locale->text('Shipping Address') . qq|
- -
$form->{title}
+
+ + +{script} onKeyUp="highlight(event)" onClick="highlight(event)"> + + + + + +
+ +
+ - - - - $business_salesman + + + + - - + - - + - - + - - + - - + - - + - - + - - + - - + - + - - |; -##LINET - added fields for contact person - print qq| - - - |; -##/LINET - print qq| $bcc - $tax -
| - . $locale->text('Billing Address') . qq|| - . $locale->text('Shipping Address') . qq|
| . $locale->text($label . ' Number') . qq| {db}number"}">
| . $locale->text('Greeting') . qq|  + $select_company_greeting
| . $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|
| . $locale->text('Homepage') . qq|
- {cp_id}> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| - . $locale->text('Contact Person') . qq|
| . $locale->text('Greeting') . qq|  - $select_greeting| . $locale->text('Title') . qq|  - $select_title
| - . $locale->text('Given Name') . qq|| . $locale->text('Name') . qq|
| . $locale->text('Phone1') . qq|| . $locale->text('Phone2') . qq|
| . $locale->text('E-mail') . qq|
-
- - - - - +
+ - + - - - + - + $customer - + - + - + $business - |; if ($form->{db} eq 'customer') { @@ -793,20 +1207,197 @@ sub form_header { + + + $taxzone
| . $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('Payment Terms') . qq|
- - + - - - + +
| . $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| +
+ + + + + |; +##/LINET + print qq| $bcc + $tax +
+ {cp_id}> + + $ansprechpartner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
| . $locale->text('Greeting') . qq|  + $select_greeting
| . $locale->text('Title') . qq|  + $select_title
| . $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('Mobile2') . 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|
+
+ + + + + +
+
+ + $delivery + + + + + + + + + +
| . $locale->text('From') . qq|| . $locale->text('Bis') . qq|
+
+
+
+
+ +
+ |; $lxdebug->leave_sub(); @@ -856,6 +1447,8 @@ sub form_footer { $update_button + @@ -878,7 +1471,10 @@ $update_button print qq| - + |; @@ -962,7 +1558,7 @@ sub save_and_order { $lxdebug->leave_sub(); } -sub save { +sub save_and_close { $lxdebug->enter_sub(); # $locale->text('Customer saved!') @@ -982,6 +1578,27 @@ sub save { $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!")); + if ($vertreter && $form->{db} eq "customer") { + $form->isblank("salesman_id", $locale->text("Salesman missing!")); + } + print(STDERR "SHIPTO in sub save $form->{shipto_id}\n"); + &{"CT::save_$form->{db}"}("", \%myconfig, \%$form); + + &edit; + exit; + $lxdebug->leave_sub(); +} + sub delete { $lxdebug->enter_sub(); @@ -1187,4 +1804,119 @@ sub salesman_selected { $lxdebug->leave_sub(); } +sub get_contact { + $lxdebug->enter_sub(); + + 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(); + +} + + +sub get_shipto { + $lxdebug->enter_sub(); + + CT->get_shipto(\%myconfig, \%$form); + + 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(); + +} + +sub get_delivery { + $lxdebug->enter_sub(); + + CT->get_delivery(\%myconfig, \%$form); + + @column_index = + $form->sort_columns(shiptoname, + invnumber, + ordnumber, + transdate, + description, + adr_code, + 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{adr_code} = + qq|| . $locale->text('ADR') . qq||; + $column_header{qty} = + qq|| . $locale->text('Qty') . qq||; + $column_header{unit} = + qq|| . $locale->text('Unit') . qq||; + $result .= qq| + + + +
+ + +|; + + map { $result .= "$column_header{$_}\n" } @column_index; + + $result .= qq| + +|; + + + foreach $ref (@{ $form->{DELIVERY} }) { + + if ($ref->{shiptoname} eq $sameshiptoname) { + map { $column_data{$_} = "" } @column_index; + $column_data{shiptoname} = ""; + } else { + map { $column_data{$_} = "" } @column_index; + } + + $i++; + $i %= 2; + $result .= " + +"; + + map { $result .= "$column_data{$_}\n" } @column_index; + + $result .= qq| + +|; + + $sameshiptoname = $ref->{shiptoname}; + + } + + $result .= qq| +
$ref->{$_}  $ref->{$_} 
+|; + + + my $q = new CGI; + print $q->header(); + print $result; + $lxdebug->leave_sub(); + +} + sub continue { &{ $form->{nextsub} } }