tutto ruota intorno a 3 pagine
edit_entry.php, edit_entry_handler.php e mrbs_sql.inc alla prima ho aggiunto 8 checkbox con valore si/no per dei servizi aggiuntivi.
ho creato i campi nel DB con valore "varchar", 2 - ho inserito i nome campo ne file inc e.. funziona! ma con un difetto, il check (8) inserisce nel (7) e cosi via fino ad arrivare al primo (1) che perde il valore e il campo (8) rimane vuoto.. come se scartasse tutto l'inserimento di un campo!!!!

se invece modifico la prenotazione con la stessa edit_entry.php funziona perfettamente!!! ????

non mi fa upload lo zip e la pagina è troppo lunga
la posto in due parti


<?php
# $Id: edit_entry.php,v 1.30.2.4 2007/02/13 12:53:24 jberanek Exp $
require_once('grab_globals.inc.php');
include "config.inc.php";
include "functions.inc";
include "$dbsys.inc";
include "mrbs_auth.inc";
global $twentyfourhour_format;
#If we dont know the right date then make it up
if(!isset($day) or !isset($month) or !isset($year))
{
$day = date("d");
$month = date("m");
$year = date("Y");
}
if(empty($area))
$area = get_default_area();
if(!isset($edit_type))
$edit_type = "";
if(!getAuthorised(1))
{
showAccessDenied($day, $month, $year, $area);
exit;
}
# This page will either add or modify a booking
# We need to know:
# Name of booker
# Description of meeting
# Date (option select box for day, month, year)
# Time
# Duration
# Internal/External
# Firstly we need to know if this is a new booking or modifying an old one
# and if it's a modification we need to get all the old data from the db.
# If we had $id passed in then it's a modification.
if (isset($id))
{
$sql = "select name, create_by, description, start_time, end_time,
type, room_id, entry_type, repeat_id, lavf, lavl, proie, ampli, aconf, vconf, presi, puli from $tbl_entry where id=$id";

$res = sql_query($sql);
if (! $res) fatal_error(1, sql_error());
if (sql_count($res) != 1) fatal_error(1, get_vocab("entryid") . $id . get_vocab("not_found"));

$row = sql_row($res, 0);
sql_free($res);
# Note: Removed stripslashes() calls from name and description. Previous
# versions of MRBS mistakenly had the backslash-escapes in the actual database
# records because of an extra addslashes going on. Fix your database and
# leave this code alone, please.
$name = $row[0];
$create_by = $row[1];
$description = $row[2];
$start_day = strftime('%d', $row[3]);
$start_month = strftime('%m', $row[3]);
$start_year = strftime('%Y', $row[3]);
$start_hour = strftime('%H', $row[3]);
$start_min = strftime('%M', $row[3]);
$duration = $row[4] - $row[3] - cross_dst($row[3], $row[4]);
$type = $row[5];
$room_id = $row[6];
$entry_type = $row[7];
$rep_id = $row[8];
$lavf = $row[10];
$lavl = $row[11];
$ampli = $row[12];
$proie = $row[13];
$aconf = $row[14];
$vconf = $row[15];
$presi = $row[16];
$puli = $row[17];
if($entry_type >= 1)
{
$sql = "SELECT rep_type, start_time, end_date, rep_opt, rep_num_weeks
FROM $tbl_repeat WHERE id=$rep_id";

$res = sql_query($sql);
if (! $res) fatal_error(1, sql_error());
if (sql_count($res) != 1) fatal_error(1, get_vocab("repeat_id") . $rep_id . get_vocab("not_found"));

$row = sql_row($res, 0);
sql_free($res);

$rep_type = $row[0];
if($edit_type == "series")
{
$start_day = (int)strftime('%d', $row[1]);
$start_month = (int)strftime('%m', $row[1]);
$start_year = (int)strftime('%Y', $row[1]);

$rep_end_day = (int)strftime('%d', $row[2]);
$rep_end_month = (int)strftime('%m', $row[2]);
$rep_end_year = (int)strftime('%Y', $row[2]);

switch($rep_type)
{
case 2:
case 6:
$rep_day[0] = $row[3][0] != "0";
$rep_day[1] = $row[3][1] != "0";
$rep_day[2] = $row[3][2] != "0";
$rep_day[3] = $row[3][3] != "0";
$rep_day[4] = $row[3][4] != "0";
$rep_day[5] = $row[3][5] != "0";
$rep_day[6] = $row[3][6] != "0";
if ($rep_type == 6)
{
$rep_num_weeks = $row[4];
}

break;

default:
$rep_day = array(0, 0, 0, 0, 0, 0, 0);
}
}
else
{
$rep_type = $row[0];
$rep_end_date = utf8_strftime('%A %d %B %Y',$row[2]);
$rep_opt = $row[3];
}
}
}
else
{
# It is a new booking. The data comes from whichever button the user clicked
$edit_type = "series";
$name = "";
$create_by = getUserName();
$description = "";
$start_day = $day;
$start_month = $month;
$start_year = $year;
$lavf = $lavf;
$lavl = $lavl;
$ampli = $ampli;
$proie = $proie;
$aconf = $aconf;
$vconf = $vconf;
$presi = $presi;
$puli = $puli;
// Avoid notices for $hour and $minute if periods is enabled
(isset($hour)) ? $start_hour = $hour : '';
(isset($minute)) ? $start_min = $minute : '';
$duration = ($enable_periods ? 60 : 60 * 60);
$type = "I";
$room_id = $room;
unset($id);
$rep_id = 0;
$rep_type = 0;
$rep_end_day = $day;
$rep_end_month = $month;
$rep_end_year = $year;
$rep_day = array(0, 0, 0, 0, 0, 0, 0);
}
# These next 4 if statements handle the situation where
# this page has been accessed directly and no arguments have
# been passed to it.
# If we have not been provided with a room_id
if( empty( $room_id ) )
{
$sql = "select id from $tbl_room limit 1";
$res = sql_query($sql);
$row = sql_row($res, 0);
$room_id = $row[0];
}
# If we have not been provided with starting time
if( empty( $start_hour ) && $morningstarts < 10 )
$start_hour = "0$morningstarts";
if( empty( $start_hour ) )
$start_hour = "$morningstarts";
if( empty( $start_min ) )
$start_min = "00";
// Remove "Undefined variable" notice
if (!isset($rep_num_weeks))
{
$rep_num_weeks = "";
}
$enable_periods ? toPeriodString($start_min, $duration, $dur_units) : toTimeString($duration, $dur_units);
#now that we know all the data to fill the form with we start drawing it
if(!getWritable($create_by, getUserName()))
{
showAccessDenied($day, $month, $year, $area);
exit;
}
print_header($day, $month, $year, $area);
?>
<SCRIPT LANGUAGE="JavaScript">
// do a little form verifying
function validate_and_submit ()
{
// null strings and spaces only strings not allowed
if(/(^$)|(^\s+$)/.test(document.forms["main"].name.value))
{
alert ( "<?php echo get_vocab("you_have_not_entered") . '\n' . get_vocab("brief_description") ?>");
return false;
}
<?php if( ! $enable_periods ) { ?>
h = parseInt(document.forms["main"].hour.value);
m = parseInt(document.forms["main"].minute.value);
if(h > 23 || m > 59)
{
alert ("<?php echo get_vocab("you_have_not_entered") . '\n' . get_vocab("valid_time_of_day") ?>");
return false;
}
<?php } ?>
// check form element exist before trying to access it
if( document.forms["main"].id )
i1 = parseInt(document.forms["main"].id.value);
else
i1 = 0;
i2 = parseInt(document.forms["main"].rep_id.value);
if ( document.forms["main"].rep_num_weeks)
{
n = parseInt(document.forms["main"].rep_num_weeks.value);
}
if ((!i1 || (i1 && i2)) && document.forms["main"].rep_type && document.forms["main"].rep_type[6].checked && (!n || n < 2))
{
alert("<?php echo get_vocab("you_have_not_entered") . '\n' . get_vocab("useful_n-weekly_value") ?>");
return false;
}
// check that a room(s) has been selected
// this is needed as edit_entry_handler does not check that a room(s)
// has been chosen
if( document.forms["main"].elements['rooms[]'].selectedIndex == -1 )
{
alert("<?php echo get_vocab("you_have_not_selected") . '\n' . get_vocab("valid_room") ?>");
return false;
}
// Form submit can take some times, especially if mails are enabled and
// there are more than one recipient. To avoid users doing weird things
// like clicking more than one time on submit button, we hide it as soon
// it is clicked.
document.forms["main"].save_button.disabled="true";
// would be nice to also check date to not allow Feb 31, etc...
document.forms["main"].submit();
return true;
}
function OnAllDayClick(allday) // Executed when the user clicks on the all_day checkbox.
{
form = document.forms["main"];
if (allday.checked) // If checking the box...
{
<?php if( ! $enable_periods ) { ?>
form.hour.value = "00";
form.minute.value = "00";
<?php } ?>
if (form.dur_units.value!="days") // Don't change it if the user already did.
{
form.duration.value = "1";
form.dur_units.value = "days";
}
}
}
</SCRIPT>
<h2><?php echo isset($id) ? ($edit_type == "series" ? get_vocab("editseries") : get_vocab("editentry")) : get_vocab("addentry"); ?></H2>
<FORM NAME="main" ACTION="edit_entry_handler.php" METHOD="GET">
<TABLE width="80%" BORDER=0>
<TR><TD width="48" CLASS=CR><?php echo get_vocab("namebooker")?></TD>
<TD width="619" colspan="3" CLASS=CL><INPUT NAME="name" SIZE=40 VALUE="<?php echo htmlspecialchars($name,ENT_NOQUOTES) ?>"></TD></TR>
<TR><TD CLASS=TR><?php echo get_vocab("fulldescription")?></TD>
<TD colspan="3" CLASS=TL><TEXTAREA NAME="description" ROWS=8 COLS=40 WRAP="virtual"><?php echo
htmlspecialchars ( $description ); ?></TEXTAREA></TD></TR>
<TR><TD CLASS=CR><?php echo get_vocab("date")?></TD>
<TD colspan="3" CLASS=CL>
<?php genDateSelector("", $start_day, $start_month, $start_year) ?> </TD>
</TR>
<?php if(! $enable_periods ) { ?>
<TR><TD CLASS=CR><?php echo get_vocab("time")?></TD>
<TD colspan="3" CLASS=CL><INPUT NAME="hour" SIZE=2 VALUE="<?php if (!$twentyfourhour_format && ($start_hour > 12)){ echo ($start_hour - 12);} else { echo $start_hour;} ?>" MAXLENGTH=2>:<INPUT NAME="minute" SIZE=2 VALUE="<?php echo $start_min;?>" MAXLENGTH=2>
<?php
if (!$twentyfourhour_format)
{
$checked = ($start_hour < 12) ? "checked" : "";
echo "<INPUT NAME=\"ampm\" type=\"radio\" value=\"am\" $checked>".utf8_strftime("%p",mktime(1,0,0,1,1,200 0));
$checked = ($start_hour >= 12) ? "checked" : "";
echo "<INPUT NAME=\"ampm\" type=\"radio\" value=\"pm\" $checked>".utf8_strftime("%p",mktime(13,0,0,1,1,20 00));
}
?></TD></TR>
<?php } else { ?>
<TR><TD CLASS=CR><?php echo get_vocab("period")?></TD>
<TD colspan="3" CLASS=CL>
<SELECT NAME="period">
<?php
foreach ($periods as $p_num => $p_val)
{
echo "<OPTION VALUE=$p_num";
if( ( isset( $period ) && $period == $p_num ) || $p_num == $start_min)
echo " SELECTED";
echo ">$p_val";
}
?>