<?php require_once "atc_finance.class.php"; $ATC = new ATC_Finance(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['startdate']) && strtotime($_POST['startdate'])) { try { $ATC->set_activity($_POST['activity_id'], $_POST['startdate'], $_POST['enddate'], $_POST['title'], $ATC->set_location($_POST['location_id'], $_POST['location'], null), $_POST['personnel_id'], $_POST['2ic_personnel_id'], $ATC->set_activity_type($_POST['activity_type_id'], $_POST['activity_type'], null), $_POST['dress_code'], $_POST['attendees'], $_POST['cost']); } catch (ATCExceptionInsufficientPermissions $e) { header("HTTP/1.0 401 Unauthorised"); echo 'Caught exception: ', $e->getMessage(), "\n"; } catch (ATCExceptionDBError $e) { header("HTTP/1.0 500 Internal Server Error"); echo 'Caught exception: ', $e->getMessage(), "\n"; } catch (ATCExceptionDBConn $e) { header("HTTP/1.0 500 Internal Server Error"); echo 'Caught exception: ', $e->getMessage(), "\n"; } catch (ATCException $e) { header("HTTP/1.0 400 Bad Request"); echo 'Caught exception: ', $e->getMessage(), "\n"; } catch (Exception $e) { header("HTTP/1.0 500 Internal Server Error"); echo 'Caught exception: ', $e->getMessage(), "\n"; } } elseif (isset($_POST["attendance_register"])) { try { $register = array(); foreach ($_POST as $key => $value) { if (substr($key, 0, strlen('attendance_')) == 'attendance_') { $foo = explode("_", $key); // Exclude the attendance_register entry, only go if we've got a real person record