koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] koha admin/branches.pl C4/Auth.pm C4/Context.pm...


From: LAURIN arnaud
Subject: [Koha-cvs] koha admin/branches.pl C4/Auth.pm C4/Context.pm...
Date: Fri, 19 May 2006 09:52:54 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         
Changes by:     LAURIN arnaud <address@hidden>  06/05/19 09:52:54

Modified files:
        admin          : branches.pl 
        C4             : Auth.pm Context.pm 
        koha-tmpl/intranet-tmpl/prog/en/admin: branches.tmpl 

Log message:
        committing new feature ip and printer management
        adding two fields in branches table (branchip,branchprinter)
        
        branchip : if the library enter an ip or ip range any librarian that 
connect from computer in this ip range will be temporarly affected to the 
corresponding branch .
        
        branchprinter : the library  can select a default printer for a branch

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/koha/admin/branches.pl.diff?tr1=1.31&tr2=1.32&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/koha/koha/C4/Auth.pm.diff?tr1=1.49&tr2=1.50&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/koha/koha/C4/Context.pm.diff?tr1=1.38&tr2=1.39&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/koha/koha/koha-tmpl/intranet-tmpl/prog/en/admin/branches.tmpl.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: koha/C4/Auth.pm
diff -u koha/C4/Auth.pm:1.49 koha/C4/Auth.pm:1.50
--- koha/C4/Auth.pm:1.49        Tue May  9 13:28:08 2006
+++ koha/C4/Auth.pm     Fri May 19 09:52:54 2006
@@ -28,6 +28,7 @@
 use C4::Output;              # to get the template
 use C4::Interface::CGI::Output;
 use C4::Circulation::Circ2;  # getpatroninformation
+use C4::Koha;
 # use Net::LDAP;
 # use Net::LDAP qw(:all);
 
@@ -307,6 +308,7 @@
                                        $hash{branchname},
                                        $hash{flags},
                                        $hash{emailaddress},
+                                       $hash{branchprinter}
                                );
                }
                my ($ip , $lasttime);
@@ -391,22 +393,40 @@
                                        C4::Context->_unset_userenv($sessionID);
                        }
                        if ($return == 1){
-                               my 
($bornum,$firstname,$surname,$userflags,$branchcode,$branchname,$emailaddress);
-                               my $sth=$dbh->prepare("select borrowernumber, 
firstname, surname, flags, borrowers.branchcode, branches.branchname as 
branchname, email from borrowers left join branches on 
borrowers.branchcode=branches.branchcode where userid=?");
+                               my 
($bornum,$firstname,$surname,$userflags,$branchcode,$branchname,$branchprinter,$emailaddress);
+                               my $sth=$dbh->prepare("select borrowernumber, 
firstname, surname, flags, borrowers.branchcode, branches.branchname as 
branchname,branches.branchprinter as branchprinter, email from borrowers left 
join branches on borrowers.branchcode=branches.branchcode where userid=?");
                                $sth->execute($userid);
-                               
($bornum,$firstname,$surname,$userflags,$branchcode,$branchname,$emailaddress) 
= $sth->fetchrow if ($sth->rows);
+                               
($bornum,$firstname,$surname,$userflags,$branchcode,$branchname,$branchprinter,$emailaddress)
 = $sth->fetchrow if ($sth->rows);
 #                              warn 
"$cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress";
                                unless ($sth->rows){
-                                       my $sth=$dbh->prepare("select 
borrowernumber, firstname, surname, flags, borrowers.branchcode, 
branches.branchname as branchname, email from borrowers left join branches on 
borrowers.branchcode=branches.branchcode where cardnumber=?");
+                                       my $sth=$dbh->prepare("select 
borrowernumber, firstname, surname, flags, borrowers.branchcode, 
branches.branchname as branchname, branches.branchprinter as branchprinter, 
email from borrowers left join branches on 
borrowers.branchcode=branches.branchcode where cardnumber=?");
                                        $sth->execute($cardnumber);
-                                       
($bornum,$firstname,$surname,$userflags,$branchcode,$branchcode,$emailaddress) 
= $sth->fetchrow if ($sth->rows);
+                                       
($bornum,$firstname,$surname,$userflags,$branchcode,$branchcode,$branchprinter, 
$emailaddress) = $sth->fetchrow if ($sth->rows);
 #                                      warn 
"$cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress";
                                        unless ($sth->rows){
                                                $sth->execute($userid);
-                                               
($bornum,$firstname,$surname,$userflags,$branchcode,$emailaddress) = 
$sth->fetchrow if ($sth->rows);
+                                               
($bornum,$firstname,$surname,$userflags,$branchcode,$branchprinter,$emailaddress)
 = $sth->fetchrow if ($sth->rows);
                                        }
 #                                      warn 
"$cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress";
                                }
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
# # # # # # # # 
+#  new op dev :
+# launch a sequence to check if we have a ip for the branch, if we have one we 
replace the branchcode of the userenv by the branch bound in the ip.
+       my $ip = $ENV{'REMOTE_ADDR'};
+       my $branches = getbranches();
+       my @branchesloop;
+       my $branchprinter;
+       foreach my $br (keys %$branches) {
+#              now we work with the treatment of ip
+               my $domain=$branches->{$br}->{branchip};
+               if ($domain && $ip =~ /^$domain/){
+                       $branchcode = $branches->{$br}->{'branchcode'};
+#                      new op dev : add the branchprinter and branchname in 
the cookie
+                       $branchprinter = $branches->{$br}->{'branchprinter'};
+                       $branchname = $branches->{$br}->{'branchname'};
+               }
+       }
+
                                my $hash = C4::Context::set_userenv(
                                        $bornum,
                                        $userid,
@@ -417,8 +437,9 @@
                                        $branchname,
                                        $userflags,
                                        $emailaddress,
+                                       $branchprinter,
                                );
-#                              warn 
"$cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress";
+
                                $envcookie=$query->cookie(-name => 'userenv',
                                                -value => $hash,
                                                -expires => '');
Index: koha/C4/Context.pm
diff -u koha/C4/Context.pm:1.38 koha/C4/Context.pm:1.39
--- koha/C4/Context.pm:1.38     Sun May 14 00:22:31 2006
+++ koha/C4/Context.pm  Fri May 19 09:52:54 2006
@@ -15,7 +15,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: Context.pm,v 1.38 2006/05/14 00:22:31 tgarip1957 Exp $
+# $Id: Context.pm,v 1.39 2006/05/19 09:52:54 alaurin Exp $
 package C4::Context;
 use strict;
 use DBI;
@@ -25,7 +25,7 @@
        qw($context),
        qw(@context_stack);
 
-$VERSION = do { my @v = '$Revision: 1.38 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.39 $' =~ /\d+/g;
                shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
 
 =head1 NAME
@@ -744,7 +744,7 @@
 =cut
 #'
 sub set_userenv{
-       my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, 
$userbranch, $branchname, $userflags, $emailaddress)= @_;
+       my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, 
$userbranch, $branchname, $userflags, $emailaddress,$branchprinter)= @_;
        my $var=$context->{"activeuser"};
        my $cell = {
                "number"     => $usernum,
@@ -757,6 +757,7 @@
                "branchname" => $branchname,
                "flags"      => $userflags,
                "emailaddress"  => $emailaddress,
+               "branchprinter" => $branchprinter,
        };
        $context->{userenv}->{$var} = $cell;
        return $cell;
@@ -825,6 +826,14 @@
 
 =cut
 # $Log: Context.pm,v $
+# Revision 1.39  2006/05/19 09:52:54  alaurin
+# committing new feature ip and printer management
+# adding two fields in branches table (branchip,branchprinter)
+#
+# branchip : if the library enter an ip or ip range any librarian that connect 
from computer in this ip range will be temporarly affected to the corresponding 
branch .
+#
+# branchprinter : the library  can select a default printer for a branch
+#
 # Revision 1.38  2006/05/14 00:22:31  tgarip1957
 # Adding support for getting details of different zebra servers
 #
Index: koha/admin/branches.pl
diff -u koha/admin/branches.pl:1.31 koha/admin/branches.pl:1.32
--- koha/admin/branches.pl:1.31 Fri Feb 24 11:15:01 2006
+++ koha/admin/branches.pl      Fri May 19 09:52:54 2006
@@ -51,6 +51,7 @@
 use C4::Output;
 use C4::Interface::CGI::Output;
 use HTML::Template;
+use C4::Koha;
 
 # Fixed variables
 my $linecolor1='#ffffcc';
@@ -66,7 +67,7 @@
 my $branchcode=$input->param('branchcode');
 my $branchname=$input->param('branchname');
 my $categorycode = $input->param('categorycode');
-my $op = $input->param('op') || '';
+my $op = $input->param('op');
 
 my ($template, $borrowernumber, $cookie)
     = get_template_and_user({template_name => "admin/branches.tmpl",
@@ -166,7 +167,7 @@
 # html output functions....
 
 sub default {
-       my ($message) = @_ || "";
+       my ($message) = @_;
        heading("Branches");
        $template->param('heading-branches-p' => 1);
        $template->param("$message" => 1);
@@ -182,11 +183,33 @@
 
 sub editbranchform {
        # prepares the edit form...
+
+# initiate the scrolling-list to select the printers
+       my %env;
+       my $printers=getprinters(\%env);
+       my @printerloop;
+       my $printercount=0;
+       my $oldprinter;
+       my $CGIprinter;
        my ($branchcode) = @_;
        my $data;
+       
        if ($branchcode) {
                $data = getbranchinfo($branchcode);
                $data = $data->[0];
+       # get the old printer of the branch
+               $oldprinter = $data->{'branchprinter'}; 
+#      printer loop
+               foreach my $thisprinter (keys %$printers) {
+                       my $selected = 1 if $oldprinter eq 
$printers->{$thisprinter}->{'printqueue'};
+                       my %row =(value => $thisprinter,
+                                       selected => $selected,
+                                       branchprinter => 
$printers->{$thisprinter}->{'printername'},
+                       );
+               push @printerloop, \%row;
+               }
+               
+               $template->param(printerloop => address@hidden );
                $template->param(branchcode => $data->{'branchcode'});
                $template->param(branchname => $data->{'branchname'});
                $template->param(branchaddress1 => $data->{'branchaddress1'});
@@ -195,7 +218,19 @@
                $template->param(branchphone => $data->{'branchphone'});
                $template->param(branchfax => $data->{'branchfax'});
                $template->param(branchemail => $data->{'branchemail'});
-    }
+               $template->param(branchip => $data->{'branchip'});
+       }
+       else {
+# on add new branch mode, simple scrolling list
+               $CGIprinter=CGI::scrolling_list( -name     => 'branchprinter',
+               -id => 'branchprinter',
+               -values   => address@hidden,
+               -size     => 1,
+               -multiple => 0 );       
+
+       }
+#  sending the cgiprinter to the template
+#              $template->param(printerloop => $CGIprinter);
 
     # make the checkboxs.....
     #
@@ -261,7 +296,7 @@
                $branchinfo = getbranchinfo();
        }
        my $toggle;
-       my $i=0;
+       my $i;
        my @loop_data =();
        foreach my $branch (@$branchinfo) {
                ($i % 2) ? ($toggle = 1) : ($toggle = 0);
@@ -292,7 +327,7 @@
                # Handle address fields separately
                my $address_empty_p = 1;
                for my $field ('branchaddress1', 'branchaddress2', 
'branchaddress3',
-                       'branchphone', 'branchfax', 'branchemail') {
+                       'branchphone', 'branchfax', 'branchemail', 'branchip', 
'branchprinter') {
                        $row{$field} = $branch->{$field};
                        if ( $branch->{$field} ) {
                                $address_empty_p = 0;
@@ -329,6 +364,8 @@
        }
        my @branchcategories =();
        my $catinfo = getcategoryinfo();
+       my $toggle;
+       my $i = 0;
        foreach my $cat (@$catinfo) {
                ($i % 2) ? ($toggle = 1) : ($toggle = 0);
                push @branchcategories, {
@@ -421,11 +458,11 @@
 # sets the data from the editbranch form, and writes to the database...
        my ($data) = @_;
        my $dbh = C4::Context->dbh;
-       my $sth=$dbh->prepare("replace branches 
(branchcode,branchname,branchaddress1,branchaddress2,branchaddress3,branchphone,branchfax,branchemail)
 values (?,?,?,?,?,?,?,?)");
+       my $sth=$dbh->prepare("replace branches 
(branchcode,branchname,branchaddress1,branchaddress2,branchaddress3,branchphone,branchfax,branchemail,branchip,branchprinter)
 values (?,?,?,?,?,?,?,?,?,?)");
        $sth->execute(uc($data->{'branchcode'}), $data->{'branchname'},
                $data->{'branchaddress1'}, $data->{'branchaddress2'},
                $data->{'branchaddress3'}, $data->{'branchphone'},
-               $data->{'branchfax'}, $data->{'branchemail'});
+               $data->{'branchfax'}, $data->{'branchemail'}, 
$data->{'branchip'},$data->{'branchprinter'});
 
        $sth->finish;
        # sort out the categories....
Index: koha/koha-tmpl/intranet-tmpl/prog/en/admin/branches.tmpl
diff -u koha/koha-tmpl/intranet-tmpl/prog/en/admin/branches.tmpl:1.1 
koha/koha-tmpl/intranet-tmpl/prog/en/admin/branches.tmpl:1.2
--- koha/koha-tmpl/intranet-tmpl/prog/en/admin/branches.tmpl:1.1        Fri Feb 
24 11:18:17 2006
+++ koha/koha-tmpl/intranet-tmpl/prog/en/admin/branches.tmpl    Fri May 19 
09:52:54 2006
@@ -57,6 +57,21 @@
                <td>E-mail</td>
                <td><input type="text" name="branchemail" value="<!-- TMPL_VAR 
name="branchemail" escape="HTML" -->" /></td>
        </tr>
+       <tr>
+               <td>Branch IP</td>
+               <td><input type="text" name="branchip" value="<!-- TMPL_VAR 
name="branchip" escape="HTML" -->" /></td>
+       </tr>
+       <tr>
+               <td>Branch Printer</td>
+               <td>    
+                       <select id="branchprinter" name="branchprinter">
+                               <option value="">None</option>
+                       <!-- TMPL_LOOP NAME="printerloop" -->
+                               <option value="<!-- TMPL_VAR NAME="value" 
-->"<!-- TMPL_IF NAME="selected" --> selected="selected"<!-- /TMPL_IF -->><!-- 
TMPL_VAR NAME="branchprinter" --></option>
+                               <!-- /TMPL_LOOP -->
+                       </select>
+               </td>
+       </tr>
 </table><p><input type="submit" value="Submit" /></p>
 </form>
 <!-- /TMPL_IF -->
@@ -84,6 +99,8 @@
                        <th>Code</th>
                        <th>Address</th>
                        <th>Category</th>
+                       <th>Branch IP</th>
+                       <th>Branch Printer</th>
                        <th>&nbsp;</th>
                        <th>&nbsp;</th>
                </tr>
@@ -119,6 +136,12 @@
                                        <!-- /TMPL_IF -->
                                </td>
                                <td>
+                                       <!-- TMPL_VAR NAME="branchip" -->
+                               </td>
+                               <td>
+                                       <!-- TMPL_VAR NAME="branchprinter" -->
+                               </td>
+                               <td>
                                        <form action="<!-- TMPL_VAR name=action 
-->" method="post">
                                        <input type="hidden" name="op" 
value="edit" />
                                        <input type="hidden" name="branchcode" 
value="<!-- TMPL_VAR name=value escape="HTML" -->" />




reply via email to

[Prev in Thread] Current Thread [Next in Thread]