示例#1
0
//var_dump($_POST);
/*
 * Add, delete or edit mandant
 */
if (isset($_POST['company'])) {
    if (isset($_POST['deleteMandant']) && $_POST['deleteMandant'] == 'yes') {
        if (is_numeric($_GET['mandantID'])) {
            if (EventDatabaseManager::deleteMandant($_GET['mandantID'])) {
                echo MANDANT_DELETED_MESSAGE;
            } else {
                echo MANDANT_NOT_DELETED_MESSAGE;
            }
        }
    } else {
        if (isset($_GET['mandantID']) && is_numeric($_GET['mandantID'])) {
            EventDatabaseManager::updateMandant($_GET['mandantID'], mysql_real_escape_string($_POST['company']));
            $locations = EventDatabaseManager::getAllLocations();
            foreach ($locations as $id => $locationName) {
                if (isset($_POST['location_' . $id])) {
                    EventDatabaseManager::addLocationToMandant($_GET['mandantID'], $id);
                } else {
                    EventDatabaseManager::removeLocationFromMandant($_GET['mandantID'], $id);
                }
            }
        } else {
            if (!isset($_GET['mandantID'])) {
                if (EventDatabaseManager::addMandant(mysql_real_escape_string($_POST['company']))) {
                    echo MANDANT_ADDED_MESSAGE;
                }
            }
        }