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