public function addPart ($component_id, $part_quantity, $product_line, $component=0) {
		//echo "$component_id, $part_quantity, $product_line, $component";
		if (is_numeric($component_id) && is_numeric($part_quantity) && is_numeric($product_line) && is_numeric($component)) {
			if ($component == 0) {
				$part = new Part($component_id);
				$description = $part->description;
				$part_id = $part->id;
			} elseif ($component == 1) {
				$component = new Component($component_id);
				$description = $component->tc_description;
				$part_id = $component->assembly_or_part_id;
			}
			$sql = "
				INSERT INTO order_parts (
					order_id, part_id, quantity, product_line, description
				) VALUES (
					{$this->order_id},
					{$part_id},
					{$part_quantity},
					{$product_line},
					'{$description}'
				)/* Order->addPart */";
			$this->dataconn->f_ExecuteSql($sql);
			$this->buildOrderStack();
		}
	}
Esempio n. 2
0
<?
require_once "clsDataConn.php";

$dataconn = new DataConn("");

	$sqlTemp = "SELECT `make` FROM `makes` WHERE 1";
	$arr_data = $dataconn->f_ReturnArrayAssoc_TF($sqlTemp);
	if (is_array($arr_data["makes.make"])) {
		var_dump($arr_data);	
	} else {
		echo "not an array";
	}
?>
function moveAssembly ($unit_id,$unit_component_id,$direction) {
	$dataconn = new DataConn("");
	//get the assemblies in the unit_components table in order
	$sql = "
		SELECT id,assembly_or_part_id,display_order 
		FROM unit_components 
		WHERE unit_id = '".mysql_real_escape_string($unit_id)."' 
			AND component_type = 1 
		ORDER BY display_order";
	$arr_data = $dataconn->f_ReturnArrayAssoc_TF($sql);
	if (!is_array($arr_data)) {
		return -1;
	}
	
	//find the ordinal of the assembly we are moving
	$int_num_assemblies = count($arr_data["unit_components.id"])-1;
	echo "int_num_assemblies: _".$int_num_assemblies."_<BR>\n";
	for ($x=0;$x<=$int_num_assemblies;$x++) {
		echo "x: _".$x."_<BR>\n";
		echo "x: _".$arr_data["unit_components.id"][$x]."_ and _".$unit_component_id."_<BR>\n";
		if ($arr_data["unit_components.id"][$x] == $unit_component_id) {
			$position_current = $x;
			break;//terminate the for loop
		}
	}
	
	//terminate if moving up and its already first or vice versa
	if ( ($position_current == 0 && $direction == "up") || ($position_current == $int_num_assemblies && $direction == "down") ) {
		return -1;
	}
	
	//swap the two items
	if ($direction == "up") {
		$sql = "
			UPDATE unit_components SET 
				display_order = '".mysql_real_escape_string($arr_data["unit_components.display_order"][$x-1])."' 
			WHERE id = '".mysql_real_escape_string($arr_data["unit_components.id"][$x])."'";
		$ignore_return = $dataconn->f_ExecuteSql($sql);
		$sql = "
			UPDATE unit_components SET 
				display_order = '".mysql_real_escape_string($arr_data["unit_components.display_order"][$x])."' 
			WHERE id = '".mysql_real_escape_string($arr_data["unit_components.id"][$x-1])."'";
		$ignore_return = $dataconn->f_ExecuteSql($sql);
	} elseif ($direction == "down") {
		$sql = "
			UPDATE unit_components SET 
				display_order = '".mysql_real_escape_string($arr_data["unit_components.display_order"][$x+1])."' 
			WHERE id = '".mysql_real_escape_string($arr_data["unit_components.id"][$x])."'";
		$ignore_return = $dataconn->f_ExecuteSql($sql);
		$sql = "
			UPDATE unit_components SET 
				display_order = '".mysql_real_escape_string($arr_data["unit_components.display_order"][$x])."' 
			WHERE id = '".mysql_real_escape_string($arr_data["unit_components.id"][$x+1])."'";
		$ignore_return = $dataconn->f_ExecuteSql($sql);
	} else {
		return -1;
	}
	//echo "position_current: _".$position_current."_<BR>\n";
	//exit;
}
function getFeaturedPart ($productLine = 3)
{
	$dataconn = new DataConn("");
	
	$sql = "
		SELECT part_id 
		FROM parts_featured 
		WHERE product_line_id = '".mysql_real_escape_string($productLine)."' 
		ORDER BY part_id";
	$arr_data = $dataconn->f_ReturnArrayAssoc_TF($sql);
	if (is_array($arr_data)) {
		$uBound = count($arr_data["parts_featured.part_id"]) - 1;
		$position_to_return = rand(0,$uBound);
		$Part = new Part($arr_data["parts_featured.part_id"][$position_to_return]);
		return $Part;
	} else {
		return NULL;
	}
}
require_once "../includes/classes/clsUnits.php";
require_once "../includes/classes/clsUnitsBrief.php";
require_once "../includes/generic_functions.php";

*/

$login = new Login();
$logged_in = $login->validate();
if (! $logged_in) {
	header ("Location: index.php");
	exit(0);
}

$message = $_GET["message"];

$dataconn = new DataConn("");

$sql2 = "
	SELECT *
	FROM `parts`
	WHERE `product_line` = '10'";
$arr_data = $dataconn->f_ReturnArrayAssoc_TF($sql2);
if (!is_array($arr_data)) {
	echo "No HPTC parts found";
	exit;
}

$int_ubound = count($arr_data["parts.product_line"])-1;
echo "inserting $int_ubound records<BR><BR>\n";
for ($x=0;$x<=$int_ubound;$x++) {
		$sql = "