<? include("../../../header_subnivel3.php");
include("../../../comun/conexion3.php");?>

<link rel="stylesheet" type="text/css" href="../../../style.css" media="all" />
<div align="justify" style="line-height:18px;margin-top:-44px; position:absolute;width: 960px; height:100%;background:url(../../../images/mundo.jpg) ">


<?php 
   	$txtsocialreason= strtoupper($_POST['txtsocialreason']); 

	$txtrfc= strtoupper($_POST['txtrfc']); 

	$txtcp= strtoupper($_POST['txtcp']); 

	$txtcity= strtoupper($_POST['txtcity']); 

	$txtdirection= strtoupper($_POST['txtdirection']); 

	$txtcontact= strtoupper($_POST['txtcontact']); 

	$txttel1= strtoupper($_POST['txttel1']); 

	$txttel2= strtoupper($_POST['txttel2']); 

	$txttel3= strtoupper($_POST['txttel3']); 

	$txtfax = strtoupper($_POST['txtfax']); 

	$txtemail= strtoupper($_POST['txtemail']); 

	$txtobservations= strtoupper($_POST['txtobservations']); 

	$txtnickname= strtoupper($_POST['txtnickname']); 

	$txtinvoicename= strtoupper($_POST['txtinvoicename']); 

	$txtinvoiceaddress= strtoupper($_POST['txtinvoiceaddress']); 

	$txtinvoicecity= strtoupper($_POST['txtinvoicecity']); 

	$txtinvoicezip= strtoupper($_POST['txtinvoicezip']); 

	

	$txtamsfilenumber= strtoupper($_POST['txtamsfilenumber']); 

	$txtinvoicerevisiondate= strtoupper($_POST['txtinvoicerevisiondate']); 

	$txtinvoiceoceanfreights= strtoupper($_POST['txtinvoiceoceanfreights']); 

	$txtcreditforoceanfreights= strtoupper($_POST['txtcreditforoceanfreights']); 

	$txtcreditforoceanfreightsdays= strtoupper($_POST['txtcreditforoceanfreightsdays']); 

	$txtcreditforoceanfreightsfromdate= strtoupper($_POST['txtcreditforoceanfreightsfromdate']); 

	$txtcreditforlocalcharges= strtoupper($_POST['txtcreditforlocalcharges']); 

	$txtcreditforlocalchargesdays= strtoupper($_POST['txtcreditforlocalchargesdays']); 

	$txtcreditforlocalchargesfromdate= strtoupper($_POST['txtcreditforlocalchargesfromdate']); 



$txtcalle_invoice=strtoupper($_POST['txtcalle_invoice']);

$txtno_ext_invoice=strtoupper($_POST['txtno_ext_invoice']);

$txtno_int_invoice=strtoupper($_POST['txtno_int_invoice']);

$txtcolonia_invoice=strtoupper($_POST['txtcolonia_invoice']);

$txtmunicipio_invoice=strtoupper($_POST['txtmunicipio_invoice']);

$txtestado_invoice=strtoupper($_POST['txtestado_invoice']);

$txtlocalidad_invoice=strtoupper($_POST['txtlocalidad_invoice']);

$txtpais_invoice=strtoupper($_POST['txtpais_invoice']);

		



	include("../../../comun/conexion3.php"); 

//	$result=mysqli_query("select * from customerexpint where nickname like '$txtnickname' and rfc like '$txtrfc' and cp like '$txtcp' and city like '$txtcity' and direction like '$txtdirection' and contact like '$txtcontact' and tel1 like '$txttel1' and tel2 like '$txttel2' and tel3 like '$txttel3' and fax like '$txtfax' and email like '$txtemail' and observations like '$txtobservations' and  nickname like '$txtnickname'");

	$result=mysqli_query("select * from customerexpint where  nickname like '$txtnickname'");

	

	if ( mysqli_fetch_array($result)){

		echo("	<form name=\"form2\" method=\"post\" action=\"customerexpint.php\">");

		echo("  <div align=\"center\"> ");

echo "<P></P>";

		echo("<br>FAILURE THE DATA NICK NAME CAN NOT BE DUPLICATED, PLEASE TRY AGAIN<br><br>");

		echo("     <input type=\"submit\" name=\"Submit\" value=\"BACK\">");

		echo("  </div>");

		echo(" </form>");

		}

	else

		{



	$result = mysqli_query("SELECT * FROM fcustomerexpint"); 

	$row = mysqli_fetch_array($result);

	$id=$row["folio"];        

   	mysqli_query("update fcustomerexpint set folio=folio*1+1");

 $numdf=$id*1+100000*1;





$cadena=$numdf; 

$txtdatos1= substr($cadena,0,1);

$txtdatos2= substr($cadena,1,1);

$txtdatos3= substr($cadena,2,1);

$txtdatos4= substr($cadena,3,1);

$txtdatos5= substr($cadena,4,1);

$txtdatos6= substr($cadena,5,1);

//Devuelve "H"

$txtvalor1 = $txtdatos1*7;

$txtvalor2 = $txtdatos2*6;

$txtvalor3 = $txtdatos3*5;

$txtvalor4 = $txtdatos4*4;

$txtvalor5 = $txtdatos5*3;

$txtvalor6 = $txtdatos6*2;

$txttotalvalor= txtvalor1*1 + txtvalor2*1 + txtvalor3*1 + txtvalor4*1 + txtvalor5*1 + txtvalor6*1;

$txttotalvalor= $txtvalor1*1 + $txtvalor2*1 + $txtvalor3*1 + $txtvalor4*1 + $txtvalor5*1 + $txtvalor6*1;

$txtresiduo= $txttotalvalor % 7 ;
$txtreferencia = 7*1 - $txtresiduo*1;

$txtresultado = $txtdatos1 . $txtdatos2 . $txtdatos3 . $txtdatos4 . $txtdatos5 . $txtdatos6 . "" . $txtreferencia;

mysqli_query("INSERT INTO customerexpint (socialreason,rfc,cp,city,direction,contact,tel1,tel2,tel3,fax,email,observations,nickname,id,invoicename,invoicecity,invoiceaddress,invoicezip,amsfilenumber ,invoicerevisiondate,invoiceoceanfreights,creditforoceanfreights,creditforoceanfreightsdays,creditforoceanfreightsfromdate,creditforlocalcharges,creditforlocalchargesdays,creditforlocalchargesfromdate,referencia_b,calle_invoice,no_ext_invoice,no_int_invoice,colonia_invoice,municipio_invoice,estado_invoice,localidad_invoice,pais_invoice) Values ('$txtsocialreason','$txtrfc','$txtcp','$txtcity','$txtdirection','$txtcontact','$txttel1','$txttel2','$txttel3','$txtfax','$txtemail','$txtobservations','$txtnickname','$id','$txtinvoicename','$txtinvoicecity','$txtinvoiceaddress','$txtinvoicezip','$txtamsfilenumber','$txtinvoicerevisiondate','$txtinvoiceoceanfreights','$txtcreditforoceanfreights','$txtcreditforoceanfreightsdays','$txtcreditforoceanfreightsfromdate','$txtcreditforlocalcharges','$txtcreditforlocalchargesdays',	'$txtcreditforlocalchargesfromdate','$txtresultado','$txtcalle_invoice','$txtno_ext_invoice','$txtno_int_invoice','$txtcolonia_invoice','$txtmunicipio_invoice','$txtestado_invoice','$txtlocalidad_invoice','$txtpais_invoice')");


$enviacorreoo="\"" . $_SESSION['name'] . "\" <" . $_SESSION['emailu'] . ">";



$enviacorreoo=strtolower($enviacorreoo);

$email=$enviacorreoo; //enviado de

$tomail= "fabiola.mendoza@interteam.com.mx";

$recibe=$tomail; //enviar a

$email=$enviacorreoo; //enviado de

$recibe=$tomail; //enviar a

$subject="Cliente agregado";

$dir = '';

$boundary = "-----=" . md5( uniqid ( rand() ) ); 

$mailheader= "MIME-Version: 1.0\n"; 

$mailheader .= "Content-Type: multipart/alternative; boundary=\"$boundary\""; 

$mailheader  = "Return-Path: " . strtolower($_SESSION['emailu']) ." \nX-Sender: " . strtolower($_SESSION['emailu']) . "\nFrom: $email\nReply-To: $email \nX-MAILER: Program  " . phpversion() . "\nX-MSMail-Priority: High\nX-MimeOLE: Produced By php on b21system.com  \n" ;

$mailtext .= "\r\n";

 $mailtext .=  "Estimados Srs(a)." .  "\n\n";

$mailtext .=  "El cliente:  $txtsocialreason   fue agregado \n"; 

$mailtext .=  "Por: ". $_SESSION['name']  .  "\n\n";

$mailtext .=  "INTERTEAM, S.A. DE C.V.". "\n";

mail(strtolower($recibe . " , " . $_SESSION['emailu']),$subject,$mailtext,$mailheader);


	echo("	<form name=\"form2\" method=\"post\" action=\"customerexpint.php\">");

		echo("  <div align=\"center\"> ");

echo "<P></P>";

		echo("<br>CUSTOMER ADDED<br><br>");

		echo("     <input type=\"submit\" name=\"Submit\" value=\"BACK\">");

		echo("  </div>");

		echo(" </form>");

 // header("Location: customerexpint.php"); 

}

?> 

</div>