function __construct($id)
 {
     if (is_numeric($id)) {
         $item_type_row = get_item_type($id);
         $this->build($item_type_row);
     }
 }
function item_settings_page()
{
    $items = get_items();
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    $new_item_url = admin_url() . 'admin.php?page=new_item_settings';
    $edit_item_url = admin_url() . 'admin.php?page=edit_item_settings';
    $pano_editor = admin_url() . "admin.php?page=view_panos_settings";
    ?>

<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<style>
#wpfooter{
  display: none;
}
</style>
<p>Manage your items!</p>
<hr>

<?php 
    if (isset($_GET['settings-saved'])) {
        ?>
    <div class="updated"><p>Settings saved successfully.</p></div>
<?php 
    }
    ?>

<h2>Items</h2>
    <table class="ui table segment">
        <tr>
            <th>Item</th>
            <th>Item Info</th>
            <th>Image</th>
            <th>Price</th>
            <th>Item Type</th>
            <th>Edit</th>
            <th>Delete</th>
            <th>Create Hotspot</th>
        </tr>
        <?php 
    foreach ($items as $item) {
        ?>
            <tr>
                <td><?php 
        echo $item->name;
        ?>
</td>
                <td><?php 
        echo $item->description;
        ?>
</td>
                <td><?php 
        echo $item->image;
        ?>
</td>
                <td><?php 
        echo $item->price;
        ?>
</td>
                <td><?php 
        echo get_item_type($item->type_id)->name;
        ?>
</td>
                <td><a class="ui blue icon button" style="padding: 7px" href="<?php 
        echo $edit_item_url;
        ?>
&id=<?php 
        echo $item->id;
        ?>
">Edit</a> </td>
                <td>
                    <form method="post" action="admin-post.php" id="delete_item_form<?php 
        echo $item->id;
        ?>
">
                        <input type="hidden" name="action" value="delete_item"/>
                        <input type="hidden" name="item_id" value="<?php 
        echo $item->id;
        ?>
"/>
                        <input type="submit" class="ui blue icon button" style="padding: 7px" value="Delete" />
                    </form>
                </td>
                <td>
                    <form method="POST" action="<?php 
        echo $pano_editor;
        ?>
">
                        <input name="item_id" type="hidden" value="<?php 
        echo $item->id;
        ?>
">
                        <input class="ui blue icon button" style="padding: 7px" type="submit" value="Create Hotspot" />
                    </form>
                </td>
            </tr>
        <?php 
    }
    ?>
    </table>
    <a class="ui blue icon button" style="padding: 7px" href="<?php 
    echo $new_item_url;
    ?>
">New Item</a>
    </div>
<?php 
}
function view_purchase_settings_page()
{
    if (isset($_GET['id']) && is_numeric($_GET['id'])) {
        $purchase = build_purchase($_GET['id']);
        $date = date('m/d/Y', strtotime($purchase->get_date()));
        $items = get_purchase_items($_GET['id']);
        $total = get_purchase_total($_GET['id']);
    }
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<style>
#wpfooter{
  display: none;
}
</style>
<p>User: <?php 
    echo get_userdata($purchase->get_user_id())->user_nicename;
    ?>
</p>
<p>Date: <?php 
    echo $date;
    ?>
</p>

<table class="ui table segment">
<tr>
    <th>Name</th>
    <th>Price</th>
    <th>Type</th>
</tr>
<?php 
    foreach ($items as $key => $item) {
        ?>
    <tr>
        <th><?php 
        echo $item->name;
        ?>
</th>
        <th><?php 
        echo $item->price;
        ?>
</th>
        <th><?php 
        echo get_item_type($item->type_id)->name;
        ?>
</th>
    </tr>
<?php 
    }
    ?>

<p>Total: <?php 
    echo $total;
    ?>
</p>
<?php 
}