[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha cataloguing/value_builder/unimarc_field_10... [rel_3_0]
From: |
Antoine Farnault |
Subject: |
[Koha-cvs] koha cataloguing/value_builder/unimarc_field_10... [rel_3_0] |
Date: |
Thu, 30 Nov 2006 11:40:56 +0000 |
CVSROOT: /sources/koha
Module name: koha
Branch: rel_3_0
Changes by: Antoine Farnault <toins> 06/11/30 11:40:56
Modified files:
cataloguing/value_builder: unimarc_field_100.pl
unimarc_field_210c.pl
koha-tmpl/intranet-tmpl/prog/en/cataloguing/value_builder:
unimarc_field_100.tmpl
unimarc_field_210c.tmpl
Log message:
SAN OP #33 + JS optimisation
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/value_builder/unimarc_field_100.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.5&r2=1.1.2.6
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/value_builder/unimarc_field_210c.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.4&r2=1.1.2.5
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/cataloguing/value_builder/unimarc_field_100.tmpl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.2&r2=1.1.2.3
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/cataloguing/value_builder/unimarc_field_210c.tmpl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.2&r2=1.1.2.3
Patches:
Index: cataloguing/value_builder/unimarc_field_100.pl
===================================================================
RCS file:
/sources/koha/koha/cataloguing/value_builder/Attic/unimarc_field_100.pl,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -b -r1.1.2.5 -r1.1.2.6
--- cataloguing/value_builder/unimarc_field_100.pl 22 Nov 2006 15:47:50
-0000 1.1.2.5
+++ cataloguing/value_builder/unimarc_field_100.pl 30 Nov 2006 11:40:56
-0000 1.1.2.6
@@ -1,7 +1,7 @@
#!/usr/bin/perl
-# $Id: unimarc_field_100.pl,v 1.1.2.5 2006/11/22 15:47:50 tipaul Exp $
+# $Id: unimarc_field_100.pl,v 1.1.2.6 2006/11/30 11:40:56 toins Exp $
# Copyright 2000-2002 Katipo Communications
#
@@ -33,15 +33,16 @@
plugin_parameters : other parameters added when the plugin is called by the
dopop function
=cut
+
sub plugin_parameters {
-my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
-return "";
+ my ( $dbh, $record, $tagslib, $i, $tabloop ) = @_;
+ return "";
}
sub plugin_javascript {
-my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
-my $function_name= "100".(int(rand(100000))+1);
-my $res="
+ my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_;
+ my $function_name = "100" . ( int( rand(100000) ) + 1 );
+ my $res = "
<script>
function Focus$function_name(subfield_managed) {
return 1;
@@ -59,50 +60,52 @@
</script>
";
-return ($function_name,$res);
+ return ( $function_name, $res );
}
+
sub plugin {
-my ($input) = @_;
+ my ($input) = @_;
my %env;
-# my $input = new CGI;
- my $index= $input->param('index');
- my $result= $input->param('result');
-
+ # my $input = new CGI;
+ my $index = $input->param('index');
+ my $result = $input->param('result');
my $dbh = C4::Context->dbh;
-my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name =>
"cataloguing/value_builder/unimarc_field_100.tmpl",
+ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name =>
"cataloguing/value_builder/unimarc_field_100.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
- flagsrequired => {editcatalogue => 1},
+ flagsrequired => { editcatalogue => 1 },
debug => 1,
- });
- $result=' d u y0frey50 ba' unless $result;
- my $f1 = substr($result,0,8);
- if ($f1 eq ' ') {
+ }
+ );
+ $result = ' d u y0frey50 ba' unless $result;
+ my $f1 = substr( $result, 0, 8 );
+ if ( $f1 eq ' ' ) {
my @today = Date::Calc::Today();
- $f1=$today[0].$today[1].$today[2];
+ $f1 = $today[0] . $today[1] . $today[2];
}
- my $f2 = substr($result,8,1);
- my $f3 = substr($result,9,4);
- my $f4 = substr($result,13,4);
- my $f5 = substr($result,17,1);
- my $f6 = substr($result,18,1);
- my $f7 = substr($result,19,1);
- my $f8 = substr($result,20,1);
- my $f9 = substr($result,21,1);
- my $f10 = substr($result,22,3);
- my $f11 = substr($result,25,1);
- my $f12 = substr($result,26,2);
- my $f13 = substr($result,28,2);
- my $f14 = substr($result,30,4);
- my $f15 = substr($result,34,2);
-
+ my $f2 = substr( $result, 8, 1 );
+ my $f3 = substr( $result, 9, 4 );
+ my $f4 = substr( $result, 13, 4 );
+ my $f5 = substr( $result, 17, 1 );
+ my $f6 = substr( $result, 18, 1 );
+ my $f7 = substr( $result, 19, 1 );
+ my $f8 = substr( $result, 20, 1 );
+ my $f9 = substr( $result, 21, 1 );
+ my $f10 = substr( $result, 22, 3 );
+ my $f11 = substr( $result, 25, 1 );
+ my $f12 = substr( $result, 26, 2 );
+ my $f13 = substr( $result, 28, 2 );
+ my $f14 = substr( $result, 30, 4 );
+ my $f15 = substr( $result, 34, 2 );
- $template->param(index => $index,
+ $template->param(
+ index => $index,
f1 => $f1,
f3 => $f3,
"f2$f2" => 1,
@@ -119,7 +122,7 @@
"f14" => $f14,
"f15$f15" => 1
);
- print $input->header(-cookie => $cookie),$template->output;
+ print $input->header( -cookie => $cookie ), $template->output;
}
1;
Index: cataloguing/value_builder/unimarc_field_210c.pl
===================================================================
RCS file:
/sources/koha/koha/cataloguing/value_builder/Attic/unimarc_field_210c.pl,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -b -r1.1.2.4 -r1.1.2.5
--- cataloguing/value_builder/unimarc_field_210c.pl 21 Nov 2006 10:45:54
-0000 1.1.2.4
+++ cataloguing/value_builder/unimarc_field_210c.pl 30 Nov 2006 11:40:56
-0000 1.1.2.5
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: unimarc_field_210c.pl,v 1.1.2.4 2006/11/21 10:45:54 toins Exp $
+# $Id: unimarc_field_210c.pl,v 1.1.2.5 2006/11/30 11:40:56 toins Exp $
# Copyright 2000-2002 Katipo Communications
#
@@ -77,7 +77,7 @@
push(@editors,"$isbn $authoritysep $editor");
}
my $res = "
-<script>
+<script type=\"text/javascript\">
function Focus$function_name(index) {
var isbn_array = [ ";
foreach my $editor (@editors) {
@@ -89,11 +89,19 @@
];
// search isbn subfield. it''s 010a
var isbn_found;
- for (i=0 ; i<document.f.field_value.length ; i++) {
+ var nb_fields = document.f.field_value.length;
+ for (i=0 ; i< nb_fields; i++) {
if (document.f.tag[i].value == '010' &&
document.f.subfield[i].value == 'a') {
isbn_found=document.f.field_value[i].value;
+ break;
}
}
+ try{
+ isbn_found.getAttribute('value'); // throw an exception if doesn't (if
no 010a)
+ }
+ catch(e){
+ return;
+ }
for (i=0;i<=isbn_array.length;i++) {
if (isbn_found.substr(0,isbn_array[i][0].length) ==
isbn_array[i][0]) {
document.f.field_value[index].value =isbn_array[i][1];
Index:
koha-tmpl/intranet-tmpl/prog/en/cataloguing/value_builder/unimarc_field_100.tmpl
===================================================================
RCS file:
/sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/cataloguing/value_builder/Attic/unimarc_field_100.tmpl,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -b -r1.1.2.2 -r1.1.2.3
---
koha-tmpl/intranet-tmpl/prog/en/cataloguing/value_builder/unimarc_field_100.tmpl
21 Nov 2006 10:29:21 -0000 1.1.2.2
+++
koha-tmpl/intranet-tmpl/prog/en/cataloguing/value_builder/unimarc_field_100.tmpl
30 Nov 2006 11:40:56 -0000 1.1.2.3
@@ -109,11 +109,11 @@
</tr>
<tr>
<td>Premiere date de publication</td>
- <td><input type="text" name="f3" maxlength=4 size=5 value="<!--
TMPL_VAR name="f3" -->"></td>
+ <td><input id="pubdate1" type="text" name="f3" maxlength=4 size=5
value="<!-- TMPL_VAR name="f3" -->"></td>
</tr>
<tr>
<td>Deuxieme date de publication</td>
- <td><input type="text" name="f4" maxlength=4 size=5
+ <td><input id="pubdate2" type="text" name="f4" maxlength=4 size=5
value="<!-- TMPL_VAR name="f4" -->"></td>
</tr>
@@ -691,7 +691,52 @@
<tr><td colspan=2><input type="submit" value="OK"></td></tr>
</table>
</form>
-<script>
+<script type="text/javascript" language="javascript">
+
+ /********************
+ * Global variables *
+ ********************/
+ var doc = opener.document;
+ var fields = doc.f.field_value;
+ var NbFields = fields.length;
+
+ GetPublicationDate(); // running directly.
+
+ /**
+ * GetPublicationDate.
+ * This function get the publication date if it's writen on 210d
+ */
+ function GetPublicationDate() {
+ var PublicationDate = null;
+
+ for (i=0 ; i<NbFields ; i++) {
+ if (doc.f.tag[i].value == '210' && doc.f.subfield[i].value == 'd')
{
+ if (doc.f.field_value[i].value != ""){
+ PublicationDate = doc.f.field_value[i].value;
+ document.getElementById('pubdate1').value =
PublicationDate;
+ }
+ return;
+ }
+ }
+ }
+
+ /**
+ * SetPublicationDate.
+ * This function set the publication date here
+ */
+ function SetPublicationDate() {
+ var PublicationDate = document.getElementById('pubdate1').value;
+ if (PublicationDate == " " || !PublicationDate){
+ return ;
+ }
+ for (i=0 ; i<NbFields ; i++) {
+ if (doc.f.tag[i].value == '210' && doc.f.subfield[i].value == 'd')
{
+ doc.f.field_value[i].value = PublicationDate;
+ break;
+ }
+ }
+ }
+
function report() {
document.f_pop.f1.value=document.f_pop.f1.value+' ';
@@ -700,19 +745,18 @@
document.f_pop.f10.value=document.f_pop.f10.value+' ';
document.f_pop.f14.value=document.f_pop.f14.value+' ';
+ document.f_pop.f1.value=document.f_pop.f1.value.substring(0,8);
+ document.f_pop.f3.value=document.f_pop.f3.value.substring(0,4);
+ document.f_pop.f4.value=document.f_pop.f4.value.substring(0,4);
+ document.f_pop.f10.value=document.f_pop.f10.value.substring(0,3);
+ document.f_pop.f14.value=document.f_pop.f14.value.substring(0,4);
-
-document.f_pop.f1.value=document.f_pop.f1.value.substring(0,8);
-document.f_pop.f3.value=document.f_pop.f3.value.substring(0,4);
-document.f_pop.f4.value=document.f_pop.f4.value.substring(0,4);
-document.f_pop.f10.value=document.f_pop.f10.value.substring(0,3);
-document.f_pop.f14.value=document.f_pop.f14.value.substring(0,4);
-
-
- opener.document.f.field_value[<!-- TMPL_VAR
+ doc.f.field_value[<!-- TMPL_VAR
name="index" -->].value= document.f_pop.f1.value +
document.f_pop.f2.value +document.f_pop.f3.value
+document.f_pop.f4.value+document.f_pop.f5.value+document.f_pop.f6.value+document.f_pop.f7.value+document.f_pop.f8.value+document.f_pop.f9.value+document.f_pop.f10.value+document.f_pop.f11.value+document.f_pop.f12.value+document.f_pop.f13.value+document.f_pop.f14.value+document.f_pop.f15.value;
+
+ SetPublicationDate();
self.close();
return false;
}
Index:
koha-tmpl/intranet-tmpl/prog/en/cataloguing/value_builder/unimarc_field_210c.tmpl
===================================================================
RCS file:
/sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/cataloguing/value_builder/Attic/unimarc_field_210c.tmpl,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -b -r1.1.2.2 -r1.1.2.3