<?php

//////////////////////////////////////////////////////////////
//===========================================================
// plans_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 dnsplans_theme(){

global $theme, $globals, $kernel, $user, $l, $dnsplans, $error, $done;

softheader($l['<title>']);
					
$buttons = array(
				0 => array(
					'name' => __('Add DNS Plan'),
					'act'  => 'adddnsplan'
				)
			);

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

echo page_header(__('DNS Plans'), 'fas fa-clipboard', '', 1, 0, $buttons);

error_handle($error);

echo '<script language="javascript" type="text/javascript"><!-- // --><![CDATA[


function Deldns(dnsplid ,ele){

	dnsplid = dnsplid || 0;
	
	// List of ids to delete
	var dns_list = new Array();
	
	if(dnsplid < 1){
		
		if($(ele).parent().prev().find("select").val() != 1){
			showalert("'.__J('No Action Selected !').'","1");
			return false;
		}
		
		$(".ios:checked").each(function() {
			dns_list.push($(this).val());
		});
		
	}else{
		
		dns_list.push(dnsplid);
		
	}
	
	if(dns_list.length < 1){
		showalert("'.__J('Nothing selected !').'","1");
		return false;
	}
	
	showalert("'.__J('Are you sure, you want to Delete the Plan ?').'" ,"3" ,function(confirm){
		if(confirm == false){
			return false;
		}else{
			var finalData = new Object();
			finalData["delete"] = dns_list.join(",");

			//alert(finalData);
			//return false;
			
			$("#progress_bar").show();
			
			$.ajax({
				type: "POST",
				url: "'.$globals['index'].'act=dnsplans&api=json",
				data : finalData,
				dataType : "json",
				success: function(data){
					$("#progress_bar").hide();
					if("done" in data){
						setTimeout(function(){showalert("'.__J('The action was completed successfully. Reloading the Page !').'");
						$("#alert-modal").on("hidden.bs.modal", function (e) {
						location.reload(true);
						});} ,200);
					}

					if("fatal_error_text" in data){
						setTimeout(function(){showalert(data["fatal_error_text"] ,"1");} ,200);
					}
				},
				error: function(data) {
					$("#progress_bar").hide();
					//alert(data.description);
					return false;
				}
			});
		}
	});
	
	
	
	
	return false;
};

// ]]></script>
<div class="card p-2 mx-3">

	<div id="showsearch" style="display:'.(optREQ('search') || (!empty($dnsplans) && !empty($globals['showsearch'])) ? "" : "none").';">
		<form accept-charset="'.$globals['charset'].'" name="dnsplans" method="GET" action="" class="form-horizontal">
			<input type="hidden" name="act" value="dnsplans">
			<div class="form-group_head">
			<div class="row mx-auto w-100">
				<div class="col-sm-4"></div>
				<div class="col-sm-4"><label>'.__('Plan Name').'</label>
				<input type="text" class="form-control" name="planname" id="planname" size="30" value="'.REQval('planname','').'"/></div>
			</div>
			<div class="row mx-auto w-100 my-2">
				<div class="col-sm-12 text-center"><button type="submit" name="search" class="go_btn mt-2" value="Search"/>'.__('Search').'</button></div> 
			</div>
			</div>
		</form>
	</div>';

	if($done){
		show_alert(__('The DNS Plan was deleted successfully'));
		//echo '<div class="notice"><b>NOTE : </b>&nbsp; '..'</div><br />';
	}
	if(empty($dnsplans)){
		optREQ('search') ? show_alert(__('No results were found for your search query'), "2") : "";
		echo '<div class="notice"><b>NOTE : </b>&nbsp; '.(optREQ('search') ? __('No results were found for your search query') : __('There are no DNS Plans. <a href="index.php?act=adddnsplan">Add a DNS Plan now</a>')).'</div>';
	}else{
	echo
	'<div class="row mx-auto w-100 mb-3">
		<div class="col-sm-4 col-lg-4 col-md-6 text-right d-flex align-items-center">
			<div class="bottom-menu float-right w-100">
				<div class="row my-auto">
					<div class="p-0">
						<label>'.__('With Selected').'</label>
					</div>
					<div class="col p-0">
						<select class="custom-select" name="dns_task_select" id="dns_task_select">
							<option value="0">---</option>
							<option value="1">'.__('Delete').'</option>
						</select>
					</div>
					<div class="pl-2">
						<input type="submit" id ="dnsplan_submit" class="go_btn" name="dnsplan_submit" value="'.__('Go').'" onclick="Deldns(0 ,this); return false;">
					</div>
				</div>
			</div>
		</div>
		<div class="col-sm-8 col-lg-8 col-md-6 d-flex align-items-center justify-content-end p-0 mt-2 mt-md-0 mt-lg-0">';
			page_links($globals['num_res'], $globals['cur_page'], $globals['reslen']);
			echo get_num_records($globals['num_res']).'
		</div>
	</div>
	<form accept-charset="'.$globals['charset'].'" name="multi_dns" id="multi_dns" method="post" action="" class="form-horizontal">
		<div class="w-100 mx-auto sticky">
			<table class="table table-hover tablesorter common-table">
			<tr class="table_heading">
				<th class="min_width z-index-1" align="center">
					'.get_checkbox('select_all', '', 'select_all', array('chk_it' => 0), '', 'select_all').'
				</th>
				<th class="min_width" align="center">'.__('ID').'</th>
				<th align="center">'.__('DNS Plan Name').'</th>
				<th align="center">'.__('DNS Server').'</th>
				<th class="text-center">'.__('Max Domains').'</th>
				<th class="text-center">'.__('Max Records').'</th>
				<th class="text-center">'.__('Default TTL').'</th>
				<th colspan="2" width="10" class="min_width text-right">'.__('Manage').'</th>
			</tr>';
			$i = 0;
			foreach($dnsplans as $k => $v){
				echo '<tr>
					<td width="20" valign="middle" align="center">
						'.get_checkbox('dnsplan_list[]', '', '', array('chk_it' => 0), $k).'
					</td>
					<td align="center">'.$v['dnsplid'].'</td>
					<td>'.$v['plan_name'].'</td>
					<td>'.$v['dns_server_name'].'</td>
					<td align="center">'.$v['max_domains'].'</td>
					<td align="center">'.$v['max_domain_records'].'</td>
					<td align="center">'.$v['def_ttl'].'</td>
					<td align="center" width="10">
						<div class="badge_container">		
							<a class="badge badge-manage" href="?act=editdnsplan&dnsplid='.$v['dnsplid'].'" title="Edit"><i class="fas fa-pencil-alt"></i></a>
							<a class="badge badge-trash" href="javascript:void(0);" onclick="return Deldns('.$k.');" title="Delete"><i class="fas fa-trash"></i></a>
						</div>
					</td>
				</tr>';
			$i++;	
			}
			echo 
			'</table>
		</div>
	</form>
	<div class="row mx-auto w-100 mt-5">
		<div class="col-sm-4 col-lg-4 col-md-6 text-right mb-3">
			<div class="bottom-menu float-right w-100">
				<div class="row my-auto">
					<div class="p-0">
						<label>'.__('With Selected').'</label>
					</div>
					<div class="col p-0">
						<select class="custom-select" name="dns_task_select" id="dns_task_select">
							<option value="0">---</option>
							<option value="1">'.__('Delete').'</option>
						</select>
					</div>
					<div class="pl-2">
						<input type="submit" id ="dnsplan_submit" class="go_btn" name="dnsplan_submit" value="'.__('Go').'" onclick="Deldns(0 ,this); return false;">
					</div>
				</div>
			</div>
		</div>
		<div class="col-sm-8 col-lg-8 col-md-6 mb-3 p-0">';
			page_links($globals['num_res'], $globals['cur_page'], $globals['reslen']);
		echo'
		</div>
	</div>

	<div id="progress_bar" style="display:none;">
		<br />
		<center>
			<font id="progress_txt" size="4">'.__('Please wait, Action in Progress.').'</font>
		</center>
		<div class="my-2" align="center">
			<div class="progress w-50">
				<div class="progress-bar bg-primary progress-bar-striped progress-bar-animated w-100">
				</div>
			</div>
		</div>
		<center>
			'.__('You will be notified once the Action is Completed.').'
		</center>
	</div>';
}
	echo 
	'<div class="text-center my-4">
		<a href="'.$globals['ind'].'act=adddnsplan" class="link_btn">'.__('Add DNS Plan').'</a>
	</div>
</div>
';
softfooter();

}
?>