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