<?php

//////////////////////////////////////////////////////////////
//===========================================================
// adduser_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 adduser_theme(){

global $theme, $l, $globals, $kernel, $_user, $error, $done, $mgs, $servergroups, $dnsplans, $user_plans, $acls;

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

$GLOBALS['breadcrumbs'] = array('dashboard', 'lm_users', 'lms_adduser');

echo page_header(__('Add User'), 'fas fa-users',$globals['docs'].'add-user/', 0, 0, '');

error_handle($error);

if(!empty($done)){
	show_alert(__('The user has been saved. Return to <a href="index.php?act=users">Users Overview</a>'),"0","users");
}else{

echo '<script language="javascript" type="text/javascript">

var lang = Array();
lang["bad"] = "'.__J('Bad').'";
lang["good"] = "'.__J('Good').'";
lang["strong"] = "'.__J('Strong').'";
lang["short"] = "'.__J('Short').'";
lang["strength_indicator"] = "'.__J('Strength Indicator').'";

var chk_flag = 0;	
function changepriority(priority){
	
	if (priority != ""){
		$_("prior").value = priority;
	}
	
	if(priority == 1){
		$("#tr_acl").show();
	}else{
		$("#tr_acl").hide();
	}

	if(priority != 2){
		if($("#inhouse_billing").prop("checked")){
			chk_flag = 1;
			$("#inhouse_billing").trigger("click");
		}
	}
	if(priority == 2){
		if(chk_flag){
			chk_flag = 0;
			$("#inhouse_billing").trigger("click");
		}
	}

	$(".cloudfield").each(function(){
		if(priority == 2){
			$(this).show();
		}else{
			$(this).hide();
		}
	});';
	
	if(!empty($globals['inhouse_billing'])){
		echo '
		update_userplan();
		update_max_cost();';
	}
	
echo ';
};

function netspeed(r){
	$_("network_speed").value = r;
}

function upspeed(r){
	$_("upload_speed").value = r;
}

// Update the media groups when selected
function updatemg(){	

	$("#mg option").each(function(){
	try{
		if(!$_($(this).attr("type")).checked){
			$(this).attr("disabled","disabled");
		}else{
			$(this).attr("disabled", false);
		}
	}catch(e){}
	});

}

// Update the userplans
function update_userplan(){	
	
	var current_user_type = $_("prior").value;
	
	$("#uplid option").each(function(){
	try{
		if($(this).attr("type") == current_user_type || $(this).attr("type") == -1){
			$(this).show();
		}else{
			$(this).hide();
		}
	}catch(e){}
	});

}

// Load the userplans
function load_userplan(){		

	var url = "'.$globals['index'].'act=edituser_plans&api=json&uplid="+$("#uplid").val();
	
	// Load the details and also update the fields
	$.getJSON(url, function(data, textStatus, jqXHR) {
		
		$plan = data["user_plans"];
		
		$.each($plan, function( index, value ){
			
			if(index == "mgs"){
				
				var i = 0;
				var size = value.length;
				$options = $("#mg option");
				$("#mg option:selected").removeAttr("selected");
				for(i; i < size; i++){
					// filter the options with the specific value and select them
					if(value[i] != ""){
						$options.filter("[value="+value[i]+"]").prop("selected", true);
					}
				}
				
			}else if(index == "allowed_virts"){
				
				$("#allowed_virts option").each(function(){
					$(this).removeAttr("selected");
				});
				
				$("#allowed_virts option").each(function(){
				try{
					
					var _val = $(this).attr("value");
					for(x in value){
						if(value[x] == _val){
							$(this).attr("selected", "selected");
						}
					}
					
				}catch(e){}
				});
				
			}else{
				
				var ele = $("#adduser").find("[name="+ index +"]");
				
				if(empty(ele)){
					return;
				}
				
				if(ele.attr("type") == "checkbox"){
					if(!empty(value)){
						ele[0].checked = true;
					}else{
						ele[0].checked = false;
					}
				}else{
					// Set the value
					ele.val(value);
				}

				update_max_cost();
				
			}
		});

	});
	
}

function update_max_cost(){
	
	try{
	
	// Show max cost field
	if($_("inhouse_billing").checked){
		$("#max_cost_row").show();
		//$("#resources").hide();
	}else{
		$("#max_cost_row").hide();
		//$("#resources").show();
	}
	
	}catch(e){}
	
}

var lang_no_limit = "'.__J('No Restriction').'";
addonload("changepriority(\''.POSTval('priority', (optGET('create') == 'cloud' ? 2 : 0)).'\'); updatemg(); fillspeedkBps(); check_pass_strength(\'newpass\');");
</script>
<style>

.sideLabel label{
	padding:8px;
	float:right;
}

.input-group-append{
	border: 0px !important;
}
</style>

<div class="row mx-0 my-3">
	<div class="col-sm-12">
		<div class="d-none d-sm-block d-md-block d-lg-block">
			<ul class="nav nav-tabs nav-fill nav-justified">
				<li id="io_0" class="nav-item flex-fill">
					<a class="nav-link w-100 active" data-toggle="tab" role="general" onclick="javascript:changepriority(\'0\');">
						<img class="mr-2" src="'.$theme['svg'].'user.svg">'.__('User').'
					</a>
				</li>
				<li id="io_2" class="nav-item flex-fill">
					<a class="nav-link w-100" data-toggle="tab" role="cpu" onclick="javascript:changepriority(\'2\');">
						<img class="mr-2" src="'.$theme['svg'].'cloud_users.svg">'.__('Cloud').'
					</a>
				</li>
				<li id="io_1" class="nav-item flex-fill">
					<a class="nav-link w-100" data-toggle="tab" role="ram" onclick="javascript:changepriority(\'1\');">
						<img class="mr-2" src="'.$theme['svg'].'admin.svg">'.__('Admin').'
					</a>
				</li>
			</ul>
		</div>
		<div class="d-block d-sm-none d-md-none d-lg-none">
			<select class="custom-select" onchange="changepriority(this.value)">
				<option value="0">'.__('User').'</option>
				<option value="2">'.__('Cloud').'</option>
				<option value="1">'.__('Admin').'</option>
			</select>
		</div>
	</div>
</div>

<div id="form-container" class="card p-2 mx-3">
	
	<form accept-charset="'.$globals['charset'].'" name="adduser" id="adduser" method="post" action="" class="form-horizontal">
		<input type="hidden" id="prior" name="priority" value="">
		<div class="row mx-auto w-100 mt-3">
			<div class="col-sm-6 mb-2">
				<label class="control-label">'.__('User Email').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('Email Address of the User').'"><i class="fas text-primary fa-info-circle"></i></a></label>
				<input type="text" class="form-control w-100" name="newemail" id="newemail" size="30" value="'.POSTval('newemail', '').'" autocomplete="off" />
			</div>

			<div class="col-sm-6 mb-2">
				<label class="control-label">'.__('Password').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('The Password for the new user').'"><i class="fas text-primary fa-info-circle"></i></a></label>
				<div class="input-group">
					<input type="text" class="form-control" name="newpass" id="newpass" size="30" onkeyup="check_pass_strength(\'newpass\');" value="'.POSTval('newpass', generateRandPwd(12)).'" autocomplete="new-password" />
					<div class="input-group-append">
						<div id="newpass_pass-strength-result" class="w-auto strong d-flex align-items-center">'.__('Strength Indicator').'</div>
						<a href="javascript: void(0);" class="btn-primary py-0 px-1 rounded-right"  onclick="$_(\'newpass\').value=randstr(12, 1, '.(!empty($globals['pass_strength']) ? $globals['pass_strength'] : 0).');check_pass_strength(\'newpass\');return false;" title="'.__('Make another Random Password').'"><i class="fas fa-key p-2"></i></a>
					</div>
				</div>
			</div>
		</div>

		<div class="row mx-auto w-100">
			<div class="col-sm-6 mb-2">
				<label class="control-label">'.__('First Name').'</label>
				<input type="text" class="form-control w-100" name="fname" size="30" value="'.POSTval('fname', '').'" />
			</div>
			<div class="col-sm-6 mb-2">
				<label class="control-label">'.__('Last Name').'</label>
				<input type="text" class="form-control w-100" name="lname" size="30" value="'.POSTval('lname', '').'" />
			</div>
			<div class="col-sm-6 mb-2" id="tr_acl">
				<label class="control-label">'.__('Access Control').'</label>
				<select class="custom-select  w-100 virt-select select2-hidden-accessible" name="acl_id">
				<option value="0" '.POSTselect('acl_id', 0).'>'.__('Not used').'</option>';
				foreach($acls as $k => $v){
					echo '<option value="'.$v['aclid'].'" '.POSTselect('acl_id', $v['aclid']).'>'.$v['acl_name'].'</option>';
				}
				echo
				'</select>
			</div>
			<div class="col-sm-6 mb-2">
				<label class="control-label">'.__('DNS Plan').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('The DNS plan for the user').'"><i class="fas text-primary fa-info-circle"></i></a></label>
				<select class="custom-select w-100 virt-select select2-hidden-accessible" name="dnsplan_id">
					<option value="0" '.POSTselect('dnsplan_id', 0).'>'.__('No Plan').'</option>';
					foreach($dnsplans as $k => $v){
						echo '<option value="'.$v['dnsplid'].'" '.POSTselect('dnsplan_id', $v['dnsplid']).'>'.$v['plan_name'].'</option>';
					}
					echo '
				</select>
			</div>
			<div class="col-sm-6 mb-2 cloudfield" id="num_vs_row">
				<label class="control-label">'.__('Number of VMs').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('The maximum number of Virtual Machines this user can create. Zero (<b>0</b>) for unlimited.').'"><i class="fas text-primary fa-info-circle"></i></a></label>
				<input type="number" class="form-control" name="num_vs" id="num_vs" size="15" value="'.POSTval('num_vs', '').'" />
			</div>
		</div>';

		if(!empty($globals['inhouse_billing'])){
			echo '
			<div class="row mx-auto w-100 mt-3">
				<div class="col-sm-6 mb-2 cloudfield" id="inhouse_billing_row">
					<div class="row d-flex h-100 align-items-center">
						<div class="col-12 my-4 my-sm-0 my-md-0 my-lg-0 col-md-6 d-flex gap-1">
							<label class="control-label">'.__('Enable Virtualizor Billing').'&nbsp;<a class="info" data-placement="right" tooltip="'.htmlizer(__('If enabled, Virtualizor will calculate resource usage and create invoices for the VMs. Otherwise your external billing system should manage the billing.<br /> For more information read <a href="https://www.virtualizor.com/docs/billing/virtualizor-cloud-billing-system" target="_blank">Virtualizor Billing</a>')).'"><i class="fas text-primary fa-info-circle"></i></a></label><br>
							<a href="https://www.virtualizor.com/docs/billing/virtualizor-cloud-billing-system" target="_blank">'.__('Refer This').'</a>
							'.get_switch('inhouse_billing', '', 'inhouse_billing', array('chk_it' => 1), 1, '', array('onchange="update_max_cost()"')).'
						</div>
						<div class="col-sm-12 col-md-6 col-lg-6 cloudfield" id="max_cost_row">
							<label class="control-label">'.__('Max Cost per VPS / month').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('The Maximum cost of a VPS per month.').'"><i class="fas text-primary fa-info-circle"></i></a></label>
							<input type="number" class="form-control" name="max_cost" id="max_cost" size="15" value="'.POSTval('max_cost', '').'" />
						</div>
					</div>
				</div>
				<div class="col-sm-6 mb-2 cloudfield">
					<label class="control-label">'.__('User Plan').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('Assign the user to a predefined plan').'"><i class="fas text-primary fa-info-circle"></i></a></label>
					<select class="custom-select w-100 virt-select select2-hidden-accessible" id="uplid" name="uplid" onchange="load_userplan()">
					<option value="0" type="-1" '.POSTselect('uplid', 0).'>'.__('No Plan').'</option>';
					foreach($user_plans as $k => $v){
						echo '<option value="'.$v['uplid'].'" type="'.$v['type'].'" '.POSTselect('uplid', $v['uplid']).'>'.$v['plan_name'].'</option>';
					}
					echo '
					</select>
				</div>
			</div>';

		}

		echo '
		<div class="col-sm-12 my-4 cloudfield">
			<div class="row">
				<div class="col-lg-2 col-md-2 d-none d-md-block d-lg-block">
					<div class="nav flex-column nav-pills" id="resource-tab" role="tablist" aria-orientation="vertical">
						<a class="nav-link active" data-toggle="pill" href="#v-pills-general" role="tab" >'.__('General').'</a>
						<a class="nav-link" data-toggle="pill" href="#v-pills-cpu" role="tab" >'.__('CPU').'</a>
						<a class="nav-link" data-toggle="pill" href="#v-pills-ram" role="tab" >'.__('Ram').'</a>
						<a class="nav-link" data-toggle="pill" href="#v-pills-storage" role="tab" >'.__('Storage').'</a>
						<a class="nav-link" data-toggle="pill" href="#v-pills-network" role="tab" >'.__('Network').'</a>
					</div>
				</div>
				<div class="col-12 d-block d-md-none mb-3">
					<select class="form-control d-md-none" onchange="tab_to_select(this)">
						<option value="v-pills-general">'.__('General').'</option>
						<option value="v-pills-cpu">'.__('CPU').'</option>
						<option value="v-pills-ram">'.__('RAM').'</option>
						<option value="v-pills-storage">'.__('Storage').'</option>
						<option value="v-pills-network">'.__('Network').'</option>
					</select>
				</div>
				<div class="col-12 col-sm-12 col-md-10 col-lg-10">
					<div class="tab-content" id="resource-tabContent">
						<div class="tab-pane fade p-2 show active" id="v-pills-general" role="tabpanel" aria-labelledby="v-pills-general-tab">
							<div class="row mx-auto w-100 ">
								<div class="col-sm-6 mb-2 cloudfield" id="num_users_row">
									<label class="control-label">'.__('Number of Users').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('The maximum number of sub-users this user can create. Zero (<b>0</b>) for unlimited.').'"><i class="fas text-primary fa-info-circle"></i></a></label>
									<input type="number" class="form-control" name="num_users" id="num_users" size="15" value="'.POSTval('num_users', '').'" />
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="service_period">
									<label class="control-label">'.__('Billing cycle').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('The billing cycle start date for bandwidth calculation.').'"><i class="fas text-primary fa-info-circle"></i></a></label>
									<input type="number" class="form-control" min="0" max="31" id="txt_service_period" name="service_period" value="'.POSTval('service_period', '0').'" />
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="allowed_virts_row">
									<label class="control-label">'.__('Allowed Virtualization').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('The Virtualization type to allow this user').'"><i class="fas text-primary fa-info-circle"></i></a></label>
									<select class="form-control w-100" id="allowed_virts" multiple="multiple" name="allowed_virts[]" onchange="updatemg()">';
									$allowedvirts = (isset($_POST['allowed_virts']) ? $_POST['allowed_virts'] : []);
									foreach($globals['virts'] as $k => $v){
										echo '<option value="'.$v.'" '.(@in_array($k, $allowedvirts) ? 'selected="selected"' : '').'>'.$globals['virt_names'][$k].'</option>';
									}
									echo '
									</select>
									<span class="help-block"></span>
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="sg_row">
									<label class="control-label">'.__('Server Groups Allowed').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('If no group is selected than the user will not be able to create any VPS').'"><i class="fas text-primary fa-info-circle"></i></a></label>
									<select class="form-control w-100" name="sgs[]" multiple="multiple">';
										$sgs = (isset($_POST['sgs']) ? $_POST['sgs'] : []);
										foreach($servergroups as $sk => $sv){
											echo '<option value="'.$sk.'" '.(in_array($sk, $sgs) ? 'selected="selected"' : '').'>'.$sv['sg_name'].'</option>';
										}
										
									echo '</select>
									<span class="help-block"></span>
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="mg_row">
									<label class="control-label">'.__('Media Groups').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('If no media group is selected, then ALL templates and ISO will become available to this user').'"><i class="fas text-primary fa-info-circle"></i></a></label>
									<select class="form-control w-100" name="mgs[]" id="mg" multiple="multiple">';
										
										foreach($mgs as $mk => $mv){
											echo '<option value="'.$mk.'" type="'.$mv['mg_type'].'" '.(in_array($mk, @$_POST['mgs']) ? 'selected="selected"' : '').'>'.$mv['mg_name'].'</option>';
										}
										
									echo '</select>
								</div>';
								if(!empty($globals['premium_apps'])){
									echo '
										<div id="premium_apps_cb" class="col-sm-6 mb-2 w-100 cloudfield">
											<div class="row d-flex h-100 align-items-center">
												<div class="col-sm-6 mb-2">
													<label class="control-label">'.__('Enable Premium Applications').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('If checked then premium application will be enabled for this Cloud User and its sub user(s)').'"><i class="fas text-primary fa-info-circle"></i></a></label>
												</div>
												<div class="col-sm-6 mb-2">
													'.get_checkbox('webuzo_prem_apps', '', 'webuzo_prem_apps').'
												</div>
											</div>
										</div>
									';
								}
								echo '
							</div>
						</div>
						<div class="tab-pane fade p-2" id="v-pills-cpu" role="tabpanel" aria-labelledby="v-pills-cpu-tab">
							<div class="row mx-auto w-100 ">
								<div class="col-sm-6 mb-2 cloudfield" id="cpu_row">
									<label class="control-label">'.__('Default CPU Weight').'</label>
									<span class="help-block"></span>
									<input type="number" class="form-control rounded" name="cpu" id="cpu" size="15" value="'.POSTval('cpu', '').'" />
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="cores_row">
									<label class="control-label">'.__('Max Cores / VPS').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('The user cannot create a VPS above this limit').'"><i class="fas text-primary fa-info-circle"></i></a></label>
									<input type="number" class="form-control" name="cores" id="cores" size="15" value="'.POSTval('cores', '4').'" />
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="cpu_percent_row">
									<label class="control-label">'.__('Default CPU % / Core').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('All VPS created by the user would have this CPU %. This is per core base. E.g. If user creates VPS with 2 cores and percentage is 40 total 80% will be assigned.').'"><i class="fas text-primary fa-info-circle"></i></a></label>
									<input type="number" class="form-control" name="cpu_percent" id="cpu_percent" size="15" value="'.POSTval('cpu_percent', '').'" />
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="num_cores_row">
									<label class="control-label">'.__('Total Cores').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('The total number of cores allowed. Zero (<b>0</b>) means unlimited cores').'"><i class="fas text-primary fa-info-circle"></i></a></label>
									<input type="number" class="form-control" name="num_cores" id="num_cores" size="15" value="'.POSTval('num_cores', '0').'" />
								</div>
							</div>
						</div>
						<div class="tab-pane fade p-2" id="v-pills-ram" role="tabpanel" aria-labelledby="v-pills-ram-tab">
							<div class="row mx-auto w-100 ">
								<div class="col-sm-6 mb-2 cloudfield" id="ram_row">
									<label class="control-label">'.__('Max Ram').'</label>
									<div class="sideLabel">
										<div class="input-group ">
											<input type="number" class="form-control rounded" name="ram" id="ram" size="15" value="'.POSTval('ram', '').'" />
											<div class="input-group-append">
												<span class="input-group-text">MB</span>
											</div>
										</div>
									</div>
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="burst_row">
									<label class="control-label">'.__('Max Burst / Swap').'</label>
									<div class="sideLabel">
										<div class="input-group ">
											<input type="number" class="form-control rounded" name="burst" id="burst" size="15" value="'.POSTval('burst', '').'" />
											<div class="input-group-append">
												<span class="input-group-text">MB</span>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="tab-pane fade p-2" id="v-pills-storage" role="tabpanel" aria-labelledby="v-pills-storage-tab">
							<div class="row mx-auto w-100 ">
								<div class="col-sm-6 mb-2 cloudfield" id="space_row">
									<label class="control-label">'.__('Max Disk Space').'</label>
									<div class="sideLabel">
										<div class="input-group ">
											<input type="number" class="form-control rounded" name="space" id="space" size="15" value="'.POSTval('space', '').'" />
											<div class="input-group-append">
												<span class="input-group-text">GB</span>
											</div>
										</div>
									</div>
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="space_per_vm_row">
									<label class="control-label">'.__('Max disk space / VPS').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('The user cannot create a VPS above this limit').'"><i class="fas text-primary fa-info-circle"></i></a></label>
									<input type="number" class="form-control" name="space_per_vm" id="space_per_vm" size="15" value="'.POSTval('space_per_vm').'" />
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="total_iops_sec_row">
									<label class="control-label">'.__('Total I/O\'s per sec').'</label>
									<div class="sideLabel">
										<div class="input-group ">
											<input type="number" class="form-control" name="total_iops_sec" id="total_iops_sec" size="15" value="'.POSTval('total_iops_sec', '').'" />
											<div class="input-group-append">
												<span class="input-group-text">M/s</span>
											</div>
										</div>
									</div>
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="read_bytes_sec_row">
									<label class="control-label">'.__('Read Mega Byte\'s/s').'</label>
									<div class="sideLabel">
										<div class="input-group ">
											<input type="number" class="form-control" name="read_bytes_sec" id="read_bytes_sec" size="15" value="'.POSTval('read_bytes_sec', '').'" />
											<div class="input-group-append">
												<span class="input-group-text">M/s</span>
											</div>
										</div>
									</div>
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="write_bytes_sec_row">
									<label class="control-label">'.__('Write Mega Byte\'s/s').'</label>
									<div class="sideLabel">
										<div class="input-group ">
											<input type="number" class="form-control" name="write_bytes_sec" id="write_bytes_sec" size="15" value="'.POSTval('write_bytes_sec', '').'" />
											<div class="input-group-append">
												<span class="input-group-text">M/s</span>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="tab-pane fade p-2" id="v-pills-network" role="tabpanel" aria-labelledby="v-pills-network-tab">
							<div class="row mx-auto w-100 ">
								<div class="col-sm-6 mb-2 cloudfield" id="num_ipv4_row">
									<label class="control-label">'.__('Max IPv4').'</label>
									<input type="number" class="form-control" name="num_ipv4" id="num_ipv4" size="15" value="'.POSTval('num_ipv4', '').'" />
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="num_ipint_row">
									<label class="control-label">'.__('Max Internal Ips').'</label>
									<input type="number" class="form-control" name="num_ip_int" id="num_ip_int" size="15" value="'.POSTval('num_ip_int', '').'" />
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="num_ipv6_subnet_row">
									<label class="control-label">'.__('Max IPv6 Subnets').'</label>
									<input type="number" class="form-control" name="num_ipv6_subnet" id="num_ipv6_subnet" size="15" value="'.POSTval('num_ipv6_subnet', '').'" />
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="num_ipv6_row">
									<label class="control-label">'.__('Max IPv6').'</label>
									<input type="number" class="form-control" name="num_ipv6" id="num_ipv6" size="15" value="'.POSTval('num_ipv6', '').'" />
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="network_speed_row">
									<label class="control-label">'.__('Network Speed').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('Enter 0 or leave empty for no restriction. <br />Use the select box for easy options').'"><i class="fas text-primary fa-info-circle"></i></a></label>
									<div class="input-group " >
										<input type="number" class="form-control rounded" name="network_speed" id="network_speed" size="8" value="'.POSTval('network_speed', '').'" />
										<div class="input-group-append">
											<span class="input-group-text mr-1">'.__('KB/s').'</span>
											<select class="virt-select speedkBps" name="network_speed2" id="network_speed2" onchange="netspeed(this.value)"></select>
										</div>
									</div>
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="upload_speed_row">
									<label class="control-label">'.__('Upload Speed').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('Enter 0 or leave empty for no restriction. <br /> Enter -1 for upload speed to be same as <b>Network Speed.</b> <br />Use the select box for easy options').'"><i class="fas text-primary fa-info-circle"></i></a></label>
									<div class="input-group">
										<input type="number" class="form-control rounded" name="upload_speed" id="upload_speed" size="8" value="'.POSTval('upload_speed', '-1').'"/>	  
										<div class="input-group-append">
											<span class="input-group-text mr-1">'.__('KB/s').'</span>
											<select class="virt-select speedkBps" name="upload_speed2" id="upload_speed2" onchange="upspeed(this.value)"></select>
										</div>
									</div>
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="bandwidth_row">
									<label class="control-label">'.__('Max Bandwidth').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('Zero (<b>0</b>) means unlimited bandwidth').'"><i class="fas text-primary fa-info-circle"></i></a></label>
									<div class="sideLabel">
										<div class="input-group ">
											<input type="number" class="form-control rounded" name="bandwidth" id="bandwidth" size="15" value="'.POSTval('bandwidth', '').'" />
											<div class="input-group-append">
												<span class="input-group-text">GB</span>
											</div>
										</div>
									</div>
								</div>
								<div class="col-sm-6 mb-2 cloudfield" id="band_suspend">
									<div class="row d-flex h-100 align-items-center">
										<div class="col-6">
											<label class="control-label">'.__('Bandwidth Suspend').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('If checked then all the cloud user\'s VPS(s) will be suspended if the specified bandwidth limit is exceeded').'"><i class="fas text-primary fa-info-circle"></i></a></label>
										</div>
										<div class="col-6">
											'.get_checkbox('band_suspend', '', 'ck_band_sus').'
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

		<span class="help-block"></span>
		<br/><br/>
		<center>
			<input type="submit" name="adduser" value="'.__('Save user').'" class="go_btn">
		</center>
		<br/><br/>
	</form>
</div>';
}

softfooter();

}

