use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
-# set the version for version checking
-$VERSION = 3.00;
+BEGIN {
+ # set the version for version checking
+ $VERSION = 3.01;
+ @ISA = qw(Exporter);
+ @EXPORT = qw(
+ &GetBranchCategory
+ &GetBranchName
+ &GetBranch
+ &GetBranches
+ &GetBranchDetail
+ &get_branchinfos_of
+ &ModBranch
+ &CheckBranchCategorycode
+ &GetBranchInfo
+ &GetCategoryTypes
+ &GetBranchCategories
+ &GetBranchesInCategory
+ &ModBranchCategoryInfo
+ &DelBranch
+ &DelBranchCategory
+ );
+}
=head1 NAME
=head1 FUNCTIONS
-=cut
-
-@ISA = qw(Exporter);
-@EXPORT = qw(
- &GetBranchCategory
- &GetBranchName
- &GetBranch
- &GetBranches
- &GetBranchDetail
- &get_branchinfos_of
- &ModBranch
- &CheckBranchCategorycode
- &GetBranchInfo
- &GetCategoryTypes
- &GetBranchCategories
- &GetBranchesInCategory
- &ModBranchCategoryInfo
- &DelBranch
- &DelBranchCategory
-);
-
=head2 GetBranches
$branches = &GetBranches();
push @branchloop, \%row;
}
-
=head3 in TEMPLATE
<select name="branch">
<option value="">Default</option>
my $dbh = C4::Context->dbh;
my $sth;
my $query="SELECT * FROM branches";
+ my @bind_parameters;
if ($onlymine && C4::Context->userenv && C4::Context->userenv->{branch}){
- $query .= " WHERE branchcode =".$dbh->quote(C4::Context->userenv->{branch});
+ $query .= ' WHERE branchcode = ? ';
+ push @bind_parameters, C4::Context->userenv->{branch};
}
- $query.=" ORDER BY branchname";
+ $query.=" ORDER BY branchname";
$sth = $dbh->prepare($query);
- $sth->execute;
+ $sth->execute( @bind_parameters );
while ( my $branch = $sth->fetchrow_hashref ) {
my $nsth =
$dbh->prepare(
- "SELECT category_id FROM branchrelations WHERE branchcode = ?");
+ "SELECT categorycode FROM branchrelations WHERE branchcode = ?");
$nsth->execute( $branch->{'branchcode'} );
while ( my ($cat) = $nsth->fetchrow_array ) {
=cut
sub ModBranchCategoryInfo {
-
my ($data) = @_;
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("replace branchcategories (categorycode,categoryname,codedescription,categorytype) values (?,?,?,?)");
- $sth->execute(uc( $data->{'categorycode'} ),$data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'} );
- $sth->finish;
+ if ($data->{'add'}){
+ # we are doing an insert
+ my $sth = $dbh->prepare("INSERT INTO branchcategories (categorycode,categoryname,codedescription,categorytype) VALUES (?,?,?,?)");
+ $sth->execute(uc( $data->{'categorycode'} ),$data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'} );
+ $sth->finish();
+ }
+ else {
+ # modifying
+ my $sth = $dbh->prepare("UPDATE branchcategories SET categoryname=?,codedescription=?,categorytype=? WHERE categorycode=?");
+ $sth->execute($data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},uc( $data->{'categorycode'} ) );
+ $sth->finish();
+ }
}
=head2 DeleteBranchCategory
return $total;
}
-
+1;
+__END__
=head1 AUTHOR