Código PHP:
<?php
error_reporting(E_ALL & ~(E_STRICT|E_NOTICE));
$conexion=mysql_connect("localhost","ROOT","");
mysql_select_db("aaa",$conexion);
/**/
$seleccion = "select * from ticket";
$risultato = mysql_query($seleccion, $conexion);
$valor = mysql_fetch_array($risultato);
$transferencia = array($valor['TRANS']);
if($transferencia = $_POST ['TRANS'])
{
$RegFedCon = $_POST['RFC'];
$DATES = $_POST['FECHA'];
$TRANSACCION = $_POST['TRANS'];
$SUC = $_POST['sucursal'];
$sql= "update ticket set RFC ='".$RegFedCon."', FECHA ='".$DATES."',SUCURSAL='".$SUC."' where TRANS='".$TRANSACCION."'";
$result = mysql_query($sql,$conexion);
if($result)
{
if($resultado = mysql_query("select cliente.CLAVE, cliente.RFC, tickets.FECHA, tickets.TRANS, tickets.TOTAL, tickets.SUCURSAL from DATOSFISCALES cliente, ticket tickets where cliente.RFC=tickets.RFC and tickets.TRANS='".$_POST['TRANS']."'",$conexion))
{
while ($fila = mysql_fetch_array($resultado))
{
$fecha = date("y-m-d");
$file = 'files/'.$fila['TRANS'].'_'.$fecha.'.mod';
$fp = fopen($file,"w");
fwrite($fp, '<?xml version="1.0" standalone="yes"?> <DATAPACKET Version="2.0"><METADATA><FIELDS><FIELD attrname="CVE_CLPV" fieldtype="string" WIDTH="10"/><FIELD attrname="NUM_ALMA" fieldtype="i4"/><FIELD attrname="CVE_PEDI" fieldtype="string" WIDTH="20"/><FIELD attrname="ESQUEMA" fieldtype="i4"/><FIELD attrname="DES_TOT" fieldtype="r8"/><FIELD attrname="DES_FIN" fieldtype="r8"/><FIELD attrname="CVE_VEND" fieldtype="string" WIDTH="5"/><FIELD attrname="COM_TOT" fieldtype="r8"/><FIELD attrname="NUM_MONED" fieldtype="i4"/><FIELD attrname="TIPCAMB" fieldtype="r8"/><FIELD attrname="STR_OBS" fieldtype="string" WIDTH="255"/><FIELD attrname="ENTREGA" fieldtype="string" WIDTH="25"/><FIELD attrname="SU_REFER" fieldtype="string" WIDTH="20"/><FIELD attrname="TOT_IND" fieldtype="r8"/><FIELD attrname="MODULO" fieldtype="string" WIDTH="4"/><FIELD attrname="CONDICION" fieldtype="string" WIDTH="25"/><FIELD attrname="dtfield" fieldtype="nested"><FIELDS><FIELD attrname="CANT" fieldtype="r8"/><FIELD attrname="CVE_ART" fieldtype="string" WIDTH="20"/><FIELD attrname="DESC1" fieldtype="r8"/><FIELD attrname="DESC2" fieldtype="r8"/><FIELD attrname="DESC3" fieldtype="r8"/><FIELD attrname="IMPU1" fieldtype="r8"/><FIELD attrname="IMPU2" fieldtype="r8"/><FIELD attrname="IMPU3" fieldtype="r8"/><FIELD attrname="IMPU4" fieldtype="r8"/><FIELD attrname="COMI" fieldtype="r8"/><FIELD attrname="PREC" fieldtype="r8"/><FIELD attrname="NUM_ALM" fieldtype="i4"/><FIELD attrname="STR_OBS" fieldtype="string" WIDTH="255"/><FIELD attrname="REG_GPOPROD" fieldtype="i4"/><FIELD attrname="REG_KITPROD" fieldtype="i4"/><FIELD attrname="NUM_REG" fieldtype="i4"/><FIELD attrname="COSTO" fieldtype="r8"/><FIELD attrname="TIPO_PROD" fieldtype="string" WIDTH="1"/><FIELD attrname="TIPO_ELEM" fieldtype="string" WIDTH="1"/><FIELD attrname="MINDIRECTO" fieldtype="r8"/><FIELD attrname="TIP_CAM" fieldtype="r8"/><FIELD attrname="FACT_CONV" fieldtype="r8"/><FIELD attrname="UNI_VENTA" fieldtype="string" WIDTH="10"/><FIELD attrname="IMP1APLA" fieldtype="i4"/><FIELD attrname="IMP2APLA" fieldtype="i4"/><FIELD attrname="IMP3APLA" fieldtype="i4"/><FIELD attrname="IMP4APLA" fieldtype="i4"/><FIELD attrname="PREC_SINREDO" fieldtype="r8"/><FIELD attrname="COST_SINREDO" fieldtype="r8"/><FIELD attrname="LINK_FIELD" fieldtype="ui4" hidden="true" linkfield="true"/></FIELDS><PARAMS CHANGE_LOG="1 0 4"/></FIELD></FIELDS><PARAMS CHANGE_LOG="1 0 4 1 1 64"/></METADATA><ROWDATA><ROW RowState="4" CVE_CLPV="w'.$fila['CLAVE'].'" NUM_ALMA="1" CVE_PEDI="" ESQUEMA="1" DES_TOT="0" DES_FIN="0" CVE_VEND="" COM_TOT="0" NUM_MONED="1" TIPCAMB="1" STR_OBS="" MODULO="FACT" CONDICION="Contado"><dtfield><ROWdtfield RowState="4" CANT="1" CVE_ART="2" DESC1="0" DESC2="0" DESC3="0" IMPU1="0" IMPU2="0" IMPU3="0" IMPU4="16" COMI="0" PREC="'.$fila['TOTAL'].'" NUM_ALM="1" STR_OBS="Ticket: '.$fila['TRANS'].'" REG_GPOPROD="0" COSTO="0" TIPO_PROD="S" TIPO_ELEM="N" TIP_CAM="1" UNI_VENTA="No aplica" IMP1APLA="0" IMP2APLA="0" IMP3APLA="0" IMP4APLA="0" PREC_SINREDO="'.$fila['TOTAL'].'" COST_SINREDO="0" LINK_FIELD="1"/></dtfield></ROW></ROWDATA></DATAPACKET>');
fclose($fp);
echo '<script>alert(" PROCESO EXITOSO ");parent.location = "index.html"</script>';
if($_POST['SUCURSAL']= 'C'){
$_para ="[email protected]";
} elseif($_POST['SUCURSAL']='L'){
$_para ="[email protected]";
}
$_asunto= "Factura Cliente W".$fila['CLAVE'].__SUC.$SUC['SUCURSAL']." ";
$_mensaje= "El cliente w".$fila['CLAVE']." ha solicitado la siguiente : ".$file." ";
$_de= "Sistema de Facturaci0n".$SUC['SUCURSAL']." ";
$_headers="mime-version:1.0;\r\n";
$_headers.= "contet-tipe: text/html\r\n carset =iso-8859-1\r\n";
$_headers.="from:". $_de."\r\n";
$_headers.="to : ".$_para." \r\n; subjet : ".$_asunto."\r\n\ ";
if (mail($_para,$_asunto,$_mensaje,$_headers)){
echo "enviado correctamente";
} else {
echo "fallo en el envio";
}
}
} }
}
$sql ("DELETE FROM ticket WHERE TRANS == .$_POST['TRANS'].")"'";
echo"<h1><center>HA OCURRIDO UN ERROR FAVOR DE VERIFICAR LOS DATOS </center></h1>";
@mysql_close($conexion);
?>