<?php require_once("../../classes/DBConnection.php"); $DB = new DBConnection();

/*echo "<br />Loading Items CC, Fueltypes, ... Started";
$res = $DB->execute("select 
	id,
	direction2,
	vin,
	va_capacity,
	new_capacity,
	atm_capacity,
	capacity 
from vinprefixes group by direction2 order by id ASC, vin DESC, va_capacity DESC, new_capacity DESC, atm_capacity DESC, capacity DESC");

if(!is_null($res)){
	$res = $res[0];
	while($W = $DB->nextRow($res)){
		$id = $W['id'];
		$vin = $W['vin'];
		$direction2 = $W['direction2'];

		$va_cc = trim($W['va_capacity']);
		$new_cc = trim($W['new_capacity']);
		$atm_cc = trim($W['atm_capacity']);
		$cc = trim($W['capacity']);

		//set the holepeg strings
		$holepeg = "fullvin = '{$vin}'";
		if($va_cc != ''){ $holepeg .= ", capacityatm = '{$va_cc}'"; }
		else if($new_cc != ''){ $holepeg .= ", capacityatm = '{$new_cc}'"; }
		else if($atm_cc != ''){ $holepeg .= ", capacityatm = '{$atm_cc}'"; }
		else if($cc != ''){ $holepeg .= ", capacityatm = '{$cc}'"; }

		//get the category too
		$R = $DB->execute("select category from vicdescriptions where direction2 = '{$direction2}' and category!=''");
		if(!is_null($R)){
			$R = $R[0];
			$Y = $DB->nextRow($R);
			$category = $Y['category'];

			//set the category holepeg string
			$holepeg .= ", category = '{$category}'";
		}

		//NOW GO
		if($DB->simpleQuery("update us_vinprefixes_this set {$holepeg} where direction2='{$direction2}'")){
			echo "<br />Done at #{$id}";
		}else{
			echo "<br /><span style='color:#F00'>Error at #{$id}</span>";
		}
	}
	echo "<br />ENDED<hr />";
}else{ "<span style='color:#F00'>Error in Commencement</span><br />"; }*/


/*echo "<br />Loading Pieces CC, Fueltypes, ... Started";
$res = $DB->execute("select * from samp_vinprefixes");

if(!is_null($res)){
	$res = $res[0];
	while($svp = $DB->nextRow($res)){
		//set the holepeg strings
		$holepeg = "";
		if($svp['new_capacity'] > 0){ $holepeg .= ", atm_capacity = '{$svp['new_capacity']}'"; }
		else if($svp['va_capacity'] > 0){ $holepeg .= ", atm_capacity = '{$svp['va_capacity']}'"; }
		else if($svp['atm_capacity'] > 0){ $holepeg .= ", atm_capacity = '{$svp['atm_capacity']}'"; }
		else if($svp['capacity'] > 0){ $holepeg .= ", atm_capacity = '{$svp['capacity']}'"; }
		else if($svp['dt_capacity'] > 0){ $holepeg .= ", atm_capacity = '{$svp['dt_capacity']}'"; }
		else if($svp['ed_capacity'] > 0){ $holepeg .= ", atm_capacity = '{$svp['ed_capacity']}'"; }

		if($svp['va_sseating'] >0){ $holepeg .= ", atm_seats = '{$svp['va_sseating']}'"; }
		else if($svp['atm_sseating'] >0){ $holepeg .= ", atm_seats = '{$svp['atm_sseating']}'"; }
		else if($svp['dt_sseating'] >0){ $holepeg .= ", atm_seats = '{$svp['dt_sseating']}'"; }
		else if($svp['ed_sseating'] >0){ $holepeg .= ", atm_seats = '{$svp['ed_sseating']}'"; }

		$holepeg =  substr($holepeg, 2);

		//NOW GO
		if($DB->simpleQuery("update us_models_i set {$holepeg} where prefixfam='{$svp['prefixfam']}'")){
			echo "<br />Done at #{$svp['id']}";
		}else{
			echo "<br /><span style='color:#F00'>Error at #{$svp['id']}</span>";
		}
	}
	echo "<br />ENDED<hr />";
}else{ "<span style='color:#F00'>Error in Commencement</span><br />"; }*/


echo "<br />Loading Pieces CC, Fueltypes, ... Started";
$res = $DB->execute("select * from popprefixes");

if(!is_null($res)){
	$res = $res[0];
	while($svp = $DB->nextRow($res)){
		//set the holepeg strings
		$holepeg = "";
		if($svp['capacity'] > 0){ $holepeg .= ", oln_capacity = '{$svp['capacity']}'"; }
		if($svp['fueltype'] !=''){ $holepeg .= ", oln_fueltype = '{$svp['fueltype']}'"; }
		if($svp['seats'] >0){ $holepeg .= ", oln_seats = '{$svp['seats']}'"; }
		
		if($holepeg!=''){
			$holepeg =  substr($holepeg, 2);
			//NOW GO
			if($DB->simpleQuery("update us_models_i set {$holepeg} where prefixfam='{$svp['prefixfam']}'")){
				echo "update us_models_i set {$holepeg} where prefixfam='{$svp['prefixfam']}'<br />";
				echo "<br />Done at #{$svp['id']}";
			}else{
				echo "<br /><span style='color:#F00'>Error at #{$svp['id']}</span>";
			}
		}else{
			echo "<br />Empty at #{$svp['id']}";
		}
	}
	echo "<br />ENDED<hr />";
}else{ "<span style='color:#F00'>Error in Commencement</span><br />"; }

?>