phpScheduleIt
May 24, 2013, 01:01:10 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: phpScheduleIt 2.4.2 has been released!
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: making the summary field 'required' when booking  (Read 1184 times)
dimpzor
Newbie
*

Karma: 0
Posts: 6


« on: July 08, 2011, 06:48:42 AM »

Hi

Been using this great software for a while, but i now need to make a few minor modifications and wonder if you can help as my php skills are little to none.
I would like the summary field to be made mandatory when placing a booking.

I've had a look through the forums and guess that i need to edit the lib/Reservation.class.php file but i'm not sure of the code needed  Sad

Also, is there a way to show this summary permanantly on the bookings (weekly) screen ias well as (or instead of) the hover over effect?

Can anyone help? Much appreciated
Andy
« Last Edit: July 08, 2011, 06:53:47 AM by dimpzor » Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #1 on: July 11, 2011, 01:38:51 PM »

Probably the easiest thing to do would be to modify the functions.js file check_reservation_form(f) function.

Something like:

if (f.summary == '')
{
msg += "- Summary is required\n";
}
Logged
dimpzor
Newbie
*

Karma: 0
Posts: 6


« Reply #2 on: July 12, 2011, 06:09:01 AM »

i added this code to the functions.js file in check_reservation_form(f) function, but it appears to do nothing Sad

(i added the extra quotation on the if f.summary == "" line)
Logged
dimpzor
Newbie
*

Karma: 0
Posts: 6


« Reply #3 on: July 18, 2011, 06:13:26 AM »

nope, still can't get this to work.
not sure what the problem is. any ideas?
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #4 on: July 18, 2011, 01:55:41 PM »

Interesting.  Can you add:

if (f.summary != "")
{
alert(f.summary);
}

to see what is coming across?
Logged
dimpzor
Newbie
*

Karma: 0
Posts: 6


« Reply #5 on: July 19, 2011, 04:12:35 AM »

hi nick

adding that code displays the popup with [object HTMLTextAreaElement] message.
Clicking the ok button confirms the booking and adds it to the system.

Andy
Logged
Gilbert Iqbal
Newbie
*

Karma: 0
Posts: 1

Adversity makes a man wise, not rich


WWW
« Reply #6 on: July 20, 2011, 11:53:14 PM »

Your idea seems useful. I fixed it out! Thank you!
Logged
dimpzor
Newbie
*

Karma: 0
Posts: 6


« Reply #7 on: July 21, 2011, 04:05:11 AM »

care to explain?
i still have the code set to show a popup when the summary field is empty but it still doesnt work.

if i edit the code where the f.summary != "" , it shows the popup if the summary field is empty or populated.
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #8 on: July 25, 2011, 01:27:03 PM »

Ahh, should have been f.summary.value
Logged
dimpzor
Newbie
*

Karma: 0
Posts: 6


« Reply #9 on: July 26, 2011, 04:41:55 AM »

hi nick

thanks, that seems to have done the trick......
« Last Edit: July 26, 2011, 04:49:31 AM by dimpzor » Logged
psi_newbie
Newbie
*

Karma: 0
Posts: 39


« Reply #10 on: February 11, 2012, 11:10:14 AM »

I did this exactly Nick but it didn't work. Any suggestions?
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #11 on: February 13, 2012, 01:27:11 PM »

Can you post what you have for the check_reservation_form(f) function?
Logged
psi_newbie
Newbie
*

Karma: 0
Posts: 39


« Reply #12 on: February 13, 2012, 05:22:55 PM »

function check_reservation_form(f) {
   var recur_ok = false;
   var days_ok = false;
   var is_repeat = false;
   var msg = "";
   
   if ((typeof f.interval != 'undefined') && f.interval.value != "none") {
      is_repeat = true;
      if (f.interval.value == "week" || f.interval.value == "month_day") {
         for (var i=0; i < f.elements["repeat_day[]"].length; i++) {
            if (f.elements["repeat_day[]"].checked == true)
               days_ok = true;
         }
      }
      else {
         days_ok = true;
      }
      
      if (f.repeat_until.value == "") {
         msg += "- Please choose an ending date\n";
         recur_ok = false;
      }
   }
   else {
      recur_ok = true;
      days_ok = true;
   }
   
   if (days_ok == false) {
      recur_ok = false;
      msg += "- Please select days to repeat on";
   }
   
   if (msg != "")
      alert(msg);
      
   return (msg == "");
   
   if (f.major.value == "") {
      msg+="-Major is required\n";
   }
   if (f.sclass.value == "") {
      msg+="-Class is required\n";
   }
   if (f.cgpa.value == "") {
      msg+="-CGPA is required\n";
   }
   if (f.summary.value == "") {
      msg+="-Summary is required\n";
   }
}
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #13 on: February 14, 2012, 01:19:42 PM »

Try this:

Code:
function check_reservation_form(f) {
   var recur_ok = false;
   var days_ok = false;
   var is_repeat = false;
   var msg = "";
   
   if ((typeof f.interval != 'undefined') && f.interval.value != "none") {
      is_repeat = true;
      if (f.interval.value == "week" || f.interval.value == "month_day") {
         for (var i=0; i < f.elements["repeat_day[]"].length; i++) {
            if (f.elements["repeat_day[]"].checked == true)
               days_ok = true;
         }
      }
      else {
         days_ok = true;
      }
     
      if (f.repeat_until.value == "") {
         msg += "- Please choose an ending date\n";
         recur_ok = false;
      }
   }
   else {
      recur_ok = true;
      days_ok = true;
   }
   
   if (days_ok == false) {
      recur_ok = false;
      msg += "- Please select days to repeat on";
   }
   
   
   if (f.major.value == "") {
      msg+="-Major is required\n";
   }
   if (f.sclass.value == "") {
      msg+="-Class is required\n";
   }
   if (f.cgpa.value == "") {
      msg+="-CGPA is required\n";
   }
   if (f.summary.value == "") {
      msg+="-Summary is required\n";
   }

   if (msg != "")
      alert(msg);
     
   return (msg == "");

}
Logged
psi_newbie
Newbie
*

Karma: 0
Posts: 39


« Reply #14 on: February 14, 2012, 02:53:59 PM »

It worked. Thanks
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2006-2007, Simple Machines Valid XHTML 1.0! Valid CSS!