<?php
$user = new user;
$type = $user->get_member_type($_POST['id']);
$content = $user->get_member_type_content($_POST['id']);
?>

<script type="text/javascript">
    $.ctrl('S', function () {
        return json_add('member_types-edit', '<?php echo $_POST['id']; ?>', '1');
    });
</script>


<form action="" method="post" id="popupform" onsubmit="return json_add('member_types-edit','<?php echo $_POST['id']; ?>','1');">


    <div id="popupsave">
        <input type="submit" value="Save" class="save"/>
    </div>

    <h1>Content Package for "<?php echo $type['name']; ?>"</h1>

    <div class="pad24t popupbody">
        <div class="small">
            <a href="null.php" onclick="return switch_popup('member_types','');">&laquo; Back to Member Types</a>
        </div>
    </div>

    <h4 class="nontable_section">Alter Existing Members?</h4>
    <div class="pad24t popupbody">
        <input type="radio" name="alter_existing" value="1" checked="checked" /> Alter existing members' access to content<br />
        <input type="radio" name="alter_existing" value="0" /> Do not change existing members' access to content
    </div>

    <h4 class="nontable_section">Content Package</h4>
    <div class="pad24t popupbody">
        <ul id="note_labels" class="popup_longlist">

            <?php
            $q1 = $db->run_query("
                SELECT *
                FROM `ppSD_member_types_content`
                WHERE `member_type`='" . $db->mysql_clean($_POST['id']) . "'
            ");
            while ($item = $q1->fetch()) {
                $content = new content;
                $cdata = $content->get_content($item['act_id']);

            ?>

                <li id="td-cell-<?php echo $item['id']; ?>">
                    <div class="floatright">Delete <input type="checkbox" name="content[<?php echo $item['id'] ?>][del]" value="1" /></div>
                    <input type="text" name="content[<?php echo $item['id'] ?>][dud]" id="<?php echo $item['id'] ?>" style="width:70%;" autocomplete="off" onkeyup="return autocom(this.id,'id','name','ppSD_content','name');" value="<?php echo $cdata['name']; ?>" />
                    <a href="null.php" onclick="return get_list('content','<?php echo $item['id'] ?>_id','<?php echo $item['id'] ?>');"><img src="imgs/icon-list.png" width="16" height="16" border="0" alt="Select from list" title="Select from list" class="icon-right"/></a>
                    <input type="hidden" name="content[<?php echo $item['id'] ?>][id]" id="<?php echo $item['id'] ?>_id" value="<?php echo $item['act_id'] ?>" /></td>
                </li>

            <?php
            }
            ?>

        </ul>

        <div class="submit">
            <a href="null.php" onclick="return add_type_content();">[+] Add Content To Package</a>
        </div>

    </div>

</form>

<script type="text/javascript">
    function add_type_content() {
        show_loading();
        var uniqid = Date.now();
        var theResponse = '<li id="td-cell-' + uniqid + '">';
        theResponse += '<input type="text" name="content[' + uniqid + '][dud]" id="' + uniqid + '" style="width:70%;" autocomplete="off" onkeyup="return autocom(this.id,\'id\',\'name\',\'ppSD_content\',\'name\');" value="" />';
        theResponse += '<a href="null.php" onclick="return get_list(\'content\',\'' + uniqid + '_id\',\'' + uniqid + '\');"><img src="imgs/icon-list.png" width="16" height="16" border="0" alt="Select from list" title="Select from list" class="icon-right"/></a>';
        theResponse += '<input type="hidden" name="content[' + uniqid + '][id]" id="' + uniqid + '_id" value="" /></td>';
        theResponse += '</li>';
        $('#note_labels').append(theResponse);
        close_loading();
        return false;
    }
</script>