- $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}";
- $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);
-
- 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";
- }
- }
- $number =
- ($form->{db} eq "customer")
- ? $locale->text('Customer Number')
- : $locale->text('Vendor Number');
-
- if ($form->{status} eq 'all') {
- $option = $locale->text('All');
- }
- if ($form->{status} eq 'orphaned') {
- $option .= $locale->text('Orphaned');
- }
- if ($form->{name}) {
- $callback .= "&name=" . $form->escape($form->{name}, 1);
- $href .= "&name=" . $form->escape($form->{name});
- $option .= "\n<br>" . $locale->text('Name') . " : $form->{name}";
- }
- if ($form->{contact}) {
- $callback .= "&contact=" . $form->escape($form->{contact}, 1);
- $href .= "&contact=" . $form->escape($form->{contact});
- $option .= "\n<br>" . $locale->text('Contact') . " : $form->{contact}";
- }
- if ($form->{"$form->{db}number"}) {
- $callback .=
- qq|&$form->{db}number=| . $form->escape($form->{"$form->{db}number"}, 1);
- $href .=
- "&$form->{db}number=" . $form->escape($form->{"$form->{db}number"});
- $option .=
- "\n<br>" . $locale->text('Number') . qq| : $form->{"$form->{db}number"}|;
- }
- if ($form->{email}) {
- $callback .= "&email=" . $form->escape($form->{email}, 1);
- $href .= "&email=" . $form->escape($form->{email});
- $option .= "\n<br>" . $locale->text('E-mail') . " : $form->{email}";
- }
-
- $form->{callback} = "$callback&sort=$form->{sort}";
- $callback = $form->escape($form->{callback});
-
- $column_header{id} =
- qq|<th class=listheading>| . $locale->text('ID') . qq|</th>|;
- $column_header{"$form->{db}number"} =
- qq|<th><a class=listheading href=$href&sort=$form->{db}number>$number</a></th>|;
- $column_header{name} =
- qq|<th><a class=listheading href=$href&sort=name>|
- . $locale->text('Name')
- . qq|</a></th>|;
- $column_header{address} =
- qq|<th><a class=listheading href=$href&sort=address>|
- . $locale->text('Address')
- . qq|</a></th>|;
- $column_header{contact} =
- qq|<th><a class=listheading href=$href&sort=contact>|
- . $locale->text('Contact')
- . qq|</a></th>|;
- $column_header{phone} =
- qq|<th><a class=listheading href=$href&sort=phone>|
- . $locale->text('Phone')
- . qq|</a></th>|;
- $column_header{fax} =
- qq|<th><a class=listheading href=$href&sort=fax>|
- . $locale->text('Fax')
- . qq|</a></th>|;
- $column_header{email} =
- qq|<th><a class=listheading href=$href&sort=email>|
- . $locale->text('E-mail')
- . qq|</a></th>|;
- $column_header{cc} =
- qq|<th><a class=listheading href=$href&sort=cc>|
- . $locale->text('Cc')
- . qq|</a></th>|;
-
- $column_header{taxnumber} =
- qq|<th><a class=listheading href=$href&sort=taxnumber>|
- . $locale->text('Tax Number')
- . qq|</a></th>|;
- $column_header{gifi_accno} =
- qq|<th><a class=listheading href=$href&sort=gifi_accno>|
- . $locale->text('GIFI')
- . qq|</a></th>|;
- $column_header{sic_code} =
- qq|<th><a class=listheading href=$href&sort=sic_code>|
- . $locale->text('SIC')
- . qq|</a></th>|;
- $column_header{business} =
- qq|<th><a class=listheading href=$href&sort=business>|
- . $locale->text('Type of Business')
- . qq|</a></th>|;
-
- $column_header{invnumber} =
- qq|<th><a class=listheading href=$href&sort=invnumber>|
- . $locale->text('Invoice')
- . qq|</a></th>|;
- $column_header{ordnumber} =
- qq|<th><a class=listheading href=$href&sort=ordnumber>|
- . $locale->text('Order')
- . qq|</a></th>|;
- $column_header{quonumber} =
- qq|<th><a class=listheading href=$href&sort=quonumber>|
- . $locale->text('Quotation')
- . qq|</a></th>|;
-
- $label = ucfirst $form->{db} . "s";
- $form->{title} = $locale->text($label);
-
- $form->header;
-
- print qq|
-<body>
-
-<table width=100%>
- <tr>
- <th class=listtop>$form->{title}</th>
- </tr>
- <tr height="5"></tr>
- <tr>
- <td>$option</td>
- </tr>
- <tr>
- <td>
- <table width=100%>
- <tr class=listheading>
-|;
-
- map { print "$column_header{$_}\n" } @column_index;
-
- print qq|
- </tr>
-|;
-
- $ordertype = ($form->{db} eq 'customer') ? 'sales_order' : 'purchase_order';
- $quotationtype =
- ($form->{db} eq 'customer') ? 'sales_quotation' : 'request_quotation';
-
- foreach $ref (@{ $form->{CT} }) {
-
- if ($ref->{id} eq $sameid) {
- map { $column_data{$_} = "<td> </td>" } @column_index;
- } else {
- map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
-
- map { $column_data{$_} = "<td>$ref->{$_} </td>" }
- (invnumber, ordnumber, quonumber);
-
- $column_data{name} =
- "<td align=left><a href=$form->{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} </td>";
-
- if ($ref->{email}) {
- $email = $ref->{email};
- $email =~ s/</\</;
- $email =~ s/>/\>/;
-
- $column_data{email} =
- qq|<td><a href="mailto:$ref->{email}">$email</a></td>|;
- }
-
- }
-
- if ($ref->{formtype} eq 'invoice') {
- $column_data{invnumber} =
- "<td><a href=$ref->{module}.pl?action=edit&id=$ref->{invid}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{invnumber} </td>";
- }
-
- if ($ref->{formtype} eq 'order') {
- $column_data{ordnumber} =
- "<td><a href=$ref->{module}.pl?action=edit&id=$ref->{invid}&type=$ordertype&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{ordnumber} </td>";
- }
-
- if ($ref->{formtype} eq 'quotation') {
- $column_data{quonumber} =
- "<td><a href=$ref->{module}.pl?action=edit&id=$ref->{invid}&type=$quotationtype&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{quonumber} </td>";
- }
-
- $i++;
- $i %= 2;
- print "
- <tr class=listrow$i>
-";
-
- map { print "$column_data{$_}\n" } @column_index;
-
- print qq|
- </tr>
-|;
-
- $sameid = $ref->{id};
-
- }
-
- print qq|
- </table>
- </td>
- </tr>
- <tr>
- <td><hr size=3 noshade></td>
- </tr>
-</table>
-
-<br>
-<form method=post action=$form->{script}>
-
-<input name=callback type=hidden value="$form->{callback}">
-<input name=db type=hidden value=$form->{db}>
-
-<input type=hidden name=path value=$form->{path}>
-<input type=hidden name=login value=$form->{login}>
-<input type=hidden name=password value=$form->{password}>
-
-<input class=submit type=submit name=action value="|
- . $locale->text('Add') . qq|">|;
-
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
- }
-
- print qq|
- </form>
-
-</body>
-</html>
-|;
-
- $lxdebug->leave_sub();
-}
-
-sub edit {
- $lxdebug->enter_sub();
-
- # $locale->text('Edit Customer')
- # $locale->text('Edit Vendor')
-
- CT->get_tuple(\%myconfig, \%$form);
-
- # format " into "
- map { $form->{$_} =~ s/\"/"/g } keys %$form;
-
- $form->{title} = "Edit";
-
- # format discount
- $form->{discount} *= 100;
-
- &form_header;
- &form_footer;
-
- $lxdebug->leave_sub();
-}
-
-sub form_header {
- $lxdebug->enter_sub();
-
- $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
- $form->{creditlimit} =
- $form->format_amount(\%myconfig, $form->{creditlimit}, 0);
- $form->{discount} = $form->format_amount(\%myconfig, $form->{discount});
-
- if ($myconfig{role} eq 'admin') {
- $bcc = qq|
- <tr>
- <th align=right nowrap>| . $locale->text('Bcc') . qq|</th>
- <td><input name=bcc size=35 value="$form->{bcc}"></td>
- </tr>
-|;
- }
- $form->{obsolete} = "checked" if $form->{obsolete};
-
- $lang = qq|<option value=""></option>|;
- foreach $item (@{ $form->{languages} }) {
- if ($form->{language_id} eq $item->{id}) {
- $lang .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
- } else {
- $lang .= qq|<option value="$item->{id}">$item->{description}</option>|;
- }
- }
-
- $payment = qq|<option value=""></option>|;
- foreach $item (@{ $form->{payment_terms} }) {
- if ($form->{payment_id} eq $item->{id}) {
- $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
- } else {
- $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
- }
- }
-
- if (!$form->{id}) {
- if ($form->{db} eq "customer") {
- $form->{taxzone_id} = 0;
- } else {
- $form->{taxzone_id} = 0;
- }
- }
-
- if (@{ $form->{TAXZONE} }) {
- foreach $item (@{ $form->{TAXZONE} }) {
- if ($item->{id} == $form->{taxzone_id}) {
- $form->{selecttaxzone} .=
- "<option value=$item->{id} selected>$item->{description}\n";
- } else {
- $form->{selecttaxzone} .=
- "<option value=$item->{id}>$item->{description}\n";
- }
-
- }
- }
-
- $taxzone = qq|
- <tr>
- <th align=right>| . $locale->text('Steuersatz') . qq|</th>
- <td><select name=taxzone_id>$form->{selecttaxzone}</select></td>
- <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
- </tr>|;
-
- $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} = "<option value=0></option>";
- if (@{ $form->{CONTACTS} }) {
- foreach $item (@{ $form->{CONTACTS} }) {
- if ($item->{cp_id} == $form->{cp_id}) {
- $form->{selectcontact} .=
- qq|<option value=$item->{cp_id} selected>$item->{cp_name}</option>\n|;
- } else {
- $form->{selectcontact} .=
- qq|<option value=$item->{cp_id}>$item->{cp_name}</option>\n|;
- }
-
- }
- }
- push(@ { $form->{AJAX} }, $pjx);
- $ansprechpartner = qq|
- <tr>
- <th align=right>| . $locale->text('Ansprechpartner') . qq|</th>
- <td><select id=cp_id name=cp_id onChange="get_contact(['cp_id__' + this.value], ['cp_name', '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'])">$form->{selectcontact}</select></td>
- <input type=hidden name=selectcontact value="$form->{selectcontact}">
- </tr>|;
- $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} = "<option value=0></option>";
- if (@{ $form->{SHIPTO} }) {
- foreach $item (@{ $form->{SHIPTO} }) {
- if ($item->{id} == $form->{shipto_id}) {
- $form->{selectshipto} .=
- "<option value=$item->{id} selected>$item->{shiptoname}\n";
- } else {
- $form->{selectshipto} .=
- "<option value=$item->{id}>$item->{shiptoname}\n";
- }
-
- }
- }
- push(@ { $form->{AJAX} }, $pjy);
-
- $shipto = qq|
- <tr>
- <th align=right>| . $locale->text('Shipping Address') . qq|</th>
- <td><select id=shipto_id name=shipto_id onChange="get_shipto(['shipto_id__' + this.value], ['shiptoname','shiptodepartment_1', 'shiptodepartment_2','shiptostreet','shiptozipcode','shiptocity','shiptocountry','shiptocontact','shiptophone','shiptofax','shiptoemail'])">$form->{selectshipto}</select></td>
- <input type=hidden name=selectshipto value="$form->{selectshipto}">
- </tr>|;
-
-
- $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|
- <tr>
- <th align=right>| . $locale->text('Shipping Address') . qq|</th>
- <td><select id=delivery_id name=delivery_id onChange="get_delivery(['shipto_id__' + this.value, 'from__' + from.value, 'to__' + to.value], ['delivery'])">$form->{selectshipto}</select></td>
- </tr>|;
-
- foreach $item (split / /, $form->{taxaccounts}) {
- if (($form->{tax}{$item}{taxable}) || !($form->{id})) {
- $taxable .=
- qq| <input name="tax_$item" value=1 class=checkbox type=checkbox checked> <b>$form->{tax}{$item}{description}</b>|;
- } else {
- $taxable .=
- qq| <input name="tax_$item" value=1 class=checkbox type=checkbox> <b>$form->{tax}{$item}{description}</b>|;
- }
- }
-
-##LINET
- $taxable = "";
-
- if ($taxable) {
- $tax = qq|
- <tr>
- <th align=right>| . $locale->text('Taxable') . qq|</th>
- <td colspan=2>
- <table>
- <tr>
- <td>$taxable</td>
- <td><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
- <th align=left>| . $locale->text('Tax Included') . qq|</th>
- </tr>
- </table>
- </td>
- </tr>
-|;
- }
- $form->{selectbusiness} = qq|<option>\n|;
- map {
- $form->{selectbusiness} .=
- qq|<option value=$_->{id}>$_->{description}\n|
- } @{ $form->{all_business} };
- if ($form->{business_save}) {
- $form->{selectbusiness} = $form->{business_save};
- }
- $form->{selectbusiness} =~
- s/<option value=$form->{business}>/<option value=$form->{business} selected>/;
-
- $label = ucfirst $form->{db};
- if ($form->{title} eq "Edit") {
- $form->{title} = $locale->text("$form->{title} $label") . " $form->{name}";
- } else {
- $form->{title} = $locale->text("$form->{title} $label");
- }
- if ($form->{title_save}) {
- $form->{title} = $form->{title_save};
- }
- if ($form->{db} eq 'vendor') {
- $customer = qq|
- <th align=right>| . $locale->text('Kundennummer') . qq|</th>
- <td><input name=v_customer_id size=10 tabindex=18 maxlength=35 value="$form->{v_customer_id}"></td>
-|;
- }
-
- if ($form->{db} eq 'customer') {
-
- $customer = qq|
- <th align=right>| . $locale->text('KNr. beim Kunden') . qq|</th>
- <td><input name=c_vendor_id size=10 tabindex=18 maxlength=35 value="$form->{c_vendor_id}"></td>
-|;
- }
- $business_salesman = "";
- $business = "<th></th><td></td>";
- if ($vertreter) {
- $business_salesman = qq|
- <tr>
- <td colspan=3>
- <table>
- <th align=right>| . $locale->text('Type of Business') . qq|</th>
- <td><select name=business tabindex=1>$form->{selectbusiness}</select></td>
- <th align=right>| . $locale->text('Salesman') . qq|</th>
- <td><input name=salesman tabindex=2 value="$form->{salesman}"></td>
- <input type=hidden name=salesman_id value="$form->{salesman_id}">
- <input type=hidden name=oldsalesman value="$form->{oldsalesman}">
- </table>
- </td>
- <tr>|;
- $business = qq|
- <th align=right>| . $locale->text('Username') . qq|</th>
- <td><input name=username maxlength=50 tabindex=22 value="$form->{username}"></td>
- <th align=right>| . $locale->text('Password') . qq|</th>
- <td><input name=user_password maxlength=12 tabindex=23 value="$form->{user_password}"></td>|;
- } else {
- $business = qq|
- <th align=right>| . $locale->text('Type of Business') . qq|</th>
- <td><select name=business tabindex=22>$form->{selectbusiness}</select></td>
- |;
- }
-
-## LINET: Create a drop-down box with all prior titles and greetings.
- CT->query_titles_and_greetings(\%myconfig, \%$form);
-
- $select_title = qq| <select name=selected_cp_title><option></option>|;
- map({ $select_title .= qq|<option>$_</option>|; } @{ $form->{TITLES} });
- $select_title .= qq|</select>|;
-
- $select_greeting =
- qq| <select name=selected_cp_greeting><option></option>|;
- map(
- { $select_greeting .= qq|<option>$_</option>|; } @{ $form->{GREETINGS} });
- $select_greeting .= qq|</select>|;