<?php

$title = 'Member Box Sticker';
require './header.php';
$cards = fRecordSet::build('Card', array('uid=' => $_GET['cardid']));
if ($cards->count() == 0) {
    fURL::redirect("/kiosk/addcard.php?cardid=" . $_GET['cardid']);
}
$card = $cards->getRecord(0);
$user = new User($card->getUserId());
$user->load();
if (isset($_POST['print']) && $user->isMember()) {
    $data = array('owner_id' => $user->getId(), 'owner_name' => $user->getFull_Name());
    $data_string = json_encode($data);
    $ch = curl_init('http://kiosk.london.hackspace.org.uk:12345/print/box');
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string)));
    $result = curl_exec($ch);
    curl_close($ch);
    echo "<p>Your sticker is being printed now.</p>";
}
?>

<?php 
if ($user->isMember()) {
    ?>

<p>On this page you can print a label for your box.</p>
require './header.php';
$cards = fRecordSet::build('Card', array('uid=' => $_GET['cardid']));
if ($cards->count() == 0) {
    fURL::redirect("/kiosk/addcard.php?cardid=" . $_GET['cardid']);
}
$card = $cards->getRecord(0);
$user = new User($card->getUserId());
$user->load();
# echo json_encode($_POST);
if (isset($_POST['print']) && $user->isMember()) {
    try {
        fRequest::validateCSRFToken($_POST['token']);
        $validator = new fValidation();
        $validator->addRequiredFields('more_info');
        $validator->validate();
        $data = array('donor_id' => $user->getId(), 'donor_name' => $user->getFull_Name(), 'donor_email' => $user->getEmail(), 'dispose_date' => date('Y-m-d', strtotime("+2 weeks")), 'more_info' => $_POST['more_info']);
        $data_string = json_encode($data);
        $ch = curl_init('http://kiosk.london.hackspace.org.uk:12345/print/hackme');
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string)));
        $result = curl_exec($ch);
        curl_close($ch);
        echo "<p>Your sticker is being printed now.</p>";
    } catch (fValidationException $e) {
        $e->printMessage();
    }
}
?>
$user->load();
$user_profile = $user->createUsersProfile();
/*

Hello my name is
[name]
and you can find me on
irc:
email:
the web:


*/
if (isset($_POST['print']) && $user->isMember()) {
    $data = array(
        'name' => $user->getFull_Name(),
        'items' => array(),
    );

    if($user_profile->getAllowEmail()) { 
        $data['items']['email'] = $user->getEmail();
    }

    if($user_profile->getWebsite() != '') {
        $data['items']['website'] = $user_profile->getWebsite();
    }
    if($user->hasUsersAliases()) {
        foreach($user->buildUsersAliases() as $alias) {
            $data['items'][$alias->getAliasId()] = $alias->getUsername();
            // fix up twitter handles
            if ($alias->getAliasId() == 'Twitter') {
$title = 'Fix Me Sticker';
require './header.php';
$cards = fRecordSet::build('Card', array('uid=' => $_GET['cardid']));
if ($cards->count() == 0) {
    fURL::redirect("/kiosk/addcard.php?cardid=" . $_GET['cardid']);
}
$card = $cards->getRecord(0);
$user = new User($card->getUserId());
$user->load();
if (isset($_POST['print']) && $user->isMember()) {
    try {
        fRequest::validateCSRFToken($_POST['token']);
        $validator = new fValidation();
        $validator->addRequiredFields('name', 'more_info');
        $validator->validate();
        $data = array('name' => $_POST['name'], 'reporter_id' => $user->getId(), 'reporter_name' => $user->getFull_Name(), 'reporter_email' => $user->getEmail(), 'more_info' => $_POST['more_info']);
        $data_string = json_encode($data);
        $ch = curl_init('http://kiosk.london.hackspace.org.uk:12345/print/fixme');
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string)));
        $result = curl_exec($ch);
        curl_close($ch);
        echo "<p>Your sticker is being printed now.</p>";
    } catch (fValidationException $e) {
        $e->printMessage();
    }
}
?>
<?php

$title = 'Notice of Disposal';
require './header.php';
$cards = fRecordSet::build('Card', array('uid=' => $_GET['cardid']));
if ($cards->count() == 0) {
    fURL::redirect("/kiosk/addcard.php?cardid=" . $_GET['cardid']);
}
$card = $cards->getRecord(0);
$user = new User($card->getUserId());
$user->load();
# echo json_encode($_POST);
if (isset($_POST['print']) && $user->isMember()) {
    fRequest::validateCSRFToken($_POST['token']);
    $data = array('id' => $user->getId(), 'name' => $user->getFull_Name(), 'email' => $user->getEmail());
    $data_string = json_encode($data);
    #    echo($data_string);
    $ch = curl_init('http://kiosk.london.hackspace.org.uk:12345/print/nod');
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string)));
    $result = curl_exec($ch);
    curl_close($ch);
    echo "<p>Your sticker is being printed now.</p>";
}
?>

<?php 
if ($user->isMember()) {
    ?>