<form id="role_form" method="post" action="/admin/role_save" class="nvForm">
	<input type="hidden" name="acl_role_id" value="<?php echo($acl_role_id); ?>" />
	<?php csrf(); ?>

	<div class="row">
		<div class="<?php echo(TOP_LEFT); ?>">
			<h2>Edit Role</h2>
		</div>
		<div class="<?php echo(TOP_RIGHT); ?>">
			<button type="submit" name="submit_action" id="submit" value="close" class="btn btn-primary"><em class="fas fa-save" aria-hidden="true"></em> Save &amp; Close</button>
			<button type="submit" name="submit_action" id="submit2" value="continue" class="btn btn-primary"><em class="fas fa-save" aria-hidden="true"></em> Save &amp; Continue</button>
			<a href="/admin/roles" class="btn btn-secondary"><em class="fas fa-times" aria-hidden="true"></em> Cancel</a>
		</div>
	</div>
	<div class="row">
		<div class="<?php echo(TWO_COL); ?>">
			<fieldset>
				<legend>Role Information</legend>

				<div class="<?php echo(FORM_ROW); ?>">
					<label for="role" class="<?php echo(LABEL_COL); ?>">Name</label>
					<div class="<?php echo(FIELD_COL); ?>"><input type="text" name="role" id="role" value="<?php echo($role->role); ?>" placeholder="Administrators" class="form-control" required /></div>
				</div>

				<div class="<?php echo(FORM_ROW); ?>">
					<label for="description" class="<?php echo(LABEL_COL); ?>">Description</label>
					<div class="<?php echo(FIELD_COL); ?>"><textarea name="description" id="description" class="form-control"><?php echo($role->description); ?></textarea></div>
				</div>
			</fieldset>
		</div>

		<div class="<?php echo(TWO_COL); ?>">
			<fieldset>
				<?php
				if($role->acl_role_id == 3)
				{
					?><div class="alert alert-info">Administrators automatically have read/write access to everything.</div><?php
				}
				else
				{
					?>
					<legend>Access to all existing Content Pages</legend>
					<input type="radio" name="bulk_page_acl" id="bulk_page_acl_nochange" value="" checked /> <label for="bulk_page_acl_nochange" class="inline">No Change</label>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bulk_page_acl" id="bulk_page_acl_none" value="n" /> <label for="bulk_page_acl_none" class="inline">None</label>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bulk_page_acl" id="bulk_page_acl_r" value="r" /> <label for="bulk_page_acl_r" class="inline">Read Only</label>
					<?php
					if($role->acl_role_id > 1)
					{
						?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bulk_page_acl" id="bulk_page_acl_rw" value="rw" /> <label for="bulk_page_acl_rw" class="inline">Read / Write</label><?php
					}
					?><br><br>

					<legend>Access to all existing Documents</legend>
					<input type="radio" name="bulk_document_acl" id="bulk_document_acl_nochange" value="" checked /> <label for="bulk_document_acl_nochange" class="inline">No Change</label>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bulk_document_acl" id="bulk_document_acl_none" value="n" /> <label for="bulk_document_acl_none" class="inline">None</label>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bulk_document_acl" id="bulk_document_acl_r" value="r" /> <label for="bulk_document_acl_r" class="inline">Read Only</label>
					<?php
					if($role->acl_role_id > 1)
					{
						?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bulk_document_acl" id="bulk_document_acl_rw" value="rw" /> <label for="bulk_document_acl_rw" class="inline">Read / Write</label><?php
					}
					?><br><br>

					<legend>Access to all existing Modules</legend>
					<input type="radio" name="bulk_module_acl" id="bulk_module_acl_nochange" value="" checked /> <label for="bulk_module_acl_nochange" class="inline">No Change</label>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bulk_module_acl" id="bulk_module_acl_none" value="n" /> <label for="bulk_module_acl_none" class="inline">None</label>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bulk_module_acl" id="bulk_module_acl_r" value="r" /> <label for="bulk_module_acl_r" class="inline">Read Only</label>
					<?php
					if($role->acl_role_id > 1)
					{
						?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bulk_module_acl" id="bulk_module_acl_rw" value="rw" /> <label for="bulk_module_acl_rw" class="inline">Read / Write</label><?php
					}
					?><br><br>

					<legend>Access to all existing Menu Items</legend>
					<input type="radio" name="bulk_menu_acl" id="bulk_menu_acl_nochange" value="" checked /> <label for="bulk_menu_acl_nochange" class="inline">No Change</label>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bulk_menu_acl" id="bulk_menu_acl_none" value="n" /> <label for="bulk_menu_acl_none" class="inline">None</label>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bulk_menu_acl" id="bulk_menu_acl_r" value="r" /> <label for="bulk_menu_acl_r" class="inline">Read Only</label>
					<?php
					if($role->acl_role_id > 1)
					{
						?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bulk_menu_acl" id="bulk_menu_acl_rw" value="rw" /> <label for="bulk_menu_acl_rw" class="inline">Read / Write</label><?php
					}
				}
				?>
			</fieldset>
		</div>
	</div>

	<fieldset>
		<legend>Which Actions Can This Role Can Perform?</legend>

		<?php
		if($role->acl_role_id == 1)
		{
			?><div class="alert alert-danger">For security reasons you may not assign actions to public users.</div><?php
		}
		else if(isset($actions) && count($actions) > 0)
		{
			?><div class="row"><?php
			$count = 0;
			$split = floor(count($actions)/4);

			foreach($actions as $action)
			{
				if($count == 0 || $count == $split)
				{
					if($count == $split)
					{
						?></div><?php
						$count = 0;
					}
					?><div class="col-12 col-sm-6 col-md-4 col-lg-3"><?php
				}

				FeralCheckbox("action_" . $action->acl_action_id, $action->active);
				?> <label for='action_<?php echo($action->acl_action_id); ?>_checkbox'><?php echo($action->action); ?></label><br /><?php
				$count++;
			}
			?></div></div><?php
		}
		else
		{
			?><div class="alert alert-danger">No Actions Defined Yet.</div><?php
		}
		?>
	</fieldset>
</form>
