<?php
namespace Noahtech\Sistemas\InterjamaBundle\Handler;
use Noahtech\Sistemas\InterjamaBundle\Entity\McPrecarga;
use Noahtech\Sistemas\InterjamaBundle\Utils\Constants;
use Noahtech\Sistemas\InterjamaBundle\Utils\EmailsMessages;
use Noahtech\Sistemas\InterjamaBundle\Utils\Encrypt;
use DateInterval;
use DateTime;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpFoundation\Request;
use Noahtech\Sistemas\InterjamaBundle\Utils\PDF;
use Symfony\Component\HttpFoundation\Response;
use Afip;
use UltraMsg;
use Exception;
date_default_timezone_set('America/Argentina/Buenos_Aires');
class McPrecargaHandler extends BaseHandler {
public function __construct(ContainerInterface $container, EntityManagerInterface $entityManager) {
$this->container = $container;
$this->entityManager = $entityManager;
$this->repository = $entityManager->getRepository(McPrecarga::class);
}
public function search($offset, $limit, $sortField, $sortDirection, $searchParam) {
$lp = $this->repository->search($offset, $limit, $sortField, $sortDirection, $searchParam);
$precargas = $this->toarray($lp->getListado(), 'precarga');
$lp->setListado($precargas);
return $lp;
}
public function searchPrecargasFinalizadas($offset, $limit, $sortField, $sortDirection, $searchParam) {
$lp = $this->repository->searchPrecargasFinalizadas($offset, $limit, $sortField, $sortDirection, $searchParam);
$montoAduana = $this->repository->getTotalMontoAduana($searchParam);
$precargas = $this->toarray($lp->getListado(), 'precarga');
if (COUNT($precargas) > 0 ) {
foreach ($precargas as $key => &$value) {
if ($key == 0) {
$value['montoAduana'] = (COUNT($montoAduana) > 0 ) ? $montoAduana[0] : [];
break;
}
}
}
foreach ($precargas as &$precarga) {
$precarga['tiposTramites'] = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaTipoTramitesHandler")->getByPrecarga((int)$precarga['id']);
$precarga["hoja_ruta"] = false;
// Verificar si el trámite es 'Entrada'
if ($precarga['tramite'] == 'Entrada') {
foreach ($precarga['tiposTramites'] as &$tipo) {
// Comprobamos si el nombre del tipo de trámite contiene la palabra 'cargado' (ignorando mayúsculas/minúsculas)
if (stripos($tipo["tipos_tramite"]["nombre"], 'cargado') !== false) {
$precarga["hoja_ruta"] = true;
break;
}
}
}
}
$lp->setListado($precargas);
return $lp;
}
public function searchPrecargasFinalizadasConDeudas($offset, $limit, $sortField, $sortDirection, $searchParam) {
$lp = $this->repository->searchPrecargasFinalizadasConDeudas($offset, $limit, $sortField, $sortDirection, $searchParam);
$precargas = $this->toarray($lp->getListado(), 'precarga');
$lp->setListado($precargas);
return $lp;
}
public function searchPrecargasFumigadas($offset, $limit, $sortField, $sortDirection, $searchParam) {
$lp = $this->repository->searchPrecargasFumigadas($offset, $limit, $sortField, $sortDirection, $searchParam);
$precargas = $this->toarray($lp->getListado(), 'precarga');
$lp->setListado($precargas);
return $lp;
}
public function searchPrecargasByCliente($offset, $limit, $sortField, $sortDirection, $searchParam) {
$lp = $this->repository->searchPrecargasByCliente($offset, $limit, $sortField, $sortDirection, $searchParam);
$precargas = $this->toarray($lp->getListado(), 'precarga');
$lp->setListado($precargas);
return $lp;
}
public function searchPrecargasByChofer($offset, $limit, $sortField, $sortDirection, $searchParam) {
$lp = $this->repository->searchPrecargasByChofer($offset, $limit, $sortField, $sortDirection, $searchParam);
$precargas = $this->toarray($lp->getListado(), 'precarga');
$lp->setListado($precargas);
return $lp;
}
public function searchAtenciones($offset, $limit, $sortField, $sortDirection, $searchParam) {
$lp = $this->repository->searchPrecargasAtendidas($offset, $limit, $sortField, $sortDirection, $searchParam);
$precargas = $this->toarray($lp->getListado(), 'precarga');
foreach ($precargas as &$precarga) {
$precarga['tiposTramites'] = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaTipoTramitesHandler")->getByPrecarga((int)$precarga['id']);
$precarga["hoja_ruta"] = false;
foreach ($precarga['tiposTramites'] as &$tipo) {
if ($tipo["tipos_tramite"]["nombre"] == 'Entrada cargado') {
$precarga["hoja_ruta"] = true;
}
}
}
$lp->setListado($precargas);
return $lp;
}
public function searchPrecargasParaFinalizar($offset, $limit, $sortField, $sortDirection, $searchParam) {
$lp = $this->repository->searchPrecargasParaFinalizar($offset, $limit, $sortField, $sortDirection, $searchParam);
$precargas = $this->toarray($lp->getListado(), 'precarga');
foreach ($precargas as &$precarga) {
$precarga['tiposTramites'] = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaTipoTramitesHandler")->getByPrecarga((int)$precarga['id']);
$precarga["hoja_ruta"] = false;
foreach ($precarga['tiposTramites'] as &$tipo) {
if ($tipo["tipos_tramite"]["nombre"] == 'Entrada cargado') {
$precarga["hoja_ruta"] = true;
}
}
}
$lp->setListado($precargas);
return $lp;
}
public function getPrecargaSinFinalizarByDominio($dominio) {
$aux = null;
$precarga = $this->repository->findBy(array('dominio1' => $dominio, 'estado' => [0,1,2]));
if (COUNT($precarga) > 0) {
$aux = $this->toarray($precarga, 'precarga');
}
return $aux;
}
public function getVehiculoByDominio($dominio1) {
$aux = null;
$vehiculo = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McVehiculoHandler")->getVehiculoByDominio($dominio1);
if (!is_null($vehiculo)) {
$precarga = $this->getPrecargaSinFinalizarByDominio($dominio1);
if (is_null($precarga)) {
$aux = $this->toarray($vehiculo, "vehiculo");
} else {
throw new HttpException(409, "El dominio ingresado " . $dominio1. " tiene una precarga no Finalizada.");
}
};
return $aux;
}
public function getVehiculoByDominioByCliente($dominio1, $clienteId) {
$aux = null;
$vehiculo = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McVehiculoHandler")->getVehiculoByDominioByCliente($dominio1,$clienteId);
if (!is_null($vehiculo)) {
$precarga = $this->getPrecargaByDominioByCliente($dominio1, $clienteId);
if (is_null($precarga)) {
$aux = $this->toarray($vehiculo, "vehiculo");
} else {
throw new HttpException(409, "El dominio ingresado " . $dominio1. " tiene una precarga no Finalizada.");
}
};
return $aux;
}
public function base64ToImage($val_pic) {
$path = $this->getPathFiles();
//Crea la carpeta si no existe
if (!file_exists($path)) {
mkdir($path, 0777, true);
}
$fname = 'foto';
$fextension = 'png';
$nameMd5 = md5($fname.time());
$nameFileMd5 = "$nameMd5.$fextension";
$nameFileMd5File = "$nameMd5.$fextension";
$pathFile = $path.$nameFileMd5;
$img = str_replace('data:image/png;base64,', '', $val_pic);
$img = str_replace(' ', '+', $img);
$img = base64_decode($img);
file_put_contents($pathFile, $img);
return $nameFileMd5File;
}
public function comprobarArchivo($archivo, $foto) {
//Sección que almadena el archivo relacionado
if (!is_null($archivo) && $archivo['name'] !== '') {
$pathFile = $this->saveImageFile($archivo);
if ($archivo['result']) {
$archivo = $archivo['name_file_Md5'];
} else {
$this->deleteFile($pathFile);
}
} else if (isset($foto)) {
$fotoFile = $this->base64ToImage($foto);
$archivo = $fotoFile;
} else {
$archivo = null;
}
return $archivo;
// fin carga de archivo
}
public function getPrecargaFromRequest(Request $request, $usuario, int $id = null): McPrecarga {
$dominio1 = $request->request->get('dominio1');
$dominio2 = $request->request->get('dominio2');
if (is_null($dominio2) || empty($dominio2) || $dominio2 == 'null') {
$dominio2 = null;
}
$chofer = $request->request->get('chofer');
$tramite = str_replace('string:', '', $request->request->get('tramite'));
$clienteId = (int)$request->request->get('cliente_id');
$cliente = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McClienteHandler")
->getClienteById($clienteId);
$registro = $request->request->get('registro');
$tras = $request->request->get('tras');
$rg = $request->request->get('rg');
$tlmd = $request->request->get('tlmd');
$mani = $request->request->get('mani');
$aduana = $request->request->get('aduana');
$aduana_nombre = str_replace('string:', '', $request->request->get('aduana_nombre'));
$plazo = $request->request->get('plazo');
$tipoOperacion = $request->request->get('tipo_operacion');
$paisOrigen = $request->request->get('pais_origen');
$mercaderia = $request->request->get('mercaderia');
$expImp = $request->request->get('exp_imp');
$tipoPago = str_replace('string:', '', $request->request->get('tipo_pago'));
$monedaId = (int)$request->request->get('moneda');
$moneda = $this->container
->get("Noahtech\Sistemas\InterjamaBundle\Handler\McMonedaHandler")
->getMonedaById((int)$monedaId);
$total = $request->request->get('total');
$mercaderia1 = $request->request->get('mercaderia_1');
if (is_null($id)) {
$precarga = new McPrecarga();
$precarga->setFechaCreacion(new DateTime());
$precarga->setEstado(3);
$precarga->setLeido('Leido');
} else {
$precarga = $this->repository->findOneById($id);
$precarga->setFechaActualizacion(new DateTime());
$precarga->setLeido('Leido');
}
// Validar duplicado de registro
if (!is_null($registro)) {
$registroExistente = $this->repository->buscarNumRegistro(trim($registro), null);
if (COUNT($registroExistente) > 0) {
throw new HttpException(409, "El N° de Registro " . $registro . " ya se encuentra almacenado en el sistema.");
}
}
// Seteo de campos
$precarga->setTramite($tramite);
$precarga->setTipoPago($tipoPago);
$precarga->setMoneda($moneda);
$precarga->setTotal($total);
$precarga->setRegistro($registro);
$precarga->setTras(!is_null($tras) ? json_encode($tras) : null);
$precarga->setRg($rg);
$precarga->setTlmd($tlmd);
$precarga->setMani($mani);
$precarga->setAduana($aduana);
$precarga->setAduanaNombre($aduana_nombre);
$precarga->setPlazo($plazo);
$precarga->setTipoOperacion($tipoOperacion);
$precarga->setPaisOrigen($paisOrigen);
$precarga->setMercaderia($mercaderia);
$precarga->setExpImp($expImp);
$precarga->setDominio1($dominio1);
$precarga->setDominio2($dominio2);
$precarga->setChofer($chofer);
$precarga->setUsuario($usuario);
$precarga->setCliente($cliente);
$precarga->setMercaderia1($mercaderia1);
return $precarga;
}
public function saveImageFile(&$archivo){
$data['result'] = false;
$path = $this->getPathFiles();
//Crea la carpeta si no existe
if (!file_exists($path)) {
mkdir($path, 0777, true);
}
$info = pathinfo($archivo['name']);
$ext = $info['extension']; // get the extension of the file
$name = $info['filename'];
$nameMd5 = md5($name.time());
$nameFileMd5 = "$nameMd5.$ext";
$nameFileMd5File = "$nameMd5.$ext";
$pathFile = $path.$nameFileMd5;
$archivo['result'] = true;
move_uploaded_file($archivo['tmp_name'], $pathFile);
$archivo['name_md5']=$nameMd5;
$archivo['name_file_Md5'] = $nameFileMd5;
$archivo['path_file']=$pathFile;
$archivo['path_only']=$path;
return $pathFile;
}
private function getPathFiles(){
$basePath = $this->container->getParameter('kernel.root_dir');
$basePath = str_replace('/app', '/web', $basePath);
$basePath = $basePath . $this->container->getParameter('path_files_precargas');
$path = "$basePath/";
return $path;
}
private function deleteFile($pathFile) {
try {
unlink($pathFile);
} catch (Exception $e) {
}
return $pathFile;
}
public function validarPrecargaSinFinalizar($precarga) {
$precargaSinFinalizar = $this->repository->getPrecargasSinfinalizar($precarga->getId(), $precarga->getDominio1());
if (!is_null($precargaSinFinalizar)) {
throw new HttpException(409, "El dominio ingresado " . $precarga->getDominio1(). " cuenta con una precarga sin finalizar.");
}
}
public function validarPrecargaAndCrt ($crt) {
if (!is_null($crt->request->get('crt'))) {
$crtId = (int)$crt->request->get('crt');
$crtCantidad = (int)$crt->request->get('cantidad');
$crtDB = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McCrtHandler")->getCrtById($crtId);
$cantidadBd = $crtDB->getCantidad();
$precargasCrt = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaCrtHandler")->getCantidadPrecargaCrtByCrt($crtId);
if (COUNT($precargasCrt) > 0) {
$cantidadAux = 0;
//Realizar el calculo
foreach ($precargasCrt as $crt) {
$cantidadAux = $cantidadAux + $crt->getCantidad();
}
$cantidadAux = $cantidadAux + $crtCantidad;
if ($cantidadAux > $cantidadBd) {
throw new HttpException(409, "La Cantidad ingresada es mayor a la cantidad registrada para el CRT ingresado.");
}
} else {
if ($crtCantidad > $cantidadBd) {
throw new HttpException(409, "La Cantidad ingresada es mayor a la cantidad registrada para el CRT ingresado.");
}
}
}
}
public function save(McPrecarga $precarga, Request $request) {
//$this->validarPrecargaSinFinalizar($precarga);
$this->validarPrecargaAndCrt($request);
// Guardar la precarga
$precarga = $this->repository->save($precarga);
// Registro de movimiento en caja
$monedaId = str_replace('number:', '', $request->request->get('moneda'));
$cajaId = $request->request->get('caja');
$tipoPago = str_replace('string:', '', $request->request->get('tipo_pago'));
$total = $request->request->get('total');
if (!is_numeric((int)$monedaId) || !is_numeric((int)$cajaId) || !is_numeric((float)$total)) {
throw new HttpException(400, "Datos numéricos inválidos para el movimiento de caja.");
}
$moneda = $this->container
->get("Noahtech\Sistemas\InterjamaBundle\Handler\McMonedaHandler")
->getMonedaById((int)$monedaId);
$this->container
->get("Noahtech\Sistemas\InterjamaBundle\Handler\McMovimientoHandler")
->saveFromAtencionPrecarga((int)$monedaId, (int)$cajaId, $tipoPago, (float)$total, $precarga->getUsuario(), $precarga);
// Guardar tipos de trámite
$tiposTramites = $request->request->get('tipoTramite');
$importes = $request->request->get('importe');
if (!is_array($tiposTramites)) {
throw new HttpException(400, "Los tipos de trámite deben ser enviados como un arreglo.");
}
foreach ($tiposTramites as $key => $value) {
$tipoId = str_replace('number:', '', $value);
$this->container
->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaTipoTramitesHandler")
->saveNew($precarga, (int)$tipoId, $importes[$key]);
}
// Guardar precarga_crt si viene en request
$this->container
->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaCrtHandler")
->savePrecargaCrt($precarga, $request);
// Actualizo el turno como atendido = 1
$this->container
->get("Noahtech\Sistemas\InterjamaBundle\Handler\McTurnoHandler")
->update((int)$request->request->get('turno'));
$precarga = $this->toarray($precarga, "precarga");
$precarga['tiposTramites'] = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaTipoTramitesHandler")->getByPrecarga((int)$precarga['id']);
return $precarga;
}
public function update(McPrecarga $precarga, $archivos, Request $request, int $id) {
$this->validarPrecargaSinFinalizar($precarga);
$precarga = $this->repository->update($precarga);
//Compruebo si hay que eliminar archivos
$removeArchivosIds = $request->request->get('removeIdArchivo'); // Array;
$this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaArchivoHandler")->removeArchivo($precarga->getId(), $removeArchivosIds);
//Se editan o eliminan las imagenes/fotos en la edición de la precarga
$fotos = $request->request->get('fotos'); // Array
$this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaArchivoHandler")->save($precarga, $fotos, true);
$this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaArchivoHandler")->save($precarga, $archivos, false);
$precarga = $this->toarray($precarga, "precarga");
return $precarga;
}
public function getById($id) {
$precarga = $this->repository->findOneById($id);
$precarga = $this->toarray($precarga, "precarga");
$precarga['archivos'] = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaArchivoHandler")->findAllByPrecarga((int)$id);
return $precarga;
}
public function getPrecargaById($id) {
return $this->repository->findOneById($id);
}
public function getPrecargaByCliente($id, $clienteId) {
return $this->repository->findBy(array('id' => $id, 'cliente' => $clienteId));
}
public function getPrecargaByChofer($id, $choferId) {
return $this->repository->findBy(array('id' => $id, 'choferId' => $choferId));
}
public function updateFacturado(McPrecarga $precarga) {
$precarga->setFacturado(true);
return $this->update($precarga, $precarga->getId());
}
public function getPrecargaByDominio($dominio) {
$precarga = $this->repository->findBy(array('dominio1' =>$dominio));
if (COUNT($precarga) > 0) {
$band = false;
foreach ($precarga as &$pre) {
if ($pre->getEstado() != 1) {
$band = true;
}
if ($band) {
$pre = $this->toarray($pre, "precarga");
//Obtengo los datos del tipo de tramites que se registraron
$pre['tiposTramites'] = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaTipoTramitesHandler")->getByPrecarga((int)$pre['id']);
return $pre;
}
}
if (!$band) {
throw new HttpException(409, "El dominio ingresado " . $dominio . " tiene una precarga en estado Finalizada. Registre una nueva precarga para realizar esta acción.");
}
} else {
throw new HttpException(409, "El dominio ingresado " . $dominio. " no esta registrado en una precarga en nuestra base de datos. Registre el dominio en el sistema dentro de Precargas para realizar esta acción.");
}
}
public function getPrecargaByDominioByCliente($dominio, $clienteId) {
$aux = null;
$precarga = $this->repository->findBy(array('dominio1' => $dominio, 'estado' => [0,1,2], 'cliente' => $clienteId));
if (COUNT($precarga) > 0) {
$aux = $this->toarray($precarga, "precarga");
}
return $aux;
}
public function getAtencionPrecargaFromRequest(Request $request, int $id, $usuario):McPrecarga {
$dominio1 = $request->request->get('dominio1');
$dominio2 = $request->request->get('dominio2');
if (is_null($dominio2) || empty($dominio2) || $dominio2 == 'null') {
$dominio2 = null;
}
$tramite = $request->request->get('tramite');
$tipoPago = $request->request->get('tipo_pago');
$total = $request->request->get('total');
$registro = $request->request->get('registro');
$tras = $request->request->get('tras');
$rg = $request->request->get('rg');
$tlmd = $request->request->get('tlmd');
$mani = $request->request->get('mani');
$tiposTramites = $request->request->get('tiposTramite');
$aduana = $request->request->get('aduana');
$aduana_nombre = $request->request->get('aduana_nombre');
$plazo = $request->request->get('plazo');
//Campos de intervención SENESA
$tipoOperacion = $request->request->get('tipo_operacion');
$paisOrigen = $request->request->get('pais_origen');
$mercaderia = $request->request->get('mercaderia');
$expImp = $request->request->get('exp_imp');
$mercaderia1 = $request->request->get('mercaderia_1');
$precarga = $this->repository->findOneById($id);
//Seccion donde guardo el movimiento en la caja
$monedaId = $request->request->get('moneda');
$moneda = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McMonedaHandler")->getMonedaById((int)$monedaId);
$cajaId = $request->request->get('caja');
$movimiento = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McMovimientoHandler")->saveFromAtencionPrecarga((int)$monedaId, (int)$cajaId, $tipoPago, (float)$total, $usuario, $precarga);
// Fin del registro del movimiento
// Elimino todos los tipos y agrego los que vienen
$this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaTipoTramitesHandler")->removeAllTiposByPrecarga((int)$id);
// Corroboramos que no exista el mismo N° de Registro
if (!is_null($registro)) {
$registroExistente = $this->repository->buscarNumRegistro(trim($registro), $id);
$registroExistente = $this->toarray($registroExistente, 'precarga');
if (COUNT($registroExistente) > 0) {
throw new HttpException(409, "El N° de Registro " . $registro. " ya se encuentra almacenado en el sistema.");
}
}
foreach ($tiposTramites as &$tipo) {
$this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaTipoTramitesHandler")->save($id, $tipo);
};
$precarga->setDominio1($dominio1);
$precarga->setDominio2($dominio2);
$precarga->setTramite($tramite);
$precarga->setTipoPago($tipoPago);
$precarga->setMoneda($moneda);
$precarga->setTotal($total);
$precarga->setRegistro($registro);
$precarga->setTras($tras);
$precarga->setRg($rg);
$precarga->setTlmd($tlmd);
$precarga->setMani($mani);
$precarga->setAduana($aduana);
$precarga->setAduanaNombre($aduana_nombre);
$precarga->setPlazo($plazo);
$precarga->setTipoOperacion($tipoOperacion);
$precarga->setPaisOrigen($paisOrigen);
$precarga->setMercaderia($mercaderia);
$precarga->setExpImp($expImp);
$precarga->setMercaderia1($mercaderia1);
return $precarga;
}
public function updateAtencion(McPrecarga $precarga, int $id) {
// Corroboramos que no exista el mismo N° de Registro
if (!is_null($precarga->getRegistro())) {
$registroExistente = $this->repository->buscarNumRegistro($precarga->getRegistro(), $id);
$registroExistente = $this->toarray($registroExistente, 'precarga');
if (COUNT($registroExistente) > 0) {
throw new HttpException(409, "El N° de Registro " . $precarga->getRegistro(). " ya se encuentra almacenado en el sistema.");
}
}
$precarga = $this->repository->update($precarga);
$precarga = $this->toarray($precarga, "precarga");
$precarga['tiposTramites'] = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaTipoTramitesHandler")->getByPrecarga((int)$precarga['id']);
return $precarga;
}
public function searchPrecargasAtendidas($offset, $limit, $sortField, $sortDirection, $searchParam) {
$lp = $this->repository->searchPrecargasAtendidas($offset, $limit, $sortField, $sortDirection, $searchParam);
$precargas = $this->toarray($lp->getListado(), 'precarga');
$lp->setListado($precargas);
return $lp;
}
public function getPrecargaAtencionById ($id) {
$precarga = $this->repository->findOneById($id);
$precarga = $this->toarray($precarga, "precarga");
$precarga['tiposTramites'] = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaTipoTramitesHandler")->getByPrecarga((int)$precarga['id']);
return $precarga;
}
public function getAtencionPrecargaFinalizarFromRequest(Request $request, $archivo, $usuario, int $id = null):McPrecarga {
$foto = $request->request->get('foto');
$precarga = $this->repository->findOneById($id);
$precarga->setFechaActualizacion(new DateTime());
$archivoBD = $precarga->getArchivo();
$archivoReverso = $this->comprobarArchivo($archivo,$foto);
$precarga->setUsuario($usuario);
$precarga->setEstado(3); //Estado de finalización de la atención
$precarga->setArchivoReverso($archivoReverso);
//Envio mensaje de WhatsApp al chofer con la finaliazaion del trámite
//$this->sendMessaggeWhatsApp($precarga);
return $precarga;
}
public function descargaManifiestoPdf($id) {
$precarga = $this->getById((int)$id);
$trastlmd = ' - ';
$trastlmdNumero = ' - ';
if (!is_null($precarga['tras']) && trim($precarga['tras']) != '') {
$trastlmd = 'TRAS';
$trastlmdNumero = $precarga['tras'];
} else if (!is_null($precarga['tlmd']) && trim($precarga['tlmd']) != '') {
$trastlmd = 'TLMD';
$trastlmdNumero = $precarga['tlmd'];
}
$fechaHoy = date('d/m/Y');
$anio = date('Y');
$basePath = $this->container->getParameter('kernel.root_dir');
$urlLogo = strstr($basePath, 'app_dev.php', true);
$urlLogo .= "app/images/afip-logo.jpeg";
// create new PDF document
$pdf = new PDF();
$pdf->SetTitle("Panilla - Afip");
$pdf->SetSubject("Panilla - Afip");
$pdf->setFontSubsetting(true);
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
$pdf->SetFont('helvetica', '', 11, '', true);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->setPrintFooter(false);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->AddPage('P', 'A4');
$pdf->Image($urlLogo, 15, 4, 35, 25, 'JPEG', '', '', false, 150, '', false, false, 0, false, false, false);
$html = <<<EOD
<br/>
<div style="text-align: center;">
<span style="font-size: 30px; font-weight: bold;">MANIFIESTO DE CARGA</span>
</div>
<div style="text-align: left;">
<h2> ADUANA DE: <u>JUJUY - ACI - PASO DE JAMA</u></h2>
</div>
<div style="float:left; clear:none;">
<strong style="text-align: left;font-size: 17px;"> AÑO: </strong><span style="font-size: 17px;">{$anio}</span> <strong style="text-align: left;font-size: 17px;">ADUANA: </strong><span style="font-size: 17px;">031</span> <strong style="text-align: left;font-size: 17px;">MANI: </strong><span style="font-size: 17px;">{$precarga['mani']}</span><br>
EOD;
if ($trastlmd == 'TLMD') {
$html .= <<<EOD
<strong style="text-align: left; font-size: 17px;"> AÑO: </strong><span style="font-size: 17px;">{$anio}</span> <strong style="text-align: right; font-size: 17px;">ADUANA: </strong><span style="font-size: 17px;">031</span> <strong style="text-align: left; font-size: 17px;">{$trastlmd}: </strong><span style="font-size: 17px;">{$trastlmdNumero}</span><br>
</div>
<br/>
<div style="text-align: center;">
<span style="font-size: 20px;">/__/__/__/__/__/</span>
</div>
<div style="text-align: center;">
<span style="font-size: 20px;">/__/__/__/__/__/</span>
</div>
<div style="text-align: center;">
<span style="font-size: 20px;">/__/__/__/__/__/</span>
</div>
EOD;
} else {
$trastlmdNumero = json_decode($trastlmdNumero);
if (!is_array($trastlmdNumero)) {
$html .= <<<EOD
<strong style="text-align: left; font-size: 17px;"> AÑO: </strong><span style="font-size: 17px;">{$anio}</span> <strong style="text-align: right; font-size: 17px;">ADUANA: </strong><span style="font-size: 17px;">031</span> <strong style="text-align: left; font-size: 17px;">{$trastlmd}: </strong><span style="font-size: 17px;">{$trastlmdNumero}</span><br>
</div>
<br/>
EOD;
} else {
if (COUNT($trastlmdNumero) == 0) {
$html .= <<<EOD
<strong style="text-align: left; font-size: 17px;"> AÑO: </strong><span style="font-size: 17px;">{$anio}</span> <strong style="text-align: right; font-size: 17px;">ADUANA: </strong><span style="font-size: 17px;">031</span> <strong style="text-align: left; font-size: 17px;">{$trastlmd}: </strong> - <br>
</div>
<br/>
<div style="text-align: center;">
<span style="font-size: 20px;">/__/__/__/__/__/</span>
</div>
<div style="text-align: center;">
<span style="font-size: 20px;">/__/__/__/__/__/</span>
</div>
<div style="text-align: center;">
<span style="font-size: 20px;">/__/__/__/__/__/</span>
</div>
EOD;
} else {
if (COUNT($trastlmdNumero) > 1) {
foreach ($trastlmdNumero as $key => $value ) {
$html .= <<<EOD
<strong style="text-align: left;"> AÑO: </strong>{$anio} <strong style="text-align: right;">ADUANA: </strong>031 <strong style="text-align: left;">{$trastlmd}: </strong>{$value}<br>
EOD;
}
$html .= <<<EOD
</div>
EOD;
} else {
$html .= <<<EOD
<div style="text-align: center;">
<span style="font-size: 20px;">/__/__/__/__/__/</span>
</div>
<div style="text-align: center;">
<span style="font-size: 20px;">/__/__/__/__/__/</span>
</div>
<div style="text-align: center;">
<span style="font-size: 20px;">/__/__/__/__/__/</span>
</div>
EOD;
}
}
}
}
$html .= <<<EOD
<div style="text-align: center;">
<span style="font-size: 30px; font-weight: bold;">SISTEMA INFORMÁTICO</span>
</div>
<div style="text-align: center;">
<span style="font-size: 50px; font-weight: bold;">MALVINAS</span>
</div>
<div style="text-align: center;">
<span style="font-size: 30px; font-weight: bold;">(S.I.M)</span>
</div>
<br/>
<div style="text-align: left;">
<span style="font-size: 30px;">PAD Nº 2503140001 _______________ {$anio}</span>
</div>
<span style="font-size: 15px;"> OM-2017JU</span>
<br><br>
<div style="text-align: center;">
<span style="font-size: 50px; font-weight: bold;">INTERJAMA S.R.L.</span>
</div>
EOD;
$pdf->writeHTML($html, true, false, false, false, '');
return new Response($pdf->Output("Panilla de Afip", "S"), 200, array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="Panilla-Afip.pdf"'
)
);
}
public function getNombreAduana($nombre_aduana) {
$aux = explode('-', $nombre_aduana);
$nombre = trim(strtolower($aux[1]));
$sin_acentos = iconv('UTF-8', 'ASCII//TRANSLIT', $nombre);
return $sin_acentos . '.png';
}
public function descargaHojaRutaPdf($id) {
$imagenHojaRuta = false;
$basePath = $this->container->getParameter('kernel.root_dir');
$urlLogo = strstr($basePath, 'app_dev.php', true);
$urlLogo .= "app/images/afip-logo.jpeg";
$precarga = $this->getById((int)$id);
$precarga['plazo'] = (!is_null($precarga['plazo']) && $precarga['plazo'] != 'No disponible') ? $precarga['plazo'] . " (dias)" : 'No disponible';
// Se arma la imagen de la hoja de ruta
$imagen = $this->getNombreAduana($precarga['aduana_nombre']);
$urlHojaRutaAduana = strstr($basePath, 'app_dev.php', true);
$urlHojaRutaAduana .= 'app/images/'.$imagen;
if (file_exists($urlHojaRutaAduana)) {
$imagenHojaRuta = true;
}
$anio = date('Y');
$fechaHoy = date('d-m-Y');
$horaHoy = date('H:m:s');
// create new PDF document
$pdf = new PDF();
$pdf->SetTitle("Hoja de ruta");
$pdf->SetSubject("Hoja de ruta");
$pdf->setFontSubsetting(true);
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
$pdf->SetFont('helvetica', '', 10, '', true);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->setPrintFooter(false);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->AddPage('P', 'A4');
$pdf->Image($urlLogo, 15, 4, 35, 25, 'JPEG', '', '', false, 150, '', false, false, 0, false, false, false);
$html = <<<EOD
<div style="text-align:right;">
<h5>INSTRUCCION GENERAL Nº 32/2001 (DGA)<br>
ACTUACION 0432/2001 AD JUJUY<br>
MEMORANDO 27-29/2007 (ADJUJU)
</h5>
</div>
<div style="text-align: center;">
<h2><u>HOJA DE RUTA</u></h2>
</div>
<div>
<strong style="text-align: left;"> FECHA: </strong> {$fechaHoy} <strong style="text-align: left;">HORA: </strong> {$horaHoy} <strong style="text-align: left;">PLAZO: </strong> {$precarga['plazo']}<br>
</div>
<div>
EOD;
if ($imagenHojaRuta) {
$html .= <<<EOD
<img src="{$urlHojaRutaAduana}" alt="{$precarga['aduana_nombre']}" width="300" heigth="300" />
EOD;
} else {
$html .= <<<EOD
<span style="font-size: 12px; font-weight: bold;"> Sin recorrido cargado.</span><br>
EOD;
}
$html .=<<<EOD
</div>
<div>
EOD;
if ($precarga['aduana_nombre'] == '061 - SANTA CRUZ') {
$html .= <<<EOD
<span style="font-size: 12px; font-weight: bold;"> POR LA PRESENTE SE NOTIFICA AL CONDUCTOR QUE DEBE INGRESAR DE MANERA OBLIGATORIA A ZONA PRIMARIA ADUANERA PALPALA (Z.P.A.P.).</span><br>
EOD;
}
$html .= <<<EOD
<span style="font-size: 12px; font-weight: bold;"> CERTIFICO EL COMPROMIDO DE CUMPLIR CON EL INTINERARIO DETALLADO.</span>
</div>
<div style="float:left; clear:none;">
<br>
<strong style="text-align: left;"> CONDUCTOR: </strong> _ _ _ _ _ _ _ _ _ _ _ _ <strong>Agente de Transporte ADUANERO</strong> _ _ _ _ _ _ _ _ _ _ _ _<br>
<br/>
<br/>
<br/>
<strong style="text-align: left;"> Servicio ADUANERO: </strong> _ _ _ _ _ _ _ _ _ _ _ _<br>
</div>
<div>
<p> Cuando un hecho impida la prosecución del medio de transporte, el conductor dará aviso inmediato a la autoridad policial más cercana, bajo cuya vigilancia quedaran el camión y la carga, hasta que tome intervención el servicio ADUANERO.-</p>
</div>
EOD;
$pdf->writeHTML($html, true, false, false, false, '');
return new Response($pdf->Output("Hoja de ruta", "S"), 200, array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="Hoja-Ruta.pdf"'
)
);
}
public function descargaMcdtaPdf($id) {
$precarga = $this->getById((int)$id);
$anio = substr($precarga['fecha_creacion'], 0, 4);
$fechaHoy = date('d-m-Y');
$horaHoy = date('h:m:s');
// create new PDF document
$pdf = new PDF();
$pdf->SetTitle("MCDTA");
$pdf->SetSubject("MCDTA");
$pdf->setFontSubsetting(true);
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
$pdf->SetFont('helvetica', '', 11, '', true);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->setPrintFooter(false);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->AddPage('P', 'A4');
$html = <<<EOD
<div style="width: 100%;height: 100%;display: table;text-align: center;">
<span style="font-size: 15px; font-weight: bold;display: table-cell;vertical-align: middle;">{$anio}031MANI{$precarga['mani']}</span><br>
<span style="font-size: 15px; font-weight: bold;display: table-cell;vertical-align: middle;">{$anio}031TLMD{$precarga['tlmd']}</span>
</div>
EOD;
$pdf->writeHTML($html, true, false, false, false, '');
return new Response($pdf->Output("Hoja de ruta", "S"), 200, array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="MCDTA.pdf"'
)
);
}
public function saveFromFumigacion ($certificado) {
$precarga = new McPrecarga();
$precarga->setFechaCreacion(new DateTime());
$precarga->setEstado(0);
$precarga->setDominio1($certificado->getVehiculo()->getDominio1());
$precarga->setDominio2($certificado->getVehiculo()->getDominio2());
$precarga->setChofer($certificado->getChofer());
$precarga->setUsuario($certificado->getUsuario());
$precarga->setCliente($certificado->getCliente());
$precarga->setOrigen("Fumigación");
$precargaBD = $this->repository->save($precarga);
$precargaBD = $this->toarray($precargaBD, "precarga");
return $precargaBD;
}
public function updatePrecargaAsignarNumero($request, $id) {
$precarga = $this->repository->findOneById((int)$id);
$registro = $request->request->get('registro');
// Corroboramos que no exista el mismo N° de Registro
if (!is_null($registro) && str_replace(' ', '', $registro) != '') {
$registroExistente = $this->repository->buscarNumRegistro($registro, $id);
$registroExistente = $this->toarray($registroExistente, 'precarga');
if (COUNT($registroExistente) > 0) {
throw new HttpException(409, "El N° de Registro " . $precarga->getRegistro(). " ya se encuentra almacenado en el sistema.");
}
$precarga->setRegistro($registro);
$precarga->setEstado(2); // Atendido
}
$precarga = $this->updateAtencion($precarga, $id);
return $precarga;
}
public function descargaReciboPdf($id) {
$precarga = $this->getById((int)$id);
$precarga['tiposTramites'] = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaTipoTramitesHandler")->getByPrecarga((int)$id);
$precarga['aduana'] = (!is_null($precarga['aduana']) && !empty($precarga['aduana'])) ? $precarga['aduana'] : 0;
$fechaHoy = date('d-m-Y');
$anio = substr($precarga['fecha_creacion'], 0, 4);
$fechaHoy = date('d-m-Y');
$chofer = $precarga['chofer'];
// create new PDF document
$pdf = new PDF();
$pdf->SetTitle("Recibo Atención");
$pdf->SetSubject("Recibo Atención");
$pdf->setFontSubsetting(true);
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
$pdf->SetFont('helvetica', '', 9, '', true);
$pdf->SetMargins(5, 5, 5);
$pdf->SetHeaderMargin(0);
$pdf->SetFooterMargin(0);
$pdf->setPrintFooter(false);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->AddPage('P', 'A4');
$html = <<<EOD
<table style="width: 100%; border-top: 1px solid black;border-left: 1px solid black;border-right: 1px solid black;">
<tr>
<th style="text-align: left">
<span></span><br>
<img src="app/images/interjama-logo.jpeg" alt="Interjama" width="300" height="100" />
</th>
<th style="text-align: center">
<span style="font-size: 30px; font-weight: bold;">RECIBO</span><br>
<span style="font-size: 10px;">Original</span>
</th>
<th style="text-align: center">
<span></span><br>
<span style="font-size: 12px; font-weight: bold;">Recibo</span><br>
<span style="font-size: 12px; font-weight: bold;">Nº {$id}</span><br>
<span style="font-size: 12px; font-weight: bold;">{$fechaHoy}</span>
</th>
</tr>
</table>
<table style="width: 100%; border-bottom: 1px solid black;border-left: 1px solid black;border-right: 1px solid black;">
<tr>
<th style="text-align: left; border-right: 1px solid black">
<strong style="text-align: left;">Razón Social: </strong>INTERJAMA S.R.L.<br>
<strong style="text-align: left;">Fecha de Emisión: {$fechaHoy}</strong><br>
<strong style="text-align: left;">Domicilio comercial: </strong>Alvear 495 Piso:2 Dpto:C - San Salvador de Jujuy - Jujuy<br>
<strong style="text-align: left;">Sitio web: </strong>www.interjama.com.ar<br>
</th>
<th style="text-align: left">
<strong style="text-align: left;">Condición frente al IVA: IVA Responsable Inscripto</strong><br>
<strong style="text-align: left;">CUIT: </strong>30714865044<br>
<strong style="text-align: left;">Ingresos Brutos: </strong>A-1-55049<br>
<strong style="text-align: left;">Fecha de Inicio de Actividad: </strong>01/07/2015
</th>
</tr>
</table>
<br/>
<div style="width: 100%; border: 0.5px solid black; margin-top: 1px;">
<strong style="margin-left: 10px;">Preriodo Facturado Desde:</strong> {$fechaHoy} <strong style="margin-left: 90px;">Hasta:</strong> {$fechaHoy} <strong style="margin-left: 200px;">Fecha de Vto. para el pago:</strong> {$fechaHoy}
</div>
<div style="width: 100%; border: 0.5px solid black; margin-top: 1px;">
<strong style="text-align: left;">CUIT:</strong> {$precarga['cliente']['cuit']}<br>
<strong style="text-align: left;">Apellido y Nombre / Razón Social</strong> {$precarga['cliente']['razon_social']}<br>
<strong style="text-align: left;">Condición frente al IVA:</strong> {$precarga['cliente']['condicion_iva']}<br>
<strong style="text-align: left;">Condición de venta:</strong> {$precarga['tipo_pago']}<br>
<strong style="text-align: left;">Chofer:</strong> {$chofer}<br>
<strong style="text-align: left;">Dominio:</strong> {$precarga['dominio1']}<br>
<strong style="text-align: left;">Dominio Trailer:</strong> {$precarga['dominio2']}
</div>
<br/>
<table border="0.5">
<tr style="background-color: grey;">
<th>Cantidad</th>
<th>Trámite</th>
<th>Tipo trámite</th>
<th>Importe</th>
<th>Subtotal</th>
</tr>
EOD;
foreach ($precarga['tiposTramites'] as $tipo) {
$html .= <<<EOD
<tr>
<td>1,00</td>
<td>{$tipo['tipos_tramite']['tipo']}</td>
<td>{$tipo['tipos_tramite']['nombre']}</td>
<td>{$tipo['importe']}</td>
<td>{$tipo['importe']}</td>
</tr>
EOD;
}
$html .= <<<EOD
</table>
<br/>
<br/>
<table border="0.5">
<tr>
<th><strong style="margin-left: 0%;"> Imp. Aduana: $:</strong> {$precarga['aduana']}</th>
<th><strong style="margin-left: 30%;"> Subtotal: $</strong> {$precarga['total']}</th>
<th><strong style="margin-left: 60%;"> Importe Total: $</strong> {$precarga['total']}</th>
</tr>
</table>
EOD;
$pdf->writeHTML($html, true, false, false, false, '');
return new Response($pdf->Output("Recibo", "S"), 200, array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="Panilla-Afip.pdf"'
)
);
}
public function numeroAddZero($nro) {
$numero = "";
$nro1 = strlen((string)$nro);
switch($nro1) {
case 1:
$numero = "000000" . $nro;
break;
case 2:
$numero = "00000" . $nro;
break;
case 3:
$numero = "0000" . $nro;
break;
case 4:
$numero = "000" . $nro;
break;
case 5:
$numero = "00" . $nro;
break;
case 6:
$numero = "0" . $nro;
break;
case 7:
$numero = $nro;
break;
}
return $numero;
}
public function descargaFacturaAfipPdf($id, $factura) {
$precarga = $this->getById((int)$id);
if (is_null($precarga['facturado']) || !$precarga['facturado']) {
$precargaObj = $this->getPrecargaById((int)$id);
$precarga['tiposTramites'] = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaTipoTramitesHandler")->getByPrecarga((int)$id);
$precarga['aduana'] = (!is_null($precarga['aduana']) && !empty($precarga['aduana'])) ? $precarga['aduana'] : 0;
$fechaHoy = date('d/m/Y');
$tipoFactura = "A";
/*
$afip = new Afip(array(
'CUIT' => 27332574049,
'cert' => 'tramite/cert',
'key' => 'tramite/key'
));
*/
if ($factura == 'A') {
try {
$last_voucher = 1;
//$last_voucher = $afip->ElectronicBilling->GetLastVoucher(1,1);
} catch (Exception $e) {
return $e->getMessage();
}
} elseif ($factura == 'B') {
try {
$last_voucher = 1;
//$last_voucher = $afip->ElectronicBilling->GetLastVoucher(1,6);
} catch (Exception $e) {
return $e->getMessage();
}
}
$valfac = $last_voucher + 1;
$nroComprobante = $this->numeroAddZero($valfac);
$ptoVta = "0001";
$neto = round($precarga['total'] / 1.21, 2);
$iva = round($neto * 0.21, 2);
//Se arma factura A
$data = array(
'CantReg' => 1, // Cantidad de comprobantes a registrar
'PtoVta' => 1, // Punto de venta
'Concepto' => 1, // Concepto del Comprobante: (1)Productos, (2)Servicios, (3)Productos y Servicios
'DocTipo' => 80, // Tipo de documento del comprador (99 consumidor final, ver tipos disponibles)
'DocNro' => $precarga['cliente']['cuit'], // Número de documento del comprador (0 consumidor final)
'CbteDesde' => $valfac, // Número de comprobante o numero del primer comprobante en caso de ser mas de uno
'CbteHasta' => $valfac, // Número de comprobante o numero del último comprobante en caso de ser mas de uno
'CbteFch' => intval(date('Ymd')), // (Opcional) Fecha del comprobante (yyyymmdd) o fecha actual si es nulo
'ImpTotal' => $precarga['total'], // Importe total del comprobante
'ImpTotConc' => 0, // Importe neto no gravado
'ImpNeto' => $neto, // Importe neto gravado
'ImpOpEx' => 0, // Importe exento de IVA
'ImpIVA' => $iva, //Importe total de IVA
'ImpTrib' => 0, //Importe total de tributos
'MonId' => 'PES', //Tipo de moneda usada en el comprobante (ver tipos disponibles)('PES' para pesos argentinos)
'MonCotiz' => 1, // Cotización de la moneda usada (1 para pesos argentinos)
'Iva' => array( // (Opcional) Alícuotas asociadas al comprobante
array(
'Id' => 5, // Id del tipo de IVA (5 para 21%)(ver tipos disponibles)
'BaseImp' => $neto, // Base imponible
'Importe' => $iva // Importe
)
),
);
if ($factura == 'A') {
$data['CbteTipo'] = 1;
$codigo = 'Código 01';
} elseif ($factura == 'B') {
$data['CbteTipo'] = 6;
$tipoFactura = "B";
$codigo = 'Código 06';
} else {
//Se arma factura E de exportación
}
try {
/*
$res = $afip->ElectronicBilling->CreateVoucher($data);
$this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McFacturaHandler")->saveFacturaPrecarga($precargaObj, $tipoFactura, $res, $nroComprobante);
$this->updateFacturado($precargaObj);
*/
$res['CAE'] = '987654321';
$res['CAEFchVto'] = '2023-12-31';
} catch (Exception $e) {
return $e->getMessage();
}
$res['CAE']; //CAE asignado el comprobante
$res['CAEFchVto']; //Fecha de vencimiento del CAE (yyyy-mm-dd)
// Fin de sección de factura de AFIP
//Creacion del PDF
// create new PDF document
$pdf = new PDF();
$pdf->SetTitle("Precargas atendidas");
$pdf->SetSubject("Precargas atendidas");
$pdf->setFontSubsetting(true);
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
$pdf->SetFont('helvetica', '', 9, '', true);
$pdf->SetMargins(5,5,5);
$pdf->SetHeaderMargin(0);
$pdf->SetFooterMargin(0);
$pdf->SetPrintFooter(false);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->AddPage('P', 'A4');
// Datos de la empresa emisora de la factura
$html = <<<EOD
<table style="width: 100%; border-top: 1px solid black;border-left: 1px solid black;border-right: 1px solid black;">
<tr>
<th style="text-align: left">
<span></span><br>
<img src="app/images/interjama-logo.jpeg" alt="Interjama" width="300" height="100" />
</th>
<th style="text-align: center">
<span style="font-size: 30px; font-weight: bold;">{$tipoFactura}</span><br>
<span style="font-size: 10px;">{$codigo}</span>
</th>
<th style="text-align: center">
<span></span><br>
<span style="font-size: 12px; font-weight: bold;">Factura</span><br>
<span style="font-size: 12px; font-weight: bold;">Nº {$nroComprobante}</span><br>
<span style="font-size: 12px; font-weight: bold;">{$fechaHoy}</span>
</th>
</tr>
</table>
<table style="width: 100%; border-bottom: 1px solid black;border-left: 1px solid black;border-right: 1px solid black;">
<tr>
<th style="text-align: left; border-right: 1px solid black">
<strong style="text-align: left;">Razón Social: </strong>INTERJAMA S.R.L.<br>
<strong style="text-align: left;">Punto de venta: {$ptoVta} Comp. Nro: {$nroComprobante}</strong><br>
<strong style="text-align: left;">Domicilio comercial: </strong>Alvear 495 Piso:2 Dpto:C - San Salvador de Jujuy - Jujuy<br>
<strong style="text-align: left;">Sitio web: </strong>www.interjama.com.ar<br>
</th>
<th style="text-align: left">
<strong style="text-align: left;">Condición frente al IVA: IVA Responsable Inscripto</strong><br>
<strong style="text-align: left;">CUIT: </strong>30714865044<br>
<strong style="text-align: left;">Ingresos Brutos: </strong>A-1-55049<br>
<strong style="text-align: left;">Fecha de Inicio de Actividad: </strong>01/07/2015
</th>
</tr>
</table>
<br/>
<div style="width: 100%; border: 0.5px solid black; margin-top: 2px;">
<strong style="margin-left: 10px;">Preriodo Facturado Desde:</strong> {$fechaHoy} <strong style="margin-left: 90px;">Hasta:</strong> {$fechaHoy} <strong style="margin-left: 200px;">Fecha de Vto. para el pago:</strong> {$fechaHoy}
</div>
<div style="width: 100%; border: 0.5px solid black; margin-top: 2px;">
<strong style="text-align: left;">CUIT:</strong> {$precarga['cliente']['cuit']}<br>
<strong style="text-align: left;">Appelidoy Nombre / Razón Social</strong> {$precarga['cliente']['razon_social']}<br>
<strong style="text-align: left;">Condición frente al IVA:</strong> {$precarga['cliente']['condicion_iva']}<br>
<strong style="text-align: left;">Condición de venta:</strong> {$precarga['tipo_pago']}
</div>
<br/>
<table border="0.5">
<tr style="background-color: grey;">
<th>Cantidad</th>
<th>Trámite</th>
<th>Tipo trámite</th>
<th>Importe</th>
<th>Subtotal</th>
</tr>
EOD;
foreach ($precarga['tiposTramites'] as $tipo) {
$html .= <<<EOD
<tr>
<td>1,00</td>
<td>{$tipo['tipos_tramite']['tipo']}</td>
<td>{$tipo['tipos_tramite']['nombre']}</td>
<td>{$tipo['importe']}</td>
<td>{$tipo['importe']}</td>
</tr>
EOD;
}
$html .= <<<EOD
</table>
<br/>
<br/>
<table border="0.5">
<tr>
<th><strong style="margin-left: 0%;"> Imp. Aduana: $:</strong> {$precarga['aduana']}</th>
<th><strong style="margin-left: 30%;"> Subtotal: $</strong> {$precarga['total']}</th>
<th><strong style="margin-left: 60%;"> Importe Total: $</strong> {$precarga['total']}</th>
</tr>
</table>
<div style="float:right; margin-top: 2px; text-align: right;">
<strong>CAE Nº:</strong> {$res['CAE']}<br>
<strong>Fecha Vto. de CAE:</strong> {$res['CAEFchVto']}
</div>
<br/>
<table style="width: 100%;">
<tr>
<th>
<img src="app/images/qr.png" alt="Código QR" width="50" height="50"/>
</th>
<th>
<img src="app/images/afip-logo.png" alt="Código QR" width="50" height="15"/><br>
<span><b>Comprobante Autorizado</b></span>
</th>
<th>
</th>
<th>
</th>
</tr>
</table>
EOD;
$pdf->writeHTML($html, true, false, false, false, '');
return new Response($pdf->Output("Precarga-Factura", "S"), 200, array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="Precarga-Factura.pdf"'
)
);
} else {
throw new HttpException(409, "La precarga ya se encuentra facturado.");
}
}
public function downloadSenasa($data, $id) {
$precarga = $this->getById((int)$id);
$dominios = '('. $precarga['dominio1'] .' - '. $precarga['dominio2'] . ')';
$fechaHoy = date('d/m/Y');
$horaHoy = date('H:i:s');
$tipoExportacion = '';
$tipoImportacion = '';
$tipoTransito = '';
$tipoRetorno = '';
$tipoOtro = '';
if ($data['tipo'] == 'exportacion') {
$tipoExportacion = 'X';
} else if ($data['tipo'] == 'importacion') {
$tipoImportacion = 'X';
} else if ($data['tipo'] == 'transito') {
$tipoTransito = 'X';
} else if ($data['tipo'] == 'retorno de exportacion') {
$tipoRetorno = 'X';
} else {
$tipoOtro = 'X';
}
$pais = strtoupper($data['pais']);
$mercaderia = strtoupper($data['mercaderia']);
$nombre = strtoupper($data['nombre']);
$basePath = $this->container->getParameter('kernel.root_dir');
$urlLogo = strstr($basePath, 'app_dev.php', true);
$urlLogo .= "app/images/senasa.png";
// create new PDF document
$pdf = new PDF();
$pdf->SetTitle("Panilla - Senasa");
$pdf->SetSubject("Panilla - Senasa");
$pdf->setFontSubsetting(true);
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
$pdf->SetFont('times', '', 11, '', true);
$pdf->SetMargins(PDF_MARGIN_LEFT, 15, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->setPrintFooter(false);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->AddPage('P', 'A4');
$pdf->Image($urlLogo, 17, 20, 33, 20, 'PNG', '', '', false, 150, '', false, false, 0, false, false, false);
$html = <<<EOD
<table style="border-top: 2px solid black ; border-left: 2px solid black; border-right: 2px solid black; border-bottom: 2px solid black; width: 100%; border-collapse: collapse;">
<tr>
<th style="width: 20%;"></th>
<th style="background-color: #b5b5b5; width: 60%; border-bottom: 2px solid black; border-top: 2px solid black; border-left: 2px solid black; border-right: 2px solid black; text-align: center;">
<br>
<strong>SERVICIO NACIONAL DE <br> Y CALIDAD AGROALIMENTARIA</strong>
<br>
</th>
<th style="width: 20%;">
<p style="font-size: 8px; text-align: left;">FOR N° 1 POE N° 1<br>Emisión: 08/11/00</p>
</th>
</tr>
<tr>
<th style="width: 20%;"></th>
<th style="width: 60%; border-left: 2px solid black; border-right: 2px solid black; text-align: center">
<br>
Manual de procedimientos a desarrollar en los<br> Puestos de Fronteras Habilitados
<br>
</th>
<th style="width: 20%;">
<p style="font-size: 8px; text-align: left;">Vigencia:19/11/11<br>Hoja:1</p>
</th>
</tr>
</table>
<br/>
<br/>
<table style="border-collapse: collapse; width: 100%;">
<tr>
<th style="width: 20%;"></th>
<th style="text-align: center; width: 60%;">
<br>
SOLICITUD DE INTERVENCIÓN: {$precarga['id']}/2023
</th>
<th style="width: 20%;">
</th>
</tr>
<tr>
<th style="width: 20%;"></th>
<th style="width: 60%; text-align: center">
No se encuentran entradas de índice.
</th>
<th style="width: 20%;"></th>
</tr>
<tr>
<th style="width: 20%;"></th>
<th style="width: 60%; text-align: center">
N° ......................(Asignado por SENASA)
</th>
<th style="width: 20%;"></th>
</tr>
</table>
<br/>
<table style="border-collapse: collapse; width: 100%;">
<tr>
<th style="width: 50%; text-align: left;">
<p>Lugar, Paso de Jama, {$fechaHoy}</p>
</th>
<th style="width: 50%; text-align: left;">
<p>Hora: </p>
</th>
</tr>
</table>
<table style="border-collapse: collapse; width: 100%;">
<tr>
<th style="width: 100%; text-align: left;">
Sr. Jefe del Puesto de Frontera:
</th>
</tr>
</table>
<br/>
<table style="border-collapse: collapse;">
<tr>
<th style="width: 100%; text-align: left;">
<p style="font-size: 11px;">Me dirijo a Ud. a fin solicitar la presencia de personal de esa Unidad Operativa, a efectos de
intervenir, en la operación cuyos datos se detallan a continuación:</p>
</th>
</tr>
</table>
<br/>
<br/>
<table style="border-collapse: collapse;">
<tr>
<th style="width: 100%; text-align: left;">
TIPO DE OPERACIÓN (marcar a la derecha de la operación que corresponda)
</th>
</tr>
</table>
<br/>
<br/>
<table border="1" style="border-collapse: collapse; width: 100%;">
<tr>
<th style="width: 20%; background-color: #b5b5b5;">EXPORTACIÓN</th>
<th style="width: 5%;"> {$tipoExportacion}</th>
<th style="width: 20%;">TRANSITO</th>
<th style="width: 5%;">{$tipoTransito}</th>
<th style="width: 45%; background-color: #b5b5b5;">RETORNO DE EXPORTACIÓN</th>
<th style="width: 5%;">{$tipoRetorno}</th>
</tr>
<tr>
<th style="width: 20%;">IMPORTACIÓN</th>
<th style="width: 5%;"> {$tipoImportacion}</th>
<th style="width: 20%; background-color: #b5b5b5;">OTRO</th>
<th style="width: 55%;">{$tipoOtro}</th>
</tr>
</table>
<table style="border-collapse: collapse; width: 100%;">
<tr>
<th style="width: 30%;"><strong>PAÍS DE ORIGEN:</strong></th>
<th style="width: 70%;"> {$pais}</th>
</tr>
<tr>
<th style="width: 30%;"><strong>MERCADERÍA:</strong></th>
<th style="width: 70%;"> {$mercaderia}</th>
</tr>
<tr>
<th style="width: 30%;"><strong>TRANSPORTE de ARRIBO:</strong></th>
<th style="width: 70%;"> {$precarga['cliente']['razon_social']} {$dominios}</th>
</tr>
<tr>
<th style="width: 70%;"><strong>LUGAR PREVISTO DE LA INTERVENCIÓN:</strong></th>
<th style="width: 30%;"> Paso de Jama</th>
</tr>
</table>
<table style="border-collapse: collapse; width: 100%;">
<tr style="background-color: #b5b5b5;">
<th style="width: 70%; text-align: left;">
SOLICITO PRESENCIA DE PERSONAL DEL SENASA PARA:
</th>
<th style="width: 30%;"></th>
</tr>
</table>
<table style="border-collapse: collapse; width: 100%; border-top: 1px solid black; border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black;">
<tr>
<th style="width: 20%;"><br/>Fecha:</th>
<th style="width: 30%;"> {$fechaHoy}</th>
<th style="width: 20%;"><br/>Hora:</th>
<th style="width: 30%;"></th>
</tr>
</table>
<table style="border-collapse: collapse; width: 100%;">
<tr>
<th style="width: 30%;"><strong>NOMBRE DE EXP E IMP:</strong></th>
<th style="width: 70%;"> {$nombre}</th>
</tr>
<tr>
<th style="width: 30%;"><strong>PRESENTANTE:</strong></th>
<th style="width: 70%;"> ATA...INTERJAMA SRL 30-71486504-4</th>
</tr>
<tr>
<th style="width: 30%;"><strong>DOMICILIO:</strong></th>
<th style="width: 70%;"> RUTA 52 KM 236 PASO DE JAMA</th>
</tr>
<tr>
<th style="width: 30%;"><strong>TELEFONO</strong> (urgencias):</th>
<th style="width: 70%;"> 0388 -154580629</th>
</tr>
</table>
<table style="border-collapse: collapse; width: 100%;">
<tr style="background-color: #b5b5b5;">
<th style="width: 100%; text-align: left;">
<p>Por la presente declaro conocer la normativa vigente de aplicación del SENASA y de otros Organismos que
pudieran estar involucrados en esta operatoria, así como las pautas operativas actuales.</p>
</th>
</tr>
</table>
<br/>
<br/>
<table style="border-collapse: collapse;
border-top: 1px solid black;
border-bottom: 1px solid black;
border-left: 1px solid black;
border-right: 1px solid black;
">
<tr>
<th style="width: 50%; text-align: left; border-right: 1px solid black;">
N° de recepción otorgado (correlativo):................
</th>
<th style="width: 50%; text-align: left;">
Firma y sello aclaratorio del Interesado
</th>
</tr>
<tr>
<th style="width: 50%; text-align: left; border-right: 1px solid black;">
Recibido en SENASA el....../......./.....hora............
</th>
<th style="width: 50%; text-align: left;">
</th>
</tr>
<tr>
<th style="width: 50%; text-align: left; border-right: 1px solid black;">
<br/>
<br/>
<br/>
<p>Firma y aclaración</p>
</th>
<th style="width: 50%; text-align: left;">
</th>
</tr>
</table>
<br/>
<br/>
<br/>
<table style="border-top: 2px solid black ; border-left: 2px solid black; border-right: 2px solid black; border-bottom: 2px solid black; width: 100%; border-collapse: collapse;">
<tr>
<th style="width: 50%; border-right: 2px solid black; text-align: center;">Elaboraron:</th>
<th style="width: 50%; text-align: center;">
Aprobó
</th>
</tr>
<tr>
<th style="width: 50%; border-right: 2px solid black; text-align: center;">Dr. E. Saint Jean, Dr. H. Castellini, Dra. T. Bianchi</th>
<th style="width: 50%; text-align: center;">
Dr. L. Mascitelli
</th>
</tr>
</table>
EOD;
$pdf->writeHTML($html, true, false, false, false, '');
return new Response($pdf->Output("Formulario SENASA", "S"), 200, array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="Formulario-Senasa.pdf"'
)
);
}
private function FechaCastellano(){
$date = date('Y-m-d');
$mes_ = date('F', strtotime($date));
$_ES = array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
$_EN = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$nombreMes = str_replace($_EN, $_ES, $mes_);
return $nombreMes;
}
public function downloadAnmac($data, $id) {
$renar = $data['renar'];
$precarga = $this->getById((int)$id);
$chofer = (!is_null($precarga['chofer'])) ? $precarga['chofer'] : $precarga['chofer_id']['nombre']." ".$precarga['choferId']['apellido'];
$tipo = (!is_null($precarga['chofer_id'])) ? $precarga['chofer_id']['tipo'] : null;
$numero = (!is_null($precarga['chofer_id'])) ? $precarga['chofer_id']['numero'] : null;
$fecha_nacimiento =
$fechaHoy = date('d/m/Y');
$mesActual = $this->FechaCastellano();
$diaActual = date('d', strtotime(date('Y-m-d')));
$anioActual = date('Y', strtotime(date('Y-m-d')));
$horaActual = date('H', strtotime(date('H:i:s')));
$minutoActual = date('i', strtotime(date('H:i:s')));
$horaHoy = date('H:i:s');
// create new PDF document
$pdf = new PDF();
$pdf->SetTitle("Panilla - Anmac");
$pdf->SetSubject("Panilla - Anmac");
$pdf->setFontSubsetting(true);
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
$pdf->SetFont('helvetica', '', 11, '', true);
$pdf->SetMargins(30, 15, 5);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->setPrintFooter(false);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->AddPage('P', 'CO_OFICIO');
$html = <<<EOD
<table style="width: 100%; border-collapse: collapse;">
<tr>
<th style="width: 30%;">
REPUBLICA ARGENTINA<br>GENDARMERIA NACIONAL
</th>
<th style="width: 70%; text-align: left;">
“Gral. Martin Miguel de Güemes Héroe de la Nación Argentina”
</th>
</tr>
<tr>
<th style="width: 50%;">
</th>
<th style="width: 50%;">
“1983/2023 40 AÑOS DE DEMOCRACIA”
</th>
</tr>
</table>
<br/>
<br/>
<br/>
<table style="width: 100%; border-collapse: collapse;">
<tr>
<th>
<strong><u>ACTA DE INSPECCION LEY 20.429, DECRETOS 302/83, 37/01 Y 306/07</u></strong>
</th>
</tr>
</table>
<br/>
<br/>
<table style="width: 100%; border-collapse: collapse;">
<tr>
<th style="width: 15%;">
<i><u>Referencias:</u></i>
</th>
<th style="width: 85%;">
<strong>TRÁMITE RENAR Nº {$data['renar']} ACTA DE INSPECCIÓN NRO {$data["inspeccion"]} <br> CAMIÓN {$data["camion"]}</strong>
</th>
</tr>
</table>
<table style="width: 100%; border-collapse: collapse; text-align: justify; text-justify: inter-word; line-height: 1.6;">
<p>En Paso Internacional Jama, Departamento de Susques, Provincia de Jujuy, República
Argentina, a los {$diaActual} días del mes de {$mesActual} del año {$anioActual}, siendo las {$horaActual}
horas con {$minutoActual} minutos, de conformidad a lo determinado en los Art.(s) 4 y 8 de la Ley
20.429 (Armas y Explosivos) Art. 599 del Decreto 302/83 (Reglamentación Parcial
inherente a Pólvoras, Explosivos y Afines), Decreto 306/07 y convenio preestablecido
entre el ANMaC y la Institución, la que suscribe {$data['jefe']} , en su
carácter de Jefe del Grupo Paso Internacional “JAMA”, de Gendarmería Nacional
Argentina, procede a labrar la presente acta a los fines de dejar expresa constancia de
la verificación realizada por el suscripto, acompañado por el Sargento {$data['responsable']},
de la unidad de transporte de carga de explosivos en importación al país, el
estado de dicho material, las condiciones de transporte y seguridad, como así también la
documentación respectiva, en concomitancia con el cuerpo legal citado, en lo que hace
a pólvoras, explosivos y afines Acto seguido con la presencia del Sr. {$data['agente_nombre']},
DNI {$data['agente_dni']}, con número de Registro {$data['agente_registro']}, de {$data['agente_edad']} años de edad,
con domicilio en {$data['agente_domicilio']}, Provincia de Jujuy, en
calidad de Apoderado General de Agente de Transporte Aduanero, de INTERJAMA
S.R.L. CUIT Nro. 30-71486504-4, con domicilio en Ruta Nacional 52 Km 252, Paso de
Jama, provincia de Jujuy, Agente de Transporte Aduanero, representando a la empresa
de transporte “{$precarga['cliente']['razon_social']}” y por AFIP DGA Sector Cargas del ACI Paso de
Jama, dependiente de la Aduana de Jujuy, en carácter de verificador, {$data['verificador_nombre']},
legajo {$data['verificador_legajo']} Nro. {$data['verificador_numero']}, DNI Nro. {$data['verificador_dni']}, se procede a la
inspección del transporte de carga tipo camión {$data['marca']}, Modelo {$data['modelo']} dominio
colocado “{$precarga['dominio1']}” Año {$data['anio']}, chasis {$data['chasis']}, Motor {$data['motor']},
semirremolque marca {$data['semirremolque_marca']} dominio colocado “{$precarga['dominio2']}”, Chasis
{$data['semirremolque_chasis']}, conducido por el Sr. {$chofer}, de nacionalidad
{$data['nacionalidad']}, {$tipo} Nro. {$numero}, fecha de nacimiento {$data['fecha_nacimiento']}, estado
civil {$data['estado_civil']}, con Licencia Nacional Habilitante, categoría Mercancías Peligrosas, con
fecha de vencimiento el {$data['fecha_vencimiento']}, quien transporta en la oportunidad: {$data['transporta']},
conforme detalle en MIC/DTA Nro. {$data['mic_dta']} hoja uno de uno, factura
comercial de exportación Nro. {$data['factura_exportacion']}, CRT {$data['crt']} , amparada con
autorización de Importación Permiso Nro. 009694 emitida por el R.E.N.A.R., a favor de
“{$data['razon_social']}” Se deja expresa constancia que el Despacho Aduanero
Provisorio: {$data['provisorio']} y definitivo {$data['definitivo']}, será entregado una
vez conformado por la Autoridad Interviniente, en el – Paso de Jama, Provincia de
Jujuy. Posteriormente se procedió a inspeccionar el estado general del vehículo
mencionado, identificación del mismo, con relación al material transportado, estado de la
carga y estiba de la misma, matafuegos y guía de reacción ante circunstancia de
siniestro, no detectándose anomalía alguna. Consecuentemente se puso en
conocimiento a los nombrados, los Artículos de los Decretos 302/83 y 306/07, que
guardan relación con las medidas de seguridad y consideraciones que debe tener
presentes en el transporte de explosivos - vía carretera, mediante vehículo de carga.
Asimismo, se deja constancia de la apertura del precinto de origen sello aduana
{$data['precinto']}-----------------------------------------------------------------------<br>
Seguidamente se da por terminado el acto, previa lectura que de por sí realizaron todos
los interesados de la presente, se ratifica de todo su contenido, firmando al pié, en
prueba de conformidad y para constancia, de SEIS (6) ejemplares de un mismo tenor,
por ante mi Oficial Actuante que CERTIFICO. -----------------------------------------------------</p>
</table>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<table style="width: 100%; border-collapse: collapse; text-align: center;">
<tr>
<th style="width: 50%;">
<p>NOMBRE DEL CHOFER<br>CONDUCTOR</p>
</th>
<th style="width: 50%;">
<p>ORLANDO SEBASTIAN CRUZ<br>APO – ATA</p>
</th>
</tr>
</table>
<br/>
<br/>
<br/>
<table style="width: 100%; border-collapse: collapse; text-align: center;">
<tr>
<th style="width: 50%;">
<p>SILVIA ELIANA MAMANI<br>AFIP-DGA</p>
</th>
<th style="width: 50%;">
<p>PABLO GERMAN MIGNONE<br>SARGENTO – GNA</p>
</th>
</tr>
</table>
<br/>
<br/>
<br/>
<table style="width: 100%; border-collapse: collapse; text-align: center;">
<tr>
<th style="width: 100%;">
<p>LAURA JOSE IRALA<br>ALFEREZ<br>OFICIAL ACTUANTE-GNA</p>
</th>
</tr>
</table>
EOD;
$pdf->writeHTML($html, true, false, false, false, '');
return new Response($pdf->Output("Formulario Anmac", "S"), 200, array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="Formulario-Anmac.pdf"'
)
);
}
/*
public function sendMessaggeWhatsApp($precarga) {
$chofer = $precarga->getChoferId()->getTelefono();
$ultramsg_token="uzc4beb9g5y20x6j"; // Ultramsg.com token
$instance_id="instance59052"; // Ultramsg.com instance id
$client = new UltraMsg\WhatsAppApi($ultramsg_token,$instance_id);
$to="+549".$chofer;
$body="Interjama informa: Hola " . $precarga->getChoferId()->getNombre();
$api=$client->sendChatMessage($to,$body);
}
*/
public function getAtencionesConPedidoAsignacionNumero() {
$precargas = $this->repository->getAtencionesConPedidoAsignacionNumero();
return $this->toarray($precargas, 'precarga');
}
public function putPrecargaNotificacion($request, $id) {
$precarga = $this->repository->findOneById((int)$id);
$precarga->setNotificacion(1);
$precarga->setRegistro(null);
$precarga = $this->updateAtencion($precarga, $id);
return $precarga;
}
private function obtenerExtencion($path) {
$aux = null;
$ext = explode('.',$path);
if ($ext[1] == 'png') {
$aux = 'PNG';
} elseif ($ext[1] == 'jpeg') {
$aux = 'JPEG';
} elseif ($ext[1] == 'jpg') {
$aux = 'JPG';
}
return $aux;
}
public function downloadArchivosFinalizado($precargaId) {
$path = $this->getPathFiles();
$precarga = $this->getById((int)$precargaId);
// PDF
$pdf = new PDF();
$pdf->SetTitle("trámite_".$precargaId."_finalizado");
$pdf->SetSubject("Archivos de un trámite");
$pdf->setFontSubsetting(true);
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
$pdf->SetFont('helvetica', '', 11, '', true);
$pdf->SetMargins(30, 15, 5);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->setPrintFooter(false);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// Mic-Data
if (COUNT($precarga['archivos']) > 0) {
foreach ($precarga['archivos'] as $archivo) {
$ext = $this->obtenerExtencion($archivo['ruta']);
$pathAux = $path . $precargaId . '/' . $archivo['ruta'];
$pdf->AddPage();
$pdf->Image($pathAux, 0, 0, 200, 200, $ext, '', '', false, 150, '', false, false, 0, false, false, false);
}
}
// Reverso
$pdf->AddPage();
$pathReverso = $path . $precarga['archivo_reverso'];
$ext = $this->obtenerExtencion($precarga['archivo_reverso']);
$pdf->Image($pathReverso, 0, 0, 200, 200, $ext, '', '', false, 150, '', false, false, 0, false, false, false);
return new Response($pdf->Output("Formulario Anmac", "S"), 200, array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="Archivos-tramite.pdf"'
)
);
}
public function getPrecargasByChoferSinFinalizar(int $choferId) {
$precargas = $this->repository->precargasSinFinalizarPorChofer($choferId);
return $this->toarray($precargas,'precarga');
}
public function searchPrecargasFinalizadasConDeudasByCliente($offset, $limit, $sortField, $sortDirection, $searchParam) {
$lp = $this->repository->searchPrecargasFinalizadasConDeudasByCliente($offset, $limit, $sortField, $sortDirection, $searchParam);
$precargas = $this->toarray($lp->getListado(), 'precarga');
$lp->setListado($precargas);
return $lp;
}
public function descargaReciboMultiplePdf($tramitesIds) {
$fechaHoy = date('d-m-Y');
$pdf = new PDF();
$pdf->SetTitle("Recibo Atención");
$pdf->SetSubject("Recibo Atención");
$pdf->setFontSubsetting(true);
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
$pdf->SetFont('helvetica', '', 9, '', true);
$pdf->SetMargins(5, 5, 5);
$pdf->SetHeaderMargin(0);
$pdf->SetFooterMargin(0);
$pdf->setPrintFooter(false);
$precarga1 = $this->getById($tramitesIds[0]);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// Add a page
$pdf->AddPage('P', 'A4');
// Encabezado común para todas las precargas
$html = <<<EOD
<table style="width: 100%; border-top: 1px solid black;border-left: 1px solid black;border-right: 1px solid black;">
<tr>
<th style="text-align: left">
<span></span><br>
<img src="app/images/interjama-logo.jpeg" alt="Interjama" width="300" height="100" />
</th>
<th style="text-align: center">
<span style="font-size: 30px; font-weight: bold;">RECIBO</span><br>
<span style="font-size: 10px;">Original</span>
</th>
<th style="text-align: center">
<span></span><br>
<span style="font-size: 12px; font-weight: bold;">Recibo</span><br>
<span style="font-size: 12px; font-weight: bold;">Nº MULTIPLE</span><br>
<span style="font-size: 12px; font-weight: bold;">{$fechaHoy}</span>
</th>
</tr>
</table>
<br/>
<table style="width: 100%; border-bottom: 1px solid black;border-left: 1px solid black;border-right: 1px solid black;">
<tr>
<th style="text-align: left; border-right: 1px solid black">
<strong style="text-align: left;">Razón Social: </strong>INTERJAMA S.R.L.<br>
<strong style="text-align: left;">Fecha de Emisión: {$fechaHoy}</strong><br>
<strong style="text-align: left;">Domicilio comercial: </strong>Alvear 495 Piso:2 Dpto:C - San Salvador de Jujuy - Jujuy<br>
<strong style="text-align: left;">Sitio web: </strong>www.interjama.com.ar<br>
</th>
<th style="text-align: left">
<strong style="text-align: left;">Condición frente al IVA: IVA Responsable Inscripto</strong><br>
<strong style="text-align: left;">CUIT: </strong>30714865044<br>
<strong style="text-align: left;">Ingresos Brutos: </strong>A-1-55049<br>
<strong style="text-align: left;">Fecha de Inicio de Actividad: </strong>01/07/2015
</th>
</tr>
</table>
<br/>
<div style="width: 100%; border: 0.5px solid black; margin-top: 1px;">
<strong style="margin-left: 10px;">Periodo Facturado Desde:</strong> {$fechaHoy} <strong style="margin-left: 90px;">Hasta:</strong> {$fechaHoy} <strong style="margin-left: 200px;">Fecha de Vto. para el pago:</strong> {$fechaHoy}
</div>
<div style="width: 100%; border: 0.5px solid black; margin-top: 1px;">
<strong style="text-align: left;">CUIT:</strong> {$precarga1['cliente']['cuit']}<br>
<strong style="text-align: left;">Apellido y Nombre / Razón Social</strong> {$precarga1['cliente']['razon_social']}<br>
<strong style="text-align: left;">Condición frente al IVA:</strong> {$precarga1['cliente']['condicion_iva']}<br>
<strong style="text-align: left;">Condición de venta:</strong> Contado/Efectivo
</div>
<br/>
<!-- Empezamos a mostrar los tiposTramites de todas las precargas -->
<table border="0.5">
<tr style="background-color: grey;">
<th>Cantidad</th>
<th>Trámite</th>
<th>Tipo trámite</th>
<th>Importe</th>
<th>Subtotal</th>
</tr>
EOD;
// Iteramos sobre todos los IDs de precarga
$totalAduana = 0;
$subTotal = 0;
$total = 0;
foreach ($tramitesIds as $id) {
$precarga = $this->getById((int)$id);
$totalAduana = $totalAduana + (float)$precarga['aduana'];
$subTotal = $subTotal + (float)$precarga['total'];
$total = $total + (float)$precarga['total'];
$precarga['tiposTramites'] = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaTipoTramitesHandler")->getByPrecarga((int)$id);
$precarga['aduana'] = (!is_null($precarga['aduana']) && !empty($precarga['aduana'])) ? $precarga['aduana'] : 0;
$chofer = $precarga['chofer'];
// Aquí, recorremos los tiposTramites de cada precarga y los agregamos a la tabla
foreach ($precarga['tiposTramites'] as $tipo) {
$html .= <<<EOD
<tr>
<td>1,00</td>
<td>{$tipo['tipos_tramite']['tipo']}</td>
<td>{$tipo['tipos_tramite']['nombre']}</td>
<td>{$tipo['importe']}</td>
<td>{$tipo['importe']}</td>
</tr>
EOD;
}
}
// Cerrar la tabla de los tipos de trámites
$html .= <<<EOD
</table>
<br/>
<!-- Detalle del total por cada precarga -->
<table border="0.5">
<tr>
<th><strong style="margin-left: 0%;"> Imp. Aduana: $:</strong> {$totalAduana}</th>
<th><strong style="margin-left: 30%;"> Subtotal: $</strong> {$subTotal}</th>
<th><strong style="margin-left: 60%;"> Importe Total: $</strong> {$total}</th>
</tr>
</table>
<br/>
EOD;
// Escribir el HTML al PDF
$pdf->writeHTML($html, true, false, false, false, '');
// Retornar el PDF como respuesta
return new Response($pdf->Output("Recibo_Multiple", "S"), 200, array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="Recibo-Multiple.pdf"'
));
}
public function updateDeuda(Request $request){
// Validar que los tramites son un array y que contiene solo valores válidos
$tramitesIds = $request->request->get('tramites');
$comprobante = $request->request->get('comprobante');
// Verificar que 'tramites' es un array de enteros y 'comprobante' no es vacío
if (!is_array($tramitesIds) || empty($tramitesIds)) {
throw new Exception('No se proporcionaron trámites válidos.');
}
foreach ($tramitesIds as $id) {
if (!is_int($id)) {
throw new Exception('El ID del trámite debe ser un valor numérico.');
}
}
if (empty($comprobante)) {
throw new Exception('El comprobante es obligatorio.');
}
// Iniciar la transacción
$this->entityManager->beginTransaction(); // Inicia la transacción
try {
// Iterar sobre los trámites para actualizarlos
foreach ($tramitesIds as $tramiteId) {
// Buscar el trámite
$precarga = $this->repository->findOneById($tramiteId);
// Si no se encuentra el trámite, lanzamos una excepción
if (!$precarga) {
throw new Exception("Trámite con ID {$tramiteId} no encontrado.");
}
// Actualizar el trámite
$precarga->setFechaPago(new \DateTime()); // Establecer la fecha de pago
// Guardar los cambios en el trámite
$this->repository->update($precarga);
}
// Si todo es exitoso, hacer commit de la transacción
$this->entityManager->commit();
return 'Las deudas de los trámites han sido actualizadas correctamente.';
} catch (\Exception $e) {
// Si ocurre un error, hacemos rollback de todos los cambios realizados
$this->entityManager->rollback();
// Lanzamos la excepción para que sea manejada por el controlador
throw new Exception('Error al actualizar las deudas: ' . $e->getMessage());
}
}
public function descargaFacturaAfipMultiplePdf($tramitesIds, $factura) {
$precarga1 = $this->getById($tramitesIds[0]);
if (is_null($precarga1['facturado']) || !$precarga1['facturado']) {
// Iteramos sobre todos los IDs de precarga
$totalAduana = 0;
$subTotal = 0;
$total = 0;
foreach ($tramitesIds as $id) {
$precarga = $this->getById((int)$id);
$totalAduana = $totalAduana + (float)$precarga['aduana'];
$subTotal = $subTotal + (float)$precarga['total'];
$total = $total + (float)$precarga['total'];
$precarga['tiposTramites'] = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaTipoTramitesHandler")->getByPrecarga((int)$id);
}
$fechaHoy = date('d/m/Y');
$tipoFactura = "A";
/*
$afip = new Afip(array(
'CUIT' => 27332574049,
'cert' => 'tramite/cert',
'key' => 'tramite/key'
));
*/
if ($factura == 'A') {
try {
$last_voucher = 1;
//$last_voucher = $afip->ElectronicBilling->GetLastVoucher(1,1);
} catch (Exception $e) {
return $e->getMessage();
}
} elseif ($factura == 'B') {
try {
$last_voucher = 1;
//$last_voucher = $afip->ElectronicBilling->GetLastVoucher(1,6);
} catch (Exception $e) {
return $e->getMessage();
}
}
$valfac = $last_voucher + 1;
$nroComprobante = $this->numeroAddZero($valfac);
$ptoVta = "0001";
$neto = round($precarga['total'] / 1.21, 2);
$iva = round($neto * 0.21, 2);
//Se arma factura A
$data = array(
'CantReg' => 1, // Cantidad de comprobantes a registrar
'PtoVta' => 1, // Punto de venta
'Concepto' => 1, // Concepto del Comprobante: (1)Productos, (2)Servicios, (3)Productos y Servicios
'DocTipo' => 80, // Tipo de documento del comprador (99 consumidor final, ver tipos disponibles)
'DocNro' => $precarga1['cliente']['cuit'], // Número de documento del comprador (0 consumidor final)
'CbteDesde' => $valfac, // Número de comprobante o numero del primer comprobante en caso de ser mas de uno
'CbteHasta' => $valfac, // Número de comprobante o numero del último comprobante en caso de ser mas de uno
'CbteFch' => intval(date('Ymd')), // (Opcional) Fecha del comprobante (yyyymmdd) o fecha actual si es nulo
'ImpTotal' => $total, // Importe total del comprobante
'ImpTotConc' => 0, // Importe neto no gravado
'ImpNeto' => $neto, // Importe neto gravado
'ImpOpEx' => 0, // Importe exento de IVA
'ImpIVA' => $iva, //Importe total de IVA
'ImpTrib' => 0, //Importe total de tributos
'MonId' => 'PES', //Tipo de moneda usada en el comprobante (ver tipos disponibles)('PES' para pesos argentinos)
'MonCotiz' => 1, // Cotización de la moneda usada (1 para pesos argentinos)
'Iva' => array( // (Opcional) Alícuotas asociadas al comprobante
array(
'Id' => 5, // Id del tipo de IVA (5 para 21%)(ver tipos disponibles)
'BaseImp' => $neto, // Base imponible
'Importe' => $iva // Importe
)
),
);
if ($factura == 'A') {
$data['CbteTipo'] = 1;
$codigo = 'Código 01';
} elseif ($factura == 'B') {
$data['CbteTipo'] = 6;
$tipoFactura = "B";
$codigo = 'Código 06';
} else {
//Se arma factura E de exportación
}
try {
/*
$res = $afip->ElectronicBilling->CreateVoucher($data);
$this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McFacturaHandler")->saveFacturaPrecarga($precargaObj, $tipoFactura, $res, $nroComprobante);
$this->updateFacturado($precargaObj);
*/
$res['CAE'] = '987654321';
$res['CAEFchVto'] = '2023-12-31';
} catch (Exception $e) {
return $e->getMessage();
}
$res['CAE']; //CAE asignado el comprobante
$res['CAEFchVto']; //Fecha de vencimiento del CAE (yyyy-mm-dd)
// Fin de sección de factura de AFIP
//Creacion del PDF
// create new PDF document
$pdf = new PDF();
$pdf->SetTitle("Precargas atendidas");
$pdf->SetSubject("Precargas atendidas");
$pdf->setFontSubsetting(true);
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
$pdf->SetFont('helvetica', '', 9, '', true);
$pdf->SetMargins(5,5,5);
$pdf->SetHeaderMargin(0);
$pdf->SetFooterMargin(0);
$pdf->SetPrintFooter(false);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->AddPage('P', 'A4');
// Datos de la empresa emisora de la factura
$html = <<<EOD
<table style="width: 100%; border-top: 1px solid black;border-left: 1px solid black;border-right: 1px solid black;">
<tr>
<th style="text-align: left">
<span></span><br>
<img src="app/images/interjama-logo.jpeg" alt="Interjama" width="300" height="100" />
</th>
<th style="text-align: center">
<span style="font-size: 30px; font-weight: bold;">{$tipoFactura}</span><br>
<span style="font-size: 10px;">{$codigo}</span>
</th>
<th style="text-align: center">
<span></span><br>
<span style="font-size: 12px; font-weight: bold;">Factura</span><br>
<span style="font-size: 12px; font-weight: bold;">Nº {$nroComprobante}</span><br>
<span style="font-size: 12px; font-weight: bold;">{$fechaHoy}</span>
</th>
</tr>
</table>
<table style="width: 100%; border-bottom: 1px solid black;border-left: 1px solid black;border-right: 1px solid black;">
<tr>
<th style="text-align: left; border-right: 1px solid black">
<strong style="text-align: left;">Razón Social: </strong>INTERJAMA S.R.L.<br>
<strong style="text-align: left;">Punto de venta: {$ptoVta} Comp. Nro: {$nroComprobante}</strong><br>
<strong style="text-align: left;">Domicilio comercial: </strong>Alvear 495 Piso:2 Dpto:C - San Salvador de Jujuy - Jujuy<br>
<strong style="text-align: left;">Sitio web: </strong>www.interjama.com.ar<br>
</th>
<th style="text-align: left">
<strong style="text-align: left;">Condición frente al IVA: IVA Responsable Inscripto</strong><br>
<strong style="text-align: left;">CUIT: </strong>30714865044<br>
<strong style="text-align: left;">Ingresos Brutos: </strong>A-1-55049<br>
<strong style="text-align: left;">Fecha de Inicio de Actividad: </strong>01/07/2015
</th>
</tr>
</table>
<br/>
<div style="width: 100%; border: 0.5px solid black; margin-top: 2px;">
<strong style="margin-left: 10px;">Preriodo Facturado Desde:</strong> {$fechaHoy} <strong style="margin-left: 90px;">Hasta:</strong> {$fechaHoy} <strong style="margin-left: 200px;">Fecha de Vto. para el pago:</strong> {$fechaHoy}
</div>
<div style="width: 100%; border: 0.5px solid black; margin-top: 2px;">
<strong style="text-align: left;">CUIT:</strong> {$precarga1['cliente']['cuit']}<br>
<strong style="text-align: left;">Appelidoy Nombre / Razón Social</strong> {$precarga1['cliente']['razon_social']}<br>
<strong style="text-align: left;">Condición frente al IVA:</strong> {$precarga1['cliente']['condicion_iva']}<br>
<strong style="text-align: left;">Condición de venta:</strong> Contado/Efectivo
</div>
<br/>
<table border="0.5">
<tr style="background-color: grey;">
<th>Cantidad</th>
<th>Trámite</th>
<th>Tipo trámite</th>
<th>Importe</th>
<th>Subtotal</th>
</tr>
EOD;
foreach ($tramitesIds as $id) {
$precargaAux = $this->getById((int)$id);
$precargaAux['tiposTramites'] = $this->container->get("Noahtech\Sistemas\InterjamaBundle\Handler\McPrecargaTipoTramitesHandler")->getByPrecarga((int)$id);
// Aquí, recorremos los tiposTramites de cada precarga y los agregamos a la tabla
foreach ($precargaAux['tiposTramites'] as $tipo) {
$html .= <<<EOD
<tr>
<td>1,00</td>
<td>{$tipo['tipos_tramite']['tipo']}</td>
<td>{$tipo['tipos_tramite']['nombre']}</td>
<td>{$tipo['importe']}</td>
<td>{$tipo['importe']}</td>
</tr>
EOD;
}
}
$html .= <<<EOD
</table>
<br/>
<br/>
<table border="0.5">
<tr>
<th><strong style="margin-left: 0%;"> Imp. Aduana: $:</strong> {$totalAduana}</th>
<th><strong style="margin-left: 30%;"> Subtotal: $</strong> {$subTotal}</th>
<th><strong style="margin-left: 60%;"> Importe Total: $</strong> {$total}</th>
</tr>
</table>
<div style="float:right; margin-top: 2px; text-align: right;">
<strong>CAE Nº:</strong> {$res['CAE']}<br>
<strong>Fecha Vto. de CAE:</strong> {$res['CAEFchVto']}
</div>
<br/>
<table style="width: 100%;">
<tr>
<th>
<img src="app/images/qr.png" alt="Código QR" width="50" height="50"/>
</th>
<th>
<img src="app/images/afip-logo.png" alt="Código QR" width="50" height="15"/><br>
<span><b>Comprobante Autorizado</b></span>
</th>
<th>
</th>
<th>
</th>
</tr>
</table>
EOD;
$pdf->writeHTML($html, true, false, false, false, '');
return new Response($pdf->Output("Precarga-Factura", "S"), 200, array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="Precarga-Factura.pdf"'
)
);
} else {
throw new HttpException(409, "La precarga ya se encuentra facturado.");
}
}
}