<?php
	header('Content-type: text/xml');

	include ("../../Utilidades/parse_vars.php");
	include ('../../Utilidades/db.php');
	include ('../../Utilidades/FuncionesNegocio.php');


		dbquery("INSERT
					INTO
						DetalleBultoCotizacion(
							det_bul_cot_alto,
							det_bul_cot_ancho,
							det_bul_cot_largo,
							det_bul_cot_kg,
							det_bul_cot_fecha,
							det_bul_cot_usu_id
						)
						VALUES(
							'$Hight',
							'$Width',
							'$Length',
							'$Weight',
							'$Fecha',
							'$IdUsuario'
						)");

		$Sql = dbquery("SELECT * FROM DetalleBultoCotizacion WHERE det_bul_cot_fecha='$Fecha' AND det_bul_cot_usu_id='$IdUsuario' AND det_bul_cot_cot_id IS NULL ORDER BY det_bul_cot_id DESC");
		$Array=mysql_fetch_array($Sql);

		$SCBM=0;
		$SCBM_L=0;
		$SCBM_AN=0;
		$SCBM_AL=0;
		$SKG=0;
		$KGVOL=0;


		$SqlS = dbquery("SELECT det_bul_cot_largo,det_bul_cot_ancho,det_bul_cot_alto,det_bul_cot_kg  FROM DetalleBultoCotizacion WHERE det_bul_cot_fecha='$Fecha' AND det_bul_cot_usu_id='$IdUsuario' AND det_bul_cot_cot_id IS NULL");
		while($ArrayS = mysql_fetch_array($SqlS))
		{

			$SCBM+=$ArrayS[det_bul_cot_largo] * $ArrayS[det_bul_cot_ancho] * $ArrayS[det_bul_cot_alto];
			$SKG+= $ArrayS[det_bul_cot_kg];
		}


// 		$KGVOL = $SCBM*333;


		$SCBM=number_format($SCBM,2);
		$KGVOL=number_format($KGVOL,2);
		$SKG=number_format($SKG,2);

		$dom = new DOMDocument();

		$data = $dom->createElement('data');
		$dom->appendChild($data);

		$OK = $dom->createElement('Okeey');
		$OKText = $dom->createTextNode('Bulto Ingresado');
		$OK->appendChild($OKText);


		$IdBulto = $dom->createElement('IdBulto');
		$IdBultoText = $dom->createTextNode($Array[det_bul_cot_id]);
		$IdBulto->appendChild($IdBultoText);

		$Alto = $dom->createElement('Alto');
		$AltoText = $dom->createTextNode($Array[det_bul_cot_alto]);
		$Alto->appendChild($AltoText);


		$Ancho = $dom->createElement('Ancho');
		$AnchoText = $dom->createTextNode($Array[det_bul_cot_ancho]);
		$Ancho->appendChild($AnchoText);


		$Largo = $dom->createElement('Largo');
		$LargoText = $dom->createTextNode($Array[det_bul_cot_largo]);
		$Largo->appendChild($LargoText);


		$Peso = $dom->createElement('Peso');
		$PesoText = $dom->createTextNode($Array[det_bul_cot_kg]);
		$Peso->appendChild($PesoText);

		$CBM = $dom->createElement('CBM');
		$CBMText = $dom->createTextNode($SCBM);
		$CBM->appendChild($CBMText);

		$SPeso = $dom->createElement('SumaPeso');
		$SPesoText = $dom->createTextNode($SKG);
		$SPeso->appendChild($SPesoText);

/*
		$KVol = $dom->createElement('KiloVol');
		$KVolText = $dom->createTextNode($KGVOL);
		$KVol->appendChild($KVolText);
*/



		$data->appendChild($OK);
		$data->appendChild($IdBulto);
		$data->appendChild($Alto);
		$data->appendChild($Ancho);
		$data->appendChild($Largo);
		$data->appendChild($Peso);
		$data->appendChild($CBM);
		$data->appendChild($SPeso);
// 		$data->appendChild($KVol);

		$xmlString = $dom->saveXML();

		echo $xmlString;

?>