Adding error management for memberentry.pl
authorHenri-Damien LAURENT <henridamien@koha-fr.org>
Tue, 18 Sep 2007 16:38:23 +0000 (18:38 +0200)
committerChris Cormack <crc@liblime.com>
Tue, 18 Sep 2007 20:05:22 +0000 (15:05 -0500)
Signed-off-by: Chris Cormack <crc@liblime.com>
koha-tmpl/intranet-tmpl/prog/en/js/members.js
koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tmpl
members/memberentry.pl

index 9f9a858..bbb1e30 100644 (file)
@@ -84,9 +84,7 @@ var myDate2=document.form.dateexpiry.value.split ('/');
 // function to test all fields in forms and nav in different forms(1 ,2 or 3)
  function check_form_borrowers(nav){
 var statut=0;
-if (nav < document.form.step.value) {
-       document.form.step.value=nav;
-       if ((document.form.step.value==0) && document.form.check_member.value == 1 )
+       if (document.form.check_member.value == 1 )
        {
        
                if (document.form_double.answernodouble)        {
@@ -98,25 +96,18 @@ if (nav < document.form.step.value) {
                        }
                }
        } 
-       document.form.submit();
        
-} else {
        if (document.form.BorrowerMandatoryField.value==''||document.form.FormFieldList.value=='' )
        {}
        else
        {
            var champ_verif = document.form.BorrowerMandatoryField.value.split ('|');
-           var champ_form= document.form.FormFieldList.value.split('|');
            var message ="The following fields are mandatory :\n";
            var message_champ="";
-               for (var j=0; j<champ_form.length; j++){ 
-                       if (document.getElementsByName(""+champ_form[j]+"")[0]){
                        for (var i=0; i<champ_verif.length; i++) {
                                        if (document.getElementsByName(""+champ_verif[i]+"")[0]) {
-                                       var val_champ=eval("document.form."+champ_verif[i]+".value");
-                                       var ref_champ=eval("document.form."+champ_verif[i]);
-                                       var val_form=eval("document.form."+champ_form[j]+".value");
-                                       if (champ_verif[i] == champ_form[j]){
+                                         var val_champ=eval("document.form."+champ_verif[i]+".value");
+                                         var ref_champ=eval("document.form."+champ_verif[i]);
                                                //check if it's a select
                                                if (ref_champ.type=='select-one'){
                                                        if (ref_champ.options[0].selected ){
@@ -130,16 +121,13 @@ if (nav < document.form.step.value) {
                                                                // action if the field is not empty
                                                                message_champ+=champ_verif[i]+"\n";
                                                                statut=1;
-                                                               }       
                                                        }       
-                                               }
-                                       }
-                               }
-                       }
-               }
+                                   }
+                          }
+                 }
        }
 //patrons form to test if you chcked no to the quetsion of double 
-       if (document.form.step.value==2 && statut!=1 && document.form.check_member.value > 0 )
+       if (statut!=1 && document.form.check_member.value > 0 )
        {
                
                
@@ -155,16 +143,14 @@ if (nav < document.form.step.value) {
                        }
        }
                
-                       if (statut==1){
+       if (statut==1){
                        //alert if at least 1 error
                                alert(message+"\n"+message_champ);
-                       }
-                       else 
-                       {
-                       document.form.step=nav;
+       }
+       else 
+       {
                        document.form.submit();
-                       }
-               }
+       }
 }
 
 function Dopop(link) {
index 2e9a2db..6f9f46c 100644 (file)
@@ -40,18 +40,18 @@ patron <!-- TMPL_VAR NAME="surname" --> <!-- TMPL_VAR name="firstname" -->
                <div id="problem">
                        <p>The following fields are wrong. Please fix it/them</p>
                        <!-- TMPL_IF NAME="ERROR_login_exist" -->
-                               <p>login/password already exist</p>
+                               <div name="ERROR_login_exist">login/password already exist</div>
                        <!-- /TMPL_IF -->
                        <!-- TMPL_IF NAME="ERROR_cardnumber" -->
-                               <p>Cardnumber already in use</p>
+                               <div name="ERROR_cardnumber">Cardnumber already in use</div>
                        <!-- /TMPL_IF -->
-                        <!-- TMPL_IF NAME="ERROR_age_limitations" -->
-                                Patron is too young or too old for this category
-                        <!-- /TMPL_IF -->
+      <!-- TMPL_IF NAME="ERROR_age_limitations" -->
+              <div name="ERROR_age_limitations">Patron is too young or too old for this category</div>
+      <!-- /TMPL_IF -->
                </div>
        <!-- /TMPL_IF -->
        
-  <!--TMPL_IF Name="opadd"-->
+  <!--TMPL_IF Name="allsteps"-->
     <div id="tabs">
             <a href="javascript:active(1)" class="tab_active" id="link1">Personal Information</a>
             <a href="javascript:active(2)" class="tab_inactive" id="link2">Contacts</a>
index 9830972..6a92cc0 100755 (executable)
@@ -177,7 +177,7 @@ if ($op eq 'insert' || $op eq 'modify' || $op eq 'save') {
       push @errors, "ERROR_login_exist";
       $nok=1;
     } else {
-      warn Data::Dumper::Dumper(%newdata);  
+      warn Data::Dumper::Dumper(%newdata);  
       $borrowernumber = &AddMember(%newdata);
         if ($data{'organisations'}){            
           # need to add the members organisations
@@ -240,11 +240,11 @@ if ($delete){
     }
   }
   if ($op eq 'add'){
-    $template->param( updtype => 'I',step_1=>1,step_2=>1,step_3=>1);
+    $template->param( updtype => 'I',step_1=>1,step_2=>1,step_3=>1,allsteps=>1);
   } 
-  if ($op eq "Modify")  {
+  if ($op eq "modify")  {
     $template->param( updtype => 'M');
-    $template->param( step_1=>1,step_2=>1,step_3=>1) unless $step;
+    $template->param( step_1=>1,step_2=>1,step_3=>1,allsteps=>1) unless $step;
   }
 # my $cardnumber=$data{'cardnumber'};
   $data{'cardnumber'}=fixup_cardnumber($data{'cardnumber'}) if $op eq 'add';