Advertisement
Guest User

Untitled

a guest
Aug 20th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 80.80 KB | None | 0 0
  1. <?php
  2. class Zibepla {
  3. # Datenbank Objekt
  4. var $db;
  5.  
  6. # Settings Objekt
  7. var $sets;
  8.  
  9. # Language Objekt
  10. var $lang;
  11.  
  12. # Editor Objekt
  13. var $editor;
  14.  
  15. # Editiermode
  16. var $edit = FALSE;
  17.  
  18. # Objekt ID
  19. var $obj_id = 0;
  20.  
  21. # Jahr
  22. var $year = 0;
  23.  
  24. # Belegungsdaten
  25. var $dates = array();
  26.  
  27. # Belegungsstatus
  28. var $status = array();
  29.  
  30. # Ab- und Anreisetage
  31. var $depjou_deys = array();
  32.  
  33. # Neue Belegungsdaten
  34. var $new_dates = array();
  35.  
  36. # Neue Belegungsstatus
  37. var $new_status = array();
  38.  
  39. # Beginndatum (Buchungsform)
  40. var $begin_date = '';
  41.  
  42. # Enddatum (Buchungsform)
  43. var $end_date = '';
  44.  
  45. # Letzte Änderung
  46. var $last_edit = 0;
  47.  
  48. # Array mit Bearbeiter Namen
  49. var $editors = array();
  50. var $passwords = array();
  51.  
  52. # Die Belegungsplan-Tabelle
  53. var $table = '';
  54.  
  55. # Punkt
  56. var $html_point = '<font face="symbol">&#183;</font>';
  57.  
  58. # Linie
  59. var $html_line = '<div style="margin:1px; padding-top:0px; padding-bottom:1px; border-bottom:solid 1px #999999"></div>';
  60.  
  61. # Tabellen Linie
  62. var $tab_line = 'onMouseOver="this.bgColor=getOverColor(this);" onMouseOut="this.bgColor=getOutColor(this);" onMouseDown="this.bgColor=getDownColor(this);"';
  63.  
  64. # Status des Buchungsformulars (edit/new)
  65. var $form_status = '';
  66.  
  67. # Wird bei Simulation auf true gesetzt
  68. var $simulation = FALSE;
  69.  
  70.  
  71. # HTML Tooltips
  72. var $tooltips = array();
  73.  
  74. # Bestimmt ob Bearbeiter auf fremde objekte sehen dürfen
  75. var $view_other_objects = FALSE;
  76.  
  77. # Konstruktor
  78. function Zibepla (&$sets, &$lang, &$db, &$editor, $object_id = 0, $status = ''){
  79. $qid = 'Zibepla::Zibepla';
  80.  
  81. $this->sets = &$sets;
  82. $this->lang = &$lang;
  83. $this->editor = &$editor;
  84. $this->db = &$db;
  85.  
  86. # Plan ID
  87. if ($object_id != 0) { $this->obj_id = $object_id; }
  88. elseif (is_numeric ($_POST['object_id'])) { $this->obj_id = $_POST['object_id']; }
  89. elseif (is_numeric ($_GET['id'])) { $this->obj_id = $_SESSION['obj_id'] = $_GET['id']; }
  90. else{
  91. if (is_numeric ($_SESSION['obj_id']))
  92. $this->obj_id = $_SESSION['obj_id'];
  93. else $this->obj_id = $this->sets->Get('standard_object_id');
  94. }
  95.  
  96. # Year
  97. if (is_numeric ($_GET['year'])){
  98. $this->year = $_SESSION['year'] = $_GET['year'];
  99. }
  100. else{
  101. if (is_numeric ($_SESSION['year']))
  102. $this->year = $_SESSION['year'];
  103. else $this->year = date ('Y');
  104. }
  105.  
  106. # Letzte Änderungsdatum
  107. $this->LastEdit();
  108.  
  109. # Editiermodus
  110. if ($this->editor->IsAdmin() || $this->editor->GetId() > 0){
  111. if ($status != '')
  112. $this->edit = $status;
  113. else $this->edit = $_POST['datatype'];
  114. }
  115.  
  116. # Bearbeiter laden
  117. $sql = "SELECT * FROM " . TBL_EDITORS . " ORDER BY editor_id ASC";
  118. $this->db->query($sql, $qid);
  119. while ($this->db->next_record($qid)){
  120. $this->editors[$this->db->f('editor_id', $qid)] = $this->db->f('login', $qid);
  121. $this->passwords[$this->db->f('login', $qid)] = $this->db->f('password', $qid);
  122. }
  123. }
  124.  
  125. # Lädt die Belegungsdaten
  126. function Load (){
  127. $qid = 'Zibepla::Load';
  128.  
  129. # Variablen zurück setzen
  130. $this->dates = $this->status = array();
  131.  
  132. $sql = "SELECT * FROM " . TBL_RESERVATIONS . " WHERE object_id = '" . $this->obj_id . "' ORDER BY departure ASC";
  133. $this->db->query ($sql, $qid);
  134. while ($this->db->next_record($qid)){
  135. $datefrom = format_datums($this->db->f('journey', $qid));
  136. $datetill = format_datums($this->db->f('departure', $qid));
  137. $nstatus = '';
  138.  
  139. #echo "\n \n<!-- enddate in mas = " . $this->dates[count($this->dates)-1] . " / datefrom = " . date("Y-m-d",$datefrom) . " -->\n \n";
  140.  
  141. if (format_datums($this->dates[count($this->dates)-1]) == $datefrom){
  142.  
  143. if(($this->db->f('status', $qid) == 'R')&&($this->status[$this->dates[count($this->dates)-1]] == 'RE')){
  144. $nstatus = 'R';
  145. }
  146. elseif(($this->db->f('status', $qid) == 'R')&&($this->status[$this->dates[count($this->dates)-1]] == 'OE')){
  147. $nstatus = 'OR';
  148. }
  149. elseif(($this->db->f('status', $qid) == 'O')&&($this->status[$this->dates[count($this->dates)-1]] == 'RE')){
  150. $nstatus = 'RO';
  151. }
  152. elseif(($this->db->f('status', $qid) == 'O')&&($this->status[$this->dates[count($this->dates)-1]] == 'OE')){
  153. $nstatus = 'O';
  154. }
  155. elseif(($this->db->f('status', $qid) == 'R')&&($this->db->f('one_day') == 'Y')){
  156. $nstatus = 'ODR';
  157. }
  158. elseif(($this->db->f('status', $qid) == 'O')&&($this->db->f('one_day') == 'Y')){
  159. $nstatus = 'ODO';
  160. }
  161.  
  162. unset($this->status[$this->dates[count($this->dates)-1]]);
  163. unset($this->dates[count($this->dates)-1]);
  164.  
  165. $temp_array = $this->dates = array_values($this->dates);
  166. }
  167.  
  168. $dstatus = date('I', $datefrom);
  169.  
  170. for ($curdate = $datefrom; $curdate <= $datetill; $curdate += 86400){
  171. # Korrektur für die Schalttage
  172. if ($dstatus > date('I', $curdate)) {
  173. $curdate += 3600;
  174. $dstatus = date('I', $curdate);
  175. }
  176. elseif ($dstatus < date('I', $curdate)) {
  177. $curdate -= 3600;
  178. $dstatus = date('I', $curdate);
  179. }
  180.  
  181. $this->dates[] = date("Y-m-d",$curdate);
  182. if ($curdate == $datefrom){
  183. if ($nstatus != ''){
  184. $this->status[date("Y-m-d",$curdate)] = $nstatus;
  185. } else
  186. if($this->db->f('status', $qid) == 'R'){
  187. $this->status[date("Y-m-d",$curdate)] = 'RB';
  188. }else $this->status[date("Y-m-d",$curdate)] = 'OB';
  189. } else
  190. if ($curdate == $datetill){
  191. if($this->db->f('status', $qid) == 'R'){
  192. $this->status[date("Y-m-d",$curdate)] = 'RE';
  193. }else $this->status[date("Y-m-d",$curdate)] = 'OE';
  194. } else $this->status[date("Y-m-d",$curdate)] = $this->db->f('status', $qid);
  195. // One day
  196. if ($this->status[date("Y-m-d",$curdate)] == 'RB' && $this->db->f('one_day',$qid) == 'Y'){
  197. $this->status[date("Y-m-d",$curdate)] = 'ODR';
  198. }
  199.  
  200. if ($this->status[date("Y-m-d",$curdate)] == 'OB' && $this->db->f('one_day', $qid) == 'Y'){
  201. $this->status[date("Y-m-d",$curdate)] = 'ODO';
  202. }
  203.  
  204. #if ($shortday) $curdate += 3600;
  205. }
  206. }
  207. # Ab- und Anreisetage
  208. $this->depjou_deys = array();
  209. $sql = "SELECT departure FROM " . TBL_RESERVATIONS . " WHERE object_id = '" . $this->GetID() . "'";
  210. $this->db->query ($sql, $qid);
  211. $departures = array();
  212. while ($this->db->next_record($qid))
  213. $departures[] = $this->db->f('departure', $qid);
  214. $departures_list = "('" . implode ("','", $departures) . "')";
  215. $sql = "SELECT journey FROM " . TBL_RESERVATIONS . " WHERE journey IN "
  216. . $departures_list . " AND object_id = '" . $this->GetID() . "'";
  217. $this->db->query ($sql, $qid);
  218. while ($this->db->next_record($qid))
  219. $this->depjou_deys[] = $this->db->f('journey', $qid);
  220. }
  221.  
  222. # Letzte Änderung
  223. function LastEdit (){
  224. $qid = 'Zibepla::LastEdit';
  225.  
  226. $sql = "SELECT last_edit FROM " . TBL_TIMES . " WHERE object_id = '" . $this->obj_id . "'";
  227. $this->db->query ($sql, $qid);
  228. if ($this->db->next_record($qid))
  229. $this->last_edit = $this->db->f('last_edit', $qid);
  230. else $this->last_edit = time();
  231. }
  232.  
  233. # Erstellt die Tabelle - je nach Ansichtsweise
  234. function CreateLayout(){
  235. $qid = 'Zibepla::CreateLayout';
  236.  
  237. # Wenn Object über GET bestimmt sind
  238. if ((isset ($_GET['objects']) || isset ($_SESSION['objects'])) && !isset ($_GET['group']) && $_GET['view'] != 'yearly'){
  239. $_SESSION['view'] = 'monthly';
  240. }
  241. # Wenn Gruppe über GET bzw. SESSION bestimmt ist/wurde
  242. elseif ((isset ($_GET['group']) || isset ($_SESSION['group'])) && $_GET['view'] != 'yearly'){
  243. # Sitzungsvariablen initialisieren
  244. $_SESSION['view'] = 'monthly';
  245. if (isset ($_GET['group'])) $_SESSION['group'] = $_GET['group'];
  246.  
  247. # Objekte, die dieser Gruppen ID zugehören
  248. $sql = "SELECT object_id FROM " . TBL_OBJ_SETTINGS . " WHERE object_group = '" . $_SESSION['group'] . "'";
  249. $this->db->query($sql, $qid); $objects = array();
  250. while ($this->db->next_record($qid))
  251. $objects[] = $this->db->f('object_id', $qid);
  252.  
  253. $object_names = $this->lang->ObjNames();
  254. $sort_funcname = ($this->sets->Get('object_order') == 'object_id') ? 'ksort' : 'asort';
  255. $sort_funcname ($object_names);
  256. $view_objects = array();
  257.  
  258. foreach ($object_names AS $object_id => $object_name)
  259. if (in_array ($object_id, $objects)) $view_objects[] = $object_id;
  260. $_GET['objects'] = $_SESSION['objects'] = implode (',', $view_objects);
  261.  
  262. $groups = $this->lang->ObjGroups();
  263. $_SESSION['group_name'] = (isset ($_GET['group_name'])) ? $_GET['group_name'] : $groups[$_SESSION['group']];
  264. }
  265. # Andere Möglichketen
  266. else{
  267. if ($_GET['view'] == 'monthly') $_SESSION['view'] = 'monthly';
  268. elseif ($_GET['view'] == 'yearly'){
  269. $_SESSION['view'] = 'yearly';
  270. unset ($_SESSION['objects']);
  271. unset ($_SESSION['group']);
  272. }
  273. }
  274. # Entsprechendes Layout erstellen
  275. if ($_SESSION['view'] == 'monthly')
  276. $this->CreateMonthly();
  277. else $this->CreateYearly();
  278. }
  279.  
  280. # Erstellt die Tabelle mit Monatsübersicht
  281. function CreateMonthly (){
  282. # Session
  283. global $ssn, $granted_objects;
  284.  
  285. # Leiste mit Tagen
  286. $days_border = $this->CreateDaysBorder();
  287.  
  288. # Objekte
  289. if (isset ($_GET['objects'])) $_SESSION['objects'] = $_GET['objects'];
  290. $objects = explode (',', $_SESSION['objects']);
  291. if (COUNT($objects) < 1){
  292. $object_names = $this->lang->ObjNames();
  293. $sort_funcname = ($this->sets->Get('object_order') == 'object_id') ? 'ksort' : 'asort';
  294. $sort_funcname ($object_names);
  295. $objects = array_keys ($object_names);
  296. $_SESSION['objects'] = implode (',', $objects);
  297. }
  298.  
  299. # Monat
  300. if (isset ($_GET['month'])) $_SESSION['month'] = (strlen ($_GET['month']) < 2) ? ('0' . $_GET['month']) : $_GET['month'];
  301. $month = (!empty ($_SESSION['month'])) ? $_SESSION['month'] : $_SESSION['month'] = date('m');
  302.  
  303. # Plan-Body
  304. foreach ((array)$objects AS $obj){
  305. if (is_array($granted_objects) && !in_array($obj, $granted_objects) && $this->editor->GetId() > 0)
  306. continue;
  307. # Objekt id setzen
  308. $this->obj_id = $obj;
  309. # Daten laden
  310. $this->Load();
  311. # Zeilenanfang
  312. $body .= '<tr>';
  313. # Monat
  314. $body .= $this->CreateObjectTD ($obj);
  315. # Tage
  316. for ($day = 1; $day <= 31; $day++)
  317. $body .= $this->CreateDayTD ($month, $day);
  318. # Zeilenende
  319. $body .= '</tr>';
  320. }
  321.  
  322. # Tabelle zusammensetzen
  323. $this->table = '<table class="' . $this->sets->Get('table_css_class')
  324. . '" width="' . $this->sets->Get('table_width')
  325. . '" border="' . $this->sets->Get('table_border')
  326. . '" cellspacing="' . $this->sets->Get('table_cellspacing')
  327. . '" cellpadding="' . $this->sets->Get('table_cellpadding')
  328. . '" align="' . $this->sets->Get('table_align')
  329. . '" bgcolor="#' . $this->sets->Get('table_bgcolor') . '">'
  330. . '<tr>' . $days_border . '</tr>'
  331. . $body . $days_border;
  332.  
  333. # Editor Navigationselemente
  334. if (!PRINT_MODUS) $this->CreateEditElements ();
  335.  
  336. # Formular- und Tabellenende
  337. $this->table .= '</table>';
  338.  
  339. # Monatsnavigation
  340. $this->MonthNavigation();
  341. }
  342.  
  343. # Erstellt die Tabelle mit Jahresübersicht
  344. function CreateYearly (){
  345. # Session
  346. global $ssn;
  347.  
  348. # Leiste mit Tagen
  349. $days_border = $this->CreateDaysBorder();
  350.  
  351. # Plan-Body
  352. for ($mon = 1; $mon <= 12; $mon++){
  353. # Zeilenanfang
  354. $body .= '<tr>';
  355. # Monat
  356. $body .= $this->CreateMonthTD ($mon);
  357. # Tage
  358. for ($day = 1; $day <= 31; $day++)
  359. $body .= $this->CreateDayTD ($mon, $day);
  360. # Zeilenende
  361. $body .= '</tr>';
  362. }
  363.  
  364. # Tabelle zusammensetzen
  365. $this->table = '<table class="' . $this->sets->Get('table_css_class')
  366. . '" width="' . $this->sets->Get('table_width')
  367. . '" border="' . $this->sets->Get('table_border')
  368. . '" cellspacing="' . $this->sets->Get('table_cellspacing')
  369. . '" cellpadding="' . $this->sets->Get('table_cellpadding')
  370. . '" align="' . $this->sets->Get('table_align')
  371. . '" bgcolor="#' . $this->sets->Get('table_bgcolor') . '">'
  372. . '<tr>' . $days_border . '</tr>'
  373. . $body . $days_border;
  374.  
  375. # Editor Navigationselemente
  376. if (!PRINT_MODUS) $this->CreateEditElements();
  377.  
  378. # Formular- und Tabellenende
  379. $this->table .= '</table>';
  380. }
  381.  
  382. # Initialisiert die Belegungsplan-Tabelle für Edit
  383. function CreateEditElements (){
  384. # Session
  385. global $ssn, $granted_objects;
  386.  
  387. # Logout Link
  388. if ($this->editor->GetId() != 0 && !$this->editor->IsAdmin()){
  389. $logout_link = Admin::LogoutLink($this->lang->Get('logout_word'));
  390. $logout_td = '<td>&nbsp;</td><td class="formSubmit">' . $logout_link . '</td><td>&nbsp;</td>';
  391.  
  392. if ((is_array ($granted_objects) && in_array ($this->GetId(), $granted_objects)) || $this->view_other_objects)
  393. $reservation_form_link = '<td class="formSubmit" ' . $rlink . '>' . $this->ReservationFormLink() . '</td>';
  394. else $reservation_form_link = '';
  395. }
  396. elseif($this->editor->IsAdmin() || $this->editor->GetId() > 0){
  397. $reservation_form_link = '<td class="formSubmit" ' . $rlink . '>' . $this->ReservationFormLink() . '</td>';
  398. $w1 = $w2 = '50%';
  399. }
  400. else {
  401. $w1 = '100%';
  402. $w2 = '';
  403. }
  404.  
  405. $visor = ($this->editor->IsAdmin() || $this->editor->GetId() > 0) ? true : false;
  406.  
  407. # Buttons
  408. $this->table .= '<tr><td colspan="32"><table width="100%" border="0" cellpadding="0" cellspacing="0">'
  409. . '<tr><td>' . (($visor) ? $this->ObjectNavigation() : $this->UserObjectNavigation()) . '</td>'
  410. . '<td width="100%"><table border="0" cellpadding="0" cellspacing="0"><tr><td width="' . $w1 . '">&nbsp;</td>'
  411. . (($visor) ? '<td>{PLI}</td>' : '') . '<td>{PLA}</td>' . (($visor) ? '<td>{PAL}</td>' : '') . '<td width="' . $w2 . '">&nbsp;</td></tr></table></td>'
  412. . $reservation_form_link
  413. . $logout_td
  414. . '</tr></table></td></tr>';
  415. }
  416.  
  417. # Objektnavigation für Administrator und Bearbeiter
  418. function ObjectNavigation (){
  419. $qid = 'Zibepla::ObjectNavigation';
  420.  
  421. global $ssn, $granted_objects;
  422.  
  423. # Gruppen mit Bezeichnungen
  424. $groups = $this->lang->ObjGroups();
  425. asort ($groups);
  426. $granted_objects_list = "('" . implode ("','", (array)$granted_objects) . "')";
  427.  
  428. $sql = "SELECT DISTINCT(object_group) FROM " . TBL_OBJ_SETTINGS;
  429. if (!$this->editor->IsAdmin())
  430. $sql .= " WHERE object_id IN " . $granted_objects_list;
  431.  
  432. $this->db->query ($sql, $qid);
  433. $granted_groups = array();
  434. while ($this->db->next_record($qid))
  435. if ($this->db->f('object_group', $qid) > 0)
  436. $granted_groups[] = $this->db->f('object_group', $qid);
  437.  
  438. # Gruppen options
  439. foreach ($groups AS $group_id => $group_name){
  440. if (in_array($group_id, $granted_groups) || $this->view_other_objects){
  441. $selected = ($_SESSION['group'] == $group_id && $_SESSION['view'] != 'yearly') ? 'selected' : '';
  442. $group_select .= '<option style="color:#006600" value="group_' . $group_id . '" ' . $selected . '>' . $this->lang->Get('object_group_word') . ': ' . $group_name . '</option>';
  443. }
  444. }
  445.  
  446. # Objekte mit Bezeichnungen
  447. $names = $this->lang->ObjNames();
  448. $sort_funcname = ($this->sets->Get('object_order') == 'object_id') ? 'ksort' : 'asort';
  449. $sort_funcname ($names);
  450.  
  451. # Objekte Options
  452. foreach ($names AS $object_id => $object_name){
  453. if ((is_array($granted_objects) && in_array($object_id, $granted_objects)) || $this->view_other_objects || $this->editor->IsAdmin()){
  454. $selected = (($_SESSION['obj_id'] == $object_id || $this->obj_id == $object_id) && $_SESSION['view'] != 'monthly') ? 'selected' : '';
  455. $object_select .= '<option value="' . $object_id . '" ' . $selected . '>' . $this->lang->Get('object_word') . ': ' . $object_name . '</option>';
  456. }
  457. }
  458.  
  459. # Objekte ohne Bezeichnungen options
  460. $object_ids = array_keys ($names);
  461. $objects_list = "('" . implode ("','", (array)$object_ids) . "')";
  462. $sql = "SELECT DISTINCT(object_id) FROM " . TBL_RESERVATIONS . " WHERE object_id NOT in "
  463. . $objects_list . " ORDER BY object_id ASC";
  464. $this->db->query ($sql, $qid);
  465. while ($this->db->next_record($qid)){
  466. $object_id = $this->db->f('object_id', $qid);
  467. if ((is_array($granted_objects) && in_array($object_id, $granted_objects)) || $this->view_other_objects || $this->editor->IsAdmin()){
  468. $selected = ($_SESSION['obj_id'] == $object_id && $_SESSION['view'] != 'monthly') ? 'selected' : '';
  469. $object_select .= '<option value="' . $object_id . '">'
  470. . $this->lang->Get('noname_object') . ' ' . $object_id . '</option>';
  471. }
  472. }
  473.  
  474. # Return
  475. $select = $group_select . $object_select;
  476. return $this->ObjectNavigationForm($select);
  477. }
  478.  
  479. # Objektnavigation für Besucher
  480. function UserObjectNavigation (){
  481. $qid = 'Zibepla::UserObjectNavigation';
  482.  
  483. $sql = "SELECT DISTINCT(obj.object_id), obj.object_group, ln_obj.value as obj_name, ln_group.value as obj_group_name FROM " . TBL_OBJ_SETTINGS . " AS obj "
  484. . "LEFT JOIN " . TBL_LANGUAGES . " AS ln_obj "
  485. . " ON concat('obj_name_', obj.object_id) = ln_obj.variable AND ln_obj.language = '" . $this->lang->Lang() . "' "
  486. . "LEFT JOIN " . TBL_LANGUAGES . " AS ln_group "
  487. . " ON concat('obj_group_name_', obj.object_group) = ln_group.variable AND ln_group.language = '" . $this->lang->Lang() . "' "
  488. . " WHERE enable_search = 'Y' GROUP BY obj.object_id"
  489. . " ORDER BY obj_group_name, obj_name ASC";
  490.  
  491. $this->db->query($sql, $qid);
  492. $options = $cur_group = '';
  493. while ($this->db->next_record($qid)){
  494. if ($this->db->f('obj_group_name', $qid) == null){
  495. $object_id = $this->db->f('object_id', $qid);
  496. $name = ' - ' . $this->db->f('obj_name', $qid);
  497. $selected = ($_SESSION['obj_id'] == $object_id && $_SESSION['view'] == 'yearly') ? 'selected' : '';
  498. $options .= '<option ' . $selected . ' value="' . $object_id . '">' . $name . '</option>';
  499. }
  500. elseif ($cur_group != $this->db->f('object_group', $qid)){
  501. $group_id = $cur_group = $this->db->f('object_group', $qid);
  502. $name = $this->db->f('obj_group_name', $qid);
  503. $selected = ($_SESSION['group'] == $group_id && $_SESSION['view'] != 'yearly') ? 'selected' : '';
  504. $options .= '<option ' . $selected . ' value="group_' . $group_id . '">' . $name . '</option>';
  505. }
  506. if ($this->db->f('obj_group_name', $qid) != null) {
  507. $object_id = $this->db->f('object_id', $qid);
  508. $name = ' - ' . $this->db->f('obj_name', $qid);
  509. $selected = ($_SESSION['obj_id'] == $object_id && $_SESSION['view'] == 'yearly') ? 'selected' : '';
  510. $options .= '<option ' . $selected . ' value="' . $object_id . '">' . $name . '</option>';
  511. }
  512. }
  513.  
  514. return $this->ObjectNavigationForm($options);
  515. }
  516.  
  517. # Erstellt Formular für Objektnavigation
  518. function ObjectNavigationForm ($select){
  519. global $ssn;
  520. # Formular
  521. return '<table border="0" cellpadding="0" cellspacing="0"><form action="' . $ssn->Url($_SERVER['PHP_SELF'])
  522. . '" method="get"><tr><td nowrap>'
  523. . '<div class="text">' . $this->lang->Get('yearly_view_for_object')
  524. . ':&nbsp;&nbsp;</div></td><td><select name="id">' . $select . '</select></td>'
  525. . '<td>&nbsp;</td><td><input type="submit" class="formSubmit" name="submit_view" value="'
  526. . $this->lang->Get('execute_word') . '"><input type="hidden" name="view" value="yearly">'
  527. . '</td></tr></form></table>';
  528. }
  529.  
  530. # Erstellt Leiste mit Tagen von Links nach Rechts
  531. function CreateDaysBorder (){
  532. for ($day = 1; $day <= 31; $day++) {
  533. $wn_day = (strlen($day) == 1) ? '0' . $day : $day;
  534. $days_color = $this->sets->Get('days_text_color', FALSE);
  535. # Gestylter Text
  536. $day_text = (!empty ($days_color))
  537. ? '<span class="text" style="color:#' . $days_color . '">' . $wn_day . '</span>'
  538. : '<span class="text">' . $wn_day . '</span>';
  539. # Border
  540. $border .= '<td align="center" width="' . $this->sets->Get('field_width') . '" bgcolor="' . $this->sets->Get('days_bg_color') . '">' . $day_text . '</td>';
  541. }
  542.  
  543. # Return
  544. return '<td width="' . $this->sets->Get('month_td_width') . '">&nbsp;</td>' . $border;
  545. }
  546.  
  547. # Erstellt ein TD HTML-Element mit dem Monat
  548. function CreateMonthTD ($mon){
  549. $wn_mon = (strlen($mon) == 1) ? '0' . $mon : $mon;
  550. $months_color = $this->sets->Get('months_text_color', FALSE);
  551. $month_text = (!empty ($months_color))
  552. ? '<span class="text" style="color:#' . $months_color . '">&nbsp;' . $this->lang->Get('month_' . $wn_mon) . '&nbsp;</span>'
  553. : '<span class="text">&nbsp;' . $this->lang->Get('month_' . $wn_mon) . '&nbsp;</span>';
  554. $td = '<td height="' . $this->sets->Get('field_height') . '" align="' . $this->sets->Get('month_align') . '" '
  555. . 'bgcolor="' . $this->sets->Get('months_bg_color') . '">' . $month_text . '</td>';
  556.  
  557. # Return
  558. return $td;
  559. }
  560.  
  561. # Erstellt ein TD HTML-Element mit dem Objekt (bei monthly view)
  562. function CreateObjectTD ($obj){
  563. $objects_color = $this->sets->Get('months_text_color', FALSE);
  564. $object_text = (!empty ($objects_color))
  565. ? '<span class="text" style="color:#' . $objects_color . '">&nbsp;' . $this->lang->Get('obj_name_' . $obj) . '&nbsp;</span>'
  566. : '<span class="text">&nbsp;' . $this->lang->Get('obj_name_' . $obj) . '&nbsp;</span>';
  567. $td = '<td nowrap height="' . $this->sets->Get('field_height') . '" align="' . $this->sets->Get('month_align') . '" '
  568. . 'bgcolor="' . $this->sets->Get('months_bg_color') . '">' . $object_text . '</td>';
  569.  
  570. # Return
  571. return $td;
  572. }
  573.  
  574. # Erstellt ein TD HTML-Element für ein Tag in dem Tabellenkörper
  575. function CreateDayTD ($mon, $day){
  576. $wn_day = (strlen($day) == 1) ? '0' . $day : $day;
  577. $wn_mon = (strlen($mon) == 1) ? '0' . $mon : $mon;
  578.  
  579. if (checkdate($wn_mon, $wn_day, $this->year) && $this->GetYear() >= 1970 && $this->GetYear() < 2038){
  580. $date = $this->year . '-' . $wn_mon . '-'. $wn_day;
  581. # Date Status
  582. if(in_array ($date, $this->dates))
  583. $date_status = $this->status[$date];
  584. else $date_status = 'FR';
  585. }
  586. else {
  587. $date_status = 'ND';
  588. }
  589.  
  590. # Ab- und Anreisetag
  591. if (in_array ($date, $this->depjou_deys)){
  592. $occupied_background = 'background="' . $this->sets->Get('occupied_depjou_image') . '"';
  593. $reserved_background = 'background="' . $this->sets->Get('reserved_depjou_image') . '"';
  594. $in = '';
  595. }
  596. else{
  597. $occupied_background = 'bgcolor="#' . $this->sets->Get('occupied_bg_color') . '"';
  598. $reserved_background = 'bgcolor="#' . $this->sets->Get('reserved_bg_color') . '"';
  599. }
  600.  
  601. # TD-Element erstellen
  602. switch ($date_status){
  603. # Kein Tag, Frei
  604. case 'ND': $td = '<td class="t" bgcolor="#'.$this->sets->Get('noday_bg_color').'">' . $in . '</td>'; break;
  605. case 'FR': $td = '<td class="t" bgcolor="#'.$this->sets->Get('free_bg_color').'">' . $in . '</td>'; break;
  606. # Belegt, Belegungsbeginn, etc..
  607. case 'O': $td = '<td class="t" '.$occupied_background.'>' . $in . '</td>'; break;
  608. case 'OB': $td = '<td class="t" background="'.$this->sets->Get('occupied_begin_image').'">' . $in . '</td>'; break;
  609. case 'OE': $td = '<td class="t" background="'.$this->sets->Get('occupied_end_image').'">' . $in . '</td>'; break;
  610. case 'RO': $td = '<td class="t" background="'.$this->sets->Get('reserved_occupied_image').'">' . $in . '</td>'; break;
  611. # Reserviert, Reservierungsbeginn, etc..
  612. case 'R': $td = '<td class="t" '.$reserved_background.'>' . $in . '</td>'; break;
  613. case 'RB': $td = '<td class="t" background="'.$this->sets->Get('reserved_begin_image').'">' . $in . '</td>'; break;
  614. case 'RE': $td = '<td class="t" background="'.$this->sets->Get('reserved_end_image').'">' . $in . '</td>'; break;
  615. case 'OR': $td = '<td class="t" background="'.$this->sets->Get('occupied_reserved_image').'">' . $in . '</td>'; break;
  616. case 'ODR': $td = '<td class="t" background="'.$this->sets->Get('one_day_reserved_image').'">' . $in . '</td>'; break;
  617. case 'ODO': $td = '<td class="t" background="'.$this->sets->Get('one_day_occupied_image').'">' . $in . '</td>'; break;
  618. }
  619.  
  620. # Return
  621. return $td;
  622. }
  623.  
  624. # Erstellt das Buchungsformular
  625. function ReservationForm (&$tpl){
  626. global $granted_objects;
  627.  
  628. $tpl->set_file ('bf', 'blocks/reservation_form_' . $this->lang->Lang() . '.html');
  629. $tpl->set_block ('bf', 'BF_BLOCK', 'RESERVATION_FORM');
  630. $tpl->parse ('RESERVATION_FORM', 'BF_BLOCK');
  631.  
  632. $tpl->set_var ('ADL_SELECT', $this->AdultSelect());
  633. $tpl->set_var ('CHN_SELECT', $this->ChildernSelect());
  634.  
  635. # Year Optionen
  636. for ($i = date('Y'); $i <= 2050; $i++)
  637. $jyea_options .= '<option ' . (($_POST['j_yea'] == $i) ? 'selected' : '') . ' value="' . $i . '">' . $i . '</option>';
  638. for ($i = date('Y'); $i <= 2050; $i++)
  639. $dyea_options .= '<option ' . (($_POST['d_yea'] == $i) ? 'selected' : '') . ' value="' . $i . '">' . $i . '</option>';
  640.  
  641. # Monate Optionen
  642. for ($i = 1; $i <= 12; $i++)
  643. $jmon_options .= '<option ' . (($_POST['j_mon'] == $i) ? 'selected' : '') . ' value="' . $i . '">' . ((strlen ($i) < 2) ? '0' . $i : $i) . '</option>';
  644. for ($i = 1; $i <= 12; $i++)
  645. $dmon_options .= '<option ' . (($_POST['d_mon'] == $i) ? 'selected' : '') . ' value="' . $i . '">' . ((strlen ($i) < 2) ? '0' . $i : $i) . '</option>';
  646.  
  647. # Tage Optionen
  648. for ($i = 1; $i <= 31; $i++)
  649. $jday_options .= '<option ' . (($_POST['j_day'] == $i) ? 'selected' : '') . ' value="' . $i . '">' . ((strlen ($i) < 2) ? '0' . $i : $i) . '</option>';
  650. for ($i = 1; $i <= 31; $i++)
  651. $dday_options .= '<option ' . (($_POST['d_day'] == $i) ? 'selected' : '') . ' value="' . $i . '">' . ((strlen ($i) < 2) ? '0' . $i : $i) . '</option>';
  652.  
  653. $one_day_checked = isset($_POST['one_day_reservation']) ? ' checked' : '';
  654.  
  655. # Journey
  656. $tpl->set_var ('JY_SL', '<select onChange="ChangeDepSel (this, \'d_yea\')" id="rf_1" class="reservationFormSelectField" name="j_yea">' . $jyea_options . '</select>');
  657. $tpl->set_var ('JM_SL', '<select onChange="ChangeDepSel (this, \'d_mon\')" id="rf_2" class="reservationFormSelectField" name="j_mon">' . $jmon_options . '</select>');
  658. $tpl->set_var ('JD_SL', '<select onChange="ChangeDepSel (this, \'d_day\')" id="rf_3" class="reservationFormSelectField" name="j_day">' . $jday_options . '</select>');
  659. # One day
  660. $tpl->set_var ('ONE_DAY', '<input type="checkbox" name="one_day_reservation" onclick="disableSecondDate();"' . $one_day_checked . '>');
  661. # Departure
  662. $tpl->set_var ('DY_SL', '<select onChange="ChangeSelDependence (\'d_yea\')" id="rf_4" class="reservationFormSelectField" name="d_yea">' . $dyea_options . '</select>');
  663. $tpl->set_var ('DM_SL', '<select onChange="ChangeSelDependence (\'d_mon\')" id="rf_5" class="reservationFormSelectField" name="d_mon">' . $dmon_options . '</select>');
  664. $tpl->set_var ('DD_SL', '<select onChange="ChangeSelDependence (\'d_day\')" id="rf_6" class="reservationFormSelectField" name="d_day">' . $dday_options . '</select>');
  665.  
  666. # Services Select
  667. $services = explode (';', $this->lang->Get('services'));
  668. $select = '<select id="rf_7" class="reservationFormSelectField" name="services">';
  669. $select .= '<option value=""> - - - </option>';
  670. foreach ($services AS $key => $service){
  671. $selected = ($key + 1 == $_POST['services']) ? 'selected' : '';
  672. $select .= '<option value="' . ($key + 1) . '" ' . $selected . '>' . $service . '</option>';
  673. }
  674. $tpl->set_var ('SERVICE_SELECT', $select . '</select>');
  675.  
  676. $tpl->set_var ('PREPAY', stripslashes ($_POST['prepay']));
  677. $tpl->set_var ('LASTNAME', stripslashes ($_POST['lastname']));
  678. $tpl->set_var ('FIRSTNAME', stripslashes ($_POST['firstname']));
  679. $tpl->set_var ('COMMENT', stripslashes ($_POST['comment']));
  680.  
  681. # Ausgewählter Datentyp (Reservierung / Buchung)
  682. if (isset ($_POST['datatype']))
  683. $tpl->set_var ($_POST['datatype'] . '_CHECKED', 'checked');
  684. else $tpl->set_var ('R_CHECKED', 'checked');
  685.  
  686. # Object select
  687. $sort_funcname = ($this->sets->Get('object_order') == 'object_id') ? 'ksort' : 'asort';
  688. $sort_funcname ($objects = $this->lang->ObjNames());
  689. foreach ($objects AS $id => $name)
  690. if ($this->editor->IsAdmin() || (is_array ($granted_objects) && in_array ($id, $granted_objects)))
  691. $obj_options .= '<option ' . (($_POST['object_id'] == $id) ? 'selected' : '') . ' value="' . $id . '">' . $name . '</option>';
  692.  
  693. $tpl->set_var ('OBJECT_SELECT', '<select id="rf_8" class="reservationFormSelectField" name="object_id">' . $obj_options . '</select>');
  694.  
  695. # Beim Editieren einer Buchung
  696. if (is_numeric ($_GET['er'])){
  697. $tpl->set_var ('EDIT_ID', $_GET['er']);
  698. $this->form_status = ' - <u>edit</u> ';
  699. # Neue Buchung Button
  700. $tpl->set_var ('NEW', $this->NewReservationLink());
  701. }
  702. else{
  703. $this->form_status = ' - <u>new</u> ';
  704. }
  705.  
  706. # Status des Formulars
  707. $tpl->set_var ('STATUS', $this->form_status);
  708. }
  709.  
  710. # Erstellt Filter Panel
  711. function ReservationFilterPanel (&$tpl){
  712. $qid = 'Zibepla::ReservationFilterPanel';
  713.  
  714. $editors = $objects = $groups = $status = $years = $months = array();
  715.  
  716. # Arrays initialisieren
  717. $sql = "SELECT * FROM " . TBL_RESERVATIONS . " ORDER BY id ASC";
  718. $this->db->query ($sql, $qid);
  719. while ($this->db->next_record($qid)){
  720. $j_year = substr ($this->db->f('journey',$qid), 0, 4);
  721. $d_year = substr ($this->db->f('departure', $qid), 0, 4);
  722. $j_month = substr ($this->db->f('journey', $qid), 5, 2);
  723. $d_month = substr ($this->db->f('departure', $qid), 5, 2);
  724.  
  725. if (!in_array ($this->db->f('editor_id', $qid), $editors)) $editors[] = $this->db->f('editor_id', $qid);
  726. if (!in_array ($this->db->f('object_id', $qid), $objects)) $objects[] = $this->db->f('object_id', $qid);
  727. if (!in_array ($this->db->f('status', $qid), $status)) $status[] = $this->db->f('status', $qid);
  728. if (!in_array ($j_year, $years)) $years[] = $j_year;
  729. if (!in_array ($d_year, $years)) $years[] = $d_year;
  730. if (!in_array ($j_month, $months)) $months[] = $j_month;
  731. if (!in_array ($d_month, $months)) $months[] = $d_month;
  732. }
  733.  
  734. # Array mit Bearbeiter sortieren
  735. $editor_names = $this->editors; asort ($editor_names);
  736. foreach ($editor_names AS $editor_id => $editor_name)
  737. if (!in_array ($editor_id, $editors)) unset ($editor_names[$editor_id]);
  738. unset ($editors);
  739.  
  740. # Array mit Objekten sortieren
  741. $all_objects = $this->lang->ObjNames();
  742. $sort_funcname = ($this->sets->Get('object_order') == 'object_id') ? 'ksort' : 'asort';
  743. $sort_funcname ($all_objects);
  744. foreach ($all_objects AS $object_id => $object_name)
  745. if (!in_array ($object_id, $objects)) unset ($all_objects[$object_id]);
  746. unset ($objects);
  747.  
  748. # Objektgruppen Daten
  749. $reserved_object_list = "('" . implode ("','", array_keys ($all_objects)) . "')";
  750. $sql = "SELECT DISTINCT(object_group) AS object_group FROM " . TBL_OBJ_SETTINGS
  751. . " WHERE object_id IN " . $reserved_object_list;
  752. $this->db->query($sql, $qid);
  753. while ($this->db->next_record($qid) && $this->db->f('object_group', $qid) != 0)
  754. $groups[$this->db->f('object_group', $qid)] = $this->lang->Get('obj_group_name_' . $this->db->f('object_group', $qid));
  755.  
  756. # Array mit Status, Jahren und Monaten sortieren
  757. asort ($status); sort ($years); sort ($months);
  758.  
  759. # Select mit Bearbeiter
  760. $editor_select .= '<option value="">' . $this->lang->Get('all_word') . '</option>';
  761. $editor_select .= '<option value="0" ' . (($_SESSION['editor_filter'] == '0') ? 'selected' : '')
  762. . '>' . $this->sets->Get('administrator_login') . '</option>';
  763. foreach ($editor_names AS $editor_id => $editor_name){
  764. $editor_select .= '<option value="' . $editor_id . '" '
  765. . (($_SESSION['editor_filter'] == $editor_id) ? 'selected' : '') . '>' . $editor_name . '</option>';
  766. }
  767. $editor_select = '<select id="rf_9" class="reservationFormSelectField" name="editor_filter">' . $editor_select . '</select>';
  768.  
  769. # Select mit Objekten
  770. $object_select .= '<option value="">' . $this->lang->Get('all_word') . '</option>';
  771. foreach ($all_objects AS $object_id => $object_name){
  772. $object_select .= '<option value="' . $object_id . '" '
  773. . (($_SESSION['object_filter'] == $object_id) ? 'selected' : '') . '>' . $object_name . '</option>';
  774. }
  775. $object_select = '<select id="rf_10" class="reservationFormSelectField" name="object_filter">' . $object_select . '</select>';
  776.  
  777. # Select mit Objektgrupen
  778. $group_select .= '<option value="">' . $this->lang->Get('all_word') . '</option>';
  779. foreach ($groups AS $group_id => $group_name){
  780. $group_select .= '<option value="' . $group_id . '" '
  781. . (($_SESSION['group_filter'] == $group_id) ? 'selected' : '') . '>' . $group_name . '</option>';
  782. }
  783. $group_select = '<select id="rf_11" class="reservationFormSelectField" name="group_filter">' . $group_select . '</select>';
  784.  
  785. # Select mit Status
  786. $status_select .= '<option value="">' . $this->lang->Get('all_word') . '</option>';
  787. foreach ($status AS $st){
  788. $view_status = ($st == 'O') ? $this->lang->Get('edit_occupied_word') : $this->lang->Get('edit_reserved_word');
  789. $status_select .= '<option value="' . $st . '" '
  790. . (($_SESSION['status_filter'] == $st) ? 'selected' : '') . '>' . $view_status . '</option>';
  791. }
  792. $status_select = '<select id="rf_12" class="reservationFormSelectField" name="status_filter">' . $status_select . '</select>';
  793.  
  794. # Select mit Jahren
  795. $year_select .= '<option value="">' . $this->lang->Get('all_word') . '</option>';
  796. foreach ($years AS $year){
  797. $year_select .= '<option value="' . $year . '" '
  798. . (($_SESSION['year_filter'] == $year) ? 'selected' : '') . '>' . $year . '</option>';
  799. }
  800. $year_select = '<select id="rf_13" class="reservationFormSelectField" name="year_filter">' . $year_select . '</select>';
  801.  
  802. # Select mit Monaten
  803. $month_select .= '<option value="">' . $this->lang->Get('all_word') . '</option>';
  804. foreach ($months AS $month){
  805. $month_select .= '<option value="' . $month . '" '
  806. . (($_SESSION['month_filter'] == $month) ? 'selected' : '') . '>' . $month . '</option>';
  807. }
  808. $month_select = '<select id="rf_14" class="reservationFormSelectField" name="month_filter">' . $month_select . '</select>';
  809.  
  810. # Variablen parsen
  811. if (!isset ($_SESSION['filter_link'])) $_SESSION['filter_link'] = 'AND';
  812. $tpl->set_var ('filter_' . strtolower($_SESSION['filter_link']) . '_checked', 'checked');
  813. $tpl->set_var ('RESERVED_EDITOR_SELECT', $editor_select);
  814. $tpl->set_var ('RESERVED_OBJECT_SELECT', $object_select);
  815. $tpl->set_var ('RESERVED_GROUP_SELECT', $group_select);
  816. $tpl->set_var ('RESERVATION_TYPE_SELECT', $status_select);
  817. $tpl->set_var ('YEAR_SELECT', $year_select);
  818. $tpl->set_var ('MONTH_SELECT', $month_select);
  819. }
  820.  
  821. # Erstellt Liste mit Buchungen (own - nur Buchungen, die Editor selber gemacht hat)
  822. function ReservationList (&$tpl, $own = FALSE){
  823. $qid = 'Zibepla::ReservationList';
  824.  
  825. global $ssn, $filter_keys;
  826.  
  827. # WHERE Bedingungen
  828. $conditions = array();
  829.  
  830. if ($_SESSION['editor_filter'] != '') $conditions[] = " editor_id = '" . $_SESSION['editor_filter'] . "' ";
  831. if ($_SESSION['object_filter'] != '') $conditions[] = " object_id = '" . $_SESSION['object_filter'] . "' ";
  832. if ($_SESSION['status_filter'] != '') $conditions[] = " status = '" . $_SESSION['status_filter'] . "' ";
  833.  
  834. if ($_SESSION['year_filter'] != ''){
  835. $conditions[] = " (YEAR(journey) = '" . $_SESSION['year_filter'] . "' "
  836. . " OR YEAR(departure) = '" . $_SESSION['year_filter'] . "') ";
  837. }
  838. if ($_SESSION['month_filter'] != '') {
  839. $conditions[] = " (MONTH(journey) = '" . $_SESSION['month_filter'] . "' "
  840. . " OR MONTH(departure) = '" . $_SESSION['month_filter'] . "') ";
  841. }
  842.  
  843. if ($_SESSION['group_filter'] != ''){
  844. $sql = "SELECT object_id FROM " . TBL_OBJ_SETTINGS
  845. . " WHERE object_group = '" . $_SESSION['group_filter'] . "'";
  846. $this->db->query($sql, $qid); $in_group_objects = array();
  847. while ($this->db->next_record($qid))
  848. $in_group_objects[] = $this->db->f('object_id', $qid);
  849. $conditions[] = ' object_id IN ' . "('" . implode ("','", $in_group_objects) . "') ";
  850. }
  851.  
  852. if ($own && !$this->editor->IsAdmin()) {
  853. $where = " WHERE (editor_id = '" . $this->editor->GetId() . "')";
  854. if (count($conditions) > 0)
  855. " AND (" . implode ($_SESSION['filter_link'], $conditions) . ")";
  856. }
  857. elseif (COUNT($conditions) > 0){
  858. $where = " WHERE " . implode ($_SESSION['filter_link'], $conditions);
  859. }
  860.  
  861. # Sortierung und Richtung
  862. $order_array = array('id', 'editor_name', 'object_name', 'journey', 'departure',
  863. 'firstname', 'lastname', 'adult', 'childern', 'service_name');
  864.  
  865. $_SESSION['reslist_order'] = (isset ($_GET['order']) && in_array ($_GET['order'], $order_array))
  866. ? $_GET['order'] : ((isset ($_SESSION['reslist_order'])) ? $_SESSION['reslist_order'] : 'id');
  867. $_SESSION['reslist_dir'] = (isset ($_GET['dir']) && ($_GET['dir'] == 'ASC' || $_GET['dir'] == 'DESC'))
  868. ? $_GET['dir'] : ((isset ($_SESSION['reslist_dir'])) ? $_SESSION['reslist_dir'] : 'ASC');
  869.  
  870. # SQL Zeilenanzahl
  871. if (!PRINT_MODUS) {
  872. $sql = "SELECT COUNT(*) AS num_rows FROM " . TBL_RESERVATIONS . " " . $where;
  873. $this->db->query($sql);
  874. $this->db->next_record();
  875. $reservations = $this->db->f('num_rows');
  876.  
  877. $page_for_sql = ($_GET['page'] < 1) ? $_GET['page'] : ($_GET['page'] - 1);
  878.  
  879. # Seitenblätterfunktion
  880. $pages_navigation = $this->PagesHandler($_SERVER['PHP_SELF'], '', $this->sets->Get('reservation_list_pagerows'), $reservations, $_GET['page']);
  881. }
  882.  
  883. # Ausnahme für die Sortierung
  884. $order = ($_SESSION['reslist_order'] != 'object_name') ? $_SESSION['reslist_order'] : 'ln.value';
  885.  
  886. # Daten für die Liste
  887. $sql = "SELECT rsv.* FROM " . TBL_RESERVATIONS . " AS rsv LEFT JOIN " . TBL_LANGUAGES . " AS ln "
  888. . " ON concat('obj_name_', rsv.object_id) = ln.variable AND language = '" . $this->lang->Lang() . "' " . $where
  889. . " ORDER BY " . $order . " " . $_SESSION['reslist_dir'];
  890.  
  891. $start = $this->sets->Get('reservation_list_pagerows') * $page_for_sql;
  892. if (!PRINT_MODUS)
  893. $sql .= ' LIMIT ' . $start . ', ' . $this->sets->Get('reservation_list_pagerows');
  894.  
  895. $this->db->query($sql, $qid);
  896. if ($this->db->num_rows($qid) > 0){
  897. $reservation_word = '<b>' . $this->lang->Get('reservation_id_word') . '</b>';
  898. $editor_word = '<b>' . $this->lang->Get('editor_word') . '</b>';
  899. $object_word = '<b>' . $this->lang->Get('object_word') . '</b>';
  900. $journey_word = '<b>' . $this->lang->Get('journey_word') . '</b>';
  901. $departure_word = '<b>' . $this->lang->Get('departure_word') . '</b>';
  902. $prepay_word = '<b>' . $this->lang->Get('prepay_word') . '</b>';
  903. $status_abbr = '<b>' . $this->lang->Get('status_abbreviation') . '</b>';
  904. $firstname_word = '<b>' . $this->lang->Get('firstname_word') . '</b>';
  905. $lastname_word = '<b>' . $this->lang->Get('lastname_word') . '</b>';
  906. $adult_abbr = '<b>' . $this->lang->Get('adults_abbreviation') . '</b>';
  907. $kids_abbr = '<b>' . $this->lang->Get('kids_abbreviation') . '</b>';
  908. $service_word = '<b>' . $this->lang->Get('service_word') . '</b>';
  909. $comment_abbr = '<b>' . $this->lang->Get('comment_abbreviation') . '</b>';
  910. $action_word = '<b>' . $this->lang->Get('actions_word') . '</b>';
  911.  
  912. $self = $ssn->Url ($_SERVER['PHP_SELF']);
  913. $dir = ($_SESSION['reslist_dir'] == 'ASC') ? 'DESC' : 'ASC';
  914.  
  915. $order_img = '<img src="images/order_reservations_' . strtolower ($_SESSION['reslist_dir'])
  916. . '.gif" width="13" height="9" style="margin-left:3px">';
  917.  
  918. if (!PRINT_MODUS){
  919. $reservation_word = '<a href="' . $self . '?order=id&dir=' . (($_SESSION['reslist_order'] == 'id') ? $dir : $_SESSION['reslist_dir']) . '">' . $reservation_word . (($_SESSION['reslist_order'] == 'id') ? $order_img : '') . '</a>';
  920. # $editor_word = '<a href="' . $self . '?order=editor_name&dir=' . (($_SESSION['reslist_order'] == 'editor_name') ? $dir : $_SESSION['reslist_dir']) . '">' . $editor_word . (($_SESSION['reslist_order'] == 'editor_name') ? $order_img : '') . '</a>';
  921. $object_word = '<a href="' . $self . '?order=object_name&dir=' . (($_SESSION['reslist_order'] == 'object_name') ? $dir : $_SESSION['reslist_dir']) . '">' . $object_word . (($_SESSION['reslist_order'] == 'object_name') ? $order_img : '') . '</a>';
  922. $journey_word = '<a href="' . $self . '?order=journey&dir=' . (($_SESSION['reslist_order'] == 'journey') ? $dir : $_SESSION['reslist_dir']) . '">' . $journey_word . (($_SESSION['reslist_order'] == 'journey') ? $order_img : '') . '</a>';
  923. $departure_word = '<a href="' . $self . '?order=departure&dir=' . (($_SESSION['reslist_order'] == 'departure') ? $dir : $_SESSION['reslist_dir']) . '">' . $departure_word . (($_SESSION['reslist_order'] == 'departure') ? $order_img : '') . '</a>';
  924. $firstname_word = '<a href="' . $self . '?order=firstname&dir=' . (($_SESSION['reslist_order'] == 'firstname') ? $dir : $_SESSION['reslist_dir']) . '">' . $firstname_word . (($_SESSION['reslist_order'] == 'firstname') ? $order_img : '') . '</a>';
  925. $lastname_word = '<a href="' . $self . '?order=lastname&dir=' . (($_SESSION['reslist_order'] == 'lastname') ? $dir : $_SESSION['reslist_dir']) . '">' . $lastname_word . (($_SESSION['reslist_order'] == 'lastname') ? $order_img : '') . '</a>';
  926. $adult_abbr = '<a href="' . $self . '?order=adult&dir=' . (($_SESSION['reslist_order'] == 'adult') ? $dir : $_SESSION['reslist_dir']) . '">' . $adult_abbr . (($_SESSION['reslist_order'] == 'adult') ? $order_img : '') . '</a>';
  927. $kids_abbr = '<a href="' . $self . '?order=childern&dir=' . (($_SESSION['reslist_order'] == 'childern') ? $dir : $_SESSION['reslist_dir']) . '">' . $kids_abbr . (($_SESSION['reslist_order'] == 'childern') ? $order_img : '') . '</a>';
  928. # $service_word = '<a href="' . $self . '?order=service_name&dir=' . (($_SESSION['reslist_order'] == 'service_name') ? $dir : $_SESSION['reslist_dir']) . '">' . $service_word . (($_SESSION['reslist_order'] == 'service_name') ? $order_img : '') . '</a>';
  929. }
  930.  
  931. # Die Pageshandler Zeile
  932. if (!PRINT_MODUS && $this->sets->Get('reservation_list_pagerows') < $reservations)
  933. $pages_navigation = '<tr bgcolor="#FFFAF0"><td colspan="16">' . $pages_navigation . '</td></tr>';
  934. else $pages_navigation = '';
  935.  
  936. # Die oberste Zeile
  937. $res_list = '<table style="border:solid 1px #AAAAAA; margin-top: 2px; " border="0" cellpadding="0" cellspacing="1" bgcolor="#DDDDDD" width="99%">'
  938. . $pages_navigation
  939. . '<tr bgcolor="#EEEEEE">'
  940. . '<td nowrap><span class="text">&nbsp;' . $reservation_word . '&nbsp;</span></td>'
  941. . '<td nowrap><span class="text">&nbsp;' . $editor_word . '&nbsp;</span></td>'
  942. . '<td nowrap><span class="text">&nbsp;' . $object_word . '&nbsp;</span></td>'
  943. . '<td nowrap><span class="text">&nbsp;' . $journey_word . '&nbsp;</span></td>'
  944. . '<td nowrap><span class="text">&nbsp;' . $departure_word . '&nbsp;</span></td>'
  945. . '<td nowrap><span class="text">&nbsp;' . $prepay_word . '&nbsp;</span></td>'
  946. . '<td nowrap><span class="text">&nbsp;' . $status_abbr . '&nbsp;</span></td>'
  947. . '<td nowrap><span class="text">&nbsp;' . $firstname_word . '&nbsp;</span></td>'
  948. . '<td nowrap><span class="text">&nbsp;' . $lastname_word . '&nbsp;</span></td>'
  949. . '<td nowrap><span class="text">&nbsp;' . $adult_abbr . '&nbsp;</span></td>'
  950. . '<td nowrap><span class="text">&nbsp;' . $kids_abbr . '&nbsp;</span></td>'
  951. . '<td nowrap><span class="text">&nbsp;' . $service_word . '&nbsp;</span></td>';
  952.  
  953. if (!PRINT_MODUS){
  954. $res_list .= '<td nowrap><span class="text">&nbsp;' . $comment_abbr . '&nbsp;</span></td>'
  955. . '<td colspan="3"><span class="text">&nbsp;' . $action_word . '</b></a>&nbsp;</span></td>';
  956. }
  957.  
  958. $res_list .= '</tr>';
  959.  
  960. # Array mit Service Bezeichnungen
  961. $services = explode (';', $this->lang->Get('services'));
  962.  
  963. # Schleife durchlaufe und die Tabelle erstellen
  964. while ($this->db->next_record($qid)){
  965. $ex = explode ('-', $this->db->f('journey', $qid));
  966. $journey = $ex[2] . '.' . $ex[1] . '.' . $ex[0];
  967. $ex = explode ('-', $this->db->f('departure', $qid));
  968. $departure = $ex[2] . '.' . $ex[1] . '.' . $ex[0];
  969.  
  970. $bgcolor = ($this->db->f('status', $qid) == 'R') ? 'fffaf0' : 'f5f5f5';
  971.  
  972. # Aktionen
  973. $edit = '<a href="' . $ssn->Url($_SERVER['PHP_SELF'] . '?er=' . $this->db->f('id', $qid))
  974. . '"><img src="./images/edit.gif" width="11" height="9" alt="Edit this reservation"></a>';
  975.  
  976. $convert = '<a href="' . $ssn->Url($_SERVER['PHP_SELF'] . '?cr=' . $this->db->f('id', $qid))
  977. . '"><img src="./images/convert.gif" width="9" height="11" alt="Convert this reservation"></a>';
  978.  
  979. $delete = '<a href="' . $ssn->Url($_SERVER['PHP_SELF'] . '?dr=' . $this->db->f('id', $qid))
  980. . '" onclick="return confirm(\'This reservation will be deleted.\');">'
  981. . '<img src="./images/delete.gif" width="11" height="9" alt="Delete this reservation"></a>';
  982.  
  983. # Zeile beim Editieren hervorheben
  984. $indicator = ($_GET['er'] == $this->db->f('id', $qid)) ? 'style="background-color: #FFFFCC; border-top: solid 1px #BB0000; border-bottom: solid 1px #BB0000"' : '';
  985. $left_indicator = ($_GET['er'] == $this->db->f('id', $qid)) ? 'style="background-color: #FFFFCC; border-left: solid 1px #BB0000; border-top: solid 1px #BB0000; border-bottom: solid 1px #BB0000"' : '';
  986. $right_indicator = ($_GET['er'] == $this->db->f('id', $qid)) ? 'style="background-color: #FFFFCC; border-right: solid 1px #BB0000; border-top: solid 1px #BB0000; border-bottom: solid 1px #BB0000"' : '';
  987.  
  988. # Tooltips
  989. if (!PRINT_MODUS){
  990. $eid_tag = '<a href="#" onMouseOver="lp=20;tp=20;showWMTT(\'eid_' . $this->db->f('editor_id', $qid) . '\')"; onMouseOut="hideWMTT()">';
  991. $oid_tag = '<a href="#" onMouseOver="lp=20;tp=20;showWMTT(\'oid_' . $this->db->f('object_id', $qid) . '\')"; onMouseOut="hideWMTT()">';
  992. }
  993.  
  994. if (!in_array ($this->db->f('editor_id', $qid), (array)$this->tooltips['eid']))
  995. $this->CreateTooltipEID($this->db->f('editor_id', $qid));
  996.  
  997. if (!in_array ($this->db->f('object_id', $qid), (array)$this->tooltips['oid']))
  998. $this->CreateTooltipOID($this->db->f('object_id', $qid));
  999.  
  1000. # Kommentar Tooltip
  1001. if ($this->db->f('comment', $qid) != ''){
  1002. $tp = round (strlen ($this->db->f('comment', $qid)) / 3.7);
  1003. if ($tp < 40) $tp = 40;
  1004. $comment = '<a href="#" '
  1005. . 'onMouseOver="lp=-420;tp=-' . $tp . ';showWMTT(\'com_' . $this->db->f('id', $qid) . '\')" onMouseOut="hideWMTT()" '
  1006. . 'onClick="window.open(\'popups/comment.php?id=' . $this->db->f('id', $qid) . '\', \'Comment\', \'width=350,height=200,left=100,top=100,resizable=yes,scrollbars=yes\')"'
  1007. . '>'
  1008. . '<img src="images/reservation_form_comment.gif" width="11" height="9" alt="'
  1009. . $this->lang->Get('comment_abbreviation') . '"></a>';
  1010. $comm = stripslashes (str_replace ("\n", "<br>", $this->db->f('comment', $qid)));
  1011. $this->CreateTooltipCOM($this->db->f('id', $qid), $comm);
  1012. }
  1013. else { $comment = ''; }
  1014.  
  1015. # Editor Name
  1016. $this->editors[$this->db->f('editor_id', $qid)] . " * <br>";
  1017. $editor_name = (isset ($this->editors[$this->db->f('editor_id', $qid)])) ? $this->editors[$this->db->f('editor_id', $qid)] : $this->sets->Get('administrator_login');
  1018.  
  1019. # Object Bezeichnung
  1020. $exists = $this->lang->Exists('obj_name_' . $this->db->f('object_id', $qid));
  1021. $object = (!$exists) ? ('ID: ' . $this->db->f('object_id', $qid)) : $this->lang->Get('obj_name_' . $this->db->f('object_id', $qid));
  1022.  
  1023. # Reservierungsstatus
  1024. $status_img = ($this->db->f('status', $qid) == 'O') ? 'reservation_form_occupied.gif' : 'reservation_form_reserved.gif';
  1025. $status = '<img src="images/' . $status_img . '" width="11" height="9" alt=" ' . $this->db->f('status', $qid) . '">';
  1026.  
  1027. # Service
  1028. $service_out = $services[$this->db->f('service', $qid) - 1];
  1029.  
  1030. # Editor und Objekt
  1031. $editor_name = (PRINT_MODUS) ? $editor_name : ($eid_tag . $editor_name . '</a>');
  1032. $object = (PRINT_MODUS) ? $object : ($oid_tag . $object . '</a>');
  1033.  
  1034. # Buchungssliste
  1035. $res_list .= '<tr ' . ((PRINT_MODUS) ? '' : $this->tab_line) . ' bgcolor="' . ((PRINT_MODUS) ? '#FFFFFF' : ($bgcolor)) . '">'
  1036. . '<td nowrap ' . $left_indicator . '><span class="text">&nbsp;' . $this->db->f('id', $qid) . '&nbsp;</span></td>'
  1037. . '<td nowrap ' . $indicator . '><span class="text">&nbsp;' . $editor_name . '&nbsp;</span></td>'
  1038. . '<td nowrap ' . $indicator . '><span class="text">&nbsp;' . $object . '&nbsp;</span></td>'
  1039. . '<td nowrap ' . $indicator . '><span class="text">&nbsp;' . $journey . '&nbsp;</span></td>'
  1040. . '<td nowrap ' . $indicator . '><span class="text">&nbsp;' . $departure . '&nbsp;</span></td>'
  1041. . '<td nowrap ' . $indicator . '><span class="text">&nbsp;' . $this->db->f('prepay', $qid) . '&nbsp;</span></td>'
  1042. . '<td nowrap ' . $indicator . '><span class="text">&nbsp;' . $status . '&nbsp;</span></td>'
  1043. . '<td nowrap ' . $indicator . '><span class="text">&nbsp;' . $this->db->f('firstname', $qid) . '&nbsp;</span></td>'
  1044. . '<td nowrap ' . $indicator . '><span class="text">&nbsp;' . $this->db->f('lastname', $qid) . '&nbsp;</span></td>'
  1045. . '<td nowrap ' . $indicator . '><span class="text">&nbsp;' . $this->db->f('adult', $qid) . '&nbsp;</span></td>'
  1046. . '<td nowrap ' . $indicator . '><span class="text">&nbsp;' . $this->db->f('childern', $qid) . '&nbsp;</span></td>'
  1047. . '<td nowrap ' . $indicator . '><span class="text">&nbsp;' . $service_out . '&nbsp;</span></td>';
  1048.  
  1049. if (!PRINT_MODUS){
  1050. $res_list .= '<td nowrap ' . $indicator . '><span class="text">&nbsp;' . $comment . '</a>&nbsp;</span></td>'
  1051. . '<td nowrap ' . $indicator . '><span class="text">&nbsp;' . $edit . '&nbsp;</span></td>'
  1052. . '<td nowrap ' . $indicator . '><span class="text">&nbsp;' . $convert . '&nbsp;</span></td>'
  1053. . '<td nowrap ' . $right_indicator . '><span class="text">&nbsp;' . $delete . '&nbsp;</span></td>';
  1054. }
  1055.  
  1056. $res_list .= '</tr>';
  1057. }
  1058.  
  1059. $res_list .= '</table>';
  1060. }
  1061.  
  1062. # Parse
  1063. $tpl->set_var ('RESERVATION_LIST', $res_list);
  1064. }
  1065.  
  1066. # Löscht eine Buchung
  1067. function DeleteGuest ($id){
  1068. $qid = 'Zibepla::DeleteGuest';
  1069.  
  1070. # Buchung aus der Buchungstabelle löschen
  1071. $sql = "DELETE FROM " . TBL_RESERVATIONS . " WHERE id = '" . $id . "'";
  1072. $this->db->query($sql, $qid);
  1073.  
  1074. # Daten erneut laden
  1075. $this->Load();
  1076. }
  1077.  
  1078. function EditForm ($id){
  1079. $qid = 'Zibepla::EditForm';
  1080.  
  1081. # Buchungsdaten
  1082. $sql = "SELECT * FROM " . TBL_RESERVATIONS . " WHERE id = '" . $id . "'";
  1083. $this->db->query ($sql, $qid);
  1084. if ($this->db->next_record($qid)){
  1085. $journey = $this->db->f('journey', $qid);
  1086. $departure = $this->db->f('departure', $qid);
  1087.  
  1088. $post = ($_SERVER['REQUEST_METHOD'] == 'POST') ? true : false;
  1089.  
  1090. # Post Variable initialisieren
  1091. if (!$post) $_POST['object_id'] = $this->db->f('object_id', $qid);
  1092. if (!$post) $_POST['datatype'] = $this->db->f('status', $qid);
  1093. if (!$post) $_POST['firstname'] = $this->db->f('firstname', $qid);
  1094. if (!$post) $_POST['lastname'] = $this->db->f('lastname', $qid);
  1095. if (!$post) $_POST['adult'] = $this->db->f('adult', $qid);
  1096. if (!$post) $_POST['childern'] = $this->db->f('childern', $qid);
  1097. if (!$post) $_POST['j_yea'] = substr ($journey, 0, 4);
  1098. if (!$post) $_POST['j_mon'] = substr ($journey, 5, 2);
  1099. if (!$post) $_POST['j_day'] = substr ($journey, 8, 2);
  1100. if (!$post) $_POST['d_yea'] = substr ($departure, 0, 4);
  1101. if (!$post) $_POST['d_mon'] = substr ($departure, 5, 2);
  1102. if (!$post) $_POST['d_day'] = substr ($departure, 8, 2);
  1103. if (!$post) $_POST['services'] = $this->db->f('service', $qid);
  1104. if (!$post) $_POST['comment'] = $this->db->f('comment', $qid);
  1105. if (!$post) $_POST['prepay'] = $this->db->f('prepay', $qid);
  1106. # Ein Tag Buchung
  1107. if (!$post && $journey == $departure) $_POST['one_day_reservation'] = true;
  1108. }
  1109. }
  1110.  
  1111. # Überprüft die Daten einer Buchung
  1112. function CheckGuest ($edit_id = false) {
  1113. # Nachname
  1114. if (empty ($_POST['lastname']))
  1115. smError ($this->lang->Get('err_message_reservation_form_word__1'));
  1116.  
  1117. $invalid_period = $invalid_date = $one_day = FALSE;
  1118.  
  1119. # Anreisedatum
  1120. if (!checkdate ($_POST['j_mon'], $_POST['j_day'], $_POST['j_yea'])){
  1121. smError ($this->lang->Get('err_message_reservation_form_word__2'));
  1122. $invalid_date = TRUE;
  1123. }
  1124. # Abreisedatum
  1125. if ((!checkdate ($_POST['d_mon'], $_POST['d_day'], $_POST['d_yea'])) && !isset($_POST['one_day_reservation'])){
  1126. smError ($this->lang->Get('err_message_reservation_form_word__3'));
  1127. $invalid_date = TRUE;
  1128. }
  1129.  
  1130. # Ob Abreise vor Anreise liegt
  1131. if (!$invalid_date && !isset($_POST['one_day_reservation'])) {
  1132. $j_stamp = mktime (0, 0, 0, $_POST['j_mon'], $_POST['j_day'], $_POST['j_yea']);
  1133. $d_stamp = mktime (0, 0, 0, $_POST['d_mon'], $_POST['d_day'], $_POST['d_yea']);
  1134. if ($d_stamp < $j_stamp)
  1135. smError($this->lang->Get('err_message_reservation_form_word__4'));
  1136. }
  1137.  
  1138. # Ob Anreise vor dem Abreisetag liegt
  1139. if (!$invalid_date
  1140. && (isset($_POST['one_day_reservation']) || $this->BeginDate() == $this->EndDate())) {
  1141. $this->CorrectEndDate();
  1142. $one_day = true;
  1143. }
  1144.  
  1145. # Prüfen ob Datumseingabe nicht mit bereits vorhandenen Belegungsperioden in Konflikt ist
  1146. if (!$invalid_date){
  1147. $sql = "SELECT object_id, journey, departure, one_day FROM " . TBL_RESERVATIONS
  1148. . " WHERE '" . $this->BeginDate() . "' <= departure"
  1149. . " AND '" . $this->EndDate() . "' >= journey"
  1150. . " AND object_id = '" . $_POST['object_id'] . "'";
  1151.  
  1152. if ($edit_id)
  1153. $sql .= " AND id != '" . $_POST['edit_id'] . "'";
  1154.  
  1155. $this->db->query($sql, $qid);
  1156.  
  1157. while ($this->db->next_record($qid)) {
  1158. if ($this->db->f('one_day', $qid) == 'Y' || $one_day) {
  1159. $invalid_period = true;
  1160. }
  1161. elseif ($this->BeginDate() != $this->db->f('departure', $qid) && $this->EndDate() != $this->db->f('journey', $qid)){
  1162. $invalid_period = true;
  1163. }
  1164.  
  1165. /* debug
  1166. echo $sql . "<br>";
  1167. echo $this->db->f('object_id', $qid) . "<br>";
  1168. echo 'exists ' . $this->db->f('journey', $qid) . ' - ' . $this->db->f('departure', $qid) . ' # one: ' . $this->db->f('one_day', $qid) . '<br>';
  1169. echo 'new ' . $this->BeginDate() . ' - ' . $this->EndDate() . ' # one: ' . $one_day . '<br>';
  1170. echo 'invalid: ' . $invalid_period . '<br><br>';
  1171. */
  1172. }
  1173. }
  1174.  
  1175. return array ($invalid_date, $invalid_period, $one_day);
  1176. }
  1177.  
  1178. # Fügt einen Gast hin zu
  1179. function AddGuest ($edit_user = false){
  1180. $qid = 'Zibepla::AddGuest';
  1181.  
  1182. # Gastdaten prüfen
  1183. list ($invalid_date, $invalid_period, $one_day) = $this->CheckGuest();
  1184.  
  1185. # Eingegebene An- und Abreisedatum in Daten-Array konvertieren.
  1186. if (!$invalid_date && !$invalid_period && smErrorsEx() < 1){
  1187. # Im Simulationsfall true zurück geben
  1188. if ($this->simulation) return TRUE;
  1189. $od = ($one_day) ? 'Y' : 'N';
  1190.  
  1191. $sql = "INSERT INTO " . TBL_RESERVATIONS . " (object_id, editor_id, prepay, journey, departure, "
  1192. . "one_day, status, firstname, lastname, adult, childern, service, comment) VALUES('"
  1193. . $this->GetID() . "', '" . $this->editor->GetId() . "', '" . (addslashes($_POST['prepay'])) . "', '"
  1194. . $this->BeginDate() . "', '" . $this->EndDate() . "', '" . $od . "', '" . $this->GetEdit() . "', '" . addslashes($_POST['firstname'])
  1195. . "', '" . addslashes($_POST['lastname']) . "', '" . $_POST['adult'] . "', '" . $_POST['childern'] . "', '"
  1196. . $_POST['services'] . "', '" . addslashes($_POST['comment']) . "')";
  1197. $this->db->query($sql, $qid);
  1198.  
  1199. $this->SaveLastEditTime($this->GetID());
  1200. }
  1201. elseif ($invalid_period){
  1202. # Belegungsperioden sind im Konflikt
  1203. smError ($this->lang->Get('err_message_reservation_form_word__5'));
  1204. }
  1205. }
  1206.  
  1207. # Eine Buchung editieren
  1208. function EditGuest() {
  1209. $qid = 'Zibepla::EditGuest';
  1210. global $granted_objects;
  1211.  
  1212. # Object ID der editierten Buchung
  1213. $sql = "SELECT object_id FROM " . TBL_RESERVATIONS . " WHERE id = '" . $_POST['edit_id'] . "'";
  1214. $this->db->query($sql, $qid);
  1215. $this->db->next_record($qid);
  1216. $edit_object = $this->db->f('object_id', $qid);
  1217.  
  1218. $_POST['object_id'] = (int)$_POST['object_id'];
  1219. if (is_array($granted_objects) && (!in_array($edit_object, $granted_objects) || !in_array($_POST['object_id'], $granted_objects)))
  1220. smError ($this->lang->Get('err_message_layout_word__1'));
  1221.  
  1222. # Gastdaten prüfen
  1223. list ($invalid_date, $invalid_period, $one_day) = $this->CheckGuest(true);
  1224.  
  1225. # Eingegebene An- und Abreisedatum in Daten-Array konvertieren.
  1226. if (!$invalid_date && !$invalid_period && smErrorsEx() < 1){
  1227. $od = ($one_day) ? 'Y' : 'N';
  1228. $sql = "UPDATE " . TBL_RESERVATIONS . " SET object_id = '" . $_POST['object_id'] . "',"
  1229. . " editor_id = '" . $this->editor->GetId() . "', prepay = '" . (addslashes($_POST['prepay'])) . "',"
  1230. . " journey = '" . $this->BeginDate() . "', departure = '" . $this->EndDate() . "', "
  1231. . "one_day = '" . $od . "', status = '" . $_POST['datatype'] . "',"
  1232. . " firstname = '" . addslashes($_POST['firstname']) . "', lastname = '" . addslashes($_POST['lastname']) . "',"
  1233. . " adult = '" . $_POST['adult'] . "', childern = '" . $_POST['childern'] . "',"
  1234. . " service = '" . $_POST['services'] . "', comment ='" . addslashes($_POST['comment']) . "'"
  1235. . " WHERE id = '" . $_POST['edit_id'] . "'";
  1236. $this->db->query($sql, $qid);
  1237.  
  1238. $this->SaveLastEditTime($_POST['object_id']);
  1239. }
  1240. elseif ($invalid_period){
  1241. # Belegungsperioden sind im Konflikt
  1242. smError ($this->lang->Get('err_message_reservation_form_word__5'));
  1243. }
  1244.  
  1245. # Editiermodus fortsetzen
  1246. if (smErrorsEx() > 0)
  1247. $_GET['er'] = $_POST['edit_id'];
  1248. }
  1249.  
  1250. # Konvertiert eine Reservierung zu Buchung und umgekehrt
  1251. function ConvertReservation($id){
  1252. $qid = 'Zibepla::ConvertReservation';
  1253.  
  1254. # Buchungsdaten
  1255. $sql = "SELECT * FROM " . TBL_RESERVATIONS . " WHERE id = '" . $id . "'";
  1256. $this->db->query ($sql, $qid);
  1257. if ($this->db->next_record($qid)){
  1258.  
  1259. # Neuer Status für die Tabelle mit Buchungen
  1260. $status = ($this->db->f('status', $qid) == 'O') ? 'R' : 'O';
  1261.  
  1262. $obj_id = $this->db->f('object_id', $qid);
  1263.  
  1264. # Status in der Buchungstabelle ändern
  1265. $sql = "UPDATE " . TBL_RESERVATIONS . " SET status = '" . $status . "' WHERE id = '" . $id . "'";
  1266. $this->db->query($sql, $qid);
  1267.  
  1268. $this->SaveLastEditTime($obj_id);
  1269.  
  1270. # Daten reloaden
  1271. $this->Load();
  1272. }
  1273. }
  1274.  
  1275. # Ermittelt Date-Status (frei, belegt, etc..)
  1276. function DateStatus ($prev_date, $date, $next_date){
  1277. if ($this->GetEdit() == 'O') # $this->edit
  1278. return $this->OccupiedStatus ($prev_date, $date, $next_date);
  1279. else return $this->ReservedStatus ($prev_date, $date, $next_date);
  1280. }
  1281.  
  1282. # Ermittelt Datum-Status für Belegungen
  1283. function OccupiedStatus ($prev_date, $date, $next_date){
  1284. if ($date == $this->BeginDate() && $this->GetStatus ($date) == 'OE') { $date_status = 'O'; }
  1285. elseif ($date == $this->BeginDate()) { $date_status = 'OB'; }
  1286. elseif ($date == $this->EndDate() && $this->GetStatus ($date) == 'OB') { $date_status = 'O'; }
  1287. elseif ($date == $this->EndDate()) { $date_status = 'OE'; }
  1288. elseif (!in_array ($prev_date, $this->new_dates)) { $date_status = 'OB'; }
  1289. elseif (!in_array ($next_date, $this->new_dates)) { $date_status = 'OE'; }
  1290. elseif ($this->status[$date] == 'OE' && $this->status[$next_date] == 'OB') { $date_status = 'OE'; }# OE->OB (OE)
  1291. elseif ($this->status[$prev_date] == 'OE' && $this->status[$date] == 'OB') { $date_status = 'OB'; }# OE->OB (OB)
  1292. elseif ($prev_date == $this->EndDate() && $this->status[$date] == 'OB') { $date_status = 'OB'; }# OE->OB (OB)
  1293. elseif ($this->status[$date] == 'OE') { $date_status = 'OE'; }
  1294. else { $date_status = 'O'; }
  1295.  
  1296. # Return
  1297. return $date_status;
  1298. }
  1299.  
  1300. # Ermittelt Datum-Status für Reservierungen
  1301. function ReservedStatus ($prev_date, $date, $next_date){
  1302. if ($date == $this->BeginDate() && $this->GetStatus ($date) == 'RE') $date_status = 'R';
  1303. elseif ($date == $this->BeginDate()) $date_status = 'RB';
  1304. elseif ($date == $this->EndDate() && $this->GetStatus ($date) == 'RB') $date_status = 'R';
  1305. elseif ($date == $this->EndDate()) $date_status = 'RE';
  1306. elseif (!in_array ($prev_date, $this->new_dates)) $date_status = 'RB';
  1307. elseif (!in_array ($next_date, $this->new_dates)) $date_status = 'RE';
  1308. elseif ($this->status[$date] == 'RE' && $this->status[$next_date] == 'RB') $date_status = 'RE'; # RE->RB (RE)
  1309. elseif ($this->status[$prev_date] == 'RE' && $this->status[$date] == 'RB') $date_status = 'RB'; # RE->RB (RB)
  1310. elseif ($prev_date == $this->EndDate() && $this->status[$date] == 'RB') $date_status = 'RB'; # RE->RB (RB)
  1311. elseif ($this->status[$date] == 'RE') $date_status = 'RE';
  1312. else $date_status = 'R';
  1313.  
  1314. # Return
  1315. return $date_status;
  1316. }
  1317.  
  1318. # Liefert Link zu dem vorherigen Jahr
  1319. function PrevYearLink (){
  1320. global $ssn;
  1321. $prev_year = $this->GetYear() - 1;
  1322. if ($this->GetYear() > date ('Y'))
  1323. $prev_year = '<a href="' . $ssn->Url($_SERVER['PHP_SELF']
  1324. . '?year=' . $prev_year) . '">' . $prev_year . '</a>';
  1325. return $prev_year;
  1326. }
  1327.  
  1328. # Liefert Link zu dem nächsten Jahr
  1329. function NextYearLink (){
  1330. global $ssn;
  1331. $next_year = $this->GetYear() + 1;
  1332. if ($this->GetYear() < 2037)
  1333. $next_year = '<a href="' . $ssn->Url($_SERVER['PHP_SELF']
  1334. . '?year=' . $next_year) . '">' . $next_year . '</a>';
  1335. return $next_year;
  1336. }
  1337.  
  1338. # Reservieren Link
  1339. function ReservedLink (){
  1340. global $ssn;
  1341. $link = '&nbsp;<a style="text-decoration:none; color:black; font-size:12px" href="'
  1342. . $ssn->Url($_SERVER['PHP_SELF'] . '?mode=reserved_edit') . '">'
  1343. . $this->lang->Get('edit_reserved_word') . '</a>&nbsp;';
  1344. return $link;
  1345. }
  1346.  
  1347. # Belegungen Button
  1348. function OccupiedLink (){
  1349. global $ssn;
  1350. $link = '&nbsp;<a style="text-decoration:none; color:black; font-size:12px" href="'
  1351. . $ssn->Url($_SERVER['PHP_SELF'] . '?mode=occupied_edit') . '">'
  1352. . $this->lang->Get('edit_occupied_word') . '</a>&nbsp;';
  1353. return $link;
  1354. }
  1355.  
  1356. # Link zu dem Buchungsformular
  1357. function ReservationFormLink(){
  1358. global $ssn;
  1359. $link = $ssn->Url('reservation.php');
  1360. $link = '&nbsp;<a style="text-decoration:none; color:black; font-size:12px" href="#" '
  1361. . ' onclick="window.open(\'' . $link . '\', \'reservation\', '
  1362. . '\'width=850,height=600,left=50,top=50,resizable=yes,scrollbars=yes\'); return false;">'
  1363. . $this->lang->Get('reservation_form_word') . '</a>&nbsp;';
  1364. # $link = '&nbsp;<a href="' . $link . '">'
  1365. # . $this->lang->Get('reservation_form_word') . '</a>&nbsp;';
  1366. return $link;
  1367. }
  1368.  
  1369. # Belegungen Button
  1370. function NewReservationLink (){
  1371. global $ssn;
  1372. $link = '&nbsp;<a style="text-decoration:none; color:#0000BB; font-size:12px" href="'
  1373. . $ssn->Url($_SERVER['PHP_SELF']) . '">'
  1374. . '<b><u>&gt;&gt; new reservation &lt;&lt;</u></b></a>&nbsp;';
  1375. # $link = '<table border="0" cellpadding="0" cellspacing="0"><tr>'
  1376. # . '<td nowrap style="border: solid 2px #BB0000;">' . $link . '</td></tr></table>';
  1377. return $link;
  1378. }
  1379.  
  1380. # Speichert die Editierungsdatum
  1381. function SaveLastEditTime ($obj_id){
  1382. $qid = 'Zibepla::SaveLastEditTime';
  1383.  
  1384. $sql = "REPLACE INTO " . TBL_TIMES . " (object_id, last_edit) VALUES(" . $obj_id . ", " . time() . ")";
  1385. $this->db->query($sql, $qid);
  1386. }
  1387.  
  1388. # Erstellt Erwachene-SELECT für Buchungsformular
  1389. function AdultSelect (){
  1390. $sel = '<select id="rf_15" class="reservationFormSelectField" name="adult">';
  1391. for ($i = 1; $i <= $this->sets->Get('adult_max_number'); $i++)
  1392. $sel .= '<option value="' . $i . '" ' . (($i == $_POST['adult']) ? 'selected' : '') . '>' . $i . '</option>';
  1393. return $sel . '</select>';
  1394. }
  1395.  
  1396. # Erstellt Kinder-SELECT für Buchungsformular
  1397. function ChildernSelect (){
  1398. $sel = '<select id="rf_16" class="reservationFormSelectField" name="childern">';
  1399. for ($i = 0; $i <= $this->sets->Get('childern_max_number'); $i++)
  1400. $sel .= '<option value="' . $i . '" ' . ($selected = ($i == $_POST['childern']) ? 'selected' : '') . '>' . $i . '</option>';
  1401. return $sel . '</select>';
  1402. }
  1403.  
  1404. # Fügt ein neues Datum hinzu
  1405. function AddNewDate ($date){
  1406. if (!in_array ($date, $this->new_dates))
  1407. $this->new_dates[] = $date;
  1408. }
  1409.  
  1410. # Erstellt Monatsnavigation (monthly view)
  1411. function MonthNavigation(){
  1412. global $tpl, $ssn;
  1413. # Navigation erstellen
  1414. $navigation = '<table style="margin-bottom:2px" width="99%" bgcolor="#'
  1415. . $this->sets->Get('table_bgcolor', FALSE)
  1416. . '" border="0" cellpadding="0" cellspacing="2"><tr>';
  1417. for ($mon = 1; $mon <= 12; $mon++){
  1418. if ($mon < 10) $mon = '0' . $mon;
  1419. # Link
  1420. $navigation .= '<td bgcolor="#' . $this->sets->Get('months_bg_color', FALSE)
  1421. . '"><div align="center">&nbsp;<a href="'
  1422. . $ssn->Url($_SERVER['PHP_SELF'] . '?month=' . $mon) . '">'
  1423. . (($_SESSION['month'] == $mon) ? '<b>' : '')
  1424. . $this->lang->Get('month_' . $mon)
  1425. . (($_SESSION['month'] == $mon) ? '</b>' : '')
  1426. . '</a>&nbsp;</div></td>';
  1427. }
  1428. $navigation .= '</tr></table>';
  1429. # In die Template parsen
  1430. $tpl->set_var ('MONTH_NAVIGATION', $navigation);
  1431. }
  1432.  
  1433. # Erstellt ein Tooltip und fügt diesen in die Tooltip Array
  1434. function CreateTooltip ($width, $head = '', $content, $type, $id = 0){
  1435. if ($head == ''){
  1436. $tooltip = '<div id="' . $type . '_' . $id . '" class="tooltip" style="display: none; width: '
  1437. . $width . 'px;">'
  1438. . '<div class="tooltipContent">' . $content . '</div></div>';
  1439. }
  1440. elseif ($type == 'com'){
  1441. # Tooltip mit Head erstellen
  1442. $tooltip = '<div id="' . $type . '_' . $id . '" class="tooltip" style="display: none; width: '
  1443. . $width . 'px; ' . $zindex . '">'
  1444. . '<div class="tooltipHead">' . $head . '</div>'
  1445. . '<div class="tooltipContentCOM">' . $content . '</div></div>';
  1446. }
  1447. else{
  1448. # Tooltip mit Head erstellen
  1449. $tooltip = '<div id="' . $type . '_' . $id . '" class="tooltip" style="display: none; width: '
  1450. . $width . 'px;">'
  1451. . '<div class="tooltipHead">' . $head . '</div>'
  1452. . '<div class="tooltipContent">' . $content . '</div></div>';
  1453. }
  1454.  
  1455. # Tooltip ablegen
  1456. $this->AddTooltip ($tooltip, $type, $id);
  1457. }
  1458.  
  1459. # Erstellt ein Tooltip for einen Editor
  1460. function CreateTooltipEID ($id, $name = ''){
  1461. $qid = 'Zibepla::CreateTooltipEID';
  1462.  
  1463. # Editor Name abfragen
  1464. if ($name == '' && $id != 0){
  1465. $sql = "SELECT login, password FROM " . TBL_EDITORS . " WHERE editor_id = '" . $id . "'";
  1466. $this->db->query($sql, $qid); $this->db->next_record($qid);
  1467. $name = $this->db->f('login', $qid);
  1468. $password = $this->db->f('password', $qid);
  1469. if (empty ($name)) $name = 'Editor non exists';
  1470. }
  1471.  
  1472. # Tooltip erstellen
  1473. if ($id == 0){
  1474. $this->CreateTooltip (150, '', $this->lang->Get('administrator_word'), 'eid', $id);
  1475. }
  1476. else{
  1477. $head = $this->lang->Get('editor_id_word') . ' ' . $id;
  1478. $content = 'Login: ' . $name . (($this->editor->IsAdmin()) ? ('<br>Password: ' . $password) : '');
  1479. $this->CreateTooltip (150, $head, $content, 'eid', $id);
  1480. }
  1481. }
  1482.  
  1483. # Erstellt ein Tooltip für Objekt
  1484. function CreateTooltipOID ($id){
  1485. $qid = 'Zibepla::CreateTooltipOID';
  1486.  
  1487. # Object Name
  1488. $object_name = $this->lang->get('obj_name_' . $id);
  1489. if (empty ($object_name)) $object_name = $this->lang->Get('no_indicated');
  1490.  
  1491. # Gruppen Bezeichnung
  1492. $sql = "SELECT object_group FROM " . TBL_OBJ_SETTINGS . " WHERE object_id = '" . $id . "'";
  1493. $this->db->query ($sql, $qid);
  1494. if ($this->db->next_record($qid))
  1495. $object_group = $this->lang->Get('obj_group_name_' . $this->db->f('object_group', $qid));
  1496. else $object_group = $this->lang->Get('no_indicated');
  1497.  
  1498. # Tooltip erstellen
  1499. $head = $this->lang->Get('object_word') . ' ' . $object_name;
  1500. $content = $this->lang->Get('object_id_word') . ': ' . $id
  1501. . '<br>' . $this->lang->Get('object_group_word') . ': ' . $object_group;
  1502. $this->CreateTooltip (250, $head, $content, 'oid', $id);
  1503. }
  1504.  
  1505. # Erstellt ein Tooltip für Kommentar
  1506. function CreateTooltipCOM ($id, $comment){
  1507. $this->CreateTooltip (400, $this->lang->Get('comment_word'), $comment, 'com', $id);
  1508. }
  1509.  
  1510. # Erstellt ein Tooltip - Hilfe
  1511. function CreateTooltipHelp ($id){
  1512. # Tooltip erstellen
  1513. $head = '';
  1514. $content = '';
  1515. $this->CreateTooltip (400, $this->lang->Get('comment_word'), $comment, 'hlp', $id);
  1516. }
  1517.  
  1518. # Gibt die Tooltips zurück
  1519. function GetTooltips (){
  1520. foreach ($this->tooltips AS $var)
  1521. $tooltips .= implode ('', $var);
  1522. return $tooltips;
  1523. }
  1524.  
  1525. # Ermittelt Object ID anhand von Gast ID
  1526. function GetGuestData($guest_id){
  1527. $qid = 'Zibepla::GetGuestData';
  1528.  
  1529. # Weil statische Funktion
  1530. global $db;
  1531.  
  1532. $sql = "SELECT * FROM " . TBL_RESERVATIONS . " WHERE id = '" . $guest_id . "'";
  1533. $db->query($sql, $qid);
  1534. $db->next_record($qid);
  1535.  
  1536. return array (
  1537. 'object_id' => $db->f('object_id', $qid),
  1538. 'status' => $db->f('status', $qid),
  1539. );
  1540. }
  1541.  
  1542. # Erstellt ein Link zur Druckversion
  1543. function CreatePrintLink ($mode, &$ssn){
  1544. return '<a href="#" onclick="window.open (\'' . $ssn->Url('print.php?mode=' . $mode)
  1545. . '\', \'Print\', \'width=850,height=600,left=100,top=100,resizable=yes,scrollbars=yes,menubar=yes\')">'
  1546. . '<img src="images/print_' . $mode . '.gif" width="30" height="14" hspace="3"></a>';
  1547. }
  1548.  
  1549. # Erstellt eine Seitenblätternavigation für Buchungsliste
  1550. function PagesHandler ($file, $get, $rowsPerPage, $numRows, $currentPage){
  1551. global $ssn;
  1552. # Variablen
  1553. $tr = '.';
  1554. if (empty ($currentPage)) $currentPage = 1;
  1555. # Back
  1556. if ($rowsPerPage == 0) #
  1557. smError('Zibepla::PagesHandler - Division by zero.');
  1558. else $numPages = ceil($numRows / $rowsPerPage);
  1559. if($currentPage > 1){
  1560. $back = $currentPage - 1;
  1561. # if ($back > 1)
  1562. $pages = "<a class=\"PagesHandlerLink\" href=\"".$ssn->Url($file."?page=1".((!empty($get)) ? "&".$get : ""))."\">&lt;&lt</a> <a class=\"PagesHandlerLink\" href=\"".$file."?page=".$back.((!empty($get)) ? "&".$get : "")."\">" . $this->lang->Get('back_word') . "</a> <font FACE=\"Symbol\">&#183;</font> ";
  1563. # else $pages = "<a class=\"PagesHandlerLink\" href=\"".$file.((!empty($get)) ? "?page=1&".$get : "")."\">&lt;&lt</a> <a class=\"PagesHandlerLink\" href=\"".$file."?page=1".((!empty($get)) ? "?".$get : "")."\">Zurück</a> <font FACE=\"Symbol\">&#183;</font> ";
  1564. }
  1565. # Pages
  1566. $bSub = ($numPages - $currentPage < 5) ? 10 -($numPages - $currentPage) : 5;
  1567. $eSub = (10 - $currentPage > 5) ? 10 - $currentPage : 5;
  1568. $begin = ($currentPage - $bSub < 1) ? 1 : $currentPage - $bSub;
  1569. $end = ($currentPage + $eSub > $numPages) ? $numPages : ($currentPage + $eSub);
  1570.  
  1571. for($i = $begin; $i <= $end; $i++){
  1572. if ($i == $end) $pages .= ($i != $currentPage) ? " <a class=\"PagesHandlerLink\" href=\"".$ssn->Url ($file."?page=".$i.((!empty($get)) ? "&".$get : ""))."\">$i</a> " : " <font FACE=\"Symbol\">&#183;</font> [$i/$numPages]";
  1573. elseif ($i > 1) $pages .= ($i != $currentPage) ? " <a class=\"PagesHandlerLink\" href=\"".$ssn->Url ($file."?page=".$i.((!empty($get)) ? "&".$get : ""))."\">$i</a> " : " <font FACE=\"Symbol\">&#183;</font> [$i/$numPages] <font FACE=\"Symbol\">&#183;</font> ";
  1574. else $pages .= ($i != $currentPage) ? " <a class=\"PagesHandlerLink\" href=\"".$ssn->Url ($file."?page=".$i.((!empty($get)) ? "&".$get : ""))."\">$i</a> " : "[$i/$numPages] <font FACE=\"Symbol\">&#183;</font> ";
  1575. if ($i < $end && $i != $currentPage && $i != $currentPage - 1) $pages .= ' <font FACE=\"Symbol\">&#183;</font> ';
  1576. }
  1577. # Next
  1578. if($numPages > $currentPage) {
  1579. $next = $currentPage + 1;
  1580. $pages .= " <font FACE=\"Symbol\">&#183;</font> <a class=\"PagesHandlerLink\" href=\"".$ssn->Url ($file."?page=".$next.((!empty($get)) ? "&".$get : ""))."\">" . $this->lang->Get('next_word') . "</a> <a class=\"PagesHandlerLink\" href=\"".$file."?page=".$numPages.((!empty($get)) ? "&".$get : "")."\">&gt;&gt;</a>";
  1581. }
  1582. # Table
  1583. $pages = "<div class=\"PagesHandlerField\">".$pages."</div>";
  1584. # Return
  1585. return $pages;
  1586. }
  1587.  
  1588. # Anfangs- und Enddatum bei der Buchung
  1589. function BeginDate (){ return $_POST['j_yea'] . '-' . ((strlen ($_POST['j_mon']) == 1) ? '0' . $_POST['j_mon'] : $_POST['j_mon']) . '-' . ((strlen ($_POST['j_day']) == 1) ? '0' . $_POST['j_day'] : $_POST['j_day']); }
  1590. function EndDate (){ return $_POST['d_yea'] . '-' . ((strlen ($_POST['d_mon']) == 1) ? '0' . $_POST['d_mon'] : $_POST['d_mon']) . '-' . ((strlen ($_POST['d_day']) == 1) ? '0' . $_POST['d_day'] : $_POST['d_day']); }
  1591. function CorrectEndDate () { if (!isset($_POST['d_yea'])) { $_POST['d_yea'] = $_POST['j_yea']; $_POST['d_mon'] = $_POST['j_mon']; $_POST['d_day'] = $_POST['j_day']; }}
  1592.  
  1593. # Sonstige Funktionen
  1594. function AddTooltip ($tooltip, $form, $id) { $this->tooltips[$form][$id] = $tooltip . "\n"; } # Tooltip hinzufügen
  1595. function GetLastEdit (){ return $this->last_edit; } # Letzte Änderung
  1596. function GetTable (){ return $this->table; } # Die Plan-Tabelle
  1597. function GetYear (){ return $this->year; } # Das Jahr
  1598. function GetID (){ return $this->obj_id; } # Die ID
  1599. function GetDates() { return $this->dates; } # Die Daten
  1600. function GetStatus($date) { return $this->status[$date]; } # Status
  1601. function GetEdit () { return $this->edit; } # Edit
  1602. }
  1603. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement