\n"; } /*************************************************************************** * * Textfeld * ***************************************************************************/ function text($name, $value="",$size=0, $align="",$label="",$readonly="",$color="") { $ret = "0) { $ret=$ret."size=\"".$size."\" "; } if($align || $color) { $ret = $ret."style=\""; switch($align) { case 'c': $ret=$ret."text-align:center;"; break; case 'r': $ret=$ret."text-align:right;"; break; case 'l': $ret=$ret."text-align:left;"; break; } if($color) { $ret = $ret."background-color:".$color.";"; } $ret=$ret."\" "; } if($readonly) { $ret=$ret."readonly>"; } else { $ret=$ret.">"; } if($label) { $ret=$ret."\n"; } return $ret; } /*************************************************************************** * * Selection BOX * ***************************************************************************/ function selection($name, $stop, $start=0, $step=1, $selected="") { $ret = "\n"; return $ret; } /*************************************************************************** * * Formular absenden * ***************************************************************************/ function submit($name ,$size = 0) { if($size): return "\n"; else: return "\n"; endif; } /*************************************************************************** * * Browser History back * ***************************************************************************/ function back($name,$size=0) { return "\n"; } /*************************************************************************** * * Tabellenfeld * ***************************************************************************/ function field($name="",$align="",$color="", $spanne="") { $ret="".$name."\n"; return $ret; } /*************************************************************************** * * Knopf mit Verknpfung * ***************************************************************************/ function linkbutton($label,$link) { return "\n"; } /*************************************************************************** * * Leerzeichen abschneiden * ***************************************************************************/ function trim_value(&$value) { $value = trim($value); } /*************************************************************************** * * Umlaute an HTML anpassen * ***************************************************************************/ function umlaute(&$value) { global $myumlaute; global $replace; $value = preg_replace($myumlaute, $replace, $value); } /*************************************************************************** * * Datenbankverbindung herstellen * ***************************************************************************/ function open_con() { global $HOTEL_DB; global $HOTEL_DB_SERVER; global $HOTEL_DB_USER; global $HOTEL_DB_PW; global $debug; $con = @mysql_connect($HOTEL_DB_SERVER, $HOTEL_DB_USER, $HOTEL_DB_PW) or die("Keine Verbindung zur Datenbank"); mysql_query("SET NAMES 'latin1'", $con);// latin1 = Zeichensatz $db_check = @mysql_select_db($HOTEL_DB); if($debug) {echo "
open_con
mysql_error(): ". mysql_error()."
-open_con-
\n";} } // Funktion fertig gestellt am 08.02.2008 // Schreiben von Stings in die optionen Tabelle /*************************************************************************** * * Datenbank Tabelle Optionen schreiben * ***************************************************************************/ function set_option($ref, $val) { // Tabelle: ref, 'Wert', HotelID, 'refID' global $HOTEL_DB; global $HOTEL_ID; global $debug; $anfrage = "DELETE FROM optionen WHERE ((refID = \"$ref\") and (HotelID = $HOTEL_ID))"; $result = @mysql_db_query($HOTEL_DB, $anfrage); if($debug){ echo $result." set_option: ".$anfrage."
\n";} $anfrage = "INSERT INTO optionen (Wert, HotelID, refID) VALUES(\"" . utf8_encode($val) . "\", $HOTEL_ID, \"$ref\");"; $result = @mysql_db_query($HOTEL_DB, $anfrage); if($debug){ echo $result." set_option (UNICODE):" . $anfrage . "
\n";} if($debug){ echo "Fehler: ".$error."
\n";} return $error; } // Funktion fertig gestellt am 08.02.2008 // Schreiben von Stings in die optionen Tabelle /*************************************************************************** * * Datenbank Tabelle optionen lesen * ***************************************************************************/ function get_option($ref) { global $HOTEL_ID; global $debug; $result = get_tb_values("optionen", "((refID='$ref') and (HotelID=$HOTEL_ID))"); $ret = @mysql_result($result,0,'Wert'); if ($debug){ echo "get_option (UNICODE): ". $ret . "
\n";} return utf8_decode($ret); } /*************************************************************************** * * GastDaten in die Datenbank schreiben * * ***************************************************************************/ function set_gast($Anrede, $Vorname, $Nachname, $Strasse, $Stadt, $Land, $Tel, $Fax, $email, $ResNr, $Kredit, $Ablauf, $sicherheit, $Firma, $Bemerkung) { global $debug; global $HOTEL_ID; global $HOTEL_DB; $mysql = "INSERT INTO tb_gast (ID, Anrede, Vorname, Nachname, Strasse, Stadt, Land, Tel, Fax, email, ResNr, Kredit, Ablauf, sicherheit, Firmenanschrift, Bemerkung) VALUES ($HOTEL_ID, $Anrede, \"" . utf8_encode($Vorname) . "\", \"" . utf8_encode($Nachname) . "\", \"" . utf8_encode($Strasse) . "\", \"" . utf8_encode($Stadt) . "\", \"" . utf8_encode($Land) . "\", \"$Tel\", \"$Fax\", \"$email\", $ResNr, \"$Kredit\", \"$Ablauf\", \"$sicherheit\", \"" . utf8_encode($Firma) . "\", \"" . utf8_encode($Bemerkung) . "\");"; if($debug) echo "set_gast (UNICODE):" . $mysql . "
\n"; $result = @mysql_db_query($HOTEL_DB,$mysql); if($debug) {echo "set_Gast: result: $result
\n";} } function set_gast2($mycounter, $Anrede, $Vorname, $Nachname, $Strasse, $Stadt, $Land, $Tel, $Fax, $email, $ResNr, $Kredit, $Ablauf, $sicherheit, $Firma, $Bemerkung,$hid) { global $debug; global $HOTEL_DB; $mysql = "INSERT INTO tbgast (counter, ID, Anrede, Vorname, Nachname, Strasse, Stadt, Land, Tel, Fax, email, ResNr, Kredit, Ablauf, sicherheit, Firmenanschrift, Bemerkung) VALUES ($mycounter, $hid, $Anrede, \"" . utf8_encode($Vorname) . "\", \"" . utf8_encode($Nachname) . "\", \"" . utf8_encode($Strasse) . "\", \"" . utf8_encode($Stadt) . "\", \"" . utf8_encode($Land) . "\", \"$Tel\", \"$Fax\", \"$email\", $ResNr, \"$Kredit\", \"$Ablauf\", \"$sicherheit\", \"" . utf8_encode($Firma) . "\", \"" . utf8_encode($Bemerkung) . "\");"; if($debug) echo "set_gast2 (UNICODE):" . $mysql . "
\n"; $result = @mysql_db_query($HOTEL_DB,$mysql); if($debug) {echo "
set_Gast2:
\t result: $result
\t mysql_error(): ". mysql_error()."
\n";} } /*************************************************************************** * * GastDaten in die Datenbank schreiben * * ***************************************************************************/ function save_mail($save_email, $save_body) { global $debug; global $HOTEL_ID; global $HOTEL_DB; $mysql = "INSERT INTO gebuchteemails (hid, email, text) VALUES ($HOTEL_ID, \"" . utf8_encode($save_email) . "\", \"" . utf8_encode($save_body) . "\");"; if($debug) echo "save_mail (UNICODE):" . $mysql . "
\n"; $result = @mysql_db_query($HOTEL_DB,$mysql); if($debug) {echo "save_mail: result: $result
\n";} } // Allgemein lesen aus einer Tabelle // Rckgabewerte sind alle btreoffenen Tabelleneintrge /*************************************************************************** * * Datenbank alle Felder einer Tabelle lesen * ***************************************************************************/ function get_tb_values($tabelle, $bedingung) { global $HOTEL_DB; $result = @mysql_db_query($HOTEL_DB, "SELECT * FROM $tabelle WHERE $bedingung"); // @mysql_close(); return $result; } /*************************************************************************** * * Unterscheidung ... Sekunde, minute und Stunde = dann vorgabe * Wenn sekunde, Minute und Stunde gesetzt, dann Eintag vom Gast * Datum, hid, zart, zmenge, zpreis, minimum, stornobed, resbed, gid * 11.02.2009 erfolgreich getestet * ***************************************************************************/ function set_zimmer($start_stamp, $stop_stamp, $wochentage, $zart, $zmenge, $zpreis, $minimum, $stornobed, $resbed, $gid, $option1=0, $option2=0, $option3=0) { global $HOTEL_ID; global $debug; $i_d = date("j", $start_stamp); $i_m = date("n", $start_stamp); $i_y = date("y", $start_stamp); $i_h = date("H", $start_stamp); $diffdays=round(($stop_stamp-$start_stamp)/86400); for($i=0;$i<$diffdays;$i++) { $temp_stamp = mktime($i_h,$zart,$HOTEL_ID,$i_m,$i_d+$i,$i_y); $wtag = date("w",$temp_stamp)+1; if($debug){ echo "
set_zimmer: Suche: $wochentage - $wtag
";} if($debug){ echo "set_zimmer: strstr =:" . strstr($wochentage, strval($wtag)) . ":
";} if(strstr($wochentage, strval($wtag))<>"") { do_update("zimmer","$temp_stamp, $HOTEL_ID, $zart, $zmenge, $zpreis, $minimum, $stornobed, $resbed, $gid, $option1, option2, option3", "Datum=$temp_stamp, hid=$HOTEL_ID, zart=$zart, zmenge=$zmenge, zpreis=$zpreis, minimum=$minimum, stornobed=\"$stornobed\", resbed=\"$resbed\", gid=$gid, option1=$option1, option2=$option2, option3=$option3"); } } // @mysql_close(); } /*************************************************************************** * * Unterscheidung ... Sekunde, minute und Stunde = dann vorgabe * Wenn sekunde, Minute und Stunde gesetzt, dann Eintag vom Gast * Datum, hid, zart, zmenge, zpreis, minimum, stornobed, resbed, gid * 11.02.2009 erfolgreich getestet * ***************************************************************************/ /* function update_zimmer($start_stamp, $stop_stamp, $wochentage, $zart, $zmenge, $zpreis, $minimum=0, $stornobed=0, $resbed=0, $gid=0, $option1=0, $option2=0, $option3=0) { global $HOTEL_ID; global $HOTEL_DB; global $debug; $i_d = date("j", $start_stamp); $i_m = date("n", $start_stamp); $i_y = date("y", $start_stamp); $i_h = date("H", $start_stamp); $diffdays=round(($stop_stamp-$start_stamp)/86400); for($i=0;$i<$diffdays;$i++) { $temp_stamp = mktime($i_h,$zart,$HOTEL_ID,$i_m,$i_d+$i,$i_y); $wtag = date("w",$temp_stamp)+1; if($debug){ echo "
update_zimmer: Suche: $wochentage - $wtag
";} if($debug){ echo "update_zimmer: strstr =:" . strstr($wochentage, strval($wtag)) . ":
";} if(strstr($wochentage, strval($wtag))<>"") { // bisherige Werte fr ein Zimmer lesen $anfrage = "SELECT * FROM zimmer WHERE ((datum = $temp_stamp) and (hid=$HOTEL_ID) and (gid=$gid));"; if($debug) {echo "update_zimmer: SQL: $anfrage
\n";} $result = @mysql_db_query($HOTEL_DB, $anfrage); // gelesene Werte in einen Array schreiben $i=0; for($i = 0; $array[$i] = @mysql_fetch_assoc($result); $i++) ; if ($debug) {echo "update_zimmer: Alte Werte lesen: "; print_r($array); echo "
\n";} // Letzter Eintrag ist leer, lschen array_pop($array); // Werte aktuallisieren if ($zart) {$array[0]['zart'] = $zart;} if ($zmenge!="") {$array[0]['zmenge'] = $zmenge;} if ($zpreis!="") {$array[0]['zpreis'] = $zpreis;} if ($minimum) {$array[0]['minimum'] = $minimum;} if ($stornobed){$array[0]['stornobed']= $stornobed;} if ($resbed) {$array[0]['resbed'] = $resbed;} if ($gid) {$array[0]['gid'] = $gid;} if ($option1) {$array[0]['option1'] = $option1;} if ($option2) {$array[0]['option2'] = $option2;} if ($option3) {$array[0]['option3'] = $option3;} if ($array[0]['zart']=="") {$array[0]['zart'] = 0;} if ($array[0]['zmenge']=="") {$array[0]['zmenge'] = 0;} if ($array[0]['zpreis']=="") {$array[0]['zpreis'] = 0;} if ($array[0]['minimum']=="") {$array[0]['minimum'] = 0;} if ($array[0]['stornobed']==""){$array[0]['stornobed']= 0;} if ($array[0]['resbed']=="") {$array[0]['resbed'] = 0;} if ($array[0]['gid']=="") {$array[0]['gid'] = 0;} if ($array[0]['option1']=="") {$array[0]['option1'] = 0;} if ($array[0]['option2']=="") {$array[0]['option2'] = 0;} if ($array[0]['option3']=="") {$array[0]['option3'] = 0;} if ($debug) {echo "update_zimmer: Alte Werte aktuallisiert:"; print_r($array);echo "
\n";} // neue Werte setzten do_update("zimmer","$temp_stamp, $HOTEL_ID, ".$array[0]['zart'].", ".$array[0]['zmenge'].", ".$array[0]['zpreis'].", ".$array[0]['minimum'].", ".$array[0]['stornobed'].", ".$array[0]['resbed'].", ".$array[0]['gid'].", ".$array[0]['option1'].", ".$array[0]['option2'].", ". $array[0]['option3'], "Datum=$temp_stamp, hid=$HOTEL_ID, zart=".$array[0]['zart'].", zmenge=".$array[0]['zmenge'].", zpreis=".$array[0]['zpreis'].", minimum=".$array[0]['minimum'].", stornobed=".$array[0]['stornobed'].", resbed=".$array[0]['resbed'].", gid=".$array[0]['gid'].", option1=".$array[0]['option1'].", option2=".$array[0]['option2'].", option3=".$array[0]['option3']); } } // @mysql_close(); } function update__zimmer($start_stamp, $stop_stamp, $wochentage, $zart, $zmenge, $zpreis, $minimum=0, $stornobed=0, $resbed=0, $gid=0, $option1=0, $option2=0, $option3=0) { global $HOTEL_ID; global $HOTEL_DB; global $debug; $i_d = date("j", $start_stamp); $i_m = date("n", $start_stamp); $i_y = date("y", $start_stamp); $i_h = date("H", $start_stamp); if($debug) {echo "Start: $start_stamp (" . date("H:i:s d.m.Y",$start_stamp) . ") - Stop: $stop_stamp (" . date("H:i:s d.m.Y", $stop_stamp) . ")
\n";} $diffdays=round(($stop_stamp-$start_stamp)/86400); // bisherige Werte fr ein Zimmer lesen $anfrage = "SELECT * FROM zimmer WHERE ((datum >= $start_stamp) and (datum <= $stop_stamp) and (zart=$zart) and (hid=$HOTEL_ID) and (gid=$gid));"; if($debug) {echo "update__zimmer: SQL: $anfrage
\n";} $result = @mysql_db_query($HOTEL_DB, $anfrage); // gelesene Werte in einen Array schreiben $i=0; for($i = 0; $array[$i] = @mysql_fetch_assoc($result); $i++) ; if ($debug) {echo "update__zimmer: Alte Werte lesen: "; print_r($array); echo "
\n";} // Letzter Eintrag ist leer, lschen array_pop($array); if($debug) {echo "gelesene Arraygre: ". sizeof($array) . " diffdays: " . $diffdays;} for($i=0;$i<$diffdays;$i++) { $temp_stamp = mktime($i_h,$zart,$HOTEL_ID,$i_m,$i_d+$i,$i_y); $wtag = date("w",$temp_stamp); if($debug) {echo "
update__zimmer: Suche: $wochentage - $wtag
";} if($debug) {echo "update__zimmer: strstr =:" . strstr($wochentage, strval($wtag)) . ":
";} if(strstr($wochentage, strval($wtag))<>"") { if ($debug) {echo "update__zimmer: Alte Werte:"; print_r($array[$i]); echo "
\n";} $nix = ""; if ($array[$i]['zart']=="") {$array[$i]['zart'] = 0;$nix = $nix . " art";} if ($array[$i]['zmenge']=="") {$array[$i]['zmenge'] = 0;$nix = $nix . " menge";} if ($array[$i]['zpreis']=="") {$array[$i]['zpreis'] = 0;$nix = $nix . " preis";} if ($array[$i]['minimum']=="") {$array[$i]['minimum'] = 0;$nix = $nix . " min";} if ($array[$i]['stornobed']==""){$array[$i]['stornobed']= 0;$nix = $nix . " storno";} if ($array[$i]['resbed']=="") {$array[$i]['resbed'] = 0;$nix = $nix . " res";} if ($array[$i]['gid']=="") {$array[$i]['gid'] = 0;$nix = $nix . " gid";} if ($array[$i]['option1']=="") {$array[$i]['option1'] = 0;$nix = $nix . " opt1";} if ($array[$i]['option2']=="") {$array[$i]['option2'] = 0;$nix = $nix . " opt2";} if ($array[$i]['option3']=="") {$array[$i]['option3'] = 0;$nix = $nix . " opt3";} // Werte aktuallisieren $neu = ""; if($debug) {echo $array[$i]['zpreis'] . " = " . $zpreis;} if ($zart) {$array[$i]['zart'] = $zart; $neu = $neu . " art";} if ($zmenge>=0 and $zmenge!="") {$array[$i]['zmenge'] = $zmenge; $neu = $neu . " menge";} if ($zpreis>=0 and $zpreis!="") {$array[$i]['zpreis'] = $zpreis; $neu = $neu . " preis";} if($debug) {echo $array[$i]['zpreis'] . " = " . $zpreis;} if ($minimum) {$array[$i]['minimum'] = $minimum; $neu = $neu . " min";} if ($stornobed){$array[$i]['stornobed']= $stornobed; $neu = $neu . " storno";} if ($resbed) {$array[$i]['resbed'] = $resbed; $neu = $neu . " resbed";} if ($gid) {$array[$i]['gid'] = $gid; $neu = $neu . " gid";} if ($option1) {$array[$i]['option1'] = $option1; $neu = $neu . " opt1";} if ($option2) {$array[$i]['option2'] = $option2; $neu = $neu . " opt2";} if ($option3) {$array[$i]['option3'] = $option3; $neu = $neu . " opt3";} if($array[$i]['datum']) $temp_stamp = $array[$i]['datum']; if ($debug) {echo "gendert: neu:$neu
\nnix:$nix
\n";} if ($debug) {echo "update__zimmer: Neue Werte ARR (" . date("H:i:s d.m.Y",$array[$i]['datum']) . ") TEMP (" . date("H:i:s d.m.Y",$temp_stamp) . "): "; print_r($array[$i]);} // $mysql = "DELETE FROM zimmer WHERE datum=" . $array[$i]['datum']; // $result = @mysql_db_query($HOTEL_DB, $mysql); // neue Werte setzten do_update("zimmer","$temp_stamp, $HOTEL_ID, ".$array[$i]['zart'].", ".$array[$i]['zmenge'].", ".$array[$i]['zpreis'].", ".$array[$i]['minimum'].", ".$array[$i]['stornobed'].", ".$array[$i]['resbed'].", ".$array[$i]['gid'].", ".$array[$i]['option1'].", ".$array[$i]['option2'].", ". $array[$i]['option3'], "Datum=$temp_stamp, hid=$HOTEL_ID, zart=".$array[$i]['zart'].", zmenge=".$array[$i]['zmenge'].", zpreis=".$array[$i]['zpreis'].", minimum=".$array[$i]['minimum'].", stornobed=".$array[$i]['stornobed'].", resbed=".$array[$i]['resbed'].", gid=".$array[$i]['gid'].", option1=".$array[$i]['option1'].", option2=".$array[$i]['option2'].", option3=".$array[$i]['option3']); } } // @mysql_close(); } */ /* Zimmer einstellungen incl abreise tag */ function update3zimmer($start_stamp, $stop_stamp, $wochentage, $zart, $zmenge, $zpreis, $minimum=0, $stornobed=0, $resbed=0, $gid=0, $option1=0, $option2=0, $option3=0) { global $HOTEL_ID; global $HOTEL_DB; global $debug; $i_d = date("j", $start_stamp); $i_m = date("n", $start_stamp); $i_y = date("y", $start_stamp); $i_h = date("H", $start_stamp); if($debug) {echo "
update3zimmer";}
	if($debug)  {echo "	Start: $start_stamp (" . date("H:i:s d.m.Y",$start_stamp) . ") - Stop: $stop_stamp (" . date("H:i:s d.m.Y", $stop_stamp) . ")
\n";} // Anzahl der Tage die gespeichert werden $diffdays=round(($stop_stamp-$start_stamp)/86400)+1; // bisherige Werte fr ein Zimmer lesen $anfrage = "SELECT * FROM zimmer WHERE ((datum >= $start_stamp) and (datum <= $stop_stamp) and (zart=$zart) and (hid=$HOTEL_ID) and (gid=$gid));"; $result = @mysql_db_query($HOTEL_DB, $anfrage); // gelesene Werte in einen Array schreiben $i=0; for($i = 0; $array[$i] = @mysql_fetch_assoc($result); $i++) ; // Letzter Eintrag ist leer, lschen array_pop($array); if($debug){ echo " SQL: $anfrage
\n"; echo " Alte Werte lesen: "; print_r($array); echo "
\n"; echo " gelesene Arraygre: ". sizeof($array) . " diffdays: " . $diffdays . "
\n"; } // Hilfsarray mit Standardwerten $array_help['datum']=NULL; $array_help['hid']=$HOTEL_ID; $array_help['zart']=0; $array_help['zmenge']=0; $array_help['zpreis']=0; $array_help['minimum']=0; $array_help['stornobed']=0; $array_help['resbed']=0; $array_help['gid']=0; $array_help['option1']=0; $array_help['option2']=0; $array_help['option3']=0; // Arbeitsarray, bernimmt bekannte Werte ndert diese und schreibt sie in die Datenbank $array_work = $array_help; // Problem - Chronolgie!! // Wenn nicht der letzte wochentag fehlt wird falsch eingetragen // Zhler fr Arraygre $j=0; for($i=0;$i<$diffdays;$i++) { // Datum fr den genderten Eintrag $id = $i_d+$i; $temp_stamp = mktime(12,$zart,$HOTEL_ID,$i_m,$i_d+$i,$i_y); // Wochentag bestimmen $wtag = date("w",$temp_stamp); // Datum des Arrayeintrages bestimmen $a_d = date("j", $array[$j]['datum']); $a_m = date("n", $array[$j]['datum']); $a_y = date("y", $array[$j]['datum']); if($id==$a_d AND $i_m==$a_m AND $i_y==$a_y) { // Array passt zum datum if($debug){echo " Alten Array Wert bernehen";} $array_work = $array[$j]; // beim nchsten durchlauf nchsten array eintrag prfen $j += 1; } else { if($debug) {echo " Hilfsarray einfgen";} // datum stimmt nicht berein, neuen Hilfsarray generieren $array_work = $array_help; } if($debug) {echo "
Suche Wochentag: $wochentage - $wtag
";} if($debug) {echo " Wochentag gefunden (strstr) =:" . strstr($wochentage, strval($wtag)) . ":
";} // Nur wenn der wochentag zu speichern ist if(strstr($wochentage, strval($wtag))<>"") { if ($debug) {echo " Alte Werte: array_work:"; print_r($array_work); echo "
\n";} $nix = ""; if ($array_work['zart']=="") {$array_work['zart'] = 0;$nix = $nix . " art";} if ($array_work['zmenge']=="") {$array_work['zmenge'] = 0;$nix = $nix . " menge";} if ($array_work['zpreis']=="") {$array_work['zpreis'] = 0;$nix = $nix . " preis";} if ($array_work['minimum']=="") {$array_work['minimum'] = 0;$nix = $nix . " min";} if ($array_work['stornobed']==""){$array_work['stornobed']= 0;$nix = $nix . " storno";} if ($array_work['resbed']=="") {$array_work['resbed'] = 0;$nix = $nix . " res";} if ($array_work['gid']=="") {$array_work['gid'] = 0;$nix = $nix . " gid";} if ($array_work['option1']=="") {$array_work['option1'] = 0;$nix = $nix . " opt1";} if ($array_work['option2']=="") {$array_work['option2'] = 0;$nix = $nix . " opt2";} if ($array_work['option3']=="") {$array_work['option3'] = 0;$nix = $nix . " opt3";} // Werte aktuallisieren $neu = ""; if($debug) {echo " Preistest" . $array_work['zpreis'] . " = " . $zpreis . "
";} if ($zart) {$array_work['zart'] = $zart; $neu = $neu . " art";} if ($zmenge>=0 and $zmenge!="") {$array_work['zmenge'] = $zmenge; $neu = $neu . " menge";} if ($zpreis>=0 and $zpreis!="") {$array_work['zpreis'] = $zpreis; $neu = $neu . " preis";} if($debug) {echo $array_work['zpreis'] . " = " . $zpreis;} if ($minimum) {$array_work['minimum'] = $minimum; $neu = $neu . " min";} if ($stornobed){$array_work['stornobed']= $stornobed; $neu = $neu . " storno";} if ($resbed) {$array_work['resbed'] = $resbed; $neu = $neu . " resbed";} if ($gid) {$array_work['gid'] = $gid; $neu = $neu . " gid";} if ($option1!="") {$array_work['option1'] = $option1; $neu = $neu . " opt1";} if ($option2!="") {$array_work['option2'] = $option2; $neu = $neu . " opt2";} if ($option3!="") {$array_work['option3'] = $option3; $neu = $neu . " opt3";} if($array_work['datum']) $temp_stamp = $array_work['datum']; if ($debug) {echo " gendert: neu:$neu
\nnix:$nix
\n";} if ($debug) {echo " Neue Werte ARR (" . date("H:i:s d.m.Y",$array_work['datum']) . ") TEMP (" . date("H:i:s d.m.Y",$temp_stamp) . "): "; print_r($array[$i]);} // neue Werte setzten do_update("zimmer", "$temp_stamp, $HOTEL_ID, ".$array_work['zart'].", ".$array_work['zmenge'].", ".$array_work['zpreis'].", ".$array_work['minimum'].", ".$array_work['stornobed'].", ".$array_work['resbed'].", ".$array_work['gid'].", ".$array_work['option1'].", ".$array_work['option2'].", ". $array_work['option3'], "Datum=$temp_stamp, hid=$HOTEL_ID, zart=".$array_work['zart'].", zmenge=".$array_work['zmenge'].", zpreis=".$array_work['zpreis'].", minimum=".$array_work['minimum'].", stornobed=".$array_work['stornobed'].", resbed=".$array_work['resbed'].", gid=".$array_work['gid'].", option1=".$array_work['option1'].", option2=".$array_work['option2'].", option3=".$array_work['option3']); } } if($debug) {echo "-update3zimmer-
";} } /* Zimmer einstellungen incl abreise tag */ function update4zimmer($start_stamp, $stop_stamp, $wochentage, $zart, $zmenge, $zpreis, $minimum=0, $stornobed=0, $resbed=0, $gid=0, $option1=0, $option2=0, $option3=0) { global $HOTEL_ID; global $HOTEL_DB; global $debug; $i_d = date("j", $start_stamp); $i_m = date("n", $start_stamp); $i_y = date("y", $start_stamp); $i_h = date("H", $start_stamp); if($debug) {echo "
update4zimmer";}
	if($debug)  {echo "	Start: $start_stamp (" . date("H:i:s d.m.Y",$start_stamp) . ") - Stop: $stop_stamp (" . date("H:i:s d.m.Y", $stop_stamp) . ")
\n";} // Anzahl der Tage die gespeichert werden $diffdays=round(($stop_stamp-$start_stamp)/86400)+1; // bisherige Werte fr ein Zimmer lesen $anfrage = "SELECT * FROM zimmer WHERE ((datum >= $start_stamp) and (datum <= $stop_stamp) and (zart=$zart) and (hid=$HOTEL_ID) and (gid=$gid));"; $result = @mysql_db_query($HOTEL_DB, $anfrage); // gelesene Werte in einen Array schreiben $i=0; for($i = 0; $array[$i] = @mysql_fetch_assoc($result); $i++) ; // Letzter Eintrag ist leer, lschen array_pop($array); if($debug){ echo " SQL: $anfrage
\n"; echo " Alte Werte lesen: "; print_r($array); echo "
\n"; echo " gelesene Arraygre: ". sizeof($array) . " diffdays: " . $diffdays . "
\n"; } // Hilfsarray mit Standardwerten $array_help['datum']=NULL; $array_help['hid']=$HOTEL_ID; $array_help['zart']=0; $array_help['zmenge']=0; $array_help['zpreis']=0; $array_help['minimum']=0; $array_help['stornobed']=0; $array_help['resbed']=0; $array_help['gid']=0; $array_help['option1']=0; $array_help['option2']=0; $array_help['option3']=0; // Arbeitsarray, bernimmt bekannte Werte ndert diese und schreibt sie in die Datenbank $array_work = $array_help; // Problem - Chronolgie!! // Wenn nicht der letzte wochentag fehlt wird falsch eingetragen // Zhler fr Arraygre $j=0; for($i=0;$i<$diffdays;$i++) { // Datum fr den genderten Eintrag $id = $i_d+$i; $temp_stamp = mktime(12,$zart,$HOTEL_ID,$i_m,$i_d+$i,$i_y); // Wochentag bestimmen $wtag = date("w",$temp_stamp); // Datum des Arrayeintrages bestimmen $a_d = date("j", $array[$j]['datum']); $a_m = date("n", $array[$j]['datum']); $a_y = date("y", $array[$j]['datum']); // Mit Datenbankwerten oder Standardwerten fortfahren if($id==$a_d AND $i_m==$a_m AND $i_y==$a_y) { // Array passt zum datum if($debug){echo " Alten Array Wert bernehen";} $array_work = $array[$j]; // beim nchsten durchlauf nchsten array eintrag prfen $j += 1; } else { if($debug) {echo " Hilfsarray einfgen";} // datum stimmt nicht berein, neuen Hilfsarray generieren $array_work = $array_help; } if($debug) {echo "
Suche Wochentag: $wochentage - $wtag
";} if($debug) {echo " Wochentag gefunden (strstr) =:" . strstr($wochentage, strval($wtag)) . ":
";} // Nur wenn der wochentag zu speichern ist if(strstr($wochentage, strval($wtag))<>"") { if ($debug) {echo " Alte Werte: array_work:"; print_r($array_work); echo "
\n";} $nix = ""; if ($array_work['zart']=="") {$array_work['zart'] = 0;$nix = $nix . " art";} if ($array_work['zmenge']=="") {$array_work['zmenge'] = 0;$nix = $nix . " menge";} if ($array_work['zpreis']=="") {$array_work['zpreis'] = 0;$nix = $nix . " preis";} if ($array_work['minimum']=="") {$array_work['minimum'] = 0;$nix = $nix . " min";} if ($array_work['stornobed']==""){$array_work['stornobed']= 0;$nix = $nix . " storno";} if ($array_work['resbed']=="") {$array_work['resbed'] = 0;$nix = $nix . " res";} if ($array_work['gid']=="") {$array_work['gid'] = 0;$nix = $nix . " gid";} if ($array_work['option1']=="") {$array_work['option1'] = 0;$nix = $nix . " opt1";} if ($array_work['option2']=="") {$array_work['option2'] = 0;$nix = $nix . " opt2";} if ($array_work['option3']=="") {$array_work['option3'] = 0;$nix = $nix . " opt3";} // Werte aktuallisieren $neu = ""; if($debug) {echo " Preistest" . $array_work['zpreis'] . " = " . $zpreis . "
";} if ($zart) {$array_work['zart'] = $zart; $neu = $neu . " art";} if ($zmenge>=0 and $zmenge!="") {$array_work['zmenge'] = $zmenge; $neu = $neu . " menge";} if ($zpreis>=0 and $zpreis!="") {$array_work['zpreis'] = $zpreis; $neu = $neu . " preis";} if($debug) {echo $array_work['zpreis'] . " = " . $zpreis;} if ($minimum) {$array_work['minimum'] = $minimum; $neu = $neu . " min";} if ($stornobed){$array_work['stornobed']= $stornobed; $neu = $neu . " storno";} if ($resbed) {$array_work['resbed'] = $resbed; $neu = $neu . " resbed";} if ($gid) {$array_work['gid'] = $gid; $neu = $neu . " gid";} if ($option1!="") {$array_work['option1'] = $option1; $neu = $neu . " opt1";} if ($option2!="") {$array_work['option2'] = $option2; $neu = $neu . " opt2";} if ($option3!="") {$array_work['option3'] = $option3; $neu = $neu . " opt3";} if($array_work['datum']) $temp_stamp = $array_work['datum']; if ($debug) {echo " gendert: neu:$neu
\nnix:$nix
\n";} if ($debug) {echo " Neue Werte ARR (" . date("H:i:s d.m.Y",$array_work['datum']) . ") TEMP (" . date("H:i:s d.m.Y",$temp_stamp) . "): "; print_r($array[$i]);} // neue Werte setzten do_update("zimmer", "$temp_stamp, $HOTEL_ID, ".$array_work['zart'].", ".$array_work['zmenge'].", ".$array_work['zpreis'].", ".$array_work['minimum'].", ".$array_work['stornobed'].", ".$array_work['resbed'].", ".$array_work['gid'].", ".$array_work['option1'].", ".$array_work['option2'].", ". $array_work['option3'], "Datum=$temp_stamp, hid=$HOTEL_ID, zart=".$array_work['zart'].", zmenge=".$array_work['zmenge'].", zpreis=".$array_work['zpreis'].", minimum=".$array_work['minimum'].", stornobed=".$array_work['stornobed'].", resbed=".$array_work['resbed'].", gid=".$array_work['gid'].", option1=".$array_work['option1'].", option2=".$array_work['option2'].", option3=".$array_work['option3']); } } if($debug) {echo "-update3zimmer-
";} } /*************************************************************************** * * Liest Zeile aus der Zimmertabelle * zimmerart(zart) 0= keine Wahl => alle zimmerarten * gsteID (gid) wenn leer keine Buchung * 11.02.09 zart=0, gid="" getestet * ***************************************************************************/ function get_zimmer($unix_von, $unix_bis, $zart, $gid) { global $HOTEL_DB; global $HOTEL_ID; global $debug; if ($gid<>0){$sql = "SELECT * FROM zimmer WHERE ((gid = '$gid') and (hid = $HOTEL_ID))";} else { if ($zart==0){$sql = "SELECT * FROM zimmer WHERE ((datum >= $unix_von) and (datum <= $unix_bis) and (hid = $HOTEL_ID) and (gid = 0))";} else{$sql = "SELECT * FROM zimmer WHERE ((datum >= $unix_von) and (datum <= $unix_bis) and (zart = $zart) and (hid = $HOTEL_ID) and (gid = 0))";} } $sql = $sql . " ORDER BY datum ASC, zart ASC;"; if($debug) {echo "get_zimmer: $sql

\n";} $result = @mysql_db_query($HOTEL_DB, $sql); if($debug) {echo "
get_zimmer
sql: $sql
result: $result
mysql_error(): ". mysql_error()."
-get_zimmer-
\n";} return $result; } /*************************************************************************** * * Ersetzen oder einfgen von Zeilen in eine Tabelle * 11.02.2009 erfolgreich getestet * ***************************************************************************/ function do_update($tabelle, $spaltenwerte, $einfuegen) { global $HOTEL_DB; global $debug; $mysql = "INSERT INTO $tabelle VALUES ($spaltenwerte) ON DUPLICATE KEY UPDATE $einfuegen"; $result = @mysql_db_query($HOTEL_DB, $mysql); if($debug) {echo "
do_update
SQL: ". $mysql . "
result: $result
-do_update-
\n";} } /*************************************************************************** * * Ersetzen oder einfgen von Zeilen in eine Tabelle * 11.02.2009 erfolgreich getestet * ***************************************************************************/ function do_del($tabelle, $bedingung) { global $HOTEL_DB; global $debug; $mysql = "DELETE FROM $tabelle WHERE $bedingung"; if($debug) echo "do_del: $mysql
\n"; $result = @mysql_db_query($HOTEL_DB, $mysql); if($debug) {echo "do_del: result: $result
\n";} } /*************************************************************************** * * Liest Werte aus der Datenbank und schreibt sie in einen Array * * ***************************************************************************/ function db2array($anfrage) { global $HOTEL_DB; global $debug; $arr=array(); $result = @mysql_db_query($HOTEL_DB, $anfrage); // Werte in Array schreiben $i=0; for($i = 0; $arr[$i] = mysql_fetch_assoc($result); $i++) ; array_pop($arr); if($debug) {echo "db2array($anfrage)=>
\n\n"; print_r($arr);echo "
\n\n";} return $arr; } /*************************************************************************** * * unterschied zwischen tagen bestimmen * * ***************************************************************************/ function datediff($interval, $datefrom, $dateto, $using_timestamps = false) { /* $interval can be: yyyy - Number of full years q - Number of full quarters m - Number of full months y - Difference between day numbers (eg 1st Jan 2004 is "1", the first day. 2nd Feb 2003 is "33". The datediff is "-32".) d - Number of full days w - Number of full weekdays ww - Number of full weeks h - Number of full hours n - Number of full minutes s - Number of full seconds (default) */ if (!$using_timestamps) { $datefrom = strtotime($datefrom, 0); $dateto = strtotime($dateto, 0); } $difference = $dateto - $datefrom; // Difference in seconds switch($interval) { case 'yyyy': // Number of full years $years_difference = floor($difference / 31536000); if (mktime(date("H", $datefrom), date("i", $datefrom), date("s", $datefrom), date("n", $datefrom), date("j", $datefrom), date("Y", $datefrom)+$years_difference) > $dateto) { $years_difference--; } if (mktime(date("H", $dateto), date("i", $dateto), date("s", $dateto), date("n", $dateto), date("j", $dateto), date("Y", $dateto)-($years_difference+1)) > $datefrom) { $years_difference++; } $datediff = $years_difference; break; case "q": // Number of full quarters $quarters_difference = floor($difference / 8035200); while (mktime(date("H", $datefrom), date("i", $datefrom), date("s", $datefrom), date("n", $datefrom)+($quarters_difference*3), date("j", $dateto), date("Y", $datefrom)) < $dateto) { $months_difference++; } $quarters_difference--; $datediff = $quarters_difference; break; case "m": // Number of full months $months_difference = floor($difference / 2678400); while (mktime(date("H", $datefrom), date("i", $datefrom), date("s", $datefrom), date("n", $datefrom)+($months_difference), date("j", $dateto), date("Y", $datefrom)) < $dateto) { $months_difference++; } $months_difference--; $datediff = $months_difference; break; case 'y': // Difference between day numbers $datediff = date("z", $dateto) - date("z", $datefrom); break; case "d": // Number of full days $datediff = floor(($difference / 86400)+0.3); break; case "w": // Number of full weekdays $days_difference = floor($difference / 86400); $weeks_difference = floor($days_difference / 7); // Complete weeks $first_day = date("w", $datefrom); $days_remainder = floor($days_difference % 7); $odd_days = $first_day + $days_remainder; // Do we have a Saturday or Sunday in the remainder? if ($odd_days > 7) { // Sunday $days_remainder--; } if ($odd_days > 6) { // Saturday $days_remainder--; } $datediff = ($weeks_difference * 5) + $days_remainder; break; case "ww": // Number of full weeks $datediff = floor($difference / 604800); break; case "h": // Number of full hours $datediff = floor($difference / 3600); break; case "n": // Number of full minutes $datediff = floor($difference / 60); break; default: // Number of full seconds (default) $datediff = $difference; break; } return $datediff; } /*************************************************************************** * * Tage hinzuaddieren * * ***************************************************************************/ function dayadd($user_timestamp, $days) { return $user_timestamp + $day * 24 * 60 * 60; } /*************************************************************************** * * Kreditkarten Test Funktion * Tested, ob die bergeben Nummer reel mglich sein kann * ***************************************************************************/ function Kredittest($Kartennummer) { $wechsel = false; $Karte = "unbekanntes Institut"; $nichterlaubt = array(" ", "-", ".", ",", ";", ":", "_"); $Kartennummer = str_replace($nichterlaubt, "", $Kartennummer); switch(strlen($Kartennummer)) { case 13: //VISA $Karte = "VISA Karte"; if (substr($Kartennummer, 0, 1) <> "4") {return -1;} break; case 14: //DinersClub/CarteBlanche $Karte = "Diners Club / Carte Blanche Karte"; if (substr($Kartennummer, 0, 3) < 300 || substr($Kartennummer,0, 3) > 305) { if (!(substr($Kartennummer, 0, 2) == "36" || substr($Kartennummer, 0, 2) == "38")) { return -2; } } break; case 15: //AMEX/enRoute/JCB if (substr($Kartennummer, 0, 4) == "2131" || substr($Kartennummer, 0, 4) == "1800") { $Karte = "JCB Karte"; } elseif (substr($Kartennummer, 0, 4) == "2014" || substr($Kartennummer, 0, 4) == "2149") { $Karte = "enRoute Karte"; } elseif (substr($Kartennummer, 0, 2) == "34" || substr($Kartennummer, 0, 2) == "37") { $Karte = "AMEX Karte"; } else { return -3; } break; case 16: //MC/VISA/DISCOVER/JCB if (substr($Kartennummer, 0, 4) == 6011) { $Karte = "Discover Karte"; } elseif (substr($Kartennummer, 0, 2) >= 51 And substr($Kartennummer, 0, 2) <= 55) { $Karte = "Maste Karte"; } elseif (substr($Kartennummer, 0, 1) == "3") { $Karte = "JCB Karte"; } elseif (substr($Kartennummer, 0, 1) == "4") { $Karte = "VISA Karte"; } else { return -4; } break; default: return -5; } for($i = strlen($Kartennummer)-1; $i = 0 ;$i--) { $digit = substr($Kartennummer, i, 1); if ($wechsel) { $digit = $digit * 2; switch($digit) { case 10: $digit = 1;break; case 12: $digit = 3;break; case 14: $digit = 5;break; case 16: $digit = 7;break; case 18: $digit = 9;break; } } $wechsel = !$wechsel; $summe = $summe + $digit; } if ($summe % 10) {return -6;} return $Karte; } function date2unix($datum) { global $debug; $toconv = preg_replace("#([0-9]{2})\.([0-9]{2})\.([0-9]{4})#","\\3-\\2-\\1",$datum); if($debug) echo $datum." - ".$toconv."
\n"; return strtotime(preg_replace("#([0-9]{2})\.([0-9]{2})\.([0-9]{4})#","\\3-\\2-\\1",$datum)); } function readWebBrowser($id) { global $HOTEL_DB; global $debug; $result = @mysql_db_query($HOTEL_DB, "SELECT * FROM web WHERE id='" . $id . "'"); $ret = @mysql_result($result,0,'info'); if($debug) {echo "
readWebBrowser
SQL: ". $mysql . "
result: $result
return: $ret
mysql_error(): ". mysql_error()."
-readWebBrowser-
\n";} return $ret; } function writeWebBrowser($id, $info) { global $HOTEL_DB; global $debug; $mysql = "INSERT INTO web (id, info) VALUES ('$id' , '$info') ON DUPLICATE KEY UPDATE id='" . $id . "', info='" . $info ."'"; $result = @mysql_db_query($HOTEL_DB, $mysql); if($debug) {echo "
writeWebBrowser
SQL: ". $mysql . "
result: $result
mysql_error(): ". mysql_error()."
-writeWebBrowser-
\n";} } ?> Hotel Classic Inn Hotel Classic Inn Heildeberg - Belfortstrasse 3 - 69115 Heidelberg - Tel. +49 (0)6221 1 38 32 3 - 0 <br> www.hotel-classic-inn.de - hotel@hotel-classic-inn.de <br> Herzlich Willkommen auf unserer Seite. Weiter mit <a href='home.html'>Start Seite</a>