$form->{snumber} durch $form->{snumbers} ersetzt, da dies eigentlich so vorgesehen...
[kivitendo-erp.git] / bin / mozilla / am.pl
index 276a2da..38eedb0 100644 (file)
@@ -40,16 +40,15 @@ use Data::Dumper;
 
 1;
 
-
-
 require "$form->{path}/common.pl";
 
 # end of main
 
-sub add    { &{"add_$form->{type}"} }
-sub edit   { &{"edit_$form->{type}"} }
-sub save   { &{"save_$form->{type}"} }
-sub delete { &{"delete_$form->{type}"} }
+sub add      { call_sub("add_$form->{type}"); }
+sub delete   { call_sub("delete_$form->{type}"); }
+sub save     { call_sub("save_$form->{type}"); }
+sub edit     { call_sub("edit_$form->{type}"); }
+sub continue { call_sub($form->{"nextsub"}); }
 
 sub add_account {
   $lxdebug->enter_sub();
@@ -1115,9 +1114,7 @@ sub list_business {
     $discount =
       $form->format_amount(\%myconfig, $ref->{discount} * 100);
     $description =
-      ($ref->{salesman})
-      ? "<b>$ref->{description}</b>"
-      : "$ref->{description}";
+      $ref->{description};
     $column_data{description} =
       qq|<td><a href=$form->{script}?action=edit_business&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$description</td>|;
     $column_data{discount}           = qq|<td align=right>$discount</td>|;
@@ -1167,7 +1164,6 @@ sub business_header {
   $lxdebug->enter_sub();
 
   $form->{title}    = $locale->text("$form->{title} Business");
-  $form->{salesman} = "checked" if $form->{salesman};
 
   # $locale->text('Add Business')
   # $locale->text('Edit Business')
@@ -1203,10 +1199,6 @@ sub business_header {
     <th align=right>| . $locale->text('Customernumberinit') . qq|</th>
     <td><input name=customernumberinit size=10 value=$form->{customernumberinit}></td>
   </tr>
-  <tr>
-    <td align=right>| . $locale->text('Salesman') . qq|</td>
-    <td><input name=salesman class=checkbox type=checkbox value=1 $form->{salesman}></td>
-  </tr>
   <td colspan=2><hr size=3 noshade></td>
   </tr>
 </table>
@@ -2419,114 +2411,6 @@ sub swap_payment_terms {
   $lxdebug->leave_sub();
 }
 
-sub display_stylesheet {
-  $lxdebug->enter_sub();
-
-  $form->{file} = "css/$myconfig{stylesheet}";
-  &display_form;
-
-  $lxdebug->leave_sub();
-}
-
-sub display_form {
-  $lxdebug->enter_sub();
-
-  $form->{file} =~ s/^(.:)*?\/|\.\.\///g;
-  $form->{file} =~ s/^\/*//g;
-  $form->{file} =~ s/$userspath//;
-
-  $form->error("$!: $form->{file}") unless -f $form->{file};
-
-  AM->load_template(\%$form);
-
-  $form->{title} = $form->{file};
-
-  # if it is anything but html
-  if ($form->{file} !~ /\.html$/) {
-    $form->{body} = "<pre>\n$form->{body}\n</pre>";
-  }
-
-  $form->header;
-
-  print qq|
-<body>
-
-$form->{body}
-
-<form method=post action=$form->{script}>
-
-<input name=file type=hidden value=$form->{file}>
-<input name=type type=hidden value=template>
-
-<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 name=action type=submit class=submit value="|
-    . $locale->text('Edit') . qq|">
-
-  </form>
-
-</body>
-</html>
-|;
-
-  $lxdebug->leave_sub();
-}
-
-sub edit_template {
-  $lxdebug->enter_sub();
-
-  AM->load_template(\%$form);
-
-  $form->{title} = $locale->text('Edit Template');
-
-  # convert &nbsp to &amp;nbsp;
-  $form->{body} =~ s/&nbsp;/&amp;nbsp;/gi;
-
-  $form->header;
-
-  print qq|
-<body>
-
-<form method=post action=$form->{script}>
-
-<input name=file type=hidden value=$form->{file}>
-<input name=type type=hidden value=template>
-
-<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 name=callback type=hidden value="$form->{script}?action=display_form&file=$form->{file}&path=$form->{path}&login=$form->{login}&password=$form->{password}">
-
-<textarea name=body rows=25 cols=70>
-$form->{body}
-</textarea>
-
-<br>
-<input type=submit class=submit name=action value="|
-    . $locale->text('Save') . qq|">
-
-  </form>
-
-
-</body>
-</html>
-|;
-
-  $lxdebug->leave_sub();
-}
-
-sub save_template {
-  $lxdebug->enter_sub();
-
-  AM->save_template(\%$form);
-  $form->redirect($locale->text('Template saved!'));
-
-  $lxdebug->leave_sub();
-}
-
 sub config {
   $lxdebug->enter_sub();
 
@@ -3022,14 +2906,6 @@ sub doclose {
   $lxdebug->leave_sub();
 }
 
-sub continue {
-  $lxdebug->enter_sub();
-
-  &{ $form->{nextsub} };
-
-  $lxdebug->leave_sub();
-}
-
 sub edit_units {
   $lxdebug->enter_sub();
 
@@ -3258,33 +3134,36 @@ sub show_am_history {
                                                );
        
        my $dbh = $form->dbconnect(\%myconfig);
-       
+       my $searchSNumber = $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'};
        $restriction .= ($form->{mitarbeiter} eq "" ? "" 
                                        : ($form->{mitarbeiter} =~ /^[0-9]*$/  
                                                ? " AND employee_id = " . $form->{mitarbeiter} 
                                                : " AND employee_id = " . &get_employee_id($form->{mitarbeiter}, $dbh)));
-       
-       my $query = qq|SELECT id FROM $search{$form->{what2search}} 
-                                  WHERE $searchNo{$form->{'what2search'}} ILIKE '$form->{"searchid"}' 
-                                  |;
-       
-       my $sth = $dbh->prepare($query);
+       my $query = qq|SELECT trans_id AS id FROM history_erp WHERE sNumbers = '$searchSNumber' |;
+
+  my $sth = $dbh->prepare($query);
        
        $sth->execute() || $form->dberror($query);
        
+  if($sth->fetch() <= 0) {
+    $sth->finish();
+    my $query = qq|SELECT id FROM $search{$form->{what2search}} 
+           WHERE $searchNo{$form->{'what2search'}} ILIKE '$form->{"searchid"}' 
+           |;
+  }
+  $sth->execute() || $form->dberror($query);  
        $form->{title} = $locale->text("History Search");
        $form->header();
-       
+       my $daten = "";
        while(my $hash_ref = $sth->fetchrow_hashref()){
-               print $form->parse_html_template("/common/show_history", 
-                       {"DATEN" => $form->get_history($dbh,$hash_ref->{id},$restriction),
-                        "SUCCESS" => ($form->get_history($dbh,$hash_ref->{id},$restriction) != 0),
-                        "NONEWWINDOW" => "1"   
-                       }
-               );
-       }
+    $daten =  $form->get_history($dbh,$hash_ref->{id},$restriction);
+  }
        $dbh->disconnect();
-       
+       print $form->parse_html_template("/common/show_history", 
+    {"DATEN" => $daten,
+     "SUCCESS" => ($daten != 0 ? 1 : 0),
+     "NONEWWINDOW" => 1
+    });
        $lxdebug->leave_sub();
 }