-#--------------------------------------------------------------------#
-
-=head2 AddBookseller
-
-$id = &AddBookseller($bookseller);
-
-Creates a new bookseller. C<$bookseller> is a reference-to-hash whose
-keys are the fields of the aqbooksellers table in the Koha database.
-All fields must be present.
-
-Returns the ID of the newly-created bookseller.
-
-=cut
-
-sub AddBookseller {
- my ($data) = @_;
- my $dbh = C4::Context->dbh;
- my $query = q|
- INSERT INTO aqbooksellers
- (
- name, address1, address2, address3, address4,
- postal, phone, accountnumber,fax, url,
- contact, contpos, contphone, contfax, contaltphone,
- contemail, contnotes, active, listprice, invoiceprice,
- gstreg, listincgst, invoiceincgst,gstrate, discount,
- notes, deliverytime
- )
- VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |
- ;
- my $sth = $dbh->prepare($query);
- $sth->execute(
- $data->{name} ,$data->{address1},
- $data->{address2} ,$data->{address3},
- $data->{address4} ,$data->{postal},
- $data->{phone} ,$data->{accountnumber},
- $data->{fax},
- $data->{url} ,$data->{contact},
- $data->{contpos} ,$data->{contphone},
- $data->{contfax} ,$data->{contaltphone},
- $data->{contemail} ,$data->{contnotes},
- $data->{active} ,$data->{listprice},
- $data->{invoiceprice} ,$data->{gstreg},
- $data->{listincgst} ,$data->{invoiceincgst},
- $data->{gstrate} ,$data->{discount},
- $data->{notes} ,$data->{deliverytime},
- );
-
- # return the id of this new supplier
- return $dbh->{'mysql_insertid'};
-}
-
-#-----------------------------------------------------------------#
-
-=head2 ModBookseller
-
-ModBookseller($bookseller);
-
-Updates the information for a given bookseller. C<$bookseller> is a
-reference-to-hash whose keys are the fields of the aqbooksellers table
-in the Koha database. It must contain entries for all of the fields.
-The entry to modify is determined by C<$bookseller-E<gt>{id}>.
-
-The easiest way to get all of the necessary fields is to look up a
-book seller with C<&GetBookseller>, modify what's necessary, then call
-C<&ModBookseller> with the result.
-
-=cut
-
-sub ModBookseller {
- my ($data) = @_;
- my $dbh = C4::Context->dbh;
- return unless $data->{'id'};
- my $query = 'UPDATE aqbooksellers
- SET name=?,address1=?,address2=?,address3=?,address4=?,
- postal=?,phone=?,accountnumber=?,fax=?,url=?,contact=?,contpos=?,
- contphone=?,contfax=?,contaltphone=?,contemail=?,
- contnotes=?,active=?,listprice=?, invoiceprice=?,
- gstreg=?,listincgst=?,invoiceincgst=?,
- discount=?,notes=?,gstrate=?,deliverytime=?
- WHERE id=?';
- my $sth = $dbh->prepare($query);
- return $sth->execute(
- $data->{'name'}, $data->{'address1'},
- $data->{'address2'}, $data->{'address3'},
- $data->{'address4'}, $data->{'postal'},
- $data->{'phone'}, $data->{'accountnumber'},
- $data->{'fax'},
- $data->{'url'}, $data->{'contact'},
- $data->{'contpos'}, $data->{'contphone'},
- $data->{'contfax'}, $data->{'contaltphone'},
- $data->{'contemail'}, $data->{'contnotes'},
- $data->{'active'}, $data->{'listprice'},
- $data->{'invoiceprice'}, $data->{'gstreg'},
- $data->{'listincgst'}, $data->{'invoiceincgst'},
- $data->{'discount'}, $data->{'notes'},
- $data->{'gstrate'},
- $data->{deliverytime},
- $data->{'id'}
- );
-}
-
-=head2 DelBookseller
-
-DelBookseller($booksellerid);
-
-delete the supplier record identified by $booksellerid
-This sub assumes it is called only if the supplier has no order.
-
-=cut
-
-sub DelBookseller {
- my $id = shift;
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare('DELETE FROM aqbooksellers WHERE id=?');
- return $sth->execute($id);
-}
-