<?php
date_default_timezone_set('America/Argentina/Buenos_Aires');
global $w_hora;
global $cantidad;

$w_hora = date("Y-m-d H:i:s"); 
echo "\n\n Carga CUITs nuevos en Mantenimiento de LED\n\n - Inicio del Proceso: " . $w_hora . "\n";  
$cantidad = 0;

$dirarch  = '/var/www/html/fidelitas/public/documentos/temp/ainformix/nuevos_led.txt';
if (file_exists($dirarch))
{
$connection = new PDO('dblib:host=192.168.10.15;dbname=Fidelitas;charset=utf8','sa','KraDQlo');
$contents = file_get_contents($dirarch); 
$contents = trim($contents);
$cuits = explode("\n", $contents);

foreach ($cuits as $key => $cuit) {
	$cuit = str_replace(";", "",$cuit);
	$stmt  = $connection->prepare("EXEC cendeu_a_informix_insertar '$cuit'");
	$stmt->setFetchMode(PDO::FETCH_OBJ); 
	if ($stmt) {
		 $stmt->execute();
		 }
	$cantidad += 1; 
	}
}

echo "\n\n - Cuits cargados: " . $cantidad; 
$w_hora = date("Y-m-d H:i:s"); 
echo "\n\n - Fin del Proceso: " . $w_hora; 

?>