Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision c2def905

Von Moritz Bunkus vor mehr als 15 Jahren hinzugefügt

  • ID c2def9059d4b1b8d8be43704409d49fe68f29a01
  • Vorgänger 9d8c5c5f
  • Nachfolger 96d4a37b

Kosmetik & Codevereinfachungen.

Unterschiede anzeigen:

bin/mozilla/am.pl
99 99

  
100 100
  if ( $form->{action} eq 'edit_account') {
101 101
    $form->{account_exists} = '1';
102
  } 
103
  
102
  }
103

  
104 104
  $form->{title} = $locale->text("$form->{title} Account");
105 105

  
106 106
  $form->{"$form->{charttype}_checked"} = "checked";
......
109 109
  $form->{select_tax} = "";
110 110

  
111 111
  my @tax_report_pos = USTVA->report_variables({
112
      myconfig   => \%myconfig, 
113
      form       => $form, 
114
      type       => '', 
112
      myconfig   => \%myconfig,
113
      form       => $form,
114
      type       => '',
115 115
      attribute  => 'position',
116 116
      calc       => '',
117 117
  });
......
147 147
        if ($item->{id} == $taxkey_used->{tax_id}) {
148 148
          $form->{ACCOUNT_TAXKEYS}[$i]{selecttaxkey} .=
149 149
            qq|<option value="$item->{id}" selected="selected">|
150
            . sprintf("%.2d", $item->{taxkey}) 
150
            . sprintf("%.2d", $item->{taxkey})
151 151
            . qq|. $item->{taxdescription} ($item->{rate}) |
152
            . $locale->text('Tax-o-matic Account') 
152
            . $locale->text('Tax-o-matic Account')
153 153
            . qq|: $item->{chart_accno}\n|;
154
        } 
154
        }
155 155
        else {
156 156
          $form->{ACCOUNT_TAXKEYS}[$i]{selecttaxkey} .=
157 157
            qq|<option value="$item->{id}">|
158
            . sprintf("%.2d", $item->{taxkey}) 
158
            . sprintf("%.2d", $item->{taxkey})
159 159
            . qq|. $item->{taxdescription} ($item->{rate}) |
160 160
            . $locale->text('Tax-o-matic Account')
161 161
            . qq|: $item->{chart_accno}\n|;
162 162
        }
163 163

  
164 164
      }
165
      
165

  
166 166
      # Fill in the USTVA Numbers as select options
167 167
      foreach my $item ( '', sort({ $a cmp $b } @tax_report_pos) ) {
168 168
        if ($item eq ''){
169 169
          $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="" selected="selected">-\n|;
170
        } 
170
        }
171 171
        elsif ( $item eq $taxkey_used->{pos_ustva} ) {
172 172
          $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="$item" selected="selected">$item\n|;
173 173
        }
......
175 175
          $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="$item">$item\n|;
176 176
        }
177 177

  
178
      }      
178
      }
179 179

  
180 180
      $i++;
181 181
    }
182 182
  }
183 183

  
184
  # Newaccount Folgekonto 
184
  # Newaccount Folgekonto
185 185
  if (@{ $form->{NEWACCOUNT} }) {
186 186
    if (!$form->{new_chart_valid}) {
187 187
      $form->{selectnewaccount} = qq|<option value=""> |. $locale->text('None') .q|</option>|;
......
288 288
  # this is for our parser only! Do not remove.
289 289
  # type=submit $locale->text('Add Account')
290 290
  # type=submit $locale->text('Edit Account')
291
  
291

  
292 292
  $form->{type} = "account";
293 293

  
294 294
  # preselections category
295
 
295

  
296 296
  $select_category = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
297 297

  
298 298
  %category = (
299 299
      'A'  => $locale->text('Asset'),
300 300
      'L'  => $locale->text('Liability'),
301 301
      'Q'  => $locale->text('Equity'),
302
      'I'  => $locale->text('Revenue'),      
302
      'I'  => $locale->text('Revenue'),
303 303
      'E'  => $locale->text('Expense'),
304 304
      'C'  => $locale->text('Costs'),
305 305
  );
......
311 311
    }
312 312

  
313 313
  }
314
  
314

  
315 315
  # preselection chart type
316 316
  my $select_charttype = q{};
317 317

  
......
319 319
      'A'  => $locale->text('Account'),
320 320
      'H'  => $locale->text('Header'),
321 321
  );
322
  
322

  
323 323
  foreach $item ( sort({ $a <=> $b } keys %charttype) ) {
324 324
    if ($item eq $form->{charttype}) {
325 325
      $select_charttype .= qq|<option value="$item" selected="selected">$charttype{$item}\n|;
......
331 331
  }
332 332

  
333 333
  my $ChartTypeIsAccount = ($form->{charttype} eq "A") ? "1":"";
334
  
334

  
335 335
  $form->header();
336
  
336

  
337 337
  my $parameters_ref = {
338 338
    ChartTypeIsAccount         => $ChartTypeIsAccount,
339 339
    select_category            => $select_category,
......
344 344
    select_bilanz              => $select_bilanz,
345 345
    select_eur                 => $select_eur,
346 346
  };
347
  
347

  
348 348
  # Ausgabe des Templates
349 349
  print($form->parse_html_template('am/edit_accounts', $parameters_ref));
350 350

  
......
397 397

  
398 398
  $form->isblank("accno",       $locale->text('Account Number missing!'));
399 399
  $form->isblank("description", $locale->text('Account Description missing!'));
400
  
400

  
401 401
  if ($form->{charttype} eq 'A'){
402 402
    $form->isblank("category",  $locale->text('Account Type missing!'));
403 403
  }
......
416 416

  
417 417
  $form->isblank("accno",       $locale->text('Account Number missing!'));
418 418
  $form->isblank("description", $locale->text('Account Description missing!'));
419
  
419

  
420 420
  if ($form->{charttype} eq 'A'){
421 421
    $form->isblank("category",  $locale->text('Account Type missing!'));
422 422
  }
......
460 460
    if ($ca->{amount} < 0) {
461 461
      $ca->{debit} = $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2);
462 462
    }
463
    $ca->{heading}   = ( $ca->{charttype} eq 'H' ) ? 1:''; 
463
    $ca->{heading}   = ( $ca->{charttype} eq 'H' ) ? 1:'';
464 464
    $ca->{link_edit_account} = $link_edit_account . '&id=' . E($ca->{id});
465 465
  }
466
  
467
  # Ajax 
466

  
467
  # Ajax
468 468
  my $pjx = new CGI::Ajax('list_account_details' => build_std_url('action=list_account_details'));
469 469

  
470 470
  # Eneable AJAX debuging
471 471
  #$pjx->DEBUG(1);
472 472
  #$pjx->JSDEBUG(1);
473
    
473

  
474 474
  push(@ { $form->{AJAX} }, $pjx);
475 475

  
476 476
  $form->{stylesheets} = "list_accounts.css";
477 477
  $form->{title}       = $locale->text('Chart of Accounts');
478 478

  
479 479
  $form->header;
480
  
481
  
480

  
481

  
482 482
  my $parameters_ref = {
483 483
  #   hidden_variables                => $_hidden_variables_ref,
484 484
  };
485
  
485

  
486 486
  # Ausgabe des Templates
487 487
  print($form->parse_html_template('am/list_accounts', $parameters_ref));
488
  
488

  
489 489
  $lxdebug->leave_sub();
490 490

  
491 491
}
......
876 876
|;
877 877

  
878 878
	$lead = $ref->{lead};
879
	
879

  
880 880
    $column_data{description} = qq|<td><a href="am.pl?action=edit_lead&id=$ref->{id}&callback=$callback">$ref->{lead}</td>|;
881 881

  
882 882
    map { print "$column_data{$_}\n" } @column_index;
......
2308 2308
  <tr>
2309 2309
    <th align=right>| . $locale->text('Skonto Terms') . qq|</th>
2310 2310
    <td><input name=terms_skonto size=10 value="$form->{terms_skonto}"></td>
2311
  </tr>  
2311
  </tr>
2312 2312
  <tr>
2313 2313
    <th align=right>| . $locale->text('Skonto') . qq| %</th>
2314 2314
    <td><input name=percent_skonto size=10 value="$form->{percent_skonto}"></td>
2315
  </tr> 
2315
  </tr>
2316 2316
  <td colspan=2><hr size=3 noshade></td>
2317 2317
  </tr>
2318 2318
</table>
......
2801 2801
}
2802 2802

  
2803 2803
sub show_history_search {
2804
	$lxdebug->enter_sub();
2805
	
2804
  $lxdebug->enter_sub();
2805

  
2806 2806
  $auth->assert('config');
2807 2807

  
2808
	$form->{title} = $locale->text("History Search");
2809
    $form->header();
2810
    
2811
    print $form->parse_html_template("common/search_history");
2812
	
2813
	$lxdebug->leave_sub();
2808
  $form->{title} = $locale->text("History Search");
2809
  $form->header();
2810

  
2811
  print $form->parse_html_template("common/search_history");
2812

  
2813
  $lxdebug->leave_sub();
2814 2814
}
2815 2815

  
2816 2816
sub show_am_history {
2817
	$lxdebug->enter_sub();
2817
  $lxdebug->enter_sub();
2818 2818

  
2819 2819
  $auth->assert('config');
2820 2820

  
2821
	my %search = ( "Artikelnummer" => "parts",
2822
				   "Kundennummer"  => "customer",
2823
				   "Lieferantennummer" => "vendor",
2824
				   "Projektnummer" => "project",
2825
				   "Buchungsnummer" => "oe",
2826
				   "Eingangsrechnungnummer" => "ap",
2827
				   "Ausgangsrechnungnummer" => "ar",
2828
           "Mahnungsnummer" => "dunning"
2829
		);
2830
	my %searchNo = ( "Artikelnummer" => "partnumber",
2831
				     "Kundennummer"  => "customernumber",
2832
				     "Lieferantennummer" => "vendornumber",
2833
				     "Projektnummer" => "projectnummer",
2834
				     "Buchungsnummer" => "ordnumber",
2835
				     "Eingangsrechnungnummer" => "invnumber",
2836
				     "Ausgangsrechnungnummer" => "invnumber",
2837
             "Mahnungsnummer" => "dunning_id"
2838
		);
2839
	
2840
	my $restriction;
2841
	my $tempNo = 0;
2842
	foreach(split(/\,/, $form->{einschraenkungen})) {
2843
		if($tempNo == 0) {
2844
			$restriction .= " AND addition = '" . $_ . "'";
2845
			$tempNo = 1;
2846
		} 
2847
		else {
2848
			$restriction .= " OR addition = '" . $_ . "'";
2849
		}
2850
	}
2851
	$restriction .= (($form->{transdate} ne "" && $form->{reqdate} ne "") 
2852
						? qq| AND st.itime::date >= '| . $form->{transdate} . qq|' AND st.itime::date <= '| . $form->{reqdate} . qq|'|
2853
						: (($form->{transdate} ne "" && $form->{reqdate} eq "") 
2854
							? qq| AND st.itime::date >= '| . $form->{transdate} . qq|'|
2855
							: ($form->{transdate} eq "" && $form->{reqdate} ne "") 
2856
								? qq| AND st.itime::date <= '| . $form->{reqdate} . qq|'|
2857
								: ""
2858
							)
2859
						);
2860
  $restriction .= ($form->{mitarbeiter} eq "" ? "" 
2861
          : ($form->{mitarbeiter} =~ /^[0-9]*$/  
2862
            ? " AND employee_id = " . $form->{mitarbeiter} 
2863
            : " AND employee_id = " . &get_employee_id($form->{mitarbeiter}, $dbh)));
2864
  
2865
	my $dbh = $form->dbconnect(\%myconfig);
2866
	my $query = qq|SELECT trans_id AS id FROM history_erp | . 
2867
                ($form->{'searchid'} ? 
2868
                  qq| WHERE snumbers = '| . $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'} . qq|'| : 
2869
                  qq| WHERE snumbers ~ '^| . $searchNo{$form->{'what2search'}} . qq|'|);
2870

  
2871
  my $sth = $dbh->prepare($query);
2872
	
2873
	$sth->execute() || $form->dberror($query);
2874
  
2875
  $form->{title} = $locale->text("History Search");
2876
	$form->header();
2877
	
2878
  my $i = 1;
2879
  my $daten = qq||;
2880
  while(my $hash_ref = $sth->fetchrow_hashref()){
2881
    if($i) {
2882
      $daten .= $hash_ref->{id};
2883
      $i = 0;
2884
    }
2885
    else {
2886
      $daten .= " OR trans_id = " . $hash_ref->{id};
2821
  my %search = ( "Artikelnummer"          => "parts",
2822
                 "Kundennummer"           => "customer",
2823
                 "Lieferantennummer"      => "vendor",
2824
                 "Projektnummer"          => "project",
2825
                 "Buchungsnummer"         => "oe",
2826
                 "Eingangsrechnungnummer" => "ap",
2827
                 "Ausgangsrechnungnummer" => "ar",
2828
                 "Mahnungsnummer"         => "dunning"
2829
    );
2830
  my %searchNo = ( "Artikelnummer"          => "partnumber",
2831
                   "Kundennummer"           => "customernumber",
2832
                   "Lieferantennummer"      => "vendornumber",
2833
                   "Projektnummer"          => "projectnummer",
2834
                   "Buchungsnummer"         => "ordnumber",
2835
                   "Eingangsrechnungnummer" => "invnumber",
2836
                   "Ausgangsrechnungnummer" => "invnumber",
2837
                   "Mahnungsnummer"         => "dunning_id"
2838
    );
2839

  
2840
  my $restriction;
2841
  my $tempNo = 0;
2842
  foreach(split(/\,/, $form->{einschraenkungen})) {
2843
    if($tempNo == 0) {
2844
      $restriction .= " AND addition = '" . $_ . "'";
2845
      $tempNo       = 1;
2846
    } else {
2847
      $restriction .= " OR addition = '" . $_ . "'";
2887 2848
    }
2888 2849
  }
2889
  
2850
  $restriction .=
2851
      $form->{transdate} ne "" && $form->{reqdate} ne "" ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|' AND st.itime::date <= '| . $form->{reqdate} . qq|'|
2852
    : $form->{transdate} ne "" && $form->{reqdate} eq "" ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|'|
2853
    : $form->{transdate} eq "" && $form->{reqdate} ne "" ? qq| AND st.itime::date <= '| . $form->{reqdate} . qq|'|
2854
    :                                                        ""
2855
    ;
2856
  $restriction .=
2857
      $form->{mitarbeiter} eq ""      ? ""
2858
    : $form->{mitarbeiter} =~ /^\d+$/ ? " AND employee_id = " . $form->{mitarbeiter}
2859
    :                                   " AND employee_id = " . get_employee_id($form->{mitarbeiter}, $dbh);
2860

  
2861
  my $dbh = $form->dbconnect(\%myconfig);
2862
  my $query = qq|SELECT trans_id AS id FROM history_erp | .
2863
    (  $form->{'searchid'} ? qq| WHERE snumbers = '|  . $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'} . qq|'|
2864
     :                       qq| WHERE snumbers ~ '^| . $searchNo{$form->{'what2search'}} . qq|'|);
2865

  
2866
  my @ids    = selectall_array_query($form, $dbh, $query);
2867
  my $daten .= shift @ids;
2868
  $daten    .= join '', map { " OR trans_id = $_" } @ids;
2869

  
2890 2870
  my ($sort, $sortby) = split(/\-\-/, $form->{order});
2891 2871
  $sort =~ s/.*\.(.*)$/$1/;
2892 2872

  
2893
	print $form->parse_html_template("common/show_history", 
2894
    {"DATEN" => $form->get_history($dbh, $daten, $restriction, $form->{order}),
2895
     "SUCCESS" => ($form->get_history($dbh, $daten, $restriction, $form->{order}) ne "0"),
2896
     "NONEWWINDOW" => 1,
2897
     uc($sort) => 1,
2898
     uc($sort)."BY" => $sortby
2899
    });
2900
	$dbh->disconnect();
2873
  $form->{title} = $locale->text("History Search");
2874
  $form->header();
2875

  
2876
  print $form->parse_html_template("common/show_history",
2877
                                   { "DATEN"          => $form->get_history($dbh, $daten, $restriction, $form->{order}),
2878
                                     "SUCCESS"        => ($form->get_history($dbh, $daten, $restriction, $form->{order}) ne "0"),
2879
                                     "NONEWWINDOW"    => 1,
2880
                                     uc($sort)        => 1,
2881
                                     uc($sort) . "BY" => $sortby
2882
                                   });
2883
  $dbh->disconnect();
2884

  
2901 2885
  $lxdebug->leave_sub();
2902 2886
}
2903 2887

  
......
2940 2924
  _get_taxaccount_selection();
2941 2925

  
2942 2926
  $form->header();
2943
  
2927

  
2944 2928
  my $parameters_ref = {
2945 2929
#    ChartTypeIsAccount         => $ChartTypeIsAccount,
2946 2930
  };
2947
  
2931

  
2948 2932
  # Ausgabe des Templates
2949 2933
  print($form->parse_html_template('am/edit_tax', $parameters_ref));
2950 2934

  
......
2964 2948
  $form->{rate} = $form->format_amount(\%myconfig, $form->{rate}, 2);
2965 2949

  
2966 2950
  $form->header();
2967
  
2951

  
2968 2952
  my $parameters_ref = {
2969 2953
  };
2970
  
2954

  
2971 2955
  # Ausgabe des Templates
2972 2956
  print($form->parse_html_template('am/edit_tax', $parameters_ref));
2973 2957

  
......
2988 2972
  $form->{title} = $locale->text('Tax-O-Matic');
2989 2973

  
2990 2974
  $form->header();
2991
  
2975

  
2992 2976
  # Ausgabe des Templates
2993 2977
  print($form->parse_html_template('am/list_tax', $parameters_ref));
2994 2978

  
......
3024 3008

  
3025 3009
  if ( $form->{rate} <= 0.99 && $form->{rate} > 0 ) {
3026 3010
    $form->error($locale->text('Tax Percent is a number between 0 and 100'));
3027
  }  
3011
  }
3028 3012

  
3029 3013
  AM->save_tax(\%myconfig, \%$form);
3030 3014
  $form->redirect($locale->text('Tax saved!'));
......
3277 3261

  
3278 3262
  $lxdebug->leave_sub();
3279 3263
}
3280

  

Auch abrufbar als: Unified diff