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