#1449: Installer improved to add a zebra/Nozebra screen
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / js / members.js
1 function _(s) { return s } // dummy function for gettext
2
3 // this function checks id date is like DD/MM/YYYY
4 function CheckDate(field) {
5 var d = field.value;
6 if (d!="") {
7       var amin = 1900; 
8       var amax = 2100; 
9       var date = d.split("/");
10       var ok=1;
11       var msg;
12       if ( (date.length < 2) && (ok==1) ) {
13         msg = _("Separator must be /"); 
14         alert(msg); ok=0; field.focus();
15         return;
16       }
17       var dd   = date[0];
18       var mm   = date[1];
19       var yyyy = date[2]; 
20       // checking days
21       if ( ((isNaN(dd))||(dd<1)||(dd>31)) && (ok==1) ) {
22         msg = _("day not correct."); 
23             alert(msg); ok=0; field.focus();
24             return;
25       }
26       // checking months
27       if ( ((isNaN(mm))||(mm<1)||(mm>12)) && (ok==1) ) {
28         msg = _("month not correct.");
29             alert(msg); ok=0; field.focus();
30             return;
31       }
32       // checking years
33       if ( ((isNaN(yyyy))||(yyyy<amin)||(yyyy>amax)) && (ok==1) ) {
34         msg = _("years not correct."); 
35             alert(msg); ok=0; field.focus();
36             return;
37       }
38    }
39 }
40
41 //function test if member is unique and if it's right the member is registred
42 function unique() {
43 var msg1;
44 var msg2;
45 if (  document.form.check_member.value==1){
46         if (document.form.categorycode.value != "I"){
47                 
48                 msg1 += ("Warning  !!!! Duplicate patron!!!!");
49                 alert(msg1);
50         check_form_borrowers(0);
51         document.form.submit();
52         
53         }else{
54                 msg2 += ("Warning !!!! Duplicate organisation!!!!");
55                 alert(msg2);
56         check_form_borrowers(0);
57         }
58 }
59 else
60 {
61         document.form.submit();
62 }
63
64 }
65 //end function
66 //function test if date enrooled < date expiry
67 function check_manip_date(status) {
68 if (status=='verify'){
69 // this part of function('verify') is used to check if dateenrolled<date expiry
70 if (document.form.dateenrolled != '' && document.form.dateexpiry.value !='') {
71 var myDate1=document.form.dateenrolled.value.split ('/');
72 var myDate2=document.form.dateexpiry.value.split ('/');
73         if ((myDate1[2]>myDate2[2])||(myDate1[2]==myDate2[2] && myDate1[1]>myDate2[1])||(myDate1[2]==myDate2[2] && myDate1[1]>=myDate2[1] && myDate1[0]>=myDate2[0]))
74         
75                 { 
76                 document.form.dateenrolled.focus();
77                 var msg = ("Warning !!! check date expiry  >= date enrolment");
78                 alert(msg);
79                 }
80         }
81         }
82 }
83 //end function
84
85
86 // function to test all fields in forms and nav in different forms(1 ,2 or 3)
87  function check_form_borrowers(nav){
88 var statut=0;
89         if (document.form.check_member.value == 1 )
90         {
91         
92                 if (document.form_double.answernodouble)        {
93                         if( (!(document.form_double.answernodouble.checked))){
94                                 document.form.nodouble.value=0;
95                         }
96                         else {
97                         document.form.nodouble.value=1;
98                         }
99                 }
100         } 
101         
102         if (document.form.BorrowerMandatoryField.value=='')
103         {}
104         else
105         {
106             var champ_verif = document.form.BorrowerMandatoryField.value.split ('|');
107             var message ="The following fields are mandatory :\n";
108             var message_champ="";
109                         for (var i=0; i<champ_verif.length; i++) {
110                                         if (document.getElementsByName(""+champ_verif[i]+"")[0]) {
111                                           var val_champ=eval("document.form."+champ_verif[i]+".value");
112                                           var ref_champ=eval("document.form."+champ_verif[i]);
113                                                 //check if it's a select
114                                                 if (ref_champ.type=='select-one'){
115                                                         if (ref_champ.options[0].selected ){
116                                                                 // action if field is empty
117                                                                 message_champ+=champ_verif[i]+"\n";
118                                                                 //test to konw if you must show a message with error
119                                                                 statut=1;
120                                                         }
121                                                 }else {
122                                                         if ( val_champ == '' ) {
123                                                                 // action if the field is not empty
124                                                                 message_champ+=champ_verif[i]+"\n";
125                                                                 statut=1;
126                                                         }       
127                                     }
128                            }
129                   }
130         }
131 //patrons form to test if you chcked no to the quetsion of double 
132         if (statut!=1 && document.form.check_member.value > 0 )
133         {
134                 
135                 
136                         if (!(document.form_double.answernodouble.checked)){
137                                         
138                                 message ="";
139                                         message_champ+=("Please confirm suspicious duplicate patron !!! ");
140                                         statut=1;
141                                         document.form.nodouble.value=0;
142                         }
143                         else {
144                         document.form.nodouble.value=1;
145                         }
146         }
147                 
148         if (statut==1){
149                         //alert if at least 1 error
150                                 alert(message+"\n"+message_champ);
151                                 return false;
152         }
153         else 
154         {
155                         document.form.submit();
156         }
157 }
158
159 function Dopop(link) {
160 // //   var searchstring=document.form.value[i].value;
161         var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=no,top');
162 }
163
164 function Dopopguarantor(link) {
165
166         var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=yes,top');
167 }