Advertisement
| Hall of Fame |
|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607: 608: 609: 610: 611: 612: 613: 614: 615: 616: 617: 618: 619: 620: 621: 622: 623: 624: 625: 626: 627: 628: 629: 630: 631: 632: 633: 634: 635: 636: 637: 638: 639: 640: 641: 642: 643: 644: 645: 646: 647: 648: 649: 650: 651: 652: 653: 654: 655: 656: 657: 658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668: 669: 670: 671: 672: 673: 674: 675: 676: 677: 678: 679: 680: 681: 682: 683: 684: 685: 686: 687: 688: 689: 690: 691: 692: 693: 694: 695: 696: 697: 698: 699: 700: 701: 702: 703: 704: 705: 706: 707: 708: 709: 710: 711: 712: 713: 714: 715: 716: 717: 718: 719: 720: 721: 722: 723: 724: 725: 726: 727: 728: 729: 730: 731: 732: 733: 734: 735: 736: 737: 738: 739: 740: 741: 742: 743: 744: 745: 746: 747: 748: 749: 750: 751: 752: 753: 754: 755: 756: 757: 758: 759: 760: 761: 762: 763: 764: 765: 766: 767: 768: 769: 770: 771: 772: 773: 774: 775: 776: 777: 778: 779: 780: 781: 782: 783: 784: 785: 786: 787: 788: 789: 790: 791: 792: 793: 794: 795: 796: 797: 798: 799: 800: 801: 802: 803: 804: 805: 806: 807: 808: 809: 810: 811: 812: 813: 814: 815: 816: 817: 818: 819: 820: 821: 822: 823: 824: 825: 826: 827: 828: 829: 830: 831: 832: 833: 834: 835: 836: 837: 838: 839: 840: 841: 842: 843: 844: 845: 846: 847: 848: 849: 850: 851: 852: 853: 854: 855: 856: 857: 858: 859: 860: 861: 862: 863: 864: 865: 866: 867: 868: 869: 870: 871: 872: 873: 874: 875: 876: 877: 878: 879: 880: 881: 882: 883: 884: 885: 886: 887: 888: 889: 890: 891: 892: 893: 894: 895: 896: 897: 898: 899: 900: 901: 902: 903: 904: 905: 906: 907: 908: 909: 910: 911: 912: 913: 914: 915: 916: 917: 918: 919: 920: 921: 922: 923: 924: 925: 926: 927: 928: 929: 930: 931: 932: 933: 934: 935: 936: 937: 938: 939: 940: 941: 942: 943: 944: 945: 946: 947: 948: 949: 950: 951: 952: 953: 954: 955: 956: 957: 958: 959: 960: 961: 962: 963: 964: 965: 966: 967: 968: 969: 970: 971: 972: 973: 974: 975: 976: 977: 978: 979: 980: 981: 982: 983: 984: 985: 986: 987: 988: 989: 990: 991: 992: 993: 994: 995: 996: 997: 998: 999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068: 1069: 1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108: 1109: 1110: 1111: 1112: 1113: 1114: 1115: 1116: 1117: 1118: 1119: 1120: 1121: 1122: 1123: 1124: 1125: 1126: 1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134: 1135: 1136: 1137: 1138: 1139: 1140: 1141: 1142: 1143: 1144: 1145: 1146: 1147: 1148: 1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172: 1173: 1174: 1175: 1176: 1177: 1178: 1179: 1180: 1181: 1182: 1183: 1184: 1185: 1186: 1187: 1188: 1189: 1190: 1191: 1192: 1193: 1194: 1195: 1196: 1197: 1198: 1199: 1200: 1201: 1202: 1203: 1204: 1205: 1206: 1207: 1208: 1209: 1210: 1211: 1212: 1213: 1214: 1215: 1216: 1217: 1218: 1219: 1220: 1221: 1222: 1223: 1224: 1225: 1226: 1227: 1228: 1229: 1230: 1231: 1232: 1233: 1234: 1235: 1236: 1237: 1238: 1239: 1240: 1241: 1242: 1243: 1244: 1245: 1246: 1247: 1248: 1249: 1250: 1251: 1252: 1253: 1254: 1255: 1256: 1257: 1258: 1259: 1260: 1261: 1262: 1263: 1264: 1265: 1266: 1267: 1268: 1269: 1270: 1271: 1272: 1273: 1274: 1275: 1276: 1277: 1278: 1279: 1280: 1281: 1282: 1283: 1284: 1285: 1286: 1287: 1288: 1289: 1290: 1291: 1292: 1293: 1294: 1295: 1296: 1297: 1298: 1299: 1300: 1301: 1302: 1303: 1304: 1305: 1306: 1307: 1308: 1309: 1310: 1311: 1312: 1313: 1314: 1315: 1316: 1317: 1318: 1319: 1320: 1321: 1322: 1323: 1324: 1325: 1326: 1327: 1328: 1329: 1330: 1331: 1332: 1333: 1334: 1335: 1336: 1337: 1338: 1339: 1340: 1341: 1342: 1343: 1344: 1345: 1346: 1347: 1348: 1349: 1350: 1351: 1352: 1353: 1354: 1355: 1356: 1357: 1358: 1359: 1360: 1361: 1362: 1363: 1364: 1365: 1366: 1367: 1368: 1369: 1370: 1371: 1372: 1373: 1374: 1375: 1376: 1377: 1378: 1379: 1380: 1381: 1382: 1383: 1384: 1385: 1386: 1387: 1388: 1389: 1390: 1391: 1392: 1393: 1394: 1395: 1396: 1397: 1398: 1399: 1400: 1401: 1402: 1403: 1404: 1405: 1406: 1407: 1408: 1409: 1410: 1411: 1412: 1413: 1414: 1415: 1416: 1417: 1418: 1419: 1420: 1421: 1422: 1423: 1424: 1425: 1426: 1427: 1428: 1429: 1430: 1431: 1432: 1433: 1434: 1435: 1436: 1437: 1438: 1439: 1440: 1441: 1442: 1443: 1444: 1445: 1446: 1447: 1448: 1449: 1450: 1451: 1452: 1453: 1454: 1455: 1456: 1457: 1458: 1459: 1460: 1461: 1462: 1463: 1464: 1465: 1466: 1467: 1468: 1469: 1470: 1471: 1472: 1473: 1474: 1475: 1476: 1477: 1478: 1479: 1480: 1481: 1482: 1483: 1484: 1485: 1486: 1487: 1488: 1489: 1490: 1491: 1492: 1493: 1494: 1495: 1496: 1497: 1498: 1499: 1500: 1501: 1502: 1503: 1504: 1505: 1506: 1507: 1508: 1509: 1510: 1511: 1512: 1513: 1514: 1515: 1516: 1517: 1518: 1519: 1520: 1521: 1522: 1523: 1524: 1525: 1526: 1527: 1528: 1529: 1530: 1531: 1532: 1533: 1534: 1535: 1536: 1537: 1538: 1539: 1540: 1541: 1542: 1543: 1544: 1545: 1546: 1547: 1548: 1549: 1550: 1551: 1552: 1553: 1554: 1555: 1556: 1557: 1558: 1559: 1560: 1561: 1562: 1563: 1564: 1565: 1566: 1567: 1568: 1569: 1570: 1571: 1572: 1573: 1574: 1575: 1576: 1577: 1578: 1579: 1580: 1581: 1582: 1583: 1584: 1585: 1586: 1587: 1588: 1589: 1590: 1591: 1592: 1593: 1594: 1595: 1596: 1597: 1598: 1599: 1600: 1601: 1602: 1603: 1604: 1605: 1606: 1607: 1608: 1609: 1610: 1611: 1612: 1613: 1614: 1615: 1616: 1617: 1618: 1619: 1620: 1621: 1622: 1623: 1624: 1625: 1626: 1627: 1628: 1629: 1630: 1631: 1632: 1633: 1634: 1635: 1636: 1637: 1638: 1639: 1640: 1641: 1642: 1643: 1644: 1645: 1646: 1647: 1648: 1649: 1650: 1651: 1652: 1653: 1654: 1655: 1656: 1657: 1658: 1659: 1660: 1661: 1662: 1663: 1664: 1665: 1666: 1667: 1668: 1669: 1670: 1671: 1672: 1673: 1674: 1675: 1676: 1677: 1678: 1679: 1680: 1681: 1682: 1683: 1684: 1685: 1686: 1687: 1688: 1689: 1690: 1691: 1692: 1693: 1694: 1695: 1696: 1697: 1698: 1699: 1700: 1701: 1702: 1703: 1704: 1705: 1706: 1707: 1708: 1709: 1710: 1711: 1712: 1713: 1714: 1715: 1716: 1717: 1718: 1719: 1720: 1721: 1722: 1723: 1724: 1725: 1726: 1727: 1728: 1729: 1730: 1731: 1732: 1733: 1734: 1735: 1736: 1737: 1738: 1739: 1740: 1741: 1742: 1743: 1744: 1745: 1746: 1747: 1748: 1749: 1750: 1751: 1752: 1753: 1754: 1755: 1756: 1757: 1758: 1759: 1760: 1761: 1762: 1763: 1764: 1765: 1766: 1767: 1768: 1769: 1770: 1771: 1772: 1773: 1774: 1775: 1776: 1777: 1778: 1779: 1780: 1781: 1782: 1783: 1784: 1785: 1786: 1787: 1788: 1789: 1790: 1791: 1792: 1793: 1794: 1795: 1796: 1797: 1798: 1799: 1800: 1801: 1802: 1803: 1804: 1805: 1806: 1807: 1808: 1809: 1810: 1811: 1812: 1813: 1814: 1815: 1816: 1817: 1818: 1819: 1820: 1821: 1822: 1823: 1824: 1825: 1826: 1827: 1828: 1829: 1830: 1831: 1832: 1833: 1834: 1835: 1836: 1837: 1838: 1839: 1840: 1841: 1842: 1843: 1844: 1845: 1846: 1847: 1848: 1849: 1850: 1851: 1852: 1853: 1854: 1855: 1856: 1857: 1858: 1859: 1860: 1861: 1862: 1863: 1864: 1865: 1866: 1867: 1868: 1869: 1870: 1871: 1872: 1873: 1874: 1875: 1876: 1877: 1878: 1879: 1880: 1881: 1882: 1883: 1884: 1885: 1886: 1887: 1888: 1889: 1890: 1891: 1892: 1893: 1894: 1895: 1896: 1897: 1898: 1899: 1900: 1901: 1902: 1903: 1904: 1905: 1906: 1907: 1908: 1909: 1910: 1911: 1912: 1913: 1914: 1915: 1916: 1917: 1918: 1919: 1920: 1921: 1922: 1923: 1924: 1925: 1926: 1927: 1928: 1929: 1930: 1931: 1932: 1933: 1934: 1935: 1936: 1937: 1938: 1939: 1940: 1941: 1942: 1943: 1944: 1945: 1946: 1947: 1948: 1949: 1950: 1951: 1952: 1953: 1954: 1955: 1956: 1957: 1958: 1959: 1960: 1961: 1962: 1963: 1964: 1965: 1966: 1967: 1968: 1969: 1970: 1971: 1972: 1973: 1974: 1975: 1976: 1977: 1978: 1979: 1980: 1981: 1982: 1983: 1984: 1985: 1986: 1987: 1988: 1989: 1990: 1991: 1992: 1993: 1994: 1995: 1996: 1997: 1998: 1999: 2000: 2001: 2002: 2003: 2004: 2005: 2006: 2007: 2008: 2009: 2010: 2011: 2012: 2013: 2014: 2015: 2016: 2017: 2018: 2019: 2020: 2021: 2022: 2023: 2024: 2025: 2026: 2027: 2028: 2029: 2030: 2031: 2032: 2033: 2034: 2035: 2036: 2037: 2038: 2039: 2040: 2041: 2042: 2043: 2044: 2045: 2046: 2047: 2048: 2049: 2050: 2051: 2052: 2053: 2054: 2055: 2056: 2057: 2058: 2059: 2060: 2061: 2062: 2063: 2064: 2065: 2066: 2067: 2068: 2069: 2070: 2071: 2072: 2073: 2074: 2075: 2076: 2077: 2078: 2079: 2080: 2081: 2082: 2083: 2084: 2085: 2086: 2087: 2088: 2089: 2090: 2091: 2092: 2093: 2094: 2095: 2096: |
<?php
/*
showCalendar.php
Allows for full management of reservations.
----
Copyright (C) 2002 David Thorne (mmmbena1@hotmail.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
require_once "../system/access_privileges.php";
if (!privileged('reservation')) {
header("Location: ../no_access.php?privilege=Reservations");
exit();
}
session_start();
// Gets only the selected form variables into global scope
// Taken from http://www.php.net
$param_list = array (
'act','ID','year','month','day','startTimeBeforeVariance',
'startTimeVariance','startTime','forMemberID','finishTime',
'activityID','description','respending','recurrencePeriod',
'Period','MemberID','ActivityID','BlockBookingID',
'StartTime','Description','reservations',
'reservationID','blockBookingID','startResource','finishResource',
'startTimeOfDay','finishTimeOfDay','numberPeriods','chosenIDs',
'resourceIDs','newres','oldres','minical',
'endday','endmonth','endyear','startday','startmonth','startyear'
);
foreach ($param_list as $param) {
@$$param=$_REQUEST[$param];
}
if (!isset($act)) { extract($_SESSION['_reservation']); }
if (!isset($act)) { $act = ''; }
if ($ID == '') $ID=$_SESSION['_resourceGroupID'];
require "../system/shell_iframe_header.php";
require_once "../system/opendb.php";
require_once "../system/minicals.php";
require_once "../system/recordset.php";
require_once "../system/message.php";
require_once "../system/time.php";
require_once "../system/conflict.php";
require_once "../system/global_preferences.php";
// $db_connection = mysql_connect("localhost:/var/lib/mysql/mysql.sock","root","") or die("Fatal Error: Could not connect");
// mysql_select_db("Sports") or die("Fatal Error: No Sports Database");
// Retrieve resource group information
$sql = "SELECT * FROM tbl_ResourceGroups WHERE ID=" . $ID;
$result = mysql_query($sql) or die("Fatal Error: Resource Group Query Failed");
$info = mysql_fetch_assoc($result) or die("Fatal Error: No Resource Group Information");
// Retrieve section information for this resource group
$sql = "SELECT * FROM tbl_Resources WHERE ResourceGroupID=" . $ID;
$result = mysql_recordset($sql);
$num_sections = count($result);
$_SESSION['_resourceGroupID'] = $ID;
if (!isset($day) or !isset($month) or !isset($year)) {
$year = $_SESSION['_year'];
$month = $_SESSION['_month'];
$day = $_SESSION['_day'];
} else {
while (!checkdate($month, $day, $year)) $day--;
$_SESSION['_year'] = $year;
$_SESSION['_month'] = $month;
$_SESSION['_day'] = $day;
}
if ($act == 'reserveaction') {
if (!privileged('modify')) {
require "../no_access.php";
exit();
}
extract($_SESSION['_reservation']);
if ($recurrencePeriod==0) {
$endday = $day;
$endmonth = $month;
$endyear = $year;
}
if (checkdate($endmonth,$endday,$endyear)) {
$failurenotice = 'Links to conflicts: ';
$_SESSION['_reservation'] = array();
$startTimeObj = new timeCalculator($startTime);
$finishTimeObj = new timeCalculator($finishTime);
$conflictlist="act=reserveaction&conflictid=".$reservationID."+".mktime($startTimeObj->hour,$startTimeObj->min,0,$month,$day,$year)."&";
$numberPeriods = (($finishTimeObj->dumpTS()-$startTimeObj->dumpTS())/60)/5;
$blockBookingID = mysql_send("INSERT INTO tbl_BlockBookings
(OperatorID,Pending) VALUES (" . $_SESSION['_id'] . "," . ($respending=='true'?'0':'1') . ")");
$iday = $day;
$imonth = $month;
$iyear = $year;
// MH
// Check for conflicts
$no_conflicts=true;
while (mktime(0,0,0,$imonth,$iday,$iyear)<=mktime(23,59,59,$endmonth,$endday,$endyear)) {
$startTimeTS = mktime($startTimeObj->hour,$startTimeObj->min,0,$imonth,$iday,$iyear);
$conflicts = conflict($startTimeTS,$numberPeriods*5,$resourceIDs);
if ($conflicts) {
$no_conflicts = false;
foreach ($conflicts as $conflict) {
$failurenotice .= "<a href=\"showCalendar.php?act=view&reservationID=".$conflict['id']."\">[" . strftime("%d/%m/%y %T", $conflict['startTime']) . "]</a> ";
$conflictlist.="reservationid[]=".$conflict['id']."+".$conflict['startTime']."&";
}
}
// And check the other reservations as well
if ($recurrencePeriod==0) break;
if ($recurrencePeriod==1) {
do {
$iday++;
} while (strftime('%u',mktime(0,0,0,$imonth,$iday,$iyear)) > 5);
}
if ($recurrencePeriod==2) $iday += 7;
if ($recurrencePeriod==3) $iday += 14;
}
// Reset the index date
$iday = $day;
$imonth = $month;
$iyear = $year;
// No conflicts - so go ahead
if ($no_conflicts) {
while (mktime(0,0,0,$imonth,$iday,$iyear)<=mktime(23,59,59,$endmonth,$endday,$endyear)) {
$startTimeTS = mktime($startTimeObj->hour,$startTimeObj->min,0,$imonth,$iday,$iyear);
$sql = "INSERT INTO tbl_Reservations (MemberID,ActivityID,ClientName,ClientTel,StartTime,Period,BlockBookingID,Description) VALUES ($forMemberID,$activityID,'$clientName','$clientTel','" . $startTimeTS . "'," . (5*$numberPeriods) . ",$blockBookingID,'" . $description . "')";
$reservationID = mysql_send($sql);
foreach ($resourceIDs as $resourceID) {
$sql = "INSERT INTO tbl_ReservationMappings (ResourceID,ReservationID) VALUES ($resourceID,$reservationID)";
mysql_send($sql);
}
if ($recurrencePeriod==0) break;
if ($recurrencePeriod==1) {
do {
$iday++;
} while (strftime('%u',mktime(0,0,0,$imonth,$iday,$iyear)) > 5);
}
if ($recurrencePeriod==2) $iday += 7;
if ($recurrencePeriod==3) $iday += 14;
}
$act = '';
} else {
$message = 'CONFLICTS: '.$failurenotice . "<a href=\"#\" onclick=\"javascript:window.open('popupConflicts.php?".$conflictlist."','','status=0,toolabar=0,location=0,menus=0,directories=0,resizable=0,scrollbars=1,height=195,width=360')\">Popup conflicts...</a>";
$act = 'reserve';
}
} else {
$message = "CORRECTION: End date must be in a valid format";
$act = 'reserve';
}
}
if ($act == 'reserve') {
if (!privileged('modify')) {
require "../no_access.php";
exit();
}
// remember the current reservation information
$vars = array('act','year','month','day','startTimeBeforeVariance','startTimeOfDay','finishTimeOfDay','startTimeVariance','numberPeriods','startResource','finishResource');
$_SESSION['_reservation'] = compact($vars);
$startTimeOfDayObj = new timeCalculator($startTimeOfDay);
$finishTimeOfDayObj = new timeCalculator($finishTimeOfDay);
$startTimeObj = new timeCalculator($startTimeBeforeVariance);
if (!isset($occurrences)) $occurences=1;
$activities = mysql_recordset("SELECT * FROM tbl_Activities WHERE ResourceGroupID=$ID AND SectionCount<=" . (1+$finishResource-$startResource) . " ORDER BY Name");
$sql = "SELECT tbl_Members.* FROM tbl_Members WHERE tbl_Members.ID>0 ORDER BY tbl_Members.Name";
$members = mysql_recordset($sql);
display($message);
if (count($activities)>0) {
?>
<script language=javascript>
<!--
function Deselect() {
document.mainForm.target = 'status';
document.mainForm.act.value = 'focus';
document.mainForm.memberID.value = 0;
document.mainForm.action = '../status.php';
document.mainForm.submit();
document.location = 'showCalendar.php?memberID=0';
}
function selectCont() {
// Ensure that selected resources are next to each other
firstsel = -1;
lastsel = -1;
for (i=0; i<document.getElementById('resourceIDs').length; i++) {
if (document.getElementById('resourceIDs').options[i].selected) {
// alert(i + " is selected");
if (firstsel != -1) {
lastsel = i;
} else {
firstsel = i;
lastsel = i;
}
}
}
//alert("first+last=" + firstsel + " " + lastsel);
if (firstsel != -1) {
for (i=firstsel; i<=lastsel; i++)
document.getElementById('resourceIDs').options[i].selected = true;
}
}
function correctDate() {
<?php
// correct for 2 digit year :(
// Lets hope this wont be in use later
if ($year < 80) {
$year += 2000;
} else if ($year < 100) {
$year += 1900;
}
?>
leapyear=false;
year = document.mainForm.endyear.value;
if (((year % 4 == 0) && (year % 100 != 0)) ||
(year % 400 == 0) && (year % 4000 !=0)) leapyear=true;
var daysin = new Array ('', 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
if (leapyear) daysin[2]=29;
for (i = 29; i<=31; i++) {
if (i>daysin[document.mainForm.endmonth.value]) {
document.mainForm.endday.options[i-1].disabled = true;
if (document.mainForm.endday.options[i-1].selected == true) {
document.mainForm.endday.options[daysin[document.mainForm.endmonth.value]-1].selected = true;
}
} else {
document.mainForm.endday.options[i-1].disabled = false;
}
}
}
function enableEndDate() {
if (document.mainForm.recurrencePeriod.value > 0) {
disable = false;
} else {
disable = true;
}
document.mainForm.endyear.disabled = disable;
document.mainForm.endmonth.disabled = disable;
document.mainForm.endday.disabled = disable;
}
// -->
</script>
<form method=post name=mainForm>
<input type=hidden name=ID value="<?=$ID?>">
<input type=hidden name=act value=reserveaction>
<input type=hidden name=year value="<?=$year?>">
<input type=hidden name=month value="<?=$month?>">
<input type=hidden name=day value="<?=$day?>">
<input type=hidden name=startTimeBeforeVariance value="<?=$startTimeBeforeVariance?>">
<input type=hidden name=startTimeVariance value="<?=$startTimeVariance?>">
<table class=options cellpadding=0 cellspacing=10>
<tr>
<th colspan=2><b>Make Booking</b></th>
</tr>
<tr>
<td>
<table class=options cellpadding=4 cellspacing=0>
<tr>
<td align=right>Resource: </td>
<td><b><?=$info['Name']?></b></td>
</tr>
<tr>
<td align=right>Sections: </td>
<td>
<?php
// Sort the columns with natural order sort
$to_sort = array();
foreach ($result as $row) {
array_push($to_sort, $row['Name']);
}
natcasesort($to_sort);
$sorted = array();
foreach($to_sort as $key => $value) {
array_push($sorted, $result[$key]);
}
$result = $sorted;
?>
<select id="resourceIDs" name="resourceIDs[]" size="5" multiple="multiple" onChange="selectCont()">
<?php
foreach ($result as $key => $resource) {
$checked='';
if ($startResource <= $key && $key <= $finishResource) {
$checked=' selected="selected"';
}
?>
<option value="<?=$resource['ID']?>" <?=$checked?>><?php
echo $resource[Name] ?></option>
<?php }
?>
</select>
</td>
</tr>
<tr>
<td align=right>Member: </td>
<td><select name=forMemberID>
<?php
foreach ($members as $record) {
?>
<option value="<?=$record['ID']?>"><?=$record['Name']?></option>
<?php
}
?>
</select></td>
</tr>
<tr>
<td align=right>On Date: </td>
<td><b><?=strftime('%A %e %B %Y',mktime(0,0,0,$month,$day,$year))?></b></td>
</tr>
<tr>
<td align=right>From Time: </td>
<?php $startTimeObj->addMinutes(5*$startTimeVariance); ?>
<td>
<select name=startTime>
<?php
$currentTime = $startTimeOfDayObj;
while ($currentTime->dump() < $finishTimeOfDayObj->dump()) {
if ($currentTime->dump() == $startTimeObj->dump()) { $selected = ' selected="selected"'; } else { $selected = ''; }
print ' <option value="'.$currentTime->dump().'"'.$selected.'>'.$currentTime->dump()."</option>\n";
$currentTime->addMinutes(5);
}
?>
</select>
</td>
</tr>
<tr>
<td align=right>To Time: </td>
<td>
<select name=finishTime>
<?php
$currentTime = $startTimeOfDayObj;
$currentTime->addMinutes(5);
$startTimeObj->addMinutes(5*$numberPeriods);
while ($currentTime->dump() <= $finishTimeOfDayObj->dump()) {
if ($currentTime->dump() == $startTimeObj->dump()) { $selected = ' selected="selected"'; } else { $selected = ''; }
print ' <option value="'.$currentTime->dump().'"'.$selected.'>'.$currentTime->dump()."</option>\n";
$currentTime->addMinutes(5);
}
?>
</select>
</td>
</tr>
<tr>
<td align=right>For Activity: </td>
<td>
<select name=activityID>
<?php
if (isset($_REQUEST['activityID'])) {
$activityID = $_REQUEST['activityID'];
} else {
$activityID = -1;
}
foreach ($activities as $record) {
if ($record["ID"] == $activityID) {$checked = " selected";} else {$checked = "";};
print (" <option value='{$record['ID']}'${checked}>{$record['Name']}</option>\n");
}
?>
</select>
</td>
</tr>
<tr>
<td align=right valign=top>Description: </td>
<td><textarea name="description" cols="50" rows="5"></textarea></td>
</tr>
<tr>
<td colspan=2>Note: The first line of the description is displayed
on the reservations calendar page.</td>
</tr>
<tr>
<td valign=top></td>
<td><input type="checkbox" name="respending" value="true" checked /> Confirm this booking.</td>
</tr>
<tr>
<td align=right> Recurrence: </td>
<td>
<select name=recurrencePeriod onChange="enableEndDate()">
<?php for ($i=0; $i<=3; $i++) {
$a = 'checked' . $i;
if ($recurrencePeriod == $i) {
$$a = 'selected="selected"';
} else {
$$a = '';
}
}
?>
<option value='0' <?=$checked0?>>Single Reservation</option>
<option value='1' <?=$checked1?>>Daily (Mon-Fri)</option>
<option value='2' <?=$checked2?>>Weekly</option>
<option value='3' <?=$checked3?>>Fortnightly</option>
</select>
</td>
</tr>
<tr>
<td align=right>End Date: </td>
<td>
<select name="endday" onFocus="correctDate()" disabled="disabled"><?php
for ($i=1; $i<=31; $i++) {
if (($i == $day && !isset($endday)) || $i == $endday) {
$checked = ' selected="selected"';
} else {
$checked = '';
}
?>
<option value="<?=$i?>"<?=$checked?>><?=$i?></option>
<?php } ?>
</select>
<select name="endmonth" onChange="correctDate()" disabled="disabled"><?php
$months=array('','January','February','March','April','May',
'June','July','August','September','October','November',
'December');
for ($i=1; $i<=12; $i++) {
if (($i == $month && !isset($endmonth)) || $i==$endmonth) {
$checked = ' selected="selected"';
} else {
$checked = '';
}
?>
<option value="<?=$i?>"<?=$checked?>><?=$months[$i]?></option>
<?php } ?>
</select>
<select name="endyear" onChange="correctDate()" disabled="disabled"><?php
for ($i=$year-10; $i<=$year+10; $i++) {
if (($i == $year && !isset($endyear)) || $i == $endyear) {
$checked = ' selected="selected"';
} else {
$checked = '';
}
?>
<option value="<?=$i?>"<?=$checked?>><?=$i?></option>
<?php
}
?></select>
</td>
</tr>
<tr>
<td align=right colspan=4><input type=submit class=button value="Make Reservation"><input type=reset class=button value="Reset"><input type=button class=button value="Cancel" onclick="document.location='showCalendar.php?act=&ID=<?=$ID?>'"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<script language="javascript" type="text/javascript"><!--
enableEndDate();
//--></script>
<?php
} else {
$message = "ERROR: No Activities Set Up";
$act = "";
}
}
if ($act == 'remove') {
if (!privileged('modify')) {
require "../no_access.php";
exit();
}
if (!isset($chosenIDs)) {
$message="ERROR: No reservations selected to cancel";
$act = "view";
} else {
$flag = false;
$act = "view";
$block = mysql_recordset("SELECT * FROM tbl_Reservations WHERE BlockBookingID=" . $blockBookingID);
foreach ($chosenIDs as $chosenID) {
mysql_send("DELETE FROM tbl_ReservationMappings WHERE ReservationID=$chosenID");
mysql_send("DELETE FROM tbl_Reservations WHERE ID=$chosenID");
if ($chosenID == $reservationID) { $flag = true; }
}
if (count($chosenIDs) == $reservations) {
mysql_send("DELETE FROM tbl_BlockBookings WHERE ID=$blockBookingID");
$act = "";
$flag = false;
}
$block = mysql_recordset("SELECT * FROM tbl_Reservations WHERE BlockBookingID=" . $blockBookingID);
if ($flag) {
$block = mysql_recordset("SELECT * FROM tbl_Reservations WHERE BlockBookingID=" . $blockBookingID . " ORDER BY StartTime");
$reservationID = $block[0][ID];
}
}
}
if ($act == 'editaction') {
if (!privileged('modify')) {
require "../no_access.php";
exit();
}
$_SESSION['_reservation'] = array();
if (!isset($chosenIDs)) $chosenIDs = array();
array_push($chosenIDs,$_REQUEST['reservationID']);
$sql = "SELECT * FROM tbl_Reservations WHERE ";
$flag=false;
foreach($chosenIDs as $id) {
if ($flag) {
$sql.=" OR ID=$id";
} else {
$sql.="ID=$id";
$flag=true;
}
}
$records = mysql_recordset($sql);
$startTimeObj = new timeCalculator($startTime);
$finishTimeObj = new timeCalculator($finishTime);
$period = $startTimeObj->periodUntil($finishTimeObj);
if ($period <= 0) {
$message="ERROR: The end time must be greater than the start time";
$act="edit";
} else {
// MH
// Check for conflicts
$no_conflicts=true;
foreach ($records as $record) {
$currdate = $record['StartTime'];
$imonth = strftime("%m", $currdate);
$iday = strftime("%d", $currdate);
$iyear = strftime("%y", $currdate);
$conflicts = conflict($startTimeObj->dumpTSOnDate($iyear,$imonth,$iday), $period,$newres,$record['ID']);
if ($conflicts) {
$no_conflicts = false;
foreach ($conflicts as $conflict) {
$failurenotice .= "<a href=\"showCalendar.php?act=view&reservationID=".$conflict['id']."\">[" . strftime("%d/%m/%y %T", $conflict['startTime']) . "]</a> ";
$conflictlist.="reservationid[]=".$conflict['id']."+".$conflict['startTime']."&";
}
}
}
// ***************************
/*
$conflictlist="act=editaction&conflictid=".$reservationID."+".mktime($startTimeObj->hour,$startTimeObj->min,0,$month,$day,$year)."&";
$failurenotice="Links to conflict: ";
foreach ($records as $record) {
$currdate = $record['StartTime'];
$imonth = strftime("%m", $currdate);
$iday = strftime("%d", $currdate);
$iyear = strftime("%y", $currdate);
// Get reservations on the same day as the one we are considering
$stimetmp = mktime(0,0,0,$imonth,$iday,$iyear);
$etimetmp = mktime(23,59,59,$imonth,$iday,$iyear);
foreach ($_REQUEST['newres'] as $resourceID) {
$sql = <<<EOSQL
SELECT StartTime,Period,ReservationID
FROM tbl_Reservations,tbl_ReservationMappings
WHERE tbl_Reservations.ID=tbl_ReservationMappings.ReservationID
AND tbl_Reservations.ID != {$record['ID']}
AND tbl_ReservationMappings.ResourceID=$resourceID
AND tbl_Reservations.StartTime>=$stimetmp
AND tbl_Reservations.StartTime<$etimetmp
EOSQL;
$result=mysql_recordset($sql);
// Now check each for conflicts
foreach ($result as $res) {
if(conflicts($startTimeObj->dumpTSOnDate($iyear,$imonth,$iday), $period,
$res['StartTime'],$res['Period'])) {
$failurenotice .= "<a href=\"showCalendar.php?act=view&reservationID=".$res['ReservationID']."\">".strftime(" [%d/%m/%y %T] ",
$res['StartTime']) . "</a> ";
$conflictlist.="reservationid[]=".$res['ReservationID']."+".$res['StartTime']."&";
$no_conflicts=FALSE;
}
}
}
}
*/
if ($no_conflicts) {
reset($records);
foreach ($records as $record) {
$currdate = $record['StartTime'];
$imonth = strftime("%m", $currdate);
$iday = strftime("%d", $currdate);
$iyear = strftime("%y", $currdate);
// Need to merge new start time with the date
$st = mktime($startTimeObj->hour, $startTimeObj->min, 0,
$imonth, $iday, $iyear);
// Update time
mysql_send("UPDATE tbl_Reservations SET StartTime=$st,
Period=$period WHERE ID = {$record['ID']}");
// Update resources
$res_to_add=array_diff($_REQUEST['newres'], $_REQUEST['oldres']);
$res_to_del=array_diff($_REQUEST['oldres'], $_REQUEST['newres']);
foreach ($res_to_add as $resource) {
mysql_send("INSERT INTO tbl_ReservationMappings
(ReservationID, ResourceID) VALUES
({$record['ID']}, $resource)");
}
foreach ($res_to_del as $resource) {
mysql_send("DELETE FROM tbl_ReservationMappings
WHERE ResourceID = $resource
AND ReservationID = {$record['ID']}");
}
}
$message = "Reservation successfully updated [at " .
date("h:i a") . "]";
$act = "view";
} else {
$message = "CONFLICTS: " . $failurenotice . "<a href=\"#\" onclick=\"javascript:window.open('popupConflicts.php?".$conflictlist."','','status=0,toolabar=0,location=0,menus=0,directories=0,resizable=0,scrollbars=1,height=195,width=360')\">Popup conflicts...</a>" . "<br />Changes to times and resources were unsuccessful due to conflicts with other reservations. All other changes were successful.";
$act="edit";
}
}
reset($records);
foreach ($records as $record) {
mysql_send("UPDATE tbl_Reservations SET MemberID={$_REQUEST['forMemberID']},
ActivityID=$activityID, Description='{$_REQUEST['description']}'
WHERE ID= {$record['ID']}");
}
mysql_send("UPDATE tbl_BlockBookings SET Pending=" .
($_REQUEST['respending']=='true'?'0':'1') .
" WHERE ID=" . $records[0]['BlockBookingID']);
}
if ($act == 'confirm') {
if (!privileged('modify')) {
require "../no_access.php";
exit();
}
$record = mysql_recordset("SELECT * FROM tbl_Reservations
WHERE ID={$_REQUEST['reservationID']}");
mysql_send("UPDATE tbl_BlockBookings SET Pending=" .
($_REQUEST['respending']=='true'?'0':'1') .
" WHERE ID=" . $record[0]['BlockBookingID']);
$message = "Reservation successfully updated [at ".date("h:i a") . "]";
$act = "view";
}
if ($act == 'addaction') {
if (!privileged('modify')) {
require "../no_access.php";
exit();
}
if ((checkdate($endmonth,$endday,$endyear) || $recurrencePeriod == 0) &&
checkdate($startmonth,$startday,$startyear)) {
// We have dates, we have a description - hopefully.. we have a go
// Get the start time in seconds without any date
$reservationTime=strftime("%H",$_POST['StartTime']) * 3600;
$reservationTime+=strftime("%M",$_POST['StartTime']) * 60;
// Now get the date range in unix time format also
$sdate=mktime(0,0,0,$startmonth, $startday, $startyear);
$edate=mktime(0,0,0,$endmonth,$endday,$endyear);
$currdate=$sdate;
// hack in case edate (doesnt matter for single reservation) > sdate
if ($_POST['recurrencePeriod'] == 0) $edate = $sdate;
// Check for conflicts
$no_conflicts=TRUE;
$conflictlist="act=addaction&conflictid=".$reservationID."+".mktime($_POST['StartTime']->hour,$_POST['StartTime']->min,0,$month,$day,$year)."&";
$failurenotice="Links to conflicts: ";
while ($currdate <= $edate) {
$currtime = $currdate + $reservationTime;
$imonth = strftime("%m", $currdate);
$iday = strftime("%d", $currdate);
$iyear = strftime("%y", $currdate);
// Get reservations on the same day as the one we are considering
$stimetmp = mktime(0,0,0,$imonth,$iday,$iyear);
$etimetmp = mktime(23,59,59,$imonth,$iday,$iyear);
foreach ($_POST['resourceIDs'] as $resourceID) {
$sql = <<<EOSQL
SELECT StartTime,Period,ReservationID
FROM tbl_Reservations,tbl_ReservationMappings
WHERE tbl_Reservations.ID=tbl_ReservationMappings.ReservationID
AND tbl_ReservationMappings.ResourceID=$resourceID
AND tbl_Reservations.StartTime>=$stimetmp
AND tbl_Reservations.StartTime<$etimetmp
EOSQL;
$result=mysql_recordset($sql);
// Now check each for conflicts
foreach ($result as $res) {
if(conflicts($currtime, $_POST['Period'], $res['StartTime'],
$res['Period'])) {
$failurenotice .= "<a href=\"showCalendar.php?act=view&reservationID=".$res['ReservationID']."\">".strftime(" [%d/%m/%y %T] ",
$res['StartTime']) . "</a> ";
$conflictlist.="reservationid[]=".$res['ReservationID']."+".$res['StartTime']."&";
$no_conflicts=FALSE;
}
}
}
switch($_POST['recurrencePeriod']) {
case 0:
// Single
$currdate=$edate+1; // Break out of loop
break;
case 1:
// Daily
do {
$currdate=addDays($currdate,1);
} while (strftime("%u", $currdate) > 5);
break;
case 2:
// Weekly
$currdate=addDays($currdate,7);
break;
case 3:
// Fortnightly
$currdate=addDays($currdate,14);
break;
}
}
if ($no_conflicts) {
$currdate=$sdate; // reset currdate
while ($currdate <= $edate) {
$currtime = $currdate + $reservationTime;
$sql="INSERT INTO tbl_Reservations (MemberID, ActivityID, ";
$sql.="StartTime, Period, BlockBookingID, Description) ";
$sql.="VALUES ($_POST[MemberID], $_POST[ActivityID], ";
$sql.="$currtime, $_POST[Period], $_POST[BlockBookingID], ";
$sql.="\"$_POST[Description]\")";
$reservationID = mysql_send($sql);
//echo $reservationID;
// funky loop here to get all resources used
// (Needs to have resources passed from Add
foreach ($_POST['resourceIDs'] as $resourceID) {
$sql="INSERT INTO tbl_ReservationMappings (ReservationID, ";
$sql.="ResourceID)";
$sql.="VALUES ($reservationID,$resourceID)";
mysql_send($sql);
}
//echo strftime("%d/%m/%y %T", $currtime) . "<br>";
switch($_POST['recurrencePeriod']) {
case 0:
// Single
$currdate=$edate+1; // Break out of loop
break;
case 1:
// Daily
do {
$currdate=addDays($currdate,1);
} while (strftime("%u", $currdate) > 5);
break;
case 2:
// Weekly
$currdate=addDays($currdate,7);
break;
case 3:
// Fortnightly
$currdate=addDays($currdate,14);
break;
}
}
// Right, all done, move to view
$message = "Reservation successfully added [at ".date("h:i a")."]";
$act="view";
} else {
$message = "CONFLICTS: " . $failurenotice . "<a href=\"#\" onclick=\"javascript:window.open('popupConflicts.php?".$conflictlist."','','status=0,toolabar=0,location=0,menus=0,directories=0,resizable=0,scrollbars=1,height=100,width=195')\">Popup conflicts...</a>";
$act="Add";
}
} else {
$message="ERROR: One of the dates entered is invalid";
$act="Add";
}
}
if ($act == 'Add') {
if (!privileged('modify')) {
require "../no_access.php";
exit();
}
// Get one of the original reservations for time info etc..
$sql="SELECT r.*, m.Name AS memberName, a.Name AS activityName ";
$sql.="FROM tbl_Reservations AS r, tbl_Members AS m, tbl_Activities AS a ";
$sql.="WHERE r.ID=$reservationID ";
$sql.="AND m.ID=r.MemberID AND a.ID=r.ActivityID";
$result = mysql_recordset($sql);
$reservation=$result[0];
// And get the Sections in use by the reservation
$sql="SELECT rm.*, r.Name, r.ID AS rID ";
$sql.="FROM tbl_ReservationMappings AS rm, tbl_Resources as r ";
$sql.="WHERE rm.ReservationID=$reservationID AND rm.ResourceID=r.ID";
$resources = mysql_recordset($sql);
if (isset($_POST['Description'])) {
$description = $_POST['Description'];
} else {
$description = $reservation['Description'];
}
// Sometimes, case sensitivity is a pain.. but rather than fix it, heres
// a little hack
if (isset($_POST['BlockBookingID'])) {
$blockBookingID=$_POST['BlockBookingID'];
} else {
$blockBookingID=$_POST['blockBookingID'];
}
display($message);
?>
<script language="javascript"><!--
function correctStartDate() {
<?php
// correct for 2 digit year :(
// Lets hope this wont be in use later
if ($year < 80) {
$year += 2000;
} else if ($year < 100) {
$year += 1900;
}
?>
leapyear=false;
year = document.mainForm.startyear.value;
if (((year % 4 == 0) && (year % 100 != 0)) ||
(year % 400 == 0) && (year % 4000 !=0)) leapyear=true;
var daysin = new Array ('', 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
if (leapyear) daysin[2]=29;
for (i = 29; i<=31; i++) {
if (i>daysin[document.mainForm.startmonth.value]) {
document.mainForm.startday.options[i-1].disabled = true;
if (document.mainForm.startday.options[i-1].selected == true) {
document.mainForm.startday.options[daysin[document.mainForm.startmonth.value]-1].selected = true;
}
} else {
document.mainForm.startday.options[i-1].disabled = false;
}
}
}
function correctEndDate() {
leapyear=false;
year = document.mainForm.endyear.value;
if (((year % 4 == 0) && (year % 100 != 0)) ||
(year % 400 == 0) && (year % 4000 !=0)) leapyear=true;
var daysin = new Array ('', 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
if (leapyear) daysin[2]=29;
for (i = 29; i<=31; i++) {
if (i>daysin[document.mainForm.endmonth.value]) {
document.mainForm.endday.options[i-1].disabled = true;
if (document.mainForm.endday.options[i-1].selected == true) {
document.mainForm.endday.options[daysin[document.mainForm.endmonth.value]-1].selected = true;
}
} else {
document.mainForm.endday.options[i-1].disabled = false;
}
}
}
function enableEndDate() {
if (document.mainForm.recurrencePeriod.value > 0) {
disable = false;
} else {
disable = true;
}
document.mainForm.endyear.disabled = disable;
document.mainForm.endmonth.disabled = disable;
document.mainForm.endday.disabled = disable;
}
--></script>
<form method=post name=mainForm>
<input type=hidden name=ID value="<?=$ID?>">
<input type=hidden name=act value="addaction">
<input type=hidden name=Period value="<?=$reservation['Period']?>">
<input type=hidden name=MemberID value="<?=$reservation['MemberID']?>">
<input type=hidden name=ActivityID value="<?=$reservation['ActivityID']?>">
<input type=hidden name=BlockBookingID value="<?=$blockBookingID?>">
<input type=hidden name=StartTime value="<?=$reservation['StartTime'];?>">
<?php
foreach ($resources as $section) {
echo "<input type=hidden name=resourceIDs[] value='$section[rID]'>";
}
?>
<table class=options cellpadding=0 cellspacing=10>
<tr>
<th colspan=2><b>Add Reservation</b></th>
</tr>
<tr>
<td>
<table class=options cellpadding=4 cellspacing=0>
<tr>
<td align="right">Resource: </td>
<td><b><?=$info[Name]?></b></td>
</tr>
<tr>
<td align="right">Sections: </td>
<td><b><?php
$printcomma=false;
foreach ($resources as $section) {
if ($printcomma) {
echo ", ";
} else {
$printcomma = TRUE;
}
echo $section['Name'];
}
?></b></td>
</tr>
<tr>
<td align="right">Member: </td>
<td><b><?=$reservation['memberName'];?></b></td>
</tr>
<tr>
<td align="right">Activity: </td>
<td><b><?=$reservation['activityName'];?></b></td>
</tr>
<tr>
<td align=right>Start Time: </td>
<td><b><?=strftime("%H:%M",$reservation['StartTime']);?></b></td>
</tr>
<tr>
<td align=right>End Time: </td>
<td><b><?=strftime("%H:%M",$reservation['StartTime']+
($reservation['Period']*60)) ?></b></td>
<tr>
<td align=right valign=top>Description: </td>
<td><textarea name="Description" cols="50"
rows="5"><?=$description?></textarea></td>
</tr>
<tr>
<td colspan=2>Note: The first line of the description is displayed
on the reservations calendar page.</td>
</tr>
<tr>
<td align=right> Recurrence: </td>
<td>
<select name=recurrencePeriod onChange="enableEndDate()">
<option value='0'>Single Reservation</option>
<option value='1'>Daily (Mon-Fri)</option>
<option value='2'>Weekly</option>
<option value='3'>Fortnightly</option>
</select>
</td>
</tr>
<tr>
<?php
// Havent got any stored date range from a previous attempt
if ($endyear=='') {
$startyear = $year;
$startmonth = $month;
$startday = $day;
$endyear = $year;
$endmonth = $month;
$endday = $day;
}
?>
<td align=right>Start Date: </td>
<td>
<select name="startday" onFocus="correctStartDate()"><?php
for ($i=1; $i<=31; $i++) {
$checked = $i == $startday ? ' selected="selected"' : ''; ?>
<option value="<?=$i?>"<?=$checked?>><?=$i?></option>
<?php } ?>
</select>
<select name="startmonth" onChange="correctStartDate()"><?php
$months=array('','January','February','March','April','May',
'June','July','August','September','October','November',
'December');
for ($i=1; $i<=12; $i++) {
$checked = $i == $startmonth ? ' selected="selected"' : '' ?>
<option value="<?=$i?>"<?=$checked?>><?=$months[$i]?></option>
<?php } ?>
</select>
<select name="startyear" onChange="correctStartDate()"><?php
for ($i=$year-10; $i<=$year+10; $i++) {
$checked = $i == $startyear ? ' selected="selected"' : '' ?>
<option value="<?=$i?>"<?=$checked?>><?=$i?></option>
<?php
}
?></select>
</td>
</tr>
<tr>
<td align=right>End Date: </td>
<td>
<select name="endday" disabled="disabled" onFocus="correctEndDate()"><?php
for ($i=1; $i<=31; $i++) {
$checked = $i == $endday ? ' selected="selected"' : ''; ?>
<option value="<?=$i?>"<?=$checked?>><?=$i?></option>
<?php } ?>
</select>
<select name="endmonth" disabled="disabled" onChange="correctEndDate()"><?php
$months=array('','January','February','March','April','May',
'June','July','August','September','October','November',
'December');
for ($i=1; $i<=12; $i++) {
$checked = $i == $endmonth ? ' selected="selected"' : '' ?>
<option value="<?=$i?>"<?=$checked?>><?=$months[$i]?></option>
<?php } ?>
</select>
<select name="endyear" disabled="disabled" onChange="correctEndDate()"><?php
for ($i=$year-10; $i<=$year+10; $i++) {
$checked = $i == $endyear ? ' selected="selected"' : '' ?>
<option value="<?=$i?>"<?=$checked?>><?=$i?></option>
<?php
}
?></select>
</td>
</tr>
<tr>
<td align=right colspan=4>
<input type=submit class=button value="Add Reservation">
<input type=reset class=button value="Reset">
<input type=button class=button value="Cancel"
onclick="document.location='showCalendar.php?act=&ID=<?=$ID?>'">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<?php
}
if ($act == 'view') {
$_SESSION['_reservation'] = array();
$today = $_SESSION['_today'];
$reservation = mysql_recordset("SELECT tbl_Reservations.*,tbl_Activities.Name AS ActivityName FROM tbl_Reservations,tbl_Activities WHERE tbl_Reservations.ID=$reservationID AND tbl_Reservations.ActivityID=tbl_Activities.ID");
if (count($reservation) == 0) {
$reservation = mysql_recordset("SELECT tbl_Reservations.*,tbl_Activities.Name AS ActivityName FROM tbl_Reservations,tbl_Activities WHERE tbl_Reservations.ActivityID=tbl_Activities.ID");
}
$memberID = $reservation[0][MemberID];
$operator = mysql_recordset("SELECT tbl_Operators.* FROM tbl_Operators, tbl_BlockBookings WHERE tbl_Operators.ID = tbl_BlockBookings.OperatorID AND tbl_BlockBookings.ID = " . $reservation[0]['BlockBookingID']);
$mappings = mysql_recordset("SELECT tbl_Resources.* FROM tbl_ReservationMappings,tbl_Resources WHERE tbl_Resources.ID=tbl_ReservationMappings.ResourceID AND tbl_ReservationMappings.reservationID=$reservationID");
$member = mysql_recordset("SELECT * FROM tbl_Members WHERE ID=$memberID");
$todaytime = mktime (0,0,0,date("m"),date("d"),date("Y"));
$block = mysql_recordset("SELECT * FROM tbl_Reservations WHERE
BlockBookingID=" . $reservation[0][BlockBookingID] .
" AND (StartTime>=".$todaytime.") ORDER BY StartTime");
$oldblock = mysql_recordset("SELECT * FROM tbl_Reservations WHERE
BlockBookingID=" . $reservation[0][BlockBookingID] .
" AND (StartTime<".$todaytime.") ORDER BY StartTime DESC");
$blockbooking = mysql_recordset("SELECT * FROM tbl_BlockBookings WHERE ID=" . $reservation[0][BlockBookingID]);
$startTimeObj = new timeCalculator(strftime('%H:%M',$reservation[0][StartTime]));
display($message);
?>
<script language="javascript">
<!--
function submitForm(act) {
document.mainForm.act.value = act;
document.mainForm.submit();
}
//-->
</script>
<form method=post name=mainForm>
<input type=hidden name=ID value="<?=$ID?>">
<input type=hidden name=MemberID value="<?=$memberID?>">
<input type=hidden name=act value=confirm>
<input type=hidden name=year value="<?=$year?>">
<input type=hidden name=month value="<?=$month?>">
<input type=hidden name=day value="<?=$day?>">
<input type=hidden name=reservations value="<?=count($block)+count($oldblock)?>">
<input type=hidden name=reservationID value="<?=$reservation[0][ID]?>">
<input type=hidden name=blockBookingID value="<?=$reservation[0][BlockBookingID]?>">
<table class=options cellpadding=4 cellspacing=10 width="90%" align="center">
<tr>
<th colspan=2><b>View Reservation</b></th>
</tr>
<tr>
<td valign=top>
<table class=options cellpadding=4 cellspacing=0>
<tr>
<td align=right>For Resource: </td>
<td colspan=3><b><?=$info['Name']?></b></td>
</tr>
<tr>
<td align=right>For Sections: </td>
<td colspan=3>
<?php
$flag = FALSE;
foreach ($mappings as $resource) {
if ($flag) {
print ', ';
} else {
$flag = TRUE;
}
print ' <b>' . $resource[Name] . '</b>';
print '<input type=hidden name="resourceIDs[]" value="' . $resource[ID] . '">';
}
?>
</td>
</tr>
<tr>
<td align=right>For Member: </td>
<td colspan=3><b><a href="../members/members.php?act=view&memberID=<?=$member[0]['ID']?>"><?=$member[0][Name]?></a></b></td>
</tr>
<tr>
<td align="right">Booked By: </td>
<td colspan=3><b><?=$operator[0]['Name']?></b></td>
</tr>
<?php
if ($member[0][ID] == 0) {
?>
<tr>
<td align=right>Name: </td>
<td colspan=3><input type=text name=clientName value="<?=$reservation[0][ClientName]?>"></td>
</tr>
<tr>
<td align=right>Tel: </td>
<td colspan=3><input type=text name=clientTel value="<?=$reservation[0][ClientTel]?>"></td>
</tr>
<?php
}
?>
<tr>
<td align=right>On Date: </td>
<td colspan=3><b><?=date("l j F Y",$reservation[0][StartTime])?></b></td>
</tr>
<tr>
<td align=right>From Time: </td>
<td colspan=3><b><?=$startTimeObj->dump()?></b></td>
</tr>
<tr>
<td align=right>To Time: </td>
<?php $startTimeObj->addMinutes($reservation[0][Period]); ?>
<td colspan=3><b><?=$startTimeObj->dump()?></b><input type=hidden name=Period value="<?=$reservation[0][Period]?>"></td>
</tr>
<tr>
<td align=right>For Activity: </td>
<td colspan=3><b><?=$reservation[0][ActivityName]?></b></td>
</tr>
<tr>
<td align=right valign=top>Description: </td>
<td colspan=3><b><?=$reservation[0][Description]?></b></td>
</tr>
<tr>
<td colspan=2>Note: The first line of the description is displayed
on the reservations calendar page.</td>
</tr>
<tr>
<?php
if (privileged('modify')) {
?>
<td valign=top> </td>
<td><input type="checkbox" name="respending" value="true" <?=$blockbooking[0][Pending]==1?'':'checked="checked"'?> /> Confirm this booking.</td>
</tr>
<tr>
<td align=right colspan=3><input type=submit class=button value="Submit Changes" /></td>
<td align=right colspan=2><input type=button class=button
value="Edit" onclick="submitForm('edit')">
<input type=reset class=button value="Reset">
</td>
<?php
} else {
?>
<td colspan="5"> </td>
<?php
}
?>
<td align="left" colspan="2">
<input type=button class=button value="Back to daily view" onclick="document.location='showCalendar.php?ID=<?=$ID?>'">
<input type=button class=button value="Back to monthly view" onclick="document.location='showMonthly.php?month=<?=date("m",$reservation[0][StartTime])?>&year=<?=date("Y",$reservation[0][StartTime])?>&resourceID=<?=$mappings[0]['ID']?>'" /></td>
</tr>
<tr>
<td></td>
<td align=right colspan=3> </td>
</tr>
</table>
</td>
<td valign=top style="border-left: solid 1px #bbbbbb">
<table class=options cellpadding=4 cellspacing=0>
<?php
if (count($block) > 0) {
?>
<tr valign=top>
<td colspan=4>Present and upcoming reservations for this booking: </td>
</tr>
<tr>
<td></td>
<td colspan=3>
<?php
$checkboxnumber = 0;
foreach ($block as $record) {
$text = " ";
if ($record[ID]!=$reservationID)
$text .= "<a href=\"showCalendar.php?act=view&reservationID=" . $record[ID] . "\">";
else
$text .= "<b>";
$text .= date("l j F Y",$record[StartTime]);
if ($record[ID]!=$reservationID)
$text .= "</a>";
else
$text .= "</b> (this)";
if (privileged('modify')) {
print "<input id=\"cb" . $checkboxnumber++ . "\" style=\"margin:0px\" type=checkbox name=\"chosenIDs[]\" value=\"" . $record[ID] . "\"> $text";
} else {
print $text;
}
print "<br>\n";
}
?>
</td>
</tr>
<?php
if (privileged('modify')) {
?>
<tr>
<td></td>
<td colspan=3><input type=button class=button value="Select All" onClick="setCheckBoxes()" />
</tr>
<tr>
<td></td>
<td colspan=3><input type=button class=button value="Cancel Reservation(s)" onclick="submitForm('remove')" />
</tr>
<?php
}
} else {
$checkboxnumber = 0;
?>
<tr valign=top>
<td colspan=4>Present and upcoming reservations for this booking: </td>
</tr>
<tr>
<td></td>
<td colspan=3><b>No reservations.</b>
</td>
</tr>
<?php
}
if (privileged('modify')) {
?>
<tr>
<td></td>
<td colspan=3><input type=button class=button value="Add Reservation" onclick="submitForm('Add')" />
</tr>
<?php
}
if (count($oldblock) > 0) {
?>
<tr valign=top>
<td colspan=4>Past reservations for this booking: </td>
</tr>
<tr>
<td></td>
<td colspan=3>
<?php
foreach ($oldblock as $record) {
$text = " ";
if ($record[ID]!=$reservationID)
$text .= "<a href=\"showCalendar.php?act=view&reservationID=" . $record[ID] . "\">";
else
$text .= "<b>";
$text .= date("l j F Y",$record[StartTime]);
if ($record[ID]!=$reservationID)
$text .= "</a>";
else
$text .= "</b> (this)";
print $text;
print "<br>\n";
}
?>
</td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
</table>
</form>
<script language="javascript" src="<? echo $site_url; ?>system/xplatform.js"></script>
<script language="javascript">
<!--
function setCheckBoxes() {
var i;
for (i=0;i<=<?=$checkboxnumber?>;i++) {
getObj('cb' + i).checked = 'true';
}
}
//-->
</script>
<?php
}
if ($act == 'edit') {
if (!privileged('modify')) {
require "../no_access.php";
exit();
}
$_SESSION['_reservation'] = array();
$today = $_SESION['_today'];
$reservation = mysql_recordset("SELECT tbl_Reservations.*,tbl_Activities.Name AS ActivityName FROM tbl_Reservations,tbl_Activities WHERE tbl_Reservations.ID=$reservationID AND tbl_Reservations.ActivityID=tbl_Activities.ID");
if (count($reservation) == 0) {
$reservation = mysql_recordset("SELECT tbl_Reservations.*,tbl_Activities.Name AS ActivityName FROM tbl_Reservations,tbl_Activities WHERE tbl_Reservations.ActivityID=tbl_Activities.ID");
}
$memberID = $reservation[0][MemberID];
$members = mysql_recordset("SELECT tbl_Members.* FROM tbl_Members WHERE
tbl_Members.ID>0 ORDER BY tbl_Members.Name");
$activities = mysql_recordset("SELECT * from tbl_Activities WHERE
ResourceGroupID = $ID");
$mappings = mysql_recordset("SELECT tbl_Resources.* FROM tbl_ReservationMappings,tbl_Resources WHERE tbl_Resources.ID=tbl_ReservationMappings.ResourceID AND tbl_ReservationMappings.reservationID=$reservationID");
$allresources = mysql_recordset("SELECT * from tbl_Resources WHERE
ResourceGroupID = $ID");
$member = mysql_recordset("SELECT * FROM tbl_Members WHERE ID=$memberID");
$block = mysql_recordset("SELECT * FROM tbl_Reservations WHERE BlockBookingID=" . $reservation[0][BlockBookingID] . " ORDER BY StartTime");
$blockbooking = mysql_recordset("SELECT * FROM tbl_BlockBookings WHERE ID=" . $reservation[0][BlockBookingID]);
$startTimeObj = new timeCalculator(strftime('%H:%M',$reservation[0][StartTime]));
$startTimeOfDayObj = new timeCalculator($info['StartTime']);
$finishTimeOfDayObj = new timeCalculator($info['FinishTime']);
display($message);
?>
<script language="javascript">
<!--
function submitForm(act) {
document.mainForm.act.value = act;
document.mainForm.submit();
}
function selectCont() {
// Ensure that selected resources are next to each other
firstsel = -1;
lastsel = -1;
for (i=0; i<document.getElementById('resourceIDs').length; i++) {
if (document.getElementById('resourceIDs').options[i].selected) {
// alert(i + " is selected");
if (firstsel != -1) {
lastsel = i;
} else {
firstsel = i;
lastsel = i;
}
}
}
//alert("first+last=" + firstsel + " " + lastsel);
if (firstsel != -1) {
for (i=firstsel; i<=lastsel; i++)
document.getElementById('resourceIDs').options[i].selected = true;
}
}
//-->
</script>
<form method=post name=mainForm>
<input type=hidden name=ID value="<?=$ID?>">
<input type=hidden name=MemberID value="<?=$memberID?>">
<input type=hidden name=act value=editaction>
<input type=hidden name=year value="<?=$year?>">
<input type=hidden name=month value="<?=$month?>">
<input type=hidden name=day value="<?=$day?>">
<input type=hidden name=reservations value="<?=count($block)+count($oldblock)?>">
<input type=hidden name=reservationID value="<?=$reservation[0][ID]?>">
<input type=hidden name=blockBookingID value="<?=$reservation[0][BlockBookingID]?>">
<table class=options cellpadding=4 cellspacing=10 width="90%" align="center">
<tr>
<th colspan=2><b>Edit Reservation</b></th>
</tr>
<tr>
<td valign=top>
<table class=options cellpadding=4 cellspacing=0>
<tr>
<td align=right>For Resource: </td>
<td colspan=3><b><?=$info['Name']?></b></td>
</tr>
<tr>
<td align=right>For Sections: </td>
<td colspan=3>
<select id="resourceIDs" name="newres[]" size="5" multiple="multiple" onChange="selectCont()">
<?php
foreach ($allresources as $resource) {
$checked='';
foreach ($mappings as $check) {
if ($resource['ID'] == $check['ID']) {
$checked=' selected="selected"';
}
}?>
<option value="<?=$resource['ID']?>" <?=$checked?>><?php
echo $resource[Name] ?></option>
<?php }
?>
</select>
<?php foreach($mappings as $resource) {
echo "<input type='hidden' name='oldres[]'
value='{$resource['ID']}'>";
}
?>
</td>
</tr>
<tr>
<td colspan=4>
Note: To select more than one section, either drag the mouse
when selecting, or hold down CTRL and click on each entry.
</td>
</tr>
<tr>
<td align=right>For Member: </td>
<td colspan=3>
<select name=forMemberID>
<?php
foreach ($members as $record) {
if ($record['ID'] == $member[0][ID]) {
$checked = ' selected="selected"';
} else {
$checked = '';
}?><option value="<?=$record['ID']?>"<?=$checked?>>
<?=$record['Name']?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td align=right>On Date: </td>
<td colspan=3><b><?=date("l j F Y",$reservation[0][StartTime])?></b></td>
</tr>
<tr>
<td align=right>From Time: </td>
<td colspan=3><select name=startTime>
<?php
$currentTime = $startTimeOfDayObj;
while ($currentTime->dump() < $finishTimeOfDayObj->dump()) {
if ($currentTime->dump() == $startTimeObj->dump()) { $selected = '
selected="selected"'; } else { $selected = ''; }
print ' <option
value="'.$currentTime->dump().'"'.$selected.'>'.$currentTime->dump()."</option>\n";
$currentTime->addMinutes(5);
}
?>
</select></td>
</tr>
<tr>
<td align=right>To Time: </td>
<td colspan=3><select name=finishTime>
<?php
$startTimeObj->addMinutes($reservation[0][Period]);
$currentTime = $startTimeOfDayObj;
while ($currentTime->dump() <= $finishTimeOfDayObj->dump()) {
if ($currentTime->dump() == $startTimeObj->dump()) { $selected = '
selected="selected"'; } else { $selected = ''; }
print ' <option
value="'.$currentTime->dump().'"'.$selected.'>'.$currentTime->dump()."</option>\n";
$currentTime->addMinutes(5);
}
?>
</select></td>
</tr>
<tr>
<td align=right>For Activity: </td>
<td colspan=3><select name=activityID>
<?php
foreach ($activities as $record) {
if ($record['ID'] == $reservation[0]['ActivityID']) {
$checked = ' selected="selected"';
} else {
$checked = '';
}?><option value="<?=$record['ID']?>"<?=$checked?>>
<?=$record['Name']?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td align=right valign=top>Description: </td>
<td colspan=3><textarea name="description" cols="50"
rows="5"><?=$reservation[0][Description]?></textarea></td>
</tr>
<tr>
<td colspan=2>Note: The first line of the description is displayed
on the reservations calendar page.</td>
</tr>
<tr>
<td valign=top></td>
<td><input type="checkbox" name="respending" value="true" <?=$blockbooking[0][Pending]==1?'':'checked="checked"'?> /> Confirm this booking.</td>
</tr>
<tr>
<td align=right colspan=4><input type=submit class=button value="Submit Changes" />
<input type=reset class=button value="Reset">
<input type=button class=button value="Back" onclick="document.location='showCalendar.php?ID=<?=$ID?>'"></td>
</tr>
<tr>
<td></td>
<td align=right colspan=3> </td>
</tr>
</table>
</td>
<td valign=top style="border-left: solid 1px #bbbbbb">
<table class=options cellpadding=4 cellspacing=0>
<tr valign=top>
<td colspan=4>Apply changes to these bookings as well: </td>
</tr>
<tr>
<td></td>
<td colspan=3>
<?php
$checkboxnumber = 0;
foreach ($block as $record) {
if ($record[ID]!=$reservationID) {
$text = " " . date("l j F Y",$record[StartTime]);
print "<input id=\"cb" . $checkboxnumber . "\" style=\"margin:0px\" type=checkbox name=\"chosenIDs[]\" value=\"" . $record[ID] . "\"> $text";
print "<br>\n";
$checkboxnumber++;
}
}
?>
</td>
</tr>
<tr>
<td></td>
<td colspan=3><input type=button class=button value="Select All" onClick="setCheckBoxes()" />
</tr>
</tr>
</table>
</form>
<script language="javascript" src="<? echo $site_url; ?>system/xplatform.js"></script>
<script language="javascript">
<!--
function setCheckBoxes() {
var i;
for (i=0;i<=<?=$checkboxnumber?>;i++) {
getObj('cb' + i).checked = 'true';
}
}
//-->
</script>
<?php
}
if ($act == '') {
$_SESSION['_reservation'] = array();
$i= mktime(0,0,0,$month,$day+1,$year);
$nextDayY = date("Y",$i);
$nextDayM = date("m",$i);
$nextDayD = date("d",$i);
$i= mktime(0,0,0,$month,$day-1,$year);
$previousDayY = date("Y",$i);
$previousDayM = date("m",$i);
$previousDayD = date("d",$i);
// Calculate time information
$startTime = new timeCalculator($info['StartTime']);
$finishTime = new timeCalculator($info['FinishTime']);
// Retrieve reservation information
$sql = "SELECT tbl_Reservations.*,tbl_ResourceGroups.Period AS StandardPeriod,tbl_Resources.ID AS ResourceID,tbl_Activities.Name AS ActivityName, tbl_Members.Colour AS MemberColour, tbl_Members.Name AS MemberName, tbl_BlockBookings.Pending FROM tbl_Reservations,tbl_ReservationMappings,tbl_Resources,tbl_ResourceGroups,tbl_Activities,tbl_Members,tbl_BlockBookings WHERE tbl_Reservations.BlockBookingID=tbl_BlockBookings.ID AND tbl_Reservations.ID=tbl_ReservationMappings.ReservationID AND tbl_Resources.ID=tbl_ReservationMappings.ResourceID AND tbl_Activities.ID=tbl_Reservations.ActivityID AND tbl_Reservations.MemberID=tbl_Members.ID AND tbl_Reservations.StartTime>=" . mktime(0,0,0,$month,$day,$year) . " AND tbl_Reservations.StartTime<=" . mktime(0,0,0,$nextDayM,$nextDayD,$nextDayY) . " AND tbl_Resources.ResourceGroupID=$ID AND tbl_ResourceGroups.ID=$ID ORDER BY tbl_Reservations.StartTime,tbl_ReservationMappings.ResourceID";
$reservations = mysql_recordset($sql);
display($message);
?>
<script language="javascript" src="<? echo $site_url; ?>system/xplatform.js"></script>
<script language="javascript">
<!--
var highlightColour = '#6666ff';
var lowlightColour = '#dddddd';
var highlightColumnColour = '#8888ff';
var lowlightColumnColour = '#aaaacc';
var highlightRowColour = '#8888ff';
var lowlightRowColour = '#ccccee';
var startx,starty,endx,endy,starti,startj,endi,endj,selecting = 0;
var maxx = <?=$num_sections?>,maxy;
var selectColumns = false,selectRows = false,conflict = false;
function flip() {
conflict = false;
if (startx <= endx) {
endi = endx;
starti = startx;
} else {
endi = startx;
starti = endx;
}
if (starty <= endy) {
endj = endy;
startj = starty;
}else {
endj = starty;
startj = endy;
}
}
function highlight(x,y) {
if (!(x == 0 && y == 0)) {
var Colour;
if (y==0) {
Colour = highlightColumnColour;
} else if (x==0) {
Colour = highlightRowColour;
} else {
Colour = highlightColour;
}
if (!(selecting == 1 && (x == 0 || y == 0))) {
if (getObj('tx' + x + 'y' + y + 't') == null || getObj('tx' + x + 'y' + y + 't').className == 'reserved') {
if (!(x == 0 || y == 0)) conflict = true;
} else {
setBGCOLOR(getObj('tx' + x + 'y' + y + 't'),Colour);
// if (y > 0) getObj('tx' + x + 'y' + y + 't').style.border = 'solid 1px ' + Colour;
}
}
}
}
function lowlight(x,y) {
if (!(x == 0 && y == 0)) {
var Colour;
if (y==0) {
Colour = lowlightColumnColour;
} else if (x==0) {
Colour = lowlightRowColour;
} else {
Colour = lowlightColour;
}
if (!(selecting == 1 && (x == 0 || y == 0))) {
if (getObj('tx' + x + 'y' + y + 't') == null || getObj('tx' + x + 'y' + y + 't').className == 'reserved') {
if (!(x == 0 || y == 0)) conflict = true;
} else {
setBGCOLOR(getObj('tx' + x + 'y' + y + 't'),Colour);
// if (y > 0) getObj('tx' + x + 'y' + y + 't').style.border = 'solid 1px ' + Colour;
}
}
}
}
function high(x,y) {
if (selecting==0) {
highlight(x,y);
if (x == 0) {
for (k=1;k<=maxx;k++) {
highlight(k,y);
}
} else {
highlight(x,0);
}
if (y == 0) {
for (k=1;k<=maxy;k++) {
highlight(x,k);
}
} else {
highlight(0,y);
}
} else if (selecting == 1) {
if (selectColumns == true) {
endx = x;
} else if (selectRows == true) {
endy = y;
} else {
endy = y;
endx = x;
}
flip();
for (i=starti;i<=endi;i++) {
for (j=startj;j<=endj;j++) {
highlight(i,j);
}
}
selecting = 0;
highlight(0,y);
highlight(x,0);
selecting = 1;
}
}
function low(x,y) {
if (selecting==0) {
lowlight(x,y);
if (x == 0) {
for (k=1;k<=maxx;k++) {
lowlight(k,y);
}
} else {
lowlight(x,0);
}
if (y == 0) {
for (k=1;k<=maxy;k++) {
lowlight(x,k);
}
} else {
lowlight(0,y);
}
} else if (selecting == 1) {
for (i=starti;i<=endi;i++) {
for (j=startj;j<=endj;j++) {
lowlight(i,j);
}
}
selecting = 0;
lowlight(0,y);
lowlight(x,0);
selecting = 1;
}
}
function startSelect(x,y) {
if (selecting == 0 && getObj('tx' + x + 'y' + y + 't').className != 'reserved') {
if (y == 0) {
startx = x;
starty = 1;
endy = maxy;
selectColumns = true;
} else if (x == 0) {
startx = 1;
starty = y;
endx = maxx;
selectRows = true;
} else {
starty = y;
startx = x;
}
low(x,y);
selecting = 1;
high(x,y);
} else if (selecting == 1 && getObj('tx' + x + 'y' + y + 't').className != 'reserved') {
selecting = 2;
selectColumns = false;
selectRows = false;
lowlight(0,y);
lowlight(x,0);
} else if (selecting == 2) {
if (!conflict && getBGCOLOR('tx' + x + 'y' + y + 't') == highlightColour) {
var timeObj = getObj('tx0y' + (startj-((startj-1)%6)) + 't');
document.mainForm.startResource.value = starti-1;
document.mainForm.finishResource.value = endi-1;
document.mainForm.startTimeBeforeVariance.value = timeObj.innerHTML;
document.mainForm.startTimeVariance.value = (startj-1)%6;
document.mainForm.numberPeriods.value = 1 + endj - startj;
document.mainForm.submit();
} else {
if (conflict && getBGCOLOR(getObj('tx' + x + 'y' + y + 't')) == highlightColour) {
alert('You have chosen a block that conflicts with existing reservations.\n\nPlease choose another block.');
}
selecting = 0;
for (i=starti;i<=endi;i++) {
for (j=startj;j<=endj;j++) {
lowlight(i,j);
}
}
}
}
}
function bookWholeDay() {
<?php
$st = new timeCalculator($info['StartTime']);
$ft = new timeCalculator($info['FinishTime']);
$numper = $st->periodUntil($ft)/5;
?>
document.mainForm.startResource.value = 0;
document.mainForm.finishResource.value = 0;
// Cheating here, starttime should be in half hour intervals
// With the starttimevariance adding on 5 minutes each time
document.mainForm.startTimeBeforeVariance.value = '<?=$info['StartTime']?>';
document.mainForm.startTimeVariance.value = 0;
document.mainForm.numberPeriods.value = <?=$numper?>;
document.mainForm.submit();
}
// -->
</script>
<form method=post action="showCalendar.php" name=mainForm>
<input type=hidden name=ID value="<?=$ID?>">
<input type=hidden name=startResource value="">
<input type=hidden name=finishResource value="">
<input type=hidden name=startTimeOfDay value="<?=$info['StartTime']?>">
<input type=hidden name=finishTimeOfDay value="<?=$info['FinishTime']?>">
<input type=hidden name=startTimeBeforeVariance value="">
<input type=hidden name=startTimeVariance value="">
<input type=hidden name=year value="<?=$year?>">
<input type=hidden name=month value="<?=$month?>">
<input type=hidden name=day value="<?=$day?>">
<input type=hidden name=numberPeriods value="">
<input type=hidden name=act value=reserve>
<?php
$prev3months=mktime(0,0,0,$month - 3,$day,$year);
$next3months=mktime(0,0,0,$month + 3,$day,$year);
$prev6months=mktime(0,0,0,$month - 6,$day,$year);
$next6months=mktime(0,0,0,$month + 6,$day,$year);
?>
<div id="minical" style="position:absolute;visibility:<?=(!isset($minical))?'hidden':$minical?>;top:5;left:5;border: solid black 1px;background:white;">
<table>
<tr>
<td style="font-size:10px;"><a href="showCalendar.php?year=<?=date("y",$prev3months)?>&month=<?=date("m",$prev3months)?>&day=<?=date("d",$prev3months)?>&minical=visible">Back 3 months</a></td>
<td style="font-size:10px;"> </td>
<td align="right" style="font-size:10px;"><a href="showCalendar.php?year=<?=date("y",$next3months)?>&month=<?=date("m",$next3months)?>&day=<?=date("d",$next3months)?>&minical=visible">Forward 3 months</a></td>
</tr>
<tr>
<td style="font-size:10px;"><a href="showCalendar.php?year=<?=date("y",$prev6months)?>&month=<?=date("m",$prev6months)?>&day=<?=date("d",$prev6months)?>&minical=visible">Back 6 months</a></td>
<td style="font-size:10px;"> </td>
<td align="right" style="font-size:10px;"><a href="showCalendar.php?year=<?=date("y",$next6months)?>&month=<?=date("m",$next6months)?>&day=<?=date("d",$next6months)?>&minical=visible">Forward 6 months</a></td>
</tr>
<tr>
<?php
minicals($year, $month, $day, 'visible');
?>
</tr>
<tr><td colspan=3 align=right>[<a href="#" onClick="getObj('minical').style.visibility = 'hidden'">Close Calendar</a>]</td>
</tr>
</table>
</div>
<table cellpadding="0" cellspacing="0" width="100%" class="calendar">
<?php
$i= mktime(0,0,0,$month,$day,$year);
foreach ($reservations as $reservation) {
$today[$reservation['ResourceID']][$reservation['StartTime']] = $reservation;
}
if (isset($today)) {
$_SESSION['_today'] = $today;
}
// Sort the columns/resources with natural order sort
$to_sort = array();
foreach ($result as $row) {
array_push($to_sort, $row['Name']);
}
natcasesort($to_sort);
$sorted = array();
foreach($to_sort as $key => $value) {
array_push($sorted, $result[$key]);
}
?>
<tr>
<td align=right colspan=<?=($num_sections+1)?>>Reservations for
<b><?=$info['Name']?></b> on <b><?=strftime('%A %e %B %Y',$i)?></b></td>
</tr>
<tr>
<td colspan=<?=$num_sections+1?>><a href="showCalendar.php?year=<?=$previousDayY?>&month=<?=$previousDayM?>&day=<?=$previousDayD?>">Previous Day</a> | <a href="showCalendar.php?year=<?=date('Y')?>&month=<?=date('m')?>&day=<?=date('d')?>">Today</a> | <a href="showCalendar.php?year=<?=$nextDayY?>&month=<?=$nextDayM?>&day=<?=$nextDayD?>">Next Day</a> |
<a onClick="getObj('minical').style.visibility='visible'" href="#">Launch Calendar...</a> | <a href="#" onclick="javascript:window.open('popupCalendar.php?year=<?=$year?>&month=<?=$month?>&day=<?=$day?>','','status=0,toolabar=0,location=0,menus=0,directories=0,resizable=0,scrollbars=0,height=195,width=360')">Popup Calendar...</a> |
<?php
if (privileged('modify')) {
?>
<a href="javascript:bookWholeDay()">Whole Day Booking</a> |
<?php
}
?>
<a href="showMonthly.php?year=<?=$year?>&month=<?=$month?>&resourceID=<?=$sorted[0]['ID']?>">Monthly view</a>
</td>
</tr>
<tr>
<td></td>
<?php
$strHeader = "";
$strFooter = "";
$i = 1;
$columns = array();
$tablewidth=100/count($sorted);
foreach ($sorted as $row) {
$today_resource[$i] = $row['ID'];
if (privileged('modify')) {
$strHeader .= ' <th width="'.$tablewidth.'%" bgcolor="#aaaacc" id=tx'.
$i.'y0t onMouseOver="high(' . $i . ',0)" onMouseOut="low(' . $i .
',0)" onMouseDown="startSelect(' . $i . ',0)"> ' . $row['Name'] .
' </th>' . "\n";
} else {
$strHeader .= ' <th width="'.$tablewidth.'%" bgcolor="#aaaacc" id=tx'.
$i.'y0t> ' . $row['Name'] . ' </th>' . "\n";
}
$strFooter .= ' <th bgcolor="#aaaacc"> ' . $row['Name'] . ' </th>' . "\n";
$columns[] = 0;
$i++;
}
print $strHeader;
?>
</tr>
<tr>
<?php
$currentTime = $startTime;
// print_r($today);
$j = 1;
$fives = 5;
while ($currentTime->dump() < $finishTime->dump()) {
if (privileged('modify')) {
?>
<td rowspan=6 height=15px bgcolor="#ccccee" class=time id=tx0y<?=$j?>t onMouseOver="high(0,<?=$j?>)" onMouseOut="low(0,<?=$j?>)" onMouseDown="startSelect(0,<?=$j?>)"><?=$currentTime->dump()?></td>
<?php
} else {
?>
<td rowspan=6 height=15px bgcolor="#ccccee" class=time id=tx0y<?=$j?>t><?=$currentTime->dump()?></td>
<?php
}
for ($fives=0;$fives<6;$fives++) {
for ($i=1;$i<=$num_sections;$i++) {
$colspan = 1;
$currtime = mktime($currentTime->hour,$currentTime->min,0,$month,$day,
$year);
if (isset($today[$today_resource[$i]][$currtime])) {
$thisres = $today[$today_resource[$i]][$currtime];
$columns[$i-1] = $thisres['Period']/5;
for ($k=$i+1;$k<=$num_sections;$k++) {
if (isset($today[$today_resource[$k]][$currtime]['ID']) &&
$today[$today_resource[$k]][$currtime]['ID'] == $thisres['ID']) {
$columns[$k-1] = $columns[$i-1];
$colspan++;
unset($today[$today_resource[$k]][$currtime]);
}
}
if (privileged('modify')) {
?>
<td colspan="<?=$colspan?>" bgcolor="<?=$thisres['MemberColour']?>"
rowspan="<?=$columns[$i-1]?>" height="<?=$columns[$i-1]*3?>px" valign="top" class="reserved" id=tx<?=$i?>y<?=$j?>t onMouseOver="high(<?=$i?>,<?=$j?>)" onMouseOut="low(<?=$i?>,<?=$j?>)" onClick="startSelect(<?=$i?>,<?=$j?>)">
<?php
} else {
?>
<td colspan="<?=$colspan?>" bgcolor="<?=$thisres['MemberColour']?>"
rowspan="<?=$columns[$i-1]?>" height="<?=$columns[$i-1]*3?>px" valign="top" class="reserved" id=tx<?=$i?>y<?=$j?>t>
<?php
}
?>
<a href="showCalendar.php?act=view&reservationID=<?=$thisres['ID']?>"><?=$thisres['MemberName']?></a>
<?php
$thisresTimeObj = $currentTime;
$thisresTimeObj->addMinutes($thisres['Period']);
print '('.$thisres['ActivityName'].')';
if ($columns[$i-1] > 10) print '<br>';
?>
<b><?=$currentTime->dump().' - '.$thisresTimeObj->dump()?></b>
<i><?=$thisres['Pending']==1?'(Pending)':''?></i>
<?php
if ($columns[$i-1] > 20) print '<br>';
// Print the first line of the description
print strtok($thisres['Description'],"\r\n");
?>
</td>
<?php
}
if ($columns[$i-1] == 0) {
if (privileged('modify')) {
?>
<td bgcolor="#dddddd" height="3px" class="unreserved<?=($fives==5)?'boundary':''?>" align="center" id=tx<?=$i?>y<?=$j?>t onMouseOver="high(<?=$i?>,<?=$j?>)" onMouseOut="low(<?=$i?>,<?=$j?>)" onClick="startSelect(<?=$i?>,<?=$j?>)"></td>
<?php
} else {
?>
<td bgcolor="#dddddd" height="3px" class="unreserved<?=($fives==5)?'boundary':''?>" align="center" id=tx<?=$i?>y<?=$j?>t></td>
<?php
}
} else {
$columns[$i-1]--;
}
}
$currentTime->addMinutes(5);
$j++;
?>
</tr>
<tr>
<?php
}
}
?>
<td></td>
<?php print $strFooter; ?>
</tr>
</table>
</form>
<script language=javascript>
<!--
maxy = <?=($j-1)?>;
// -->
</script>
<?php
}
require "../system/shell_iframe_footer.php"
?>
|