Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision bbc63419

Von Moritz Bunkus vor mehr als 16 Jahren hinzugefügt

  • ID bbc63419b26661a6d5c9bf859dc79cfb63069048
  • Vorgänger 94e596e5
  • Nachfolger 77733865

Eingangsrechnungen: Wird das Rechnungsdatum verändert, so wird per AJAX das Fälligkeitsdatum anhand der beim Lieferanten hinterlegten Zahlungsbedingungen berechnet und im Formular ersetzt.

Unterschiede anzeigen:

SL/IR.pm
1277 1277
  return $rc;
1278 1278
}
1279 1279

  
1280
sub get_duedate {
1281
  $main::lxdebug->enter_sub();
1282

  
1283
  my $self     = shift;
1284
  my %params   = @_;
1285

  
1286
  if (!$params{vendor_id} || !$params{invdate}) {
1287
    $main::lxdebug->leave_sub();
1288
    return $params{default};
1289
  }
1290

  
1291
  my $myconfig = \%main::myconfig;
1292
  my $form     = $main::form;
1293

  
1294
  my $dbh      = $params{dbh} || $form->get_standard_dbh($myconfig);
1295

  
1296
  my $query    = qq|SELECT ?::date + pt.terms_netto
1297
                    FROM vendor v
1298
                    LEFT JOIN payment_terms pt ON (pt.id = v.payment_id)
1299
                    WHERE v.id = ?|;
1300

  
1301
  my ($sth, $duedate);
1302

  
1303
  if (($sth = $dbh->prepare($query)) && $sth->execute($params{invdate}, conv_i($params{vendor_id}))) {
1304
    ($duedate) = $sth->fetchrow_array();
1305
    $sth->finish();
1306
  } else {
1307
    $dbh->rollback();
1308
  }
1309

  
1310
  $duedate ||= $params{default};
1311

  
1312
  $main::lxdebug->leave_sub();
1313

  
1314
  return $duedate;
1315
}
1316

  
1317

  
1280 1318
1;
bin/mozilla/ir.pl
226 226

  
227 227
  $auth->assert('vendor_invoice_edit');
228 228

  
229
  push @{ $form->{AJAX} }, CGI::Ajax->new('set_duedate_vendor' => "$form->{script}?action=set_duedate_vendor");
230

  
229 231
  # set option selected
230 232
  foreach $item (qw(AP vendor currency department)) {
231 233
    $form->{"select$item"} =~ s/ selected//;
......
389 391
  $jsscript = "";
390 392

  
391 393
  $button1 = qq|
392
     <td><input name=invdate id=invdate size=11 title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\">
393
         <input type=button name=invdate id="trigger1" value=| . $locale->text('button') . qq|></td>\n|;
394
     <td nowrap>
395
         <input name=invdate id=invdate size=11 title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\"
396
                onChange="if (this.value) set_duedate_vendor(['invdate__' + this.value, 'old_duedate__' + document.getElementsByName('duedate')[0].value, 'vendor_id__' + document.getElementsByName('vendor_id')[0].value],['duedate'])">
397
         <input type=button name=invdate id="trigger1" value="?">
398
     </td>\n|;
399

  
400
#, 'old_duedate__'' + document.getElementsByName('duedate')[0].value, 'vendor_id__' + document.getElementsByName('vendor_id')[0].value],['duedate'])">
394 401
  $button2 = qq|
395
     <td width="13"><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value="$form->{duedate}"  onBlur=\"check_right_date_format(this)\">
396
                    <input type=button name=duedate id="trigger2" value=| . $locale->text('button') . qq|></td>\n|;
402
     <td width="13" nowrap>
403
          <input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value="$form->{duedate}"  onBlur=\"check_right_date_format(this)\">
404
          <input type=button name=duedate id="trigger2" value=| . $locale->text('button') . qq|>
405
     </td>\n|;
397 406

  
398 407
  #write Trigger
399 408
  $jsscript =
......
419 428
  print qq|
420 429
<body onLoad="$onload">
421 430
<script type="text/javascript" src="js/common.js"></script>
422
<form method=post action=$form->{script}>
431
<form method="post" action="ir.pl" name="Form">
423 432
|;
424 433

  
425 434
  $form->hide_form(qw(id title vc type level creditlimit creditremaining closedto locked shippted storno storno_id
......
1206 1215

  
1207 1216
  $lxdebug->leave_sub();
1208 1217
}
1218

  
1219
sub set_duedate_vendor {
1220
  $lxdebug->enter_sub();
1221

  
1222
  print $cgi->header(), IR->get_duedate('vendor_id' => $form->{vendor_id},
1223
                                        'invdate'   => $form->{invdate},
1224
                                        'default'   => $form->{old_duedate});
1225

  
1226
  $lxdebug->leave_sub();
1227
}
locale/de/ir
377 377
  'select_project'              => 'select_project',
378 378
  'send_email'                  => 'send_email',
379 379
  'set_duedate'                 => 'set_duedate',
380
  'set_duedate_vendor'          => 'set_duedate_vendor',
380 381
  'set_longdescription'         => 'set_longdescription',
381 382
  'set_pricegroup'              => 'set_pricegroup',
382 383
  'ship_to'                     => 'ship_to',

Auch abrufbar als: Unified diff