<?php

//////////////////////////////////////////////////////////////
//===========================================================
// edit_user_notice_theme.php
//===========================================================
// SOFTACULOUS VIRTUALIZOR
// Version : 1.0
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Alons
// Date:       8th Mar 2010
// Time:       23:00 hrs
// Site:       https://www.virtualizor.com/ (SOFTACULOUS VIRTUALIZOR)
// ----------------------------------------------------------
// Please Read the Terms of use at https://www.virtualizor.com
// ----------------------------------------------------------
//===========================================================
// (c)Softaculous Ltd.
//===========================================================
//////////////////////////////////////////////////////////////

if(!defined('VIRTUALIZOR')){

	die('Hacking Attempt');

}

function edit_user_notice_theme(){

global $theme, $globals, $cluster, $users, $l, $error, $done, $servergroups, $servers, $info, $notices;

softheader($l['<title>']);
					

echo page_header(__('Edit User Notice'), 'fas fa-paper-plane');

$breadcrumbs = array('dashboard', 'lm_users', 'user_notice', 'lms_edit_user_notice');

echo get_breadcrumb($breadcrumbs);

error_handle($error);

if(!empty($done)){
	show_alert($done, '', 'user_notice');
}
// r_print($notices);
// r_print($servergroups);
echo '
<script type="text/javascript" src="'.$theme['url'].'/js/tinymce/tinymce.min.js"></script>

<script>
	
	$(document).ready(function(){
		$("#serid").select2({
			placeholder : "",
			allowClear: true
		});
		$("#serid").on("select2:select", function(e){
			var id = e.params.data.id;
			var option = $(e.target).children("[value="+id+"]");
			option.detach();
			$(e.target).append(option).change();
		});
	});
	$("#serid").select2({width:"100%"});
	
</script>

<div class="card p-2 mx-3">
	<form id="mail"  accept-charset="'.$globals['charset'].'" action="" method="post" name="mail" class="form-horizontal">
		<div class="row mx-auto w-100 my-3 adj_ht">
			<div class="col-sm-2 adj_ht_cont" >
				<label for="notice">'.__('Notice Name').'</label>
			</div>
			<div class="col-sm-10 m-0 p-0">
				<input type="text" name="notice_name" class="form-control w-100" value="'.$info['notice_name'].'"/>
			</div>
		</div>
		<div class="row mx-auto w-100 my-3 adj_ht">
			<div class="col-sm-2 adj_ht_cont" >
				<label class="control-label" for="serid">'.__('Server').'</label>
			</div>
			<div class="col-sm-10 m-0 p-0">
				<select class="select2 w-100" name="serid[]" id="serid" multiple="multiple">
					<option value="-1" '.($info['serid'][0] == -1 && $info['sgid'][0] == -1 ? 'selected="selected"' : '').'>'.__('all').'</option>';
					foreach ($servergroups as $k => $v){
						echo '<option class="fhead" value="'.$k.'_group" '.(in_array($k, $info['sgid']) ? 'selected="selected"' : '').'>[Group]&nbsp;'.$v['sg_name'].'</option>';
						
						foreach ($servers as $m => $n){
							if($n['sgid'] === $k){
								echo '<option value="'.$n['serid'].'" '.(in_array($n['serid'], $info['serid']) ? 'selected="selected"' : '').'>&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;'.$n['server_name'].'</option>';
							}
						}
					}
				echo '</select>
			</div>
		</div>
		<div class="row mx-auto w-100 my-3 adj_ht">
			<div class="col-sm-2 adj_ht_cont" >
				<label class="control-label" for="user_type" >'.__('Type').'</label>
			</div>
			<div class="col-sm-10 m-0 p-0">
				<select class="custom-select w-100" name="user_type" id="user_type">
					<option value="-1" '.($info['user_type'] == '-1' ? 'selected="selected"' : '').'>'.__('all').'</option>
					<option value="0" '.($info['user_type'] == '0' ? 'selected="selected"' : '').'>'.__('User').'</option>
					<option value="2" '.($info['user_type'] == '2' ? 'selected="selected"' : '').'>'.__('Cloud').'</option>
				</select>
			</div>
		</div>
		<div class="row mx-auto w-100 my-3">
			<div class="col-sm-2 adj_ht_cont">
				<label for="notice_type">'.__('Notice Type').'</label>
			</div>
			<div class="col-sm-10 m-0 p-0">
				<select name="notice_type" id="notice_type" class="virt-select">
					<option value="primary" '.($info['notice_type'] == 'primary' ? 'selected="selected"' : '').'>'.__('Information notice in blue banner').'</option>
					<option value="warning" '.($info['notice_type'] == 'warning' ? 'selected="selected"' : '').'>'.__('Warning notice in yellow banner').'</option>
					<option value="success" '.($info['notice_type'] == 'success' ? 'selected="selected"' : '').'>'.__('Success notice in green banner').'</option>
					<option value="danger" '.($info['notice_type'] == 'danger' ? 'selected="selected"' : '').'>'.__('Danger notice in red banner').'</option>
				</select>
			</div>
		</div>
		<div class="row mx-auto w-100 my-3 adj_ht">
			<div class="col-sm-2 adj_ht_cont" >
				<label for="notice">'.__('Notice').'</label>
			</div>
			<div class="col-sm-10 m-0 p-0">
				<textarea rows="10" name="message" class="w-100">'.$info['message'].'</textarea>
			</div>
		</div>
		<div class="row mx-auto w-100 adj_ht">
			<div class="col-sm-2 adj_ht_cont" >
				<label for="notice">'.__('Enable Notice').'</label>
			</div>
			<div class="col-sm-10 m-0 p-0">
				'.get_checkbox('enabled', '', 'enabled', array('chk_it' => 1, 'name' => 'enabled', 'val' => $info['enabled'])).'
			</div>
		</div>		
		<center><input type="submit" name="edit_notice" value="'.__('Edit Notice').'" class="go_btn mt-3"/></center><br>
	</form>
</div>
</div>
';

softfooter();

}

?>
