//this is definitive, deleteUnitComponentByUnitIdAndPartId is not but works in most (if not all) cases
			deleteUnitComponentById($_GET['component_id']);
		} else {
			deleteUnitComponentByUnitIdAndPartId($_GET['unit'],$_GET['part_id']);
		}
		break;
	//may need a case here for each specific product line
	case "update_component_ref_figure_id":
		updateUnitRefFigureId($_GET['pl'],$_GET['unit'],$_GET['ref_figure_id']);
		break;
	case "add_part_to_unit":
		addComponentToUnit($_GET['unit'],$_GET['part_id']);
		break;
	case "add_unit":
		//could test for required fields here
		$new_unit_id = createUnit($_GET['pl'],$_GET['name'],$_GET['description'],$_GET['make_id'],$_GET['ref_figure_id']);
		if ($_GET['pl'] == 8) {
			header("Location: part_finder.php?pl=".$_GET['pl']."&ring_gears_unit_id=".$new_unit_id);
		} else {
			header("Location: part_finder.php?pl=".$_GET['pl']."&unit=".$new_unit_id."&make=".$_GET['make_id']);
		}
		exit(0);
		break;
	case "delete_unit":
		$new_unit_id = deleteUnit($_GET['unit'],$_GET['pl']);
		if ($_GET['pl'] == 8) {
			header("Location: part_finder.php?pl=".$_GET['pl']);
			exit(0);
		}
		break;
	case "edit_unit_name":
function insertPtsComponent ($get) {
	$dataconn = new DataConn("");
	
	//creat the phantom unit name
	$unit_name = $get["driveline_series"]." x ".$get["steel_driveshaft_tube_od"];
	
	//lookup the phantom unit (and create it if it doesn't exist)
	$sql = "
		SELECT id 
		FROM units 
		WHERE name = '".mysql_real_escape_string($unit_name)."' 
			AND product_line = 9";
	$arr_data = $dataconn->f_ReturnArrayAssoc_TF($sql);
	if (is_array($arr_data)) {
		$unit_id = $arr_data["units.id"][0];
	} else {
		$unit_id = createUnit("9",$unit_name,"",0,0);
	}
	
	//creat the new entry in the unit components table
	$sql = "
		INSERT INTO unit_components 
			(unit_id, component_type, assembly_or_part_id, display_order, 
			indent, code_on_ref_figure, notes, pts_series, driveline_series, 
			steel_driveshaft_tube_od, torque_fuse_options, description) 
		VALUES (
			'".mysql_real_escape_string($unit_id)."', 
			'0', 
			'".mysql_real_escape_string($get["part_id"])."', 
			'".mysql_real_escape_string($get["display_order"])."', 
			'".mysql_real_escape_string($get["indent"])."', 
			'".mysql_real_escape_string($get["code_on_ref_figure"])."', 
			'".mysql_real_escape_string($get["notes"])."', 
			'".mysql_real_escape_string($get["pts_series"])."', 
			'".mysql_real_escape_string($get["driveline_series"])."', 
			'".mysql_real_escape_string($get["steel_driveshaft_tube_od"])."', 
			'".mysql_real_escape_string($get["torque_fuse_options"])."', 
			'".mysql_real_escape_string($get["description"])."' 
		)";
	return $dataconn->f_ExecuteSqlInsertID($sql);
}
Esempio n. 3
0
    include_once 'libs/unit.php';
    echo json_encode(getUnit($id, $channelId));
});
/**
 * @api {POST} /unit	 	Create a Unit
 * @apiName createUnit
 * @apiGroup Unit
 *
 *
 * @apiSuccess {Unit} Unit 	Unit
 * @apiPermission Author of the Unit
 *
 */
$app->post('/unit', function () use($app) {
    include_once 'libs/unit.php';
    echo json_encode(createUnit($app->request->getBody()));
});
/**
 * @api {PUT} /unit	 	Update a Unit
 * @apiName updateUnit
 * @apiGroup Unit
 *
 *
 * @apiSuccess {Unit} Unit 	Unit
 * @apiPermission Author of the Unit
 * @apiDescription Here you can describe the function.
 *
 */
$app->put('/unit', function () use($app) {
    include_once 'libs/unit.php';
    updateUnit($app->request->getBody());