På mit bookingsystem har jeg brug for at checke om der allerede er foretaget en booking i samme tidsrum, når brugeren vil tilføje en ny booking.
Eks. hvis der er booket 10.45 - 13.00, skal det ikke kunne lade sig gøre at booke 11.30 - 13.00, men brugeren have en fejlmeddelse.
Jeg har tænkt mig, at jeg vil checke disse: title, from_, from2_, till, still.
Håber at der er en der kan hjælpe mig igang.
Bookingsystemet er en del af et portalsystem.
For nemheds skyld lægger jeg hele scriptet her:
<?php
include_once("core/main.php");
// this is forced here for security reasons
if( !check_module("events2") ) die( "module not enabled" );
require_once("phpdbform/phpdbform_form.php");
$index_page = false;
$page_name = $lang["EVENTS2_ADD"];
draw_header();
$ok_add="N";
if( $cfg["events2"]["useradd1"] )
{
if( $cfg["events2"]["useradd"] )
{
$ok_add="Y";
}
}
if( $cfg["events2"]["useradd"] )
{
if( $_SESSION["wt"]["logged"] )
{ $ok_add="Y"; }
}
if( $ok_add=="N" )
{
theme_draw_centerbox_open( $lang["EVENTS2_ADD"] );
print "<span class=\\"error\\">{$lang["EVENTS2_NOT_ADD"]}</span>";
theme_draw_centerbox_close();
draw_footer();
exit;
}
else
{
$form = new phpform( "addevent2", "add_event2.php" );
$form->add_static_listbox( "title", $lang["EVENTS2_A_TITLE"], "Bus1, Bus2");
$form->add_date( "date", $lang["EVENTS2_A_DATE"], $cfg["core"]["date_format"] );
$form->fields["date"]->value = date("Y-m-d");
$form->add_static_listbox( "from_", $lang["EVENTS2_A_FROM"], "00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,");
$form->add_static_listbox( "from2_", $lang["EVENTS2_A_FROM2"], "00,15,30,45");
$form->add_static_listbox( "till", $lang["EVENTS2_A_TIL"], "00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24");
$form->add_static_listbox( "still", $lang["EVENTS2_A_STIL"], "00,15,30,45");
$form->add_textbox( "who", $lang["EVENTS2_A_WHO"] , 40, 255 );
$form->add_textarea( "add_desc", $lang["EVENTS2_A_ADDDESC"], 40, 5 );
theme_draw_centerbox_open( $lang["EVENTS2_ADD"] );
$ok = false;
$errors = array();
if( $form->process() )
{
if( !isset($_SESSION["wt"]["addevent2"]) )
{
$form->fields["title"]->value = trim(strip_tags($form->fields["title"]->value));
$form->fields["date"]->value = trim(strip_tags($form->fields["date"]->value));
$form->fields["from_"]->value = trim(strip_tags($form->fields["from_"]->value));
$form->fields["from2_"]->value = trim(strip_tags($form->fields["from2_"]->value));
$form->fields["till"]->value = trim(strip_tags($form->fields["till"]->value));
$form->fields["still"]->value = trim(strip_tags($form->fields["still"]->value));
$form->fields["who"]->value = trim(strip_tags($form->fields["who"]->value));
$form->fields["add_desc"]->value = trim(strip_tags($form->fields["add_desc"]->value));
$form->fields["location"]->value = trim(strip_tags($form->fields["location"]->value));
if( !empty($errors) )
{
print "<div class=\\"error\\">";
while( $err = each($errors) )
{
print "{$err[1]}<br>\\n";
}
print "</div>\\n";
} else $ok = true;
if( $ok )
{
$stmt = "insert into {$config["prefix"]}_events2 set"
." title = '".addslashes($form->fields["title"]->value)."',"
." date = '".addslashes($form->fields["date"]->value)."',"
." active = 'Y',"
." from_ = '".addslashes($form->fields["from_"]->value)."',"
." from2_ = '".addslashes($form->fields["from2_"]->value)."',"
." till = '".addslashes($form->fields["till"]->value)."',"
." still = '".addslashes($form->fields["still"]->value)."',"
." who = '".addslashes($form->fields["who"]->value)."',"
." userid ='".$_SESSION[wt][uid]."',"
." add_desc = '".addslashes($form->fields["add_desc"]->value)."',"
." location = '".addslashes($form->fields["location"]->value)."'";
$ret = db_query( $stmt );
if( !$ret )
{
$ok = false;
print "<div class=\\"error\\">".$lang["ERROR_04"]."<br>".db_error()."</div>";
} else {
if( $cfg["events2"]["sendmail"] )
{
print "<div class=\\"info\\">".$lang[EVENTS2_ADD_OK]."</div>";
mail($cfg["core"]["mail_admin"], $lang["EVENTS2_M_01"], $lang["EVENTS2_M_02"]."\\n\\n".$cfg["core"]["url"],"From: ".$cfg["core"]["mail_admin"]."\\n");
}
$_SESSION["wt"]["addevent2"] = true;
}
}
} else $ok = true;
} else {
if( isset($_SESSION["wt"]["addevent2"]) ) unset($_SESSION["wt"]["addevent2"]);
}
if( !$ok ) $form->draw();
theme_draw_centerbox_close();
theme_draw_centerbox_open( $lang["EVENTS_LIST_EVENTS"] );
events2_draw_list();
theme_draw_centerbox_close();
draw_footer();
}
?>
2 svar postet i denne tråd vises herunder
1 indlæg har modtaget i alt 4 karma