Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b2d5199f

Von Moritz Bunkus vor fast 11 Jahren hinzugefügt

  • ID b2d5199fcc96a1767fa766f65b4e97d7bc377c97
  • Vorgänger a74b677c
  • Nachfolger 44cda51f

Form: nicht mehr benötigte Funktionen update_{defaults,business} entfernen

Unterschiede anzeigen:

SL/Form.pm
3173 3173
  return 0;
3174 3174
}
3175 3175

  
3176
sub update_defaults {
3177
  $main::lxdebug->enter_sub();
3178

  
3179
  my ($self, $myconfig, $fld, $provided_dbh) = @_;
3180

  
3181
  my $dbh;
3182
  if ($provided_dbh) {
3183
    $dbh = $provided_dbh;
3184
  } else {
3185
    $dbh = $self->dbconnect_noauto($myconfig);
3186
  }
3187
  my $query = qq|SELECT $fld FROM defaults FOR UPDATE|;
3188
  my $sth   = $dbh->prepare($query);
3189

  
3190
  $sth->execute || $self->dberror($query);
3191
  my ($var) = $sth->fetchrow_array;
3192
  $sth->finish;
3193

  
3194
  $var   = 0 if !defined($var) || ($var eq '');
3195
  $var   = SL::PrefixedNumber->new(number => $var)->get_next;
3196
  $query = qq|UPDATE defaults SET $fld = ?|;
3197
  do_query($self, $dbh, $query, $var);
3198

  
3199
  if (!$provided_dbh) {
3200
    $dbh->commit;
3201
    $dbh->disconnect;
3202
  }
3203

  
3204
  $main::lxdebug->leave_sub();
3205

  
3206
  return $var;
3207
}
3208

  
3209
sub update_business {
3210
  $main::lxdebug->enter_sub();
3211

  
3212
  my ($self, $myconfig, $business_id, $provided_dbh) = @_;
3213

  
3214
  my $dbh;
3215
  if ($provided_dbh) {
3216
    $dbh = $provided_dbh;
3217
  } else {
3218
    $dbh = $self->dbconnect_noauto($myconfig);
3219
  }
3220
  my $query =
3221
    qq|SELECT customernumberinit FROM business
3222
       WHERE id = ? FOR UPDATE|;
3223
  my ($var) = selectrow_query($self, $dbh, $query, $business_id);
3224

  
3225
  return undef unless $var;
3226

  
3227
  if ($var =~ m/\d+$/) {
3228
    my $new_var  = (substr $var, $-[0]) * 1 + 1;
3229
    my $len_diff = length($var) - $-[0] - length($new_var);
3230
    $var         = substr($var, 0, $-[0]) . ($len_diff > 0 ? '0' x $len_diff : '') . $new_var;
3231

  
3232
  } else {
3233
    $var = $var . '1';
3234
  }
3235

  
3236
  $query = qq|UPDATE business
3237
              SET customernumberinit = ?
3238
              WHERE id = ?|;
3239
  do_query($self, $dbh, $query, $var, $business_id);
3240

  
3241
  if (!$provided_dbh) {
3242
    $dbh->commit;
3243
    $dbh->disconnect;
3244
  }
3245

  
3246
  $main::lxdebug->leave_sub();
3247

  
3248
  return $var;
3249
}
3250

  
3251 3176
sub get_partsgroup {
3252 3177
  $main::lxdebug->enter_sub();
3253 3178

  
......
3594 3519

  
3595 3520
=head1 SPECIAL FUNCTIONS
3596 3521

  
3597
=head2 C<update_business> PARAMS
3598

  
3599
PARAMS (not named):
3600
 \%config,     - config hashref
3601
 $business_id, - business id
3602
 $dbh          - optional database handle
3603

  
3604
handles business (thats customer/vendor types) sequences.
3605

  
3606
special behaviour for empty strings in customerinitnumber field:
3607
will in this case not increase the value, and return undef.
3608

  
3609 3522
=head2 C<redirect_header> $url
3610 3523

  
3611 3524
Generates a HTTP redirection header for the new C<$url>. Constructs an

Auch abrufbar als: Unified diff