<?php

require 'include_elevforeningen_login.php';
$contact = $auth->getContact($_SESSION['contact_id']);
$client = new IntrafacePublic_Shop_XMLRPC_Client($credentials, false);
$error = array();
if (!empty($_POST)) {
    if (!empty($_POST['elevmoede'])) {
        foreach ($_POST['elevmoede'] as $key => $antal) {
            if (isset($antal) and is_numeric($antal)) {
                $client->changeBasket($key, (int) $antal);
            } elseif (!empty($antal) and !is_numeric($antal)) {
                $error[] = 'Du skal skrive et tal, når du tilmelder dig elevmødet.';
            }
        }
    }
    if (!empty($_POST['jubilaeum']) and is_jubilar($auth)) {
        foreach ($_POST['jubilaeum'] as $key => $antal) {
            if (isset($antal) and is_numeric($antal)) {
                $client->changeBasket($key, (int) $antal);
            } elseif (!empty($antal) and !is_numeric($antal)) {
                $error[] = 'Du skal skrive et tal, når du tilmelder dig jubilæet';
            }
        }
    }
    if (!empty($_POST['stjernetraef'])) {
        // sørger for at slette alle tilmeldinger med stjernetræf
        $stjernetraef = $client->getProducts(array('keywords' => array(122)));
        foreach ($stjernetraef['products'] as $product) {
            // 122 er stjernetræf
            $client->changeBasket($product['id'], 0);