<?php

/*Import data into specific Template*/
global $wpdb;


	$CyberSecurityPlanIncludePoints = $wpdb->get_results( "SELECT * FROM `".$wpdb->prefix."geek_pricing_estimator_cybersecurity_plans_point`" );	
	$PpointsTrHtml='';
	$i=1;
 	foreach ($CyberSecurityPlanIncludePoints as $Ppoints ) {

		$cyberplan_idsChkd = explode('|', $Ppoints->cyberplan_ids);
		$CyberPlanID1='';
		$CyberPlanID2='';
		$CyberPlanID3='';

		foreach ($cyberplan_idsChkd as $CyberPlan) {
			if($CyberPlan== 1){
				$CyberPlanID1='checked';
			}

			if($CyberPlan== 2){
				$CyberPlanID2='checked';
			}

			if($CyberPlan== 3){
				$CyberPlanID3='checked';
			}

		}


		$PpointsTrHtml = $PpointsTrHtml.'<tr TrPpointID="'.$Ppoints->id.'">
						<td><span class="dashicons text-danger dashicons-trash EstimateSingledel" DBName="'.$wpdb->prefix.'geek_pricing_estimator_cybersecurity_plans_point" dbID="'.$Ppoints->id.'"></span></td>						
						<th scope="row">'.$Ppoints->pint_txt.'</th>
						<td><input '.$CyberPlanID1.' class="form-control PpointsIncludeInPlanChk" type="checkbox" CyberPlanID="1" name="Ppoint_'.$Ppoints->id.'" value="'.$Ppoints->id.'" ></td>
						<td><input '.$CyberPlanID2.' class="form-control PpointsIncludeInPlanChk" type="checkbox" CyberPlanID="2" name="Ppoint_'.$Ppoints->id.'" value="'.$Ppoints->id.'" ></td>
						<td><input '.$CyberPlanID3.' class="form-control PpointsIncludeInPlanChk" type="checkbox" CyberPlanID="3" name="Ppoint_'.$Ppoints->id.'" value="'.$Ppoints->id.'" ></td>						
						</tr>';
 	}

	
	
	$GetAdonServices = $wpdb->get_results( "SELECT * FROM `".$wpdb->prefix."geek_pricing_estimator_adons`" );	
	$AdonsTrHtml='';
	$i=1;
 	foreach ($GetAdonServices as $adons ) {

		$cyberplan_idsChkd = explode('|', $adons->cyberplan_ids);
		$CyberPlanID1='';
		$CyberPlanID2='';
		$CyberPlanID3='';
		foreach ($cyberplan_idsChkd as $CyberPlan) {
			if($CyberPlan== 1){
				$CyberPlanID1='checked';
			}

			if($CyberPlan== 2){
				$CyberPlanID2='checked';
			}

			if($CyberPlan== 3){
				$CyberPlanID3='checked';
			}

		}



		$AdonsTrHtml = $AdonsTrHtml.'<tr TrAdonID="'.$adons->id.'">
						<th scope="row">'.$i++.'</th>
						<th scope="row">'.$adons->name.'</th>
						<td><input '.$CyberPlanID1.' class="form-control AdonsIncludeInPlanChk" type="checkbox" CyberPlanID="1" name="AdOnID_'.$adons->id.'" value="'.$adons->id.'" ></td>
						<td><input '.$CyberPlanID2.' class="form-control AdonsIncludeInPlanChk" type="checkbox" CyberPlanID="2" name="AdOnID_'.$adons->id.'" value="'.$adons->id.'" ></td>
						<td><input '.$CyberPlanID3.' class="form-control AdonsIncludeInPlanChk" type="checkbox" CyberPlanID="3" name="AdOnID_'.$adons->id.'" value="'.$adons->id.'" ></td>						
						</tr>';
 	}

?>

<style>
	input.AdonsIncludeInPlanChk, input.PpointsIncludeInPlanChk, input.NewPpointsIncludeInPlanChk{
		width:25px;
		height:25px;
	}
	input[type=checkbox]:focus{
		outline:none;
	}
	input[type=checkbox]:checked::before{
		height:2.4rem !important;
		width:2.6rem !important;
	}
</style>


<div id="EstimateajaxLoder"><img src="<?php echo plugins_url(); ?>/geek-price-estimator/images/loder.gif" /></div>
	
	<div class="container">

		<div class="row">
			<div class="col-md-12">
				<h1>Included Services</h1>

				<table class="table table-bordered">
					<thead class="bg-primary">
						<tr>
						<th scope="col"># </th>
						<th scope="col" style="width:600px;">Services </th>
						<th scope="col">Bronze</th>
						<th scope="col">Silver</th>
						<th scope="col">Gold</th>
						</tr>
					</thead>
					<tbody id="ServicesPointsRowCtr">
						<?php echo $PpointsTrHtml; ?>
					</tbody>
				</table>
				<span class="btn btn-primary pull-right AddNewServicesPointcyberPlan" >+ Add New</span> 	
				<span class="btn btn-success pull-right SubmitNewServicesTrriger" >Submit New Services</span>
			</div>
		</div>
	
	
<hr />
		<div class="row">
			<div class="col-md-12">
				<h1>Adons</h1>

				<table class="table table-bordered">
					<thead class="bg-primary">
						<tr>
						<th scope="col">#</th>
						<th scope="col" style="width:600px;">Add-Ons</th>
						<th scope="col">Bronze</th>
						<th scope="col">Silver</th>
						<th scope="col">Gold</th>
						</tr>
					</thead>
					<tbody>
						<?php echo $AdonsTrHtml;?>
					</tbody>
				</table>

			</div>
		</div>

</div>
