From 97182dceb2ce9d23e82c57cd91fc1f6c1d8bf382 Mon Sep 17 00:00:00 2001 From: tipaul Date: Fri, 14 Apr 2006 09:31:24 +0000 Subject: [PATCH] improvements from SAN Ouest Provence : * introducing a category_type into categories. It can be A (adult), C (children), P (Professionnal), I (institution/organisation). * each category_type has it's own forms to create members. * the borrowers table has been heavily modified (many fields changed), to get something more logic & readable * reintroducing guarantor/guanrantee system that is now independant from hardcoded C/A for categories * updating templates to fit template rules (see mail feb, 17 on koha-devel "new features for borrowers" for more details) --- C4/Date.pm | 19 + C4/Koha.pm | 348 +++++----- C4/Members.pm | 398 ++++++++++- admin/categorie.pl | 34 +- .../intranet-tmpl/prog/en/intranet-main.tmpl | 10 +- .../prog/en/members/guarantor_search.tmpl | 50 ++ .../prog/en/members/memberentryA.tmpl | 587 ++++++++++++++++ .../prog/en/members/memberentryC.tmpl | 640 +++++++++++++++++ .../prog/en/members/memberentryI.tmpl | 459 ++++++++++++ .../prog/en/members/memberentryP.tmpl | 653 ++++++++++++++++++ .../prog/en/members/memberentry_old.tmpl | 254 +++++++ .../prog/en/members/moremember.tmpl | 404 +++++------ members/guarantor_search.pl | 109 +++ members/memberentry.pl | 485 ++++++++----- members/moremember.pl | 20 +- updater/updatedatabase | 235 ++++++- 16 files changed, 4067 insertions(+), 638 deletions(-) create mode 100755 koha-tmpl/intranet-tmpl/prog/en/members/guarantor_search.tmpl create mode 100755 koha-tmpl/intranet-tmpl/prog/en/members/memberentryA.tmpl create mode 100755 koha-tmpl/intranet-tmpl/prog/en/members/memberentryC.tmpl create mode 100755 koha-tmpl/intranet-tmpl/prog/en/members/memberentryI.tmpl create mode 100755 koha-tmpl/intranet-tmpl/prog/en/members/memberentryP.tmpl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/members/memberentry_old.tmpl create mode 100755 members/guarantor_search.pl diff --git a/C4/Date.pm b/C4/Date.pm index 95e60b51fa..f19e9eb3a4 100644 --- a/C4/Date.pm +++ b/C4/Date.pm @@ -18,6 +18,7 @@ $VERSION = 0.01; &display_date_format &format_date &format_date_in_iso + &today get_date_format_string_for_DHTMLcalendar ); @@ -143,4 +144,22 @@ sub format_date_in_iso return $newdate; } + +#function to return a current date OUEST-PROVENCE +sub today +{ + my ($adddate) =@_; + my($j,$m,$a)=(localtime)[3,4,5]; + if ($j<10) { + $j= '0'.$j; + } + $m=$m+1; + if ($m<10){ + $m= '0'.$m + } + $a=$a+1900+$adddate; + return format_date("$a-$m-$j"); +} + + 1; diff --git a/C4/Koha.pm b/C4/Koha.pm index a7b92834b7..22429f88fe 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -35,9 +35,6 @@ C4::Koha - Perl Module containing convenience functions for Koha scripts $date = slashifyDate("01-01-2002") - $ethnicity = fixEthnicity('asian'); - ($categories, $labels) = borrowercategories(); - ($categories, $labels) = ethnicitycategories(); =head1 DESCRIPTION @@ -51,9 +48,6 @@ Koha.pm provides many functions for Koha scripts. @ISA = qw(Exporter); @EXPORT = qw( - &fixEthnicity - &borrowercategories &getborrowercategory - ðnicitycategories &subfield_is_koha_internal_p &getbranches &getbranch &getbranchdetail &getprinters &getprinter @@ -66,109 +60,14 @@ Koha.pm provides many functions for Koha scripts. getitemtypeimagedir getitemtypeimagesrc getitemtypeimagesrcfromurl + &getcities + &getroadtypes $DEBUG); use vars qw(); my $DEBUG = 0; -# removed slashifyDate => useless - -=head2 fixEthnicity - - $ethn_name = &fixEthnicity($ethn_code); - -Takes an ethnicity code (e.g., "european" or "pi") and returns the -corresponding descriptive name from the C table in the -Koha database ("European" or "Pacific Islander"). - -=cut -#' - -sub fixEthnicity($) { - - my $ethnicity = shift; - my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("Select name from ethnicity where code = ?"); - $sth->execute($ethnicity); - my $data=$sth->fetchrow_hashref; - $sth->finish; - return $data->{'name'}; -} - -=head2 borrowercategories - - ($codes_arrayref, $labels_hashref) = &borrowercategories(); - -Looks up the different types of borrowers in the database. Returns two -elements: a reference-to-array, which lists the borrower category -codes, and a reference-to-hash, which maps the borrower category codes -to category descriptions. - -=cut -#' - -sub borrowercategories { - my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("Select categorycode,description from categories order by description"); - $sth->execute; - my %labels; - my @codes; - while (my $data=$sth->fetchrow_hashref){ - push @codes,$data->{'categorycode'}; - $labels{$data->{'categorycode'}}=$data->{'description'}; - } - $sth->finish; - return(\@codes,\%labels); -} - -=item getborrowercategory - - $description = &getborrowercategory($categorycode); - -Given the borrower's category code, the function returns the corresponding -description for a comprehensive information display. - -=cut - -sub getborrowercategory -{ - my ($catcode) = @_; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("SELECT description FROM categories WHERE categorycode = ?"); - $sth->execute($catcode); - my $description = $sth->fetchrow(); - $sth->finish(); - return $description; -} # sub getborrowercategory - - -=head2 ethnicitycategories - - ($codes_arrayref, $labels_hashref) = ðnicitycategories(); - -Looks up the different ethnic types in the database. Returns two -elements: a reference-to-array, which lists the ethnicity codes, and a -reference-to-hash, which maps the ethnicity codes to ethnicity -descriptions. - -=cut -#' - -sub ethnicitycategories { - my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("Select code,name from ethnicity order by name"); - $sth->execute; - my %labels; - my @codes; - while (my $data=$sth->fetchrow_hashref){ - push @codes,$data->{'code'}; - $labels{$data->{'code'}}=$data->{'name'}; - } - $sth->finish; - return(\@codes,\%labels); -} - # FIXME.. this should be moved to a MARC-specific module sub subfield_is_koha_internal_p ($) { my($subfield) = @_; @@ -655,90 +554,102 @@ Returns an array of all available languages. =cut sub getalllanguages { - my $type=shift; - my $theme=shift; - my $htdocs; - my @languages; - if ($type eq 'opac') { - $htdocs=C4::Context->config('opachtdocs'); - if ($theme and -d "$htdocs/$theme") { - opendir D, "$htdocs/$theme"; - foreach my $language (readdir D) { - next if $language=~/^\./; - next if $language eq 'all'; - next if $language=~ /png$/; - next if $language=~ /css$/; - push @languages, $language; - } - return sort @languages; - } else { - my $lang; - foreach my $theme (getallthemes('opac')) { - opendir D, "$htdocs/$theme"; - foreach my $language (readdir D) { - next if $language=~/^\./; - next if $language eq 'all'; - next if $language=~ /png$/; - next if $language=~ /css$/; - $lang->{$language}=1; + my $type=shift; + my $theme=shift; + my $htdocs; + my @languages; + if ($type eq 'opac') { + $htdocs=C4::Context->config('opachtdocs'); + if ($theme and -d "$htdocs/$theme") { + opendir D, "$htdocs/$theme"; + foreach my $language (readdir D) { + next if $language=~/^\./; + next if $language eq 'all'; + next if $language=~ /png$/; + next if $language=~ /css$/; + next if $language=~ /CVS$/; + next if $language=~ /itemtypeimg$/; + push @languages, $language; + } + return sort @languages; + } else { + my $lang; + foreach my $theme (getallthemes('opac')) { + opendir D, "$htdocs/$theme"; + foreach my $language (readdir D) { + next if $language=~/^\./; + next if $language eq 'all'; + next if $language=~ /png$/; + next if $language=~ /css$/; + next if $language=~ /CVS$/; + next if $language=~ /itemtypeimg$/; + $lang->{$language}=1; + } + } + @languages=keys %$lang; + return sort @languages; } - } - @languages=keys %$lang; - return sort @languages; - } - } elsif ($type eq 'intranet') { - $htdocs=C4::Context->config('intrahtdocs'); - if ($theme and -d "$htdocs/$theme") { - opendir D, "$htdocs/$theme"; - foreach my $language (readdir D) { - next if $language=~/^\./; - next if $language eq 'all'; - next if $language=~ /png$/; - next if $language=~ /css$/; - push @languages, $language; - } - return sort @languages; - } else { - my $lang; - foreach my $theme (getallthemes('opac')) { + } elsif ($type eq 'intranet') { + $htdocs=C4::Context->config('intrahtdocs'); + if ($theme and -d "$htdocs/$theme") { + opendir D, "$htdocs/$theme"; + foreach my $language (readdir D) { + next if $language=~/^\./; + next if $language eq 'all'; + next if $language=~ /png$/; + next if $language=~ /css$/; + next if $language=~ /CVS$/; + next if $language=~ /itemtypeimg$/; + push @languages, $language; + } + return sort @languages; + } else { + my $lang; + foreach my $theme (getallthemes('opac')) { + opendir D, "$htdocs/$theme"; + foreach my $language (readdir D) { + next if $language=~/^\./; + next if $language eq 'all'; + next if $language=~ /png$/; + next if $language=~ /css$/; + next if $language=~ /CVS$/; + next if $language=~ /itemtypeimg$/; + $lang->{$language}=1; + } + } + @languages=keys %$lang; + return sort @languages; + } + } else { + my $lang; + my $htdocs=C4::Context->config('intrahtdocs'); + foreach my $theme (getallthemes('intranet')) { + opendir D, "$htdocs/$theme"; + foreach my $language (readdir D) { + next if $language=~/^\./; + next if $language eq 'all'; + next if $language=~ /png$/; + next if $language=~ /css$/; + next if $language=~ /CVS$/; + next if $language=~ /itemtypeimg$/; + $lang->{$language}=1; + } + } + $htdocs=C4::Context->config('opachtdocs'); + foreach my $theme (getallthemes('opac')) { opendir D, "$htdocs/$theme"; foreach my $language (readdir D) { - next if $language=~/^\./; - next if $language eq 'all'; + next if $language=~/^\./; + next if $language eq 'all'; next if $language=~ /png$/; next if $language=~ /css$/; - $lang->{$language}=1; + next if $language=~ /CVS$/; + next if $language=~ /itemtypeimg$/; + $lang->{$language}=1; + } } - } - @languages=keys %$lang; - return sort @languages; - } - } else { - my $lang; - my $htdocs=C4::Context->config('intrahtdocs'); - foreach my $theme (getallthemes('intranet')) { - opendir D, "$htdocs/$theme"; - foreach my $language (readdir D) { - next if $language=~/^\./; - next if $language eq 'all'; - next if $language=~ /png$/; - next if $language=~ /css$/; - $lang->{$language}=1; - } - } - $htdocs=C4::Context->config('opachtdocs'); - foreach my $theme (getallthemes('opac')) { - opendir D, "$htdocs/$theme"; - foreach my $language (readdir D) { - next if $language=~/^\./; - next if $language eq 'all'; - next if $language=~ /png$/; - next if $language=~ /css$/; - $lang->{$language}=1; - } - } - @languages=keys %$lang; - return sort @languages; + @languages=keys %$lang; + return sort @languages; } } @@ -781,6 +692,81 @@ sub getnbpages { return int(($nb_items - 1) / $nb_items_per_page) + 1; } + +=head2 getcities (OUEST-PROVENCE) + + ($id_cityarrayref, $city_hashref) = &getcities(); + +Looks up the different city and zip in the database. Returns two +elements: a reference-to-array, which lists the zip city +codes, and a reference-to-hash, which maps the name of the city. +WHERE =>OUEST PROVENCE OR EXTERIEUR + +=cut +sub getcities { + #my ($type_city) = @_; + my $dbh = C4::Context->dbh; + my $sth=$dbh->prepare("Select cityid,city_name from cities order by cityid "); + #$sth->execute($type_city); + $sth->execute(); + my %city; + my @id; +# insert empty value to create a empty choice in cgi popup + +while (my $data=$sth->fetchrow_hashref){ + + push @id,$data->{'cityid'}; + $city{$data->{'cityid'}}=$data->{'city_name'}; + } + + #test to know if the table contain some records if no the function return nothing + my $id=@id; + $sth->finish; + if ($id eq 0) + { + return(); + } + else{ + unshift (@id ,""); + return(\@id,\%city); + } +} + + +=head2 getroadtypes (OUEST-PROVENCE) + + ($idroadtypearrayref, $roadttype_hashref) = &getroadtypes(); + +Looks up the different road type . Returns two +elements: a reference-to-array, which lists the id_roadtype +codes, and a reference-to-hash, which maps the road type of the road . + + +=cut +sub getroadtypes { + my $dbh = C4::Context->dbh; + my $sth=$dbh->prepare("Select roadtypeid,road_type from roadtype order by road_type "); + $sth->execute(); + my %roadtype; + my @id; +# insert empty value to create a empty choice in cgi popup +while (my $data=$sth->fetchrow_hashref){ + push @id,$data->{'roadtypeid'}; + $roadtype{$data->{'roadtypeid'}}=$data->{'road_type'}; + } + #test to know if the table contain some records if no the function return nothing + my $id=@id; + $sth->finish; + if ($id eq 0) + { + return(); + } + else{ + unshift (@id ,""); + return(\@id,\%roadtype); + } +} + 1; __END__ diff --git a/C4/Members.pm b/C4/Members.pm index d30e75fec5..9d4bec10fe 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -24,6 +24,7 @@ require Exporter; use C4::Context; use Date::Manip; use C4::Date; +use Digest::MD5 qw(md5_base64); use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); @@ -49,8 +50,13 @@ C4::Members - Perl Module containing convenience functions for member handling @EXPORT = qw(); @EXPORT = qw( - &BornameSearch &getmember &borrdata &borrdata2 &fixup_cardnumber &findguarantees &findguarantor &NewBorrowerNumber &modmember &newmember &changepassword &borrissues &allissues + &BornameSearch &getmember &borrdata &borrdata2 &fixup_cardnumber &findguarantees &findguarantor &GuarantornameSearch &NewBorrowerNumber &modmember &newmember &changepassword &borrissues &allissues + &checkuniquemember &getzipnamecity &getidcity &getguarantordata &getcategorytype + &calcexpirydate &checkuserpassword &getboracctrecord + &borrowercategories &getborrowercategory + &fixEthnicity + ðnicitycategories ); @@ -187,19 +193,20 @@ sub borrdata { my $dbh = C4::Context->dbh; my $sth; if ($bornum eq ''){ - $sth=$dbh->prepare("Select * from borrowers where cardnumber=?"); + $sth=$dbh->prepare("Select borrowers.*,categories.category_type from borrowers left join categories on borrowers.categorycode=categories.categorycode where cardnumber=?"); $sth->execute($cardnumber); } else { - $sth=$dbh->prepare("Select * from borrowers where borrowernumber=?"); + $sth=$dbh->prepare("Select borrowers.*,categories.category_type from borrowers left join categories on borrowers.categorycode=categories.categorycode where borrowernumber=?"); $sth->execute($bornum); } my $data=$sth->fetchrow_hashref; + warn "DATA".$data->{category_type}; $sth->finish; if ($data) { return($data); } else { # try with firstname if ($cardnumber) { - my $sth=$dbh->prepare("select * from borrowers where firstname=?"); + my $sth=$dbh->prepare("Select borrowers.*,categories.category_type from borrowers left join categories on borrowers.categorycode=categories.categorycode where firstname=?"); $sth->execute($cardnumber); my $data=$sth->fetchrow_hashref; $sth->finish; @@ -283,34 +290,59 @@ sub modmember { sub newmember { my (%data) = @_; my $dbh = C4::Context->dbh; + $data{'userid'}='' unless $data{'password'}; + $data{'password'}=md5_base64($data{'password'}) if $data{'password'}; $data{'dateofbirth'}=format_date_in_iso($data{'dateofbirth'}); - $data{'joining'} = &ParseDate("today") unless $data{'joining'}; - $data{'joining'}=format_date_in_iso($data{'joining'}); - # if expirydate is not set, calculate it from borrower category subscription duration - unless ($data{'expiry'}) { - my $sth = $dbh->prepare("select enrolmentperiod from categories where categorycode=?"); - $sth->execute($data{'categorycode'}); - my ($enrolmentperiod) = $sth->fetchrow; - $enrolmentperiod = 12 unless ($enrolmentperiod); - $data{'expiry'} = &DateCalc($data{'joining'},"$enrolmentperiod years"); - } - $data{'expiry'}=format_date_in_iso($data{'expiry'}); -# $data{'borrowernumber'}=NewBorrowerNumber(); - my $query="insert into borrowers (title,expiry,cardnumber,sex,ethnotes,streetaddress,faxnumber, - firstname,altnotes,dateofbirth,contactname,emailaddress,textmessaging,dateenrolled,streetcity, - altrelationship,othernames,phoneday,categorycode,city,area,phone,borrowernotes,altphone,surname, - initials,ethnicity,physstreet,branchcode,zipcode,homezipcode,sort1,sort2) values ('$data{'title'}','$data{'expiry'}','$data{'cardnumber'}', - '$data{'sex'}','$data{'ethnotes'}','$data{'streetaddress'}','$data{'faxnumber'}', - '$data{'firstname'}','$data{'altnotes'}','$data{'dateofbirth'}','$data{'contactname'}','$data{'emailaddress'}','$data{'textmessaging'}', - '$data{'joining'}','$data{'streetcity'}','$data{'altrelationship'}','$data{'othernames'}', - '$data{'phoneday'}','$data{'categorycode'}','$data{'city'}','$data{'area'}','$data{'phone'}', - '$data{'borrowernotes'}','$data{'altphone'}','$data{'surname'}','$data{'initials'}', - '$data{'ethnicity'}','$data{'physstreet'}','$data{'branchcode'}','$data{'zipcode'}','$data{'homezipcode'}','$data{'sort1'}','$data{'sort2'}')"; + $data{'dateenrolled'}=format_date_in_iso($data{'dateenrolled'}); + $data{expiry}=format_date_in_iso($data{expiry}); +my $query="insert into borrowers set cardnumber=".$dbh->quote($data{'cardnumber'}). + ",surname=".$dbh->quote($data{'surname'}). + ",firstname=".$dbh->quote($data{'firstname'}). + ",title=".$dbh->quote($data{'title'}). + ",othernames=".$dbh->quote($data{'othernames'}). + ",initials=".$dbh->quote($data{'initials'}). + ",streetnumber=".$dbh->quote($data{'streetnumber'}). + ",streettype=".$dbh->quote($data{'streettype'}). + ",address=".$dbh->quote($data{'address'}). + ",address2=".$dbh->quote($data{'address2'}). + ",zipcode=".$dbh->quote($data{'zipcode'}). + ",city=".$dbh->quote($data{'city'}). + ",phone=".$dbh->quote($data{'phone'}). + ",email=".$dbh->quote($data{'email'}). + ",mobile=".$dbh->quote($data{'mobile'}). + ",phonepro=".$dbh->quote($data{'phonepro'}). + ",opacnote=".$dbh->quote($data{'opacnote'}). + ",guarantorid=".$dbh->quote($data{'guarantorid'}). + ",dateofbirth=".$dbh->quote($data{'dateofbirth'}). + ",branchcode=".$dbh->quote($data{'branchcode'}). + ",categorycode=".$dbh->quote($data{'categorycode'}). + ",dateenrolled=".$dbh->quote($data{'dateenrolled'}). + ",contactname=".$dbh->quote($data{'contactname'}). + ",borrowernotes=".$dbh->quote($data{'borrowernotes'}). + ",dateexpiry=".$dbh->quote($data{'dateexpiry'}). + ",contactnote=".$dbh->quote($data{'contactnote'}). + ",b_address=".$dbh->quote($data{'b_address'}). + ",b_zipcode=".$dbh->quote($data{'b_zipcode'}). + ",b_city=".$dbh->quote($data{'b_city'}). + ",b_phone=".$dbh->quote($data{'b_phone'}). + ",b_email=".$dbh->quote($data{'b_email'},). + ",password=".$dbh->quote($data{'password'}). + ",userid=".$dbh->quote($data{'userid'}). + ",sort1=".$dbh->quote($data{'sort1'}). + ",sort2=".$dbh->quote($data{'sort2'}). + ",contacttitle=".$dbh->quote($data{'contacttitle'}). + ",emailpro=".$dbh->quote($data{'emailpro'}). + ",contactfirstname=".$dbh->quote($data{'contactfirstname'}). + ",sex=".$dbh->quote($data{'sex'}). + ",fax=".$dbh->quote($data{'fax'}). + ",flags=".$dbh->quote($data{'flags'}). + ",relationship=".$dbh->quote($data{'relationship'}) + ; my $sth=$dbh->prepare($query); $sth->execute; $sth->finish; - $data{borrowernumber} =$dbh->{'mysql_insertid'}; - return $data{borrowernumber}; + $data{'borrowerid'} =$dbh->{'mysql_insertid'}; + return $data{'borrowerid'}; } sub changepassword { @@ -433,7 +465,7 @@ sub findguarantees { my ($bornum)=@_; my $dbh = C4::Context->dbh; my $sth=$dbh->prepare("select cardnumber,borrowernumber from borrowers where - guarantor=?"); + guarantorid=?"); $sth->execute($bornum); my @dat; my $i=0; @@ -464,17 +496,87 @@ from the C database table; sub findguarantor{ my ($bornum)=@_; my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("select guarantor from borrowers where borrowernumber=?"); + my $sth=$dbh->prepare("Select * from borrowers where borrowernumber=?"); $sth->execute($bornum); my $data=$sth->fetchrow_hashref; $sth->finish; - $sth=$dbh->prepare("Select * from borrowers where borrowernumber=?"); - $sth->execute($data->{'guarantor'}); - $data=$sth->fetchrow_hashref; - $sth->finish; return($data); } +=item GuarantornameSearch + + ($count, $borrowers) = &GuarantornameSearch($env, $searchstring, $type); + +Looks up guarantor by name. + +C<$env> is ignored. + +BUGFIX 499: C<$type> is now used to determine type of search. +if $type is "simple", search is performed on the first letter of the +surname only. + +C<$searchstring> is a space-separated list of search terms. Each term +must match the beginning a borrower's surname, first name, or other +name. + +C<&GuarantornameSearch> returns a two-element list. C<$borrowers> is a +reference-to-array; each element is a reference-to-hash, whose keys +are the fields of the C table in the Koha database. +C<$count> is the number of elements in C<$borrowers>. + +return all info from guarantor =>only category_type A + +=cut +#' +#used by member enquiries from the intranet +#called by guarantor_search.pl +sub GuarantornameSearch { + my ($env,$searchstring,$orderby,$type)=@_; + my $dbh = C4::Context->dbh; + my $query = ""; my $count; my @data; + my @bind=(); + + if($type eq "simple") # simple search for one letter only + { + $query="Select * from borrowers,categories where borrowers.categorycode=categories.categorycode and category_type='A' and surname like ? order by $orderby"; + @bind=("$searchstring%"); + } + else # advanced search looking in surname, firstname and othernames + { + @data=split(' ',$searchstring); + $count=@data; + $query="Select * from borrowers,categories + where ((surname like ? or surname like ? + or firstname like ? or firstname like ? + or othernames like ? or othernames like ?) and borrowers.categorycode=categories.categorycode and category_type='A' + "; + @bind=("$data[0]%","% $data[0]%","$data[0]%","% $data[0]%","$data[0]%","% $data[0]%"); + for (my $i=1;$i<$count;$i++){ + $query=$query." and (". + " surname like ? or surname like ? + or firstname like ? or firstname like ? + or othernames like ? or othernames like ?)"; + push(@bind,"$data[$i]%","% $data[$i]%","$data[$i]%","% $data[$i]%","$data[$i]%","% $data[$i]%"); + # FIXME - .= <prepare($query); + $sth->execute(@bind); + my @results; + my $cnt=$sth->rows; + while (my $data=$sth->fetchrow_hashref){ + push(@results,$data); + } + # $sth->execute; + $sth->finish; + return ($cnt,\@results); +} + =item NewBorrowerNumber $num = &NewBorrowerNumber(); @@ -619,4 +721,232 @@ borrowernumber=? order by date desc,timestamp desc"); return ($numlines,\@acctlines,$total); } + +=head2 checkuniquemember (OUEST-PROVENCE) + + $result = &checkuniquemember($collectivity,$surname,$categorycode,$firstname,$dateofbirth); + +Checks that a member exists or not in the database. + +C<&result> is 1 (=exist) or 0 (=does not exist) +C<&collectivity> is 1 (= we add a collectivity) or 0 (= we add a physical member) +C<&surname> is the surname +C<&categorycode> is from categorycode table +C<&firstname> is the firstname (only if collectivity=0) +C<&dateofbirth> is the date of birth (only if collectivity=0) + +=cut + +sub checkuniquemember{ + my ($collectivity,$surname,$firstname,$dateofbirth)=@_; + my $dbh = C4::Context->dbh; + my $request; + if ($collectivity ) { +# $request="select count(*) from borrowers where surname=? and categorycode=?"; + $request="select borrowernumber,categorycode from borrowers where surname=? "; + } else { +# $request="select count(*) from borrowers where surname=? and categorycode=? and firstname=? and dateofbirth=?"; + $request="select borrowernumber,categorycode from borrowers where surname=? and firstname=? and dateofbirth=?"; + } + my $sth=$dbh->prepare($request); + if ($collectivity) { + $sth->execute(uc($surname)); + } else { + $sth->execute(uc($surname),ucfirst($firstname),$dateofbirth); + } + my @data= $sth->fetchrow; + if ($data[0]){ + $sth->finish; + return $data[0],$data[1]; +# + }else{ + $sth->finish; + return 0; + } +} + +=head2 getzipnamecity (OUEST-PROVENCE) + +take all info from table city for the fields city and zip +check for the name and the zip code of the city selected + +=cut +sub getzipnamecity { + my ($cityid)=@_; + my $dbh = C4::Context->dbh; + my $sth=$dbh->prepare("select city_name,city_zipcode from cities where cityid=? "); + $sth->execute($cityid); + my @data = $sth->fetchrow; + return $data[0],$data[1]; +} + +=head2 updatechildguarantor (OUEST-PROVENCE) + +check for title,firstname,surname,adress,zip code and city from guarantor to +guarantorchild + +=cut +sub getguarantordata{ + my ($borrowerid)=@_; + my $dbh = C4::Context->dbh; + my $sth=$dbh->prepare("Select title,firstname,surname,streetnumber,address,streettype,address2,zipcode,city,phone,phonepro,mobile,email,emailpro from borrowers where borrowernumber =? "); + $sth->execute($borrowerid); + my $guarantor_data=$sth->fetchrow_hashref; + $sth->finish; + return $guarantor_data; +} + +=head2 getdcity (OUEST-PROVENCE) +recover cityid with city_name condition +=cut +sub getidcity { + my ($city_name)=@_; + my $dbh = C4::Context->dbh; + my $sth=$dbh->prepare("select cityid from cities where city_name=? "); + $sth->execute($city_name); + my $data = $sth->fetchrow; + return $data; +} + + +=head2 getcategorytype (OUEST-PROVENCE) + +check for the category_type with categorycode +and return the category_type + +=cut +sub getcategorytype { + my ($categorycode)=@_; + my $dbh = C4::Context->dbh; + my $sth=$dbh->prepare("Select category_type,description from categories where categorycode=? "); + $sth->execute($categorycode); + my ($category_type,$description) = $sth->fetchrow; + return $category_type,$description; +} + +sub calcexpirydate { + my ($categorycode,$dateenrolled)=@_; + my $dbh=C4::Context->dbh; + my $sth = $dbh->prepare("select enrolmentperiod from categories where categorycode=?"); + $sth->execute($categorycode); + my ($enrolmentperiod) = $sth->fetchrow; + $enrolmentperiod = 12 unless ($enrolmentperiod); + return format_date_in_iso(&DateCalc($dateenrolled,"$enrolmentperiod months")); +} + +=head2 checkuserpassword (OUEST-PROVENCE) + +check for the password and login are not used +return the number of record +0=> NOT USED 1=> USED + +=cut +sub checkuserpassword{ + my ($borrowerid,$userid,$password)=@_; + $password=md5_base64($password); + my $dbh = C4::Context->dbh; + my $sth=$dbh->prepare("Select count(*) from borrowers where borrowernumber !=? and userid =? and password=? "); + $sth->execute($borrowerid,$userid,$password); + my $number_rows=$sth->fetchrow; + return $number_rows; + +} + +=head2 borrowercategories + + ($codes_arrayref, $labels_hashref) = &borrowercategories(); + +Looks up the different types of borrowers in the database. Returns two +elements: a reference-to-array, which lists the borrower category +codes, and a reference-to-hash, which maps the borrower category codes +to category descriptions. + +=cut +#' +sub borrowercategories { + my ($category_type,$action)=@_; + my $dbh = C4::Context->dbh; + my $request; + $request="Select categorycode,description from categories where category_type=? order by categorycode"; + my $sth=$dbh->prepare($request); + $sth->execute($category_type); + my %labels; + my @codes; + while (my $data=$sth->fetchrow_hashref){ + push @codes,$data->{'categorycode'}; + $labels{$data->{'categorycode'}}=$data->{'description'}; + } + $sth->finish; + return(\@codes,\%labels); +} + +=item getborrowercategory + + $description = &getborrowercategory($categorycode); + +Given the borrower's category code, the function returns the corresponding +description for a comprehensive information display. + +=cut + +sub getborrowercategory +{ + my ($catcode) = @_; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("SELECT description FROM categories WHERE categorycode = ?"); + $sth->execute($catcode); + my $description = $sth->fetchrow(); + $sth->finish(); + return $description; +} # sub getborrowercategory + + +=head2 ethnicitycategories + + ($codes_arrayref, $labels_hashref) = ðnicitycategories(); + +Looks up the different ethnic types in the database. Returns two +elements: a reference-to-array, which lists the ethnicity codes, and a +reference-to-hash, which maps the ethnicity codes to ethnicity +descriptions. + +=cut +#' + +sub ethnicitycategories { + my $dbh = C4::Context->dbh; + my $sth=$dbh->prepare("Select code,name from ethnicity order by name"); + $sth->execute; + my %labels; + my @codes; + while (my $data=$sth->fetchrow_hashref){ + push @codes,$data->{'code'}; + $labels{$data->{'code'}}=$data->{'name'}; + } + $sth->finish; + return(\@codes,\%labels); +} + +=head2 fixEthnicity + + $ethn_name = &fixEthnicity($ethn_code); + +Takes an ethnicity code (e.g., "european" or "pi") and returns the +corresponding descriptive name from the C table in the +Koha database ("European" or "Pacific Islander"). + +=cut +#' + +sub fixEthnicity($) { + + my $ethnicity = shift; + my $dbh = C4::Context->dbh; + my $sth=$dbh->prepare("Select name from ethnicity where code = ?"); + $sth->execute($ethnicity); + my $data=$sth->fetchrow_hashref; + $sth->finish; + return $data->{'name'}; +} + 1; diff --git a/admin/categorie.pl b/admin/categorie.pl index faee98a172..1352190843 100755 --- a/admin/categorie.pl +++ b/admin/categorie.pl @@ -51,7 +51,7 @@ sub StringSearch { $searchstring=~ s/\'/\\\'/g; my @data=split(' ',$searchstring); my $count=@data; - my $sth=$dbh->prepare("Select * from categories where (description like ?)"); + my $sth=$dbh->prepare("Select * from categories where (description like ?) order by category_type,description"); $sth->execute("$data[0]%"); my @results; while (my $data=$sth->fetchrow_hashref){ @@ -92,29 +92,35 @@ if ($op eq 'add_form') { my $data; if ($categorycode) { my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,overduenoticerequired from categories where categorycode=?"); + my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,overduenoticerequired,category_type from categories where categorycode=?"); $sth->execute($categorycode); $data=$sth->fetchrow_hashref; $sth->finish; } - $template->param(description => $data->{'description'}, + $template->param(description => $data->{'description'}, enrolmentperiod => $data->{'enrolmentperiod'}, upperagelimit => $data->{'upperagelimit'}, dateofbirthrequired => $data->{'dateofbirthrequired'}, enrolmentfee => $data->{'enrolmentfee'}, overduenoticerequired => $data->{'overduenoticerequired'}, issuelimit => $data->{'issuelimit'}, - reservefee => $data->{'reservefee'}); + reservefee => $data->{'reservefee'}, + category_type => $data->{'category_type'}, + "type_".$data->{'category_type'} => " SELECTED ", + ); # END $OP eq ADD_FORM ################## ADD_VALIDATE ################################## # called by add_form, used to insert/modify data in DB } elsif ($op eq 'add_validate') { $template->param(add_validate => 1); my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("replace categories (categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,overduenoticerequired) values (?,?,?,?,?,?,?,?)"); - $sth->execute(map { $input->param($_) } ('categorycode','description','enrolmentperiod','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','overduenoticerequired')); + my $sth=$dbh->prepare("replace categories (categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,overduenoticerequired,category_type) values (?,?,?,?,?,?,?,?,?)"); + $sth->execute(map { $input->param($_) } ('categorycode','description','enrolmentperiod','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','overduenoticerequired','category_type')); $sth->finish; + print "Content-Type: text/html\n\n"; + exit; + # END $OP eq ADD_VALIDATE ################## DELETE_CONFIRM ################################## # called by default form, used to confirm deletion of data in DB @@ -128,7 +134,7 @@ if ($op eq 'add_form') { $sth->finish; $template->param(total => $total->{'total'}); - my $sth2=$dbh->prepare("select categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,overduenoticerequired from categories where categorycode=?"); + my $sth2=$dbh->prepare("select categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,overduenoticerequired,category_type from categories where categorycode=?"); $sth2->execute($categorycode); my $data=$sth2->fetchrow_hashref; $sth2->finish; @@ -143,9 +149,9 @@ if ($op eq 'add_form') { enrolmentfee => $data->{'enrolmentfee'}, overduenoticerequired => $data->{'overduenoticerequired'}, issuelimit => $data->{'issuelimit'}, - reservefee => $data->{'reservefee'}); - - + reservefee => $data->{'reservefee'}, + category_code => $data->{'category_code'} + ); # END $OP eq DELETE_CONFIRM ################## DELETE_CONFIRMED ################################## # called by delete_confirm, used to effectively confirm deletion of data in DB @@ -156,6 +162,9 @@ if ($op eq 'add_form') { my $sth=$dbh->prepare("delete from categories where categorycode=?"); $sth->execute($categorycode); $sth->finish; + print "Content-Type: text/html\n\n"; + exit; + # END $OP eq DELETE_CONFIRMED } else { # DEFAULT $template->param(else => 1); @@ -173,6 +182,7 @@ if ($op eq 'add_form') { overduenoticerequired => $results->[$i]{'overduenoticerequired'}, issuelimit => $results->[$i]{'issuelimit'}, reservefee => $results->[$i]{'reservefee'}, + category_type => $results->[$i]{'category_type'}, toggle => $toggle ); push @loop, \%row; if ( $toggle eq 0 ) @@ -187,11 +197,11 @@ if ($op eq 'add_form') { $template->param(loop => \@loop); # check that I (institution) and C (child) exists. otherwise => warning to the user my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("select categorycode from categories where categorycode='C'"); + my $sth=$dbh->prepare("select category_type from categories where category_type='C'"); $sth->execute; my ($categoryChild) = $sth->fetchrow; $template->param(categoryChild => $categoryChild); - $sth=$dbh->prepare("select categorycode from categories where categorycode='I'"); + $sth=$dbh->prepare("select category_type from categories where category_type='I'"); $sth->execute; my ($categoryInstitution) = $sth->fetchrow; $template->param(categoryInstitution => $categoryInstitution); diff --git a/koha-tmpl/intranet-tmpl/prog/en/intranet-main.tmpl b/koha-tmpl/intranet-tmpl/prog/en/intranet-main.tmpl index 9ad6b65784..01acf78908 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/intranet-main.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/intranet-main.tmpl @@ -66,9 +66,13 @@
  • Koha Administration -
  • - + +

    News

    diff --git a/koha-tmpl/intranet-tmpl/prog/en/members/guarantor_search.tmpl b/koha-tmpl/intranet-tmpl/prog/en/members/guarantor_search.tmpl new file mode 100755 index 0000000000..aa76d2ba82 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/members/guarantor_search.tmpl @@ -0,0 +1,50 @@ + + + +Guarantor Search + +/includes/common-style.css"> + +

    Search guarantor

    + Search on +
    + "> Ordered by + + +
    +
    + + +

    filter on , members found

    + + + + + + + + + + + + + + + + + + + + +
    cardnumbersurnamefirstnameDate of birthaddress

    ;self.close();">

    +

    + + + + + + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/members/memberentryA.tmpl b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryA.tmpl new file mode 100755 index 0000000000..5060176a24 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryA.tmpl @@ -0,0 +1,587 @@ + +Koha -- Member, Adult management + + + + + + +

    + Add adult member (step ) +

    + +

    + Modify adult member +

    + + + +

    +

    +
    + Duplicate suspected + ');" >Detail + Duplicate ? + &category_type=">Yes +     No, it is not + + + + + +
    +
    +

    + + + + + +
    +

    The following fields are wrong. Please fix it/them

    + +

    login/password already exist

    + +
    + + + +
    + + "> + + "> + + "> + "> + "> + "> + " /> + " /> + " /> + "> + " /> + + + "> + "> + "> + "> + "> + "> + "> + "> + "> + "> + " > + " > + " > + "> + " > + " > + + + "> + "> + + + "> + "> + " /> + " /> + " /> + + + + + + + + + +
    + Borrower identity +

    + + Female + Male + + Female + Male + +

    + +
    +
    + Borrower type +

    + + +

    + +

    + +

    + +

    + +

    +

    + +

    +
    +
    + +
    +
    + + + + +
    + + "> + + "> + + "> + "> + "> + "> + " /> + " /> + " /> + "> + " /> + + + "> + "> + " > + "> + "> + "> + " > + " > + " > + "> + " > + " > + + "> + "> + + + "> + "> + " /> + " /> + " /> + + + + + +
    + Address +

    + +

    +
    + Main Address +

    + +

    + +

    + +

    + +

    + +

    +

    + +

    +

    + +

    +

    + +

    +
    +
    + Alt Address +

    + +

    +

    + +

    +

    + +

    +
    +
    +
    + contact +

    + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +
    +
    + + +
    +

    +
    + + + +
    + + "> + + "> + + "> + "> + "> + "> + " /> + " /> + " /> + "> + " /> + + + "> + "> + " > + "> + "> + "> + " > + " > + " > + "> + " > + " > + + + "> + "> + "> + "> + "> + "> + "> + "> + "> + "> + " > + " > + " > + "> + " > + " > + + + + + +
    + Library set-up +

    + +

    +

    + +

    +

    + +

    +

    + +

    +
    +
    + OPAC login +

    + +

    +

    + +

    + + +

    Warning

    + +

    + + " value="1" >Yes + " value="0" >No +

    + + +

    +

    +
    + + + + + + +
    +
    + + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/members/memberentryC.tmpl b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryC.tmpl new file mode 100755 index 0000000000..ff9657c8e5 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryC.tmpl @@ -0,0 +1,640 @@ + +Koha -- Member, Child management + + + + + + +

    + Add children member (step ) +

    + +

    + Modify children member +

    + + + +

    +

    +
    + Duplicate suspected + ');" class="borrowers_button">Details + Duplicate ? + &category_type=" class="borrowers_button">Yes +     No, it is not + checked name="answernodouble" > +
    +
    + +

    + + + +

    ERROR

    +
    +

    The following fields are wrong. Please fix it/them

    + +

    login/password already exist

    + +
    + + + + +
    + + "> + + "> + + "> + "> + "> + "> + " /> + " /> + " /> + "> + "/> + + + "> + "> + "> + "> + "> + "> + "> + "> + "> + "> + "> + " > + " > + " > + " > + " > + " > + " > + " > + + + "> + "> + + + "> + "> + " /> + " /> + " /> + + + + + + + +

    + +

    +
    + Borrower identity +

    + + Female + Male + + Female + Male + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +

    Find guarantor +

    +
    +
    + Borrower type +

    + + +

    + +

    + +

    + +

    + +

    +

    + +

    +
    +
    + +
    +
    + + + + +
    + + "> + + "> + + "> + "> + "> + "> + " /> + " /> + " /> + "> + "/> + + + "> + "> + " > + "> + "> + " > + " > + "> + "> + "> + "> + + + "> + "> + + + "> + "> + " /> + " /> + " /> + + + + + + + + +

    + +

    +
    + Guarantor +

    + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    + +

    + +

    + +

    + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +
    +
    + Guarantor contact +

    Guarantor

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +

    Member

    +

    + +

    +
    +
    + + +
    +
    + + + +
    + + "> + + "> + + "> + "> + "> + "> + " /> + " /> + " /> + "> + "/> + + + "> + "> + " > + "> + "> + " > + " > + "> + "> + "> + "> + + "> + "> + "> + "> + "> + "> + "> + "> + "> + "> + "> + " > + " > + " > + " > + " > + " > + " > + " > + + + + + + +

    + +

    +
    + Library set-up +

    + +

    +

    + +

    +

    + +

    +

    + +

    +
    +
    + OPAC login +

    + +

    +

    + +

    + + +

    Warning

    + +

    + + " value="1" >Yes + " value="0" >No +

    + + +

    +

    +
    + + + + + + +
    +
    + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/members/memberentryI.tmpl b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryI.tmpl new file mode 100755 index 0000000000..90af8425df --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryI.tmpl @@ -0,0 +1,459 @@ + +Koha -- Member, Organisation management + + + + + + +

    + Add organisation member (step ) +

    + +

    + Modify organisation member +

    + + + +

    +

    +
    + Duplicate suspected + ');" class="borrowers_button">Details + Duplicate ? + &category_type=" class="borrowers_button">Yes +     No, it is not + checked name="answernodouble" > +
    +
    +

    + + + + +

    ERROR

    +
    +

    The following fields are wrong. Please fix it/them

    + +

    login/password already exist

    + +
    + + +
    + + "> + + "> + + "> + "> + "> + "> + " /> + " /> + " /> + "> + " /> + + + "> + "> + "> + "> + "> + "> + "> + " > + " > + + " + + + "> + "> + + + "> + "> + " /> + " /> + " /> + + + + + +

    + +

    +
    + organisation identity +

    + +

    +

    + + + + +

    +
    + Personal identity +

    + +

    +

    + +

    +
    +
    + +
    +

    + +
    + + + + +
    + + "> + + "> + + "> + "> + "> + "> + " /> + " /> + " /> + "> + " /> + + + + " > + "> + "> + "> + "> + + + "> + "> + + + "> + "> + " /> + " /> + " /> + + + + + + + +

    + +

    +
    + Organisation address +

    + +

    + +

    + +

    + +

    + +

    +

    + +

    +

    + +

    +

    + +

    + +
    +
    + Member list +

    + +

    +
    +
    + + +
    + + + + + +
    + + "> + + "> + + "> + "> + "> + "> + " /> + " /> + " /> + "> + "/> + + + " > + "> + "> + "> + "> + + + "> + "> + "> + "> + "> + + "> + " > + " > + + " + + + + + + + +

    + +

    +
    + Library set-up +

    + +

    +

    + +

    +

    + +

    +

    + +

    +
    +
    + OPAC login +

    + +

    +

    + +

    + + +

    Warning

    + +

    + + " value="1" >Yes + " value="0" >No +

    + + +

    +

    +
    + + + + + + +
    +
    + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/members/memberentryP.tmpl b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryP.tmpl new file mode 100755 index 0000000000..94cee98257 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryP.tmpl @@ -0,0 +1,653 @@ + +Koha -- Member, Professional management + + + + + + +

    + Add professional member (step ) +

    + +

    + Modify professional member +

    + + + +

    +

    +
    + Duplicate suspected + ');" class="borrowers_button">Details + Duplicate ? + &category_type=" class="borrowers_button">Yes +     No, it is not + checked name="answernodouble" > +
    +
    + +

    + + + +

    ERROR

    +
    +

    The following fields are wrong. Please fix it/them

    + +

    login/password already exist

    + +
    + + + +
    + + "> + + "> + + "> + "> + "> + "> + " /> + " /> + " /> + "> + "/> + + + "> + "> + "> + "> + "> + "> + "> + " > + " > + " > + " > + " > + "> + "> + "> + "> + "> + "> + "> + + + + "> + "> + + + "> + "> + " /> + " /> + " /> + + + + + + +

    + +

    +
    + Borrower identity +

    + + Female + Male + + Female + Male + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +
    +
    + Borrower type +

    + + +

    + +

    + +

    + +

    + +

    +

    + +

    +
    +
    + +
    +
    + + + + + + +
    + + "> + + "> + + "> + "> + "> + "> + " /> + " /> + " /> + "> + " /> + + + + "> + " > + "> + "> + "> + " > + " > + "> + "> + "> + "> + + + "> + "> + + + "> + "> + " /> + " /> + " /> + + + + + + + + " /> + +

    + +

    +
    + Professional address +

    + +

    + +

    + +

    + +

    + +

    +

    + +

    +

    + +

    +

    + +

    +

    + +

    +
    +
    + Professional contact +

    + +

    +

    + +

    +

    + +

    +

    +

    + +

    +

    + +

    +

    + +

    +
    +
    + Structure +

    + +

    +

    + +

    +

    + +

    +

    + +

    + +
    +
    + +
    +

    +
    + + + + +
    + + "> + + "> + + "> + "> + "> + "> + " /> + " /> + " /> + "> + " /> + + + "> + " > + "> + "> + "> + " > + " > + "> + "> + "> + "> + + + + "> + "> + "> + "> + "> + "> + "> + " > + " > + " > + " > + " > + "> + "> + "> + "> + "> + "> + "> + + + + + + + +

    + +

    +
    + Library set-up +

    + +

    +

    + +

    +

    + +

    +

    + +

    +
    +
    + OPAC login +

    + +

    +

    + +

    + + +

    Warning

    + +

    + + " value="1" >Yes + " value="0" >No +

    + + +

    +

    +
    + + + + + + +
    +
    + + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/members/memberentry_old.tmpl b/koha-tmpl/intranet-tmpl/prog/en/members/memberentry_old.tmpl new file mode 100644 index 0000000000..604ca165d4 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/members/memberentry_old.tmpl @@ -0,0 +1,254 @@ +Edit RecordAdd New Institutional Member + + + + + +

    + Add New Institutional Member +

    + +

    + Update Institutional Member Details +

    +

    ,

    + + + +

    Missing Information

    +

    The following fields have a forbidden value. Correct them and press OK again :

    + +
    + " /> + + " /> + " /> + " /> + + + + + + + +

    + + +

    + +

    + + " /> +

    + + +

    + + " /> +

    + + + +

    + + " /> +

    + + + +

    + + " /> +

    + + +

    + + checked="checked" />F checked="checked" /> M +

    + + + +

    " /> ()

    + + +

    Addresses:

    +
    + Mailing Address +

    + + " /> +

    +

    + + " /> +

    +

    + + " /> +

    +
    + +
    + Street Address (if different) +

    + + " /> +

    +

    + + " /> +

    +

    + + " /> +

    +
    +

    + + " /> +

    +

    + + " /> +

    +

    + + " /> +

    +

    + + " /> +

    +

    +

    + +

    +

    + + +

    + +

    + + " /> +

    + +

    + + +

    + +

    + + " /> +

    + + +

    Alternate Contact

    +

    + + " /> +

    +

    + + " /> +

    +

    + + +

    +

    + + +

    + + +

    Flags

    + +

    + + " name="" value="1" />Yes + " value="0" />No +

    + + +

    Member Details

    + +

    + + +

    + +

    + + +

    +

    + + +

    +

    + + " /> +

    + +

    Additional Fields

    +

    These fields are available for your own usage. They can be useful for statistical purposes

    +

    + + " /> +

    +

    + + " /> +

    + +" /> +UpdateAdd This Member" /> +
    + + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/members/moremember.tmpl b/koha-tmpl/intranet-tmpl/prog/en/members/moremember.tmpl index 7b7a1824cd..0046af81c1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/members/moremember.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/members/moremember.tmpl @@ -6,64 +6,30 @@

    ()

    @@ -83,172 +49,176 @@ -

    Borrower Information

    -

    -

    -

    -

    -

    -

    -

    -

    - - -

    -

    -

    - - -

    -

    -

    -

    - - -

    -

    - - -

    -

    -

    -

    -

    - - -

    -

    - - -

    -

    -

    -

    -

    -

    - - -

    -

    -

    -

    - +
    +Borrower Information +

    +

    +

    +

    +

    +

    +

    +

    + +

    +

    +

    + +

    +

    +

    +

    + +

    +

    + +
    +
    + Library use +

    +

    +

    +

    +

    + + +

    +

    + - - - -

    - - - -

    ">

    - +

    +

    +

    +

    +

    +

    +
    +
    + Alternate contact + +

    +

    +

    +

    + + + + +

    - - -

    Fines & Charges

    + + +

    ">

    + + + +
    +
    + Fines & Charges

    Total Due:

    No Outstanding Charges

    - -

    Items On Loan

    -
    - " /> - - - - - - - - - - - - - - - - - - - - - - - -
    TitleDueItemtypeChargePriceRenewReturn
    - - - &bib=&bi="> - - - - - - " /> - - - - ">Reserved - - " - - checked="checked" - - /> - " - checked="checked" - style="display: none;" - /> - - ">Return
    Total Replacement Cost: 
    -
    - - -
    -
    - -

    Reserves

    -
    - +
    +
    + Items On Loan + + " /> - - - - - - - - - + + + + + + + + + + + + + + + + + - - - " /> - " /> - - -
    TitleRequestedRemove
    - "> - - - +
    TitleDueItemtypeChargePriceRenewReturn
    + + + &bib=&bi="> + + + + + + " /> + + + + ">Reserved + + " + + checked="checked" + + /> + " + checked="checked" + style="display: none;" + /> - - -
    - - - - - + + ">Return + + + Total Replacement Cost:  + +
    + + +
    + +
    +
    + Reserves +
    + + + + + + + + + + + + + + " /> + " /> + + +
    TitleRequestedRemove
    + "> + + + + + + +
    + + + +
    +
    \ No newline at end of file diff --git a/members/guarantor_search.pl b/members/guarantor_search.pl new file mode 100755 index 0000000000..4d20b3f627 --- /dev/null +++ b/members/guarantor_search.pl @@ -0,0 +1,109 @@ +#!/usr/bin/perl + +# $Id$ + +# script to find a guarantor + +# Copyright 2006 OUEST PROVENCE +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use strict; +use C4::Auth; +use C4::Output; +use C4::Interface::CGI::Output; +use CGI; +use C4::Search; +use HTML::Template; +#op +use C4::Date; +use C4::Members; + +my $input = new CGI; +my ($template, $loggedinuser, $cookie); + + ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "members/guarantor_search.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); +# } +my $theme = $input->param('theme') || "default"; + # only used if allowthemeoverride is set + + +my $member=$input->param('member'); +my $orderby=$input->param('orderby'); +$orderby = "surname,firstname" unless $orderby; +$member =~ s/,//g; #remove any commas from search string +$member =~ s/\*/%/g; +if ($member eq ''){ + $template->param(results=>0); +}else{ + $template->param(results=>1); +} +my $env; + +my ($count,$results); +my @resultsdata; +my $background = 0; + +if ($member ne ''){ + if(length($member) == 1) + { + ($count,$results)=GuarantornameSearch($env,$member,$orderby,"simple"); + } + else + { + ($count,$results)=GuarantornameSearch($env,$member,$orderby,"advanced"); + } + for (my $i=0; $i < $count; $i++){ + #find out stats + my ($od,$issue,$fines)=borrdata2($env,$results->[$i]{'borrowerid'}); + + my %row = ( + background => $background, + count => $i+1, + borrowernumber => $results->[$i]{'borrowernumber'}, + cardnumber => $results->[$i]{'cardnumber'}, + surname => $results->[$i]{'surname'}, + firstname => $results->[$i]{'firstname'}, + categorycode => $results->[$i]{'categorycode'}, + address => $results->[$i]{'address'}, + city => $results->[$i]{'city'}, + branchcode => $results->[$i]{'branchcode'}, + + #op + dateofbirth =>format_date($results->[$i]{'dateofbirth'}), + #fi op + + odissue => "$od/$issue", + fines => $fines, + borrowernotes => $results->[$i]{'borrowernotes'}); + if ( $background ) { $background = 0; } else {$background = 1; } + push(@resultsdata, \%row); + } +} +$template->param( + member => $member, + numresults => $count, + + resultsloop => \@resultsdata ); + +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/members/memberentry.pl b/members/memberentry.pl index 035e9aa822..c4f2787740 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -1,14 +1,7 @@ #!/usr/bin/perl -# NOTE: This file uses standard 8-space tabs -# DO NOT SET TAB SIZE TO 4 - # $Id$ -#script to set up screen for modification of borrower details -#written 20/12/99 by chris@katipo.co.nz - - -# Copyright 2000-2002 Katipo Communications +# Copyright 2006 SAN OUEST PROVENCE et Paul POULAIN # # This file is part of Koha. # @@ -38,13 +31,19 @@ use HTML::Template; use Date::Manip; use C4::Date; use C4::Input; +use C4::Log; +use Digest::MD5 qw(md5_base64); my $input = new CGI; +my %data; + my $dbh = C4::Context->dbh; +my $category_type = $input->param('category_type') || die "NO CATEGORY_TYPE !"; # A, E, C, or P +my $step=$input->param('step') || 0; my ($template, $loggedinuser, $cookie) - = get_template_and_user({template_name => "members/memberentry.tmpl", + = get_template_and_user({template_name => "members/memberentry$category_type.tmpl", query => $input, type => "intranet", authnotrequired => 0, @@ -52,62 +51,147 @@ my ($template, $loggedinuser, $cookie) debug => 1, }); -my $borrowernumber=$input->param('borrowernumber'); -my $actionType=$input->param('actionType') || ''; +my $borrowerid=$input->param('borrowerid'); +my $guarantorid=$input->param('guarantorid'); my $modify=$input->param('modify'); my $delete=$input->param('delete'); my $op=$input->param('op'); my $categorycode=$input->param('categorycode'); my $destination=$input->param('destination'); +my $cardnumber=$input->param('cardnumber'); +my $check_member=$input->param('check_member'); +my $name_city=$input->param('name_city'); +my $nodouble=$input->param('nodouble'); +my $select_city=$input->param('select_city'); +my $nok=$input->param('nok'); + +# $check_categorytype contains the value of duplicate borrowers category type to redirect in good template in step =2 +my $check_categorytype=$input->param('check_categorytype'); +# NOTE: Alert for ethnicity and ethnotes fields, they are unvalided in all borrowers form + + +#function to automatic setup the mandatory fields (visual with css) +my $check_BorrowerMandatoryField=C4::Context->preference("BorrowerMandatoryField"); +my @field_check=split(/\|/,$check_BorrowerMandatoryField); +foreach (@field_check) { +$template->param( "mandatory$_" => 1); +} + +$template->param( "checked" => 1) if ($nodouble eq 1); -my $nok; # if a add or modify is requested => check validity of data. if ($op eq 'add' or $op eq 'modify') { - my %data; my @names=$input->param; foreach my $key (@names){ - $data{$key}=$input->param($key); + $data{$key}=$input->param($key)||''; $data{$key}=~ s/\'/\\\'/g; $data{$key}=~ s/\"/\\\"/g; } my @errors; - if ($data{'cardnumber'} eq ''){ - push @errors,"ERROR_cardnumber"; - $nok=1; - } else { - #check cardnumber is valid - my $nounique; - if ( $op eq "add" ) { - $nounique = 0; - } else { - $nounique = 1; - } - my $valid=checkdigit('',$data{'cardnumber'}, $nounique); - if ($valid != 1){ - $nok=1; - push @errors, "ERROR_invalid_cardnumber"; - } + #############test for member being unique ############# + if ($op eq 'add' && $step eq 2){ + (my $category_type_send=$category_type ) if ($category_type eq 'I'); + my $check_category; # recover the category code of the doublon suspect borrowers + ($check_member,$check_category)= checkuniquemember($category_type_send,$data{'surname'},$data{'firstname'},format_date_in_iso($data{'dateofbirth'})); +# recover the category type if the borrowers is a duplicate + ($check_categorytype,undef)=getcategorytype($check_category); } - if ($data{'sex'} eq '' && $categorycode ne "I"){ - push @errors, "ERROR_gender"; - $nok=1; - } - if ($data{'firstname'} eq '' && $categorycode ne "I"){ - push @errors,"ERROR_firstname"; - $nok=1; - } - if ($data{'surname'} eq ''){ - push @errors,"ERROR_surname"; - $nok=1; +# CHECKS step by step +# STEP 1 + if ($step eq 1) { + ###############test to take the right zipcode and city name ############## + if ($category_type ne 'I' and $guarantorid){ + my ($borrower_city,$borrower_zipcode)=&getzipnamecity($select_city); + $data{'city'}= $borrower_city; + $data{'zipcode'}=$borrower_zipcode; + } + if ($category_type eq 'C' and $guarantorid){ + my $guarantordata=getguarantordata($guarantorid); + if (($data{'contactname'} eq '' or $data{'contactname'} ne $guarantordata->{'surname'})) { + $data{'contactfirstname'}=$guarantordata->{'firstname'}; + $data{'contactname'}=$guarantordata->{'surname'}; + $data{'contacttitle'}=$guarantordata->{'title'}; + $data{'streetnumber'}=$guarantordata->{'streetnumber'}; + $data{'address'}=$guarantordata->{'address'}; + $data{'streettype'}=$guarantordata->{'streettype'}; + $data{'address2'}=$guarantordata->{'address2'}; + $data{'zipcode'}=$guarantordata->{'zipcode'}; + $data{'city'}=$guarantordata->{'city'}; + $data{'phone'}=$guarantordata->{'phone'}; + $data{'phonepro'}=$guarantordata->{'phonepro'}; + $data{'mobile'}=$guarantordata->{'mobile'}; + $data{'fax'}=$guarantordata->{'fax'}; + $data{'email'}=$guarantordata->{'email'}; + $data{'emailpro'}=$guarantordata->{'emailpro'}; + } + } } - if ($data{'streetaddress'} eq ''){ - push @errors, "ERROR_address"; - $nok=1; +# STEP 2 + if ($step eq 2) { + if ( ($data{'login'} eq '')){ + my $onefirstnameletter=substr($data{'firstname'},0,1); + my $fivesurnameletter=substr($data{'surname'},0,5); + $data{'login'}=lc($onefirstnameletter.$fivesurnameletter); + } + if ($op eq 'add' and $data{'dateenrolled'} eq ''){ + my $today=today(); + #insert ,in field "dateenrolled" , the current date + $data{'dateenrolled'}=$today; + #if date expiry is null u must calculate the value only in this case + $data{'dateexpiry'} = calcexpirydate($data{'categorycode'},$today); + } + if ($op eq 'modify' ){ + my $today=today(); +# if date expiry is null u must calculate the value only in this case + if ($data{'dateexpiry'} eq ''){ + $data{'dateexpiry'} = calcexpirydate($data{'categorycode'},$today); + } + } } - if ($data{'city'} eq ''){ - push @errors, "ERROR_city"; - $nok=1; +# STEP 3 + if ($step eq 3) { + # this value show if the login and password are been used + my $loginexist=checkuserpassword($borrowerid,$data{'login'},$data{'password'}); + # test to know if u must save or create the borrowers + if ($op eq 'modify'){ + # test to know if another user have the same password and same login + if ($loginexist eq 0) { + &modmember(%data); + logaction($loggedinuser,"MEMBERS","modify member", $borrowerid, ""); + } + else { + push @errors, "ERROR_login_exist"; + $nok=1; + } + }else{ + # test to know if another user have the same password and same login + if ($loginexist) { + push @errors, "ERROR_login_exist"; + $nok=1; + } else { + $borrowerid = &newmember(%data); + logaction($loggedinuser,"MEMBERS","add member", $borrowerid, ""); + } + } + + if ($nok) { + foreach my $error (@errors) { + $template->param( $error => 1); + } + $template->param(nok => 1); + $step--; # decrease step : go back to step 2, the step++ just before showing the template will go again to 3 + } + + unless ($nok) { + if($destination eq "circ"){ + print $input->redirect("/cgi-bin/koha/circ/circulation.pl?findborrower=$data{'cardnumber'}"); + } else { + if ($loginexist == 0) { + print $input->redirect("/cgi-bin/koha/members/moremember.pl?bornum=$borrowerid"); + } + } + } } if (C4::Context->preference("IndependantBranches")) { my $userenv = C4::Context->userenv; @@ -118,62 +202,34 @@ if ($op eq 'add' or $op eq 'modify') { } } } - if ($nok) { - foreach my $error (@errors) { - $template->param( $error => 1); - } - $template->param(nok => 1); - } else { - my $query="Select * from borrowers where borrowernumber=?"; - my $sth=$dbh->prepare($query); - $sth->execute($data{'borrowernumber'}); - if (my $data2=$sth->fetchrow_hashref){ - &modmember(%data); - }else{ - $borrowernumber = &newmember(%data); - } - - if($destination eq "circ"){ - print $input->redirect("/cgi-bin/koha/circ/circulation.pl?findborrower=$data{'cardnumber'}"); - } else { - print $input->redirect("/cgi-bin/koha/members/moremember.pl?bornum=$borrowernumber"); - } - } } + if ($delete){ - print $input->redirect("/cgi-bin/koha/deletemem.pl?member=$borrowernumber"); + print $input->redirect("/cgi-bin/koha/deletemem.pl?member=$borrowerid"); } else { # this else goes down the whole script - if ($actionType eq 'Add'){ - $template->param( addAction => 1); - } else { - $template->param( addAction =>0); - } # retrieve previous values : either in DB or in CGI, in case of errors in values my $data; - if ($nok) { - my @names=$input->param; - foreach my $key (@names){ - $data->{$key}=$input->param($key); - } - } else { - $data=borrdata('',$borrowernumber); +# test to now if u add or modify a borrower (modify =>to take all carateristic of the borrowers) + if (!$op and !$data{'surname'}) { + $data=borrdata('',$borrowerid); + %data=%$data; } if (C4::Context->preference("IndependantBranches")) { my $userenv = C4::Context->userenv; - if ($userenv->{flags} != 1 && $data->{branchcode}){ - unless ($userenv->{branch} eq $data->{'branchcode'}){ + if ($userenv->{flags} != 1 && $data{branchcode}){ + unless ($userenv->{branch} eq $data{'branchcode'}){ print $input->redirect("/cgi-bin/koha/members/members-home.pl"); } } } - if ($actionType eq 'Add'){ + if ($op eq 'add'){ $template->param( updtype => 'I'); } else { $template->param( updtype => 'M'); } - my $cardnumber=$data->{'cardnumber'}; - $cardnumber=fixup_cardnumber($data->{'cardnumber'}) if $actionType eq 'Add'; - if ($data->{'sex'} eq 'F'){ + my $cardnumber=$data{'cardnumber'}; + $cardnumber=fixup_cardnumber($data{'cardnumber'}) if $op eq 'add'; + if ($data{'sex'} eq 'F'){ $template->param(female => 1); } my ($categories,$labels)=ethnicitycategories(); @@ -183,36 +239,66 @@ if ($delete){ $ethcatpopup = CGI::popup_menu(-name=>'ethnicity', -id => 'ethnicity', -values=>$categories, - -default=>$data->{'ethnicity'}, + -default=>$data{'ethnicity'}, -labels=>$labels); $template->param(ethcatpopup => $ethcatpopup); # bad style, has to be fixed } - - ($categories,$labels)=borrowercategories(); + + + ($categories,$labels)=borrowercategories($category_type,$op); + + #if u modify the borrowers u must have the right value for is category code + + (my $default_category=$data{'categorycode'}) if ($op eq ''); my $catcodepopup = CGI::popup_menu(-name=>'categorycode', - -id => 'categorycode', - -values=>$categories, - -default=>$data->{'categorycode'}, - -labels=>$labels); + -id => 'categorycode', + -values=>$categories, + -default=>$default_category, + -labels=>$labels); + #test in city + my $default_city; + if ($op eq ''){ + (my $selectcity=&getidcity($data{'city'})) if ($select_city eq ''); + $default_city=$selectcity; + } + my($cityid,$name_city)=getcities(); + $template->param( city_cgipopup => 1) if ($cityid ); + my $citypopup = CGI::popup_menu(-name=>'select_city', + -id => 'select_city', + -values=>$cityid, + -labels=>$name_city, +# -override => 1, + -default=>$default_city + ); + + my $default_roadtype; + $default_roadtype=$data{'streettype'} ; + my($roadtypeid,$road_type)=getroadtypes(); + $template->param( road_cgipopup => 1) if ($roadtypeid ); + my $roadpopup = CGI::popup_menu(-name=>'streettype', + -id => 'streettype', + -values=>$roadtypeid, + -labels=>$road_type, + -override => 1, + -default=>$default_roadtype + ); - my @relationships = ('','workplace', 'relative','friend', 'neighbour'); + + my @relationships = split /,|\|/,C4::Context->preference('BorrowerRelationship'); my @relshipdata; while (@relationships) { - my $relship = shift @relationships; - next unless $relship; + my $relship = shift @relationships || ''; my %row = ('relationship' => $relship); - if ($data->{'altrelationship'} eq $relship) { - $row{'selected'}=' selected = "selected"'; + if ($data{'relationship'} eq $relship) { + $row{'selected'}=' selected'; } else { $row{'selected'}=''; } push(@relshipdata, \%row); } - - # %flags: keys=$data-keys, datas=[formname, HTML-explanation] - my %flags = ('gonenoaddress' => ['gna', 'Gone no address'], - 'lost' => ['lost', 'Lost'], - 'debarred' => ['debarred', 'Debarred']); + my %flags = ( 'gonenoaddress' => ['gonenoaddress', 'Adresse érronée'], + 'lost' => ['lost', 'Carte Perdue'], + 'debarred' => ['debarred', 'Lecteur exclu']); my @flagdata; foreach (keys(%flags)) { @@ -220,12 +306,12 @@ if ($delete){ my %row = ('key' => $key, 'name' => $flags{$key}[0], 'html' => $flags{$key}[1]); - if ($data->{$key}) { - $row{'yes'}=' checked="checked"'; + if ($data{$key}) { + $row{'yes'}=' checked'; $row{'no'}=''; } else { $row{'yes'}=''; - $row{'no'}=' checked="checked"'; + $row{'no'}=' checked'; } push(@flagdata, \%row); } @@ -235,102 +321,147 @@ if ($delete){ } #Convert dateofbirth to correct format - $data->{'dateofbirth'} = format_date($data->{'dateofbirth'}); - + $data{'dateofbirth'} = format_date($data{'dateofbirth'}); my @branches; my @select_branch; my %select_branches; my $branches=getbranches(); my $default; + # ----------------------------------------------------- + # the value of ip from the branches hash table + my $select_ip; + # $ip is the ip of user when is connect to koha + my $ip = $ENV{'REMOTE_ADDR'}; + # ----------------------------------------------------- foreach my $branch (keys %$branches) { if ((not C4::Context->preference("IndependantBranches")) || (C4::Context->userenv->{'flags'} == 1)) { push @select_branch, $branch; $select_branches{$branch} = $branches->{$branch}->{'branchname'}; - $default = $data->{'branchcode'}; - } else { +# take the ip number from branches "op" + $select_ip = $branches->{$branch}->{'branchip'} || ''; + +# test $select_ip equal $ip to attribute the default value for the scrolling list + if ($select_ip eq $ip) { + $default = $branches->{$branch}->{'branchcode'}; + } + } else { push @select_branch, $branch if ($branch eq C4::Context->userenv->{'branch'}); $select_branches{$branch} = $branches->{$branch}->{'branchname'} if ($branch eq C4::Context->userenv->{'branch'}); - $default = C4::Context->userenv->{'branch'}; - } + + $default = C4::Context->userenv->{'branch'}; + + } } +# -------------------------------------------------------------------------------------------------------- + my $CGIbranch = CGI::scrolling_list(-id => 'branchcode', + -name => 'branchcode', + -values => \@select_branch, + -labels => \%select_branches, + -size => 1, + -multiple =>0, + -override => 1, + -default => $default, + ); + + +# -------------------------------------------------------------------------------------------------------- - my $CGIbranch=CGI::scrolling_list( -name => 'branchcode', - -id => 'branchcode', - -values => \@select_branch, - -default => $data->{'branchcode'}, - -labels => \%select_branches, - -size => 1, - -multiple => 0 ); - - my $CGIsort1 = buildCGIsort("Bsort1","sort1",$data->{'sort1'}); + my $CGIsort1 = buildCGIsort("Bsort1","sort1",$data{'sort1'}); if ($CGIsort1) { $template->param(CGIsort1 => $CGIsort1); + $template->param( sort1 => $data{'sort1'}); } else { - $template->param( sort1 => $data->{'sort1'}); + $template->param( sort1 => $data{'sort1'}); } - my $CGIsort2 = buildCGIsort("Bsort2","sort2",$data->{'sort2'}); + my $CGIsort2 = buildCGIsort("Bsort2","sort2",$data{'sort2'}); if ($CGIsort2) { $template->param(CGIsort2 =>$CGIsort2); } else { - $template->param( sort2 => $data->{'sort2'}); - } - - my $CGIsort1 = buildCGIsort("Bsort1","sort1",$data->{'sort1'}); - if ($CGIsort1) { - $template->param(CGIsort1 => $CGIsort1); - } else { - $template->param( sort1 => $data->{'sort1'}); + $template->param( sort2 => $data{'sort2'}); } - my $CGIsort2 = buildCGIsort("Bsort2","sort2",$data->{'sort2'}); - if ($CGIsort2) { - $template->param(CGIsort2 =>$CGIsort2); - } else { - $template->param( sort2 => $data->{'sort2'}); - } - $template->param( actionType => $actionType, - destination => $destination, - borrowernumber => $borrowernumber, - address => $data->{'streetaddress'}, - firstname => $data->{'firstname'}, - surname => $data->{'surname'}, - othernames => $data->{'othernames'}, - initials => $data->{'initials'}, - ethcatpopup => $ethcatpopup, - catcodepopup => $catcodepopup, - streetaddress => $data->{'streetaddress'}, - physstreet => $data->{'physstreet'}, - zipcode => $data->{'zipcode'}, - streetcity => $data->{'streetcity'}, - homezipcode => $data->{'homezipcode'}, - city => $data->{'city'}, - phone => $data->{'phone'}, - phoneday => $data->{'phoneday'}, - faxnumber => $data->{'faxnumber'}, - emailaddress => $data->{'emailaddress'}, - textmessaging => $data->{'textmessaging'}, - contactname => $data->{'contactname'}, - altphone => $data->{'altphone'}, - altnotes => $data->{'altnotes'}, - borrowernotes => $data->{'borrowernotes'}, - flagloop => \@flagdata, - relshiploop => \@relshipdata, - "title_".$data->{'title'} => " SELECTED ", - joining => format_date($data->{'dateenrolled'}), - expiry => format_date($data->{'expiry'}), - cardnumber => $cardnumber, - dateofbirth => $data->{'dateofbirth'}, - dateformat => display_date_format(), - modify => $modify, - CGIbranch => $CGIbranch); - $template->param(Institution => 1) if ($categorycode eq "I"); + $data{'opacnotes'} =~ s/\\//g; + $data{'borrowernotes'} =~ s/\\//g; + # increase step to see next page + $step++; + warn "CITY".$data{city}; + $template->param( + BorrowerMandatoryField => C4::Context->preference("BorrowerMandatoryField"),#field to test with javascript + category_type => $category_type,#to know the category type of the borrower + select_city => $select_city, + "step_$step" => 1,# associate with step to know where u are + step => $step, + destination => $destination,#to know wher u come from and wher u must go in redirect + check_member => $check_member,#to know if the borrower already exist(=>1) or not (=>0) +# flags =>$data{'flags'}, + "op$op" => 1, +# op => $op, + nodouble => $nodouble, + borrowerid => $borrowerid,#register number + cardnumber => $data{'cardnumber'}, + surname => uc($data{'surname'}), + firstname => ucfirst($data{'firstname'}), + "title_".$data{'title'} => " SELECTED ", + title => $data{'title'}, + othernames => $data{'othernames'}, + initials => $data{'initials'}, + streetnumber => $data{'streetnumber'}, + streettype =>$data{'streettype'}, + address => $data{'address'}, + address2 => $data{'address2'}, + city => $data{'city'}, + zipcode => $data{'zipcode'}, + email => $data{'email'}, + phone => $data{'phone'}, + mobile => $data{'mobile'}, + fax => $data{'fax'}, + phonepro => $data{'phonepro'}, + emailpro => $data{'emailpro'}, + b_address => $data{'b_address'}, + b_city => $data{'b_city'}, + b_zipcode => $data{'b_zipcode'}, + b_email => $data{'b_email'}, + b_phone => $data{'b_phone'}, + dateofbirth => $data{'dateofbirth'}, + branchcode => $data{'branchcode'}, + catcodepopup => $catcodepopup, + categorycode => $data{'categorycode'}, + dateenrolled => format_date($data{'dateenrolled'}), + dateexpiry => format_date($data{'dateexpiry'}), + debarred => $data{'debarred'}, + gonenoaddress => $data{'gonenoaddress'}, + lost => $data{'lost'}, + contactname => uc($data{'contactname'}), + contactfirstname=> ucfirst($data{'contactfirstname'}), + "contacttitle_".$data{'contacttitle'} => "SELECTED" , + contacttitle => $data{'contacttitle'}, + guarantorid => $guarantorid, + ethcatpopup => $ethcatpopup, + sex => $data{'sex'}, + login => $data{'login'}, + password => $data{'password'}, + opacnotes => $data{'opacnotes'}, + contactnotes => $data{'contactnotes'}, + borrowernotes => $data{'borrowernotes'}, + relshiploop => \@relshipdata, + relationship => $data{'relationship'}, + citypopup => $citypopup, + roadpopup => $roadpopup, + contacttype => $data{'contacttype'}, + flagloop => \@flagdata, +# "contacttype_".$data{'contacttype'} =>" SELECTED ", + dateformat => display_date_format(), + check_categorytype =>$check_categorytype,#to recover the category type with checkcategorytype function + modify => $modify, +# city_choice => $city_choice ,#check if the city was selected + nok => $nok,#flag to konw if an error + CGIbranch => $CGIbranch, + ); + #$template->param(Institution => 1) if ($categorycode eq "I"); output_html_with_http_headers $input, $cookie, $template->output; - - } - # Local Variables: # tab-width: 8 # End: diff --git a/members/moremember.pl b/members/moremember.pl index 0efdaecd91..92e63cc1fa 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -78,7 +78,7 @@ my $data=borrdata('',$bornum); $template->param($data->{'categorycode'} => 1); # in template => instutitional (A for Adult & C for children) $data->{'dateenrolled'} = format_date($data->{'dateenrolled'}); -$data->{'expiry'} = format_date($data->{'expiry'}); +$data->{'dateexpiry'} = format_date($data->{'dateexpiry'}); $data->{'dateofbirth'} = format_date($data->{'dateofbirth'}); $data->{'IS_ADULT'} = ($data->{'categorycode'} ne 'I'); @@ -91,13 +91,13 @@ $data->{'ethnicity'} = fixEthnicity($data->{'ethnicity'}); $data->{&expand_sex_into_predicate($data->{'sex'})} = 1; if ($data->{'categorycode'} eq 'C'){ - my $data2=borrdata('',$data->{'guarantor'}); - $data->{'streetaddress'}=$data2->{'streetaddress'}; + my $data2=borrdata('',$data->{'guarantorid'}); + $data->{'address'}=$data2->{'address'}; $data->{'city'}=$data2->{'city'}; - $data->{'physstreet'}=$data2->{'physstreet'}; - $data->{'streetcity'}=$data2->{'streetcity'}; + $data->{'B_address'}=$data2->{'B_address'}; + $data->{'B_city'}=$data2->{'B_city'}; $data->{'phone'}=$data2->{'phone'}; - $data->{'phoneday'}=$data2->{'phoneday'}; + $data->{'mobile'}=$data2->{'mobile'}; $data->{'zipcode'} = $data2->{'zipcode'}; } @@ -106,7 +106,7 @@ if ($data->{'ethnicity'} || $data->{'ethnotes'}) { $template->param(printethnicityline => 1); } -if ($data->{'categorycode'} ne 'C'){ +if ($data->{'category_type'} ne 'C'){ $template->param(isguarantee => 1); # FIXME # It looks like the $i is only being returned to handle walking through @@ -122,9 +122,9 @@ if ($data->{'categorycode'} ne 'C'){ $template->param(guaranteeloop => \@guaranteedata); } else { - my ($guarantor)=findguarantor($data->{'borrowernumber'}); - unless ($guarantor->{'borrowernumber'} == 0){ - $template->param(guarantorborrowernumber => $guarantor->{'borrowernumber'}, guarantorcardnumber => $guarantor->{'cardnumber'}); + my ($guarantorid)=findguarantor($data->{guarantorid}); + if ($guarantorid->{'borrowernumber'}){ + $template->param(guarantorborrowernumber => $guarantorid->{'borrowernumber'}, guarantorcardnumber => $guarantorid->{'cardnumber'}); } } diff --git a/updater/updatedatabase b/updater/updatedatabase index 5f6acefc92..99ac0af0ea 100755 --- a/updater/updatedatabase +++ b/updater/updatedatabase @@ -135,6 +135,15 @@ my %requiretables = ( `debarred3` int(1) default '0', PRIMARY KEY (`branchcode`,`categorycode`) )", + cities => "(`cityid` int auto_increment, + `city_name` char(100) NOT NULL, + `city_zipcode` char(20), + PRIMARY KEY (`cityid`) + )", + roadtype => "(`roadtypeid` int auto_increment, + `road_type` char(100) NOT NULL, + PRIMARY KEY (`roadtypeid`) + )", ); my %requirefields = ( @@ -157,6 +166,7 @@ my %dropable_table = ( my %uselessfields = ( # tablename => "field1,field2", + borrowers => "suburb,altstreetaddress,altsuburb,altcity,studentnumber,school,area,preferredcont,altcp", ); # the other hash contains other actions that can't be done elsewhere. they are done # either BEFORE of AFTER everything else, depending on "when" entry (default => AFTER) @@ -346,6 +356,24 @@ my %tabledata = ( type => 'Choice', options => 'Calendar|Days' }, + { + uniquefieldrequired => 'variable', + variable => 'borrowerMandatoryField', + value => 'zipcode|surname', + forceupdate => { 'explanation' => 1, + 'type' => 1}, + explanation => 'List all mandatory fields for borrowers', + type => 'free', + }, + { + uniquefieldrequired => 'variable', + variable => 'borrowerRelationship', + value => 'father|mother,grand-mother', + forceupdate => { 'explanation' => 1, + 'type' => 1}, + explanation => 'The relationships between a guarantor & a guarantee (separated by | or ,)', + type => 'free', + }, ], ); @@ -415,6 +443,78 @@ my %fielddefinitions = ( extra => '', }, ], + borrowers => [ + { field => 'B_email', + type => 'text', + null => 'NULL', + after => 'B_zipcode', + }, + { + field => 'streetnumber', # street number (hidden if streettable table is empty) + type => 'char(10)', + null => 'NULL', + after => 'initials', + }, + { + field => 'streettype', # street table, list builded from a system table + type => 'char(50)', + null => 'NULL', + after => 'streetnumber', + }, + { + field => 'B_streetnumber', # street number (hidden if streettable table is empty) + type => 'char(10)', + null => 'NULL', + after => 'fax', + }, + { + field => 'B_streettype', # street table, list builded from a system table + type => 'char(50)', + null => 'NULL', + after => 'B_streetnumber', + }, + { + field => 'phonepro', + type => 'text', + null => 'NULL', + after => 'fax', + }, + { + field => 'address2', # complement address + type => 'text', + null => 'NULL', + after => 'address', + }, + { + field => 'emailpro', + type => 'text', + null => 'NULL', + after => 'fax', + }, + { + field => 'contactfirstname', # contact's firstname + type => 'text', + null => 'NULL', + after => 'contactname', + }, + { + field => 'contacttitle', # contact's title + type => 'text', + null => 'NULL', + after => 'contactfirstname', + }, + ], + categories => [ + { + field => 'category_type', + type => 'char(1)', + null => 'NOT NULL', + key => '', + default => 'A', + extra => '', + }, + ], + ); my %indexes = ( @@ -715,6 +815,123 @@ my %foreign_keys = ( # FIXME : don't constraint auth_*_table and auth_word, as they may be replaced by zebra ); + +# column changes +my %column_change = ( + # table + borrowers => [ + { + from => 'emailaddress', + to => 'email', + after => 'city', + }, + { + from => 'streetaddress', + to => 'address', + after => 'initials', + }, + { + from => 'faxnumber', + to => 'fax', + after => 'phone', + }, + { + from => 'textmessaging', + to => 'opacnote', + after => 'userid', + }, + { + from => 'altnotes', + to => 'contactnote', + after => 'opacnote', + }, + { + from => 'physstreet', + to => 'B_address', + after => 'fax', + }, + { + from => 'streetcity', + to => 'B_city', + after => 'B_address', + }, + { + from => 'phoneday', + to => 'mobile', + after => 'phone', + }, + { + from => 'zipcode', + to => 'zipcode', + after => 'city', + }, + { + from => 'homezipcode', + to => 'B_zipcode', + after => 'B_city', + }, + { + from => 'altphone', + to => 'B_phone', + after => 'B_zipcode', + }, + { + from => 'expiry', + to => 'dateexpiry', + after => 'dateenrolled', + }, + { + from => 'guarantor', + to => 'guarantorid', + after => 'contactname', + }, + { + from => 'textmessaging', + to => 'opacnotes', + after => 'flags', + }, + { + from => 'altnotes', + to => 'contactnotes', + after => 'opacnotes', + }, + { + from => 'altrelationship', + to => 'relationship', + after => 'borrowernotes', + }, + ], + ); + +foreach my $table (keys %column_change) { + $sth = $dbh->prepare("show columns from $table"); + $sth->execute(); + undef %types; + while ( ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow ) + { + $types{$column}->{type} ="$type"; + $types{$column}->{null} = "$null"; + $types{$column}->{key} = "$key"; + $types{$column}->{default} = "$default"; + $types{$column}->{extra} = "$extra"; + } # while + my $tablerows = $column_change{$table}; + foreach my $row ( @$tablerows ) { + if ($types{$row->{from}}->{type}) { + print "altering $table $row->{from} to $row->{to}\n"; + # ALTER TABLE `borrowers` CHANGE `faxnumber` `fax` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL +# alter table `borrowers` change `faxnumber` `fax` type text null after phone + my $sql = + "alter table `$table` change `$row->{from}` `$row->{to}` $types{$row->{from}}->{type} ". + ($types{$row->{from}}->{null} eq 'YES'?" NULL":" NOT NULL"). + ($types{$row->{from}}->{default}?" default ".$types{$row->{from}}->{default}:""). + "$types{$row->{from}}->{extra} after $row->{after} "; +# print "$sql"; + $dbh->do($sql); + } + } +} + #------------------- # Initialize @@ -820,6 +1037,7 @@ foreach $table ( keys %fielddefinitions ) { # $default="''" unless $default; my $extra = $row->{extra}; my $def = $definitions->{$field}; + my $after = ($row->{after}?" after ".$row->{after}:""); unless ( $type eq $def->{type} && $null eq $def->{null} @@ -846,17 +1064,16 @@ foreach $table ( keys %fielddefinitions ) { # if it's a primary key, drop the previous pk, before altering the table my $sth; if ($key ne 'PRIMARY KEY') { - $sth =$dbh->prepare("alter table $table $action $field $type $null $key $extra default ?"); + $sth =$dbh->prepare("alter table $table $action $field $type $null $key $extra default ? $after"); } else { - $sth =$dbh->prepare("alter table $table drop primary key, $action $field $type $null $key $extra default ?"); + $sth =$dbh->prepare("alter table $table drop primary key, $action $field $type $null $key $extra default ? $after"); } $sth->execute($default); - print " Alter $field in $table\n" unless $silent; + print " alter or create $field in $table\n" unless $silent; } } } - # Populate tables with required data @@ -1286,6 +1503,16 @@ sub MARCgetitem { exit; # $Log$ +# Revision 1.134 2006/04/14 09:37:29 tipaul +# improvements from SAN Ouest Provence : +# * introducing a category_type into categories. It can be A (adult), C (children), P (Professionnal), I (institution/organisation). +# * each category_type has it's own forms to create members. +# * the borrowers table has been heavily modified (many fields changed), to get something more logic & readable +# * reintroducing guarantor/guanrantee system that is now independant from hardcoded C/A for categories +# * updating templates to fit template rules +# +# (see mail feb, 17 on koha-devel "new features for borrowers" for more details) +# # Revision 1.133 2006/04/13 08:36:42 plg # new: function C4::Date::get_date_format_string_for_DHTMLcalendar based on # the system preference prefered date format. -- 2.20.1