french translation
[koha.git] / koha-tmpl / intranet-tmpl / prog / fr / includes / members.js
1 function _(s) { return s; }
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 borrower!!!!");
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 (nav < document.form.step.value) {
90         document.form.step.value=nav;
91         if ((document.form.step.value==0) && document.form.check_member.value == 1 )
92         {
93         
94                 if (document.form_double.answernodouble)        {
95                         if( (!(document.form_double.answernodouble.checked))){
96                                 document.form.nodouble.value=0;
97                         }
98                         else {
99                         document.form.nodouble.value=1;
100                         }
101                 }
102         } 
103         document.form.submit();
104         
105 } else {
106         if (document.form.BorrowerMandatoryField.value==''||document.form.FormFieldList.value=='' )
107         {}
108         else
109         {
110             var champ_verif = document.form.BorrowerMandatoryField.value.split ('|');
111             var champ_form= document.form.FormFieldList.value.split('|');
112             var message ="The following fields are mandatory :\n";
113             var message_champ="";
114                 for (var j=0; j<champ_form.length; j++){ 
115                         if (document.getElementsByName(""+champ_form[j]+"")[0]){
116                         for (var i=0; i<champ_verif.length; i++) {
117                                         if (document.getElementsByName(""+champ_verif[i]+"")[0]) {
118                                         var val_champ=eval("document.form."+champ_verif[i]+".value");
119                                         var ref_champ=eval("document.form."+champ_verif[i]);
120                                         var val_form=eval("document.form."+champ_form[j]+".value");
121                                         if (champ_verif[i] == champ_form[j]){
122                                                 //check if it's a select
123                                                 if (ref_champ.type=='select-one'){
124                                                         if (ref_champ.options[0].selected ){
125                                                                 // action if field is empty
126                                                                 message_champ+=champ_verif[i]+"\n";
127                                                                 //test to konw if you must show a message with error
128                                                                 statut=1;
129                                                         }
130                                                 }else {
131                                                         if ( val_champ == '' ) {
132                                                                 // action if the field is not empty
133                                                                 message_champ+=champ_verif[i]+"\n";
134                                                                 statut=1;
135                                                                 }       
136                                                         }       
137                                                 }
138                                         }
139                                 }
140                         }
141                 }
142         }
143 //borrowers form 2 test if u chcked no to the quetsion of double 
144         if (document.form.step.value==2 && statut!=1 && document.form.check_member.value > 0 )
145         {
146                 
147                 
148                         if (!(document.form_double.answernodouble.checked)){
149                                         
150                                 message ="";
151                                         message_champ+=("Please confirm suspicious duplicate borrower !!! ");
152                                         statut=1;
153                                         document.form.nodouble.value=0;
154                         }
155                         else {
156                         document.form.nodouble.value=1;
157                         }
158         }
159                 
160                         if (statut==1){
161                         //alert if at least 1 error
162                                 alert(message+"\n"+message_champ);
163                         }
164                         else 
165                         {
166                         document.form.step=nav;
167                         document.form.submit();
168                         }
169                 }
170 }
171
172 function Dopop(link) {
173 // //   var searchstring=document.form.value[i].value;
174         var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=no,top');
175 }
176
177 function Dopopguarantor(link) {
178
179         var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=yes,top');
180 }