-
-
Save FraGoTe/79e397d357d57e903bf467da1222d025 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Generar nuevo documentos | |
* | |
* @param serviceLocator $serviceLocator | |
* @param string $preDocumento | |
* @param string $nroDocumento | |
* @param string $rucEmpresa | |
* @param string $razEmpresa | |
* @param string $tipDocPax | |
* @param string $nroDocuPax | |
* @param string $nombrePax | |
* @return array | |
*/ | |
public function generarNuevoDocumento( | |
$serviceLocator, $preDocumento, $nroDocumento, $rucEmpresa = '', $razEmpresa = '', $tipDocPax = '', $nroDocuPax = '', $nombrePax = '' | |
) | |
{ | |
$config = $serviceLocator->get('config'); | |
$webPath = $config['web_path']; | |
$wsUrl = $webPath . 'soap-expose'; | |
$datoReserva = $serviceLocator->get('Application\Model\DocelectronicocabOraTable'); | |
$datosbol = $datoReserva->obtenerDatosReserva($preDocumento, $nroDocumento); | |
$documentoNuevo = array(); | |
foreach ($datosbol as $datbol) { | |
$fecha_doc = date('Y-m-d H:i:s'); | |
$documento = new Documento(); | |
if (empty($datbol['RUC']) || $datbol['RUC'] == '') { | |
if (empty($rucEmpresa) || $rucEmpresa == '') { | |
$tipo_doc = 'BV'; | |
} else { | |
$tipo_doc = 'FA'; | |
} | |
} else { | |
$tipo_doc = 'FA'; | |
} | |
if ($datbol['TOTALIGVMN'] > 0) { | |
$grupo_doc = '1'; | |
$afecto_doc = '1'; | |
} else { | |
$grupo_doc = '2'; | |
$afecto_doc = '2'; | |
} | |
$documento->codigoempresa = '001'; | |
$documento->codigoagencia = '113'; | |
$documento->codigoestacion = 'INET'; | |
$documento->codigousuario = 'INTERNET'; | |
$documento->fechadocumento = $fecha_doc; | |
$documento->tipodocumento = $tipo_doc; | |
$documento->grupodocumento = $grupo_doc; | |
$documento->afectodocumento = $afecto_doc; | |
if (empty($rucEmpresa) || $rucEmpresa == '') { | |
$documento->rucempresa = $datbol['RUC']; | |
$documento->razonempresa = $datbol['RAZON_SOCIAL']; | |
} else { | |
$documento->rucempresa = $rucEmpresa; | |
$documento->razonempresa = $razEmpresa; | |
} | |
if (!empty($tipDocPax)) { | |
$documento->docidentidad = $tipDocPax; | |
} else { | |
$documento->docidentidad = $datbol['TIPO_IDENTIDAD']; | |
} | |
if (!empty($nroDocuPax)) { | |
$documento->numerodocumento = $nroDocuPax; | |
} else { | |
$documento->numerodocumento = $datbol['IDENTIDAD_NUMERO']; | |
} | |
if (!empty($nombrePax)) { | |
$documento->nombres = $nombrePax; | |
} else { | |
$documento->nombres = $datbol['NOMBRE']; | |
} | |
$documento->direccion = null; | |
$documento->tipomoneda = '01'; | |
$documento->tipocambiomd = $datbol['TIPOCAMBIOMD']; | |
$documento->tipocambiome = $datbol['TIPOCAMBIOME']; | |
$documento->totalnetomn = $datbol['TOTALNETOMN']; | |
$documento->totaldescuentomn = $datbol['TOTALDESCUENTOMN']; | |
$documento->totaligvmn = $datbol['TOTALIGVMN']; | |
$documento->totalventamn = $datbol['TOTALVENTAMN']; | |
$documento->totalnetomd = $datbol['TOTALNETOMD']; | |
$documento->totaldescuentomd = $datbol['TOTALDESCUENTOMD']; | |
$documento->totaligvmd = $datbol['TOTALIGVMD']; | |
$documento->totalventamd = $datbol['TOTALVENTAMD']; | |
$documento->totalnetome = $datbol['TOTALNETOME']; | |
$documento->totaldescuentome = $datbol['TOTALDESCUENTOME']; | |
$documento->totaligvme = $datbol['TOTALIGVME']; | |
$documento->totalventame = $datbol['TOTALVENTAME']; | |
$item = new Item(); | |
$item->valornetomn = $datbol['TOTALNETOMN']; | |
$item->valordescuentomn = $datbol['TOTALDESCUENTOMN']; | |
$item->valorigvmn = $datbol['TOTALIGVMN']; | |
$item->valorventamn = $datbol['TOTALVENTAMN']; | |
$item->valornetomd = $datbol['TOTALNETOMD']; | |
$item->valordescuentomd = $datbol['TOTALDESCUENTOMD']; | |
$item->valorigvmd = $datbol['TOTALIGVMD']; | |
$item->valorventamd = $datbol['TOTALVENTAMD']; | |
$item->valornetome = $datbol['TOTALNETOME']; | |
$item->valordescuentome = $datbol['TOTALDESCUENTOME']; | |
$item->valorigvme = $datbol['TOTALIGVME']; | |
$item->valorventame = $datbol['TOTALVENTAME']; | |
$embarque = $datbol['AGENCIA']; | |
$menu = $datbol['MENU']; | |
$puntos = $datbol['PUNTOS']; | |
$descripcion = 'SERVICIO DE TRANSPORTE EN LA RUTA : ' . | |
$datbol['RUTA_ORIGEN'] . ' - ' . | |
$datbol['RUTA_DESTINO'] . | |
' / SERVICIO : ' . | |
$datbol['SERVICIO'] . | |
' / ASIENTO : ' . | |
$datbol['ASIENTO'] . | |
' / PAX : ' . | |
$datbol['PAX'] . | |
' / ' . $datbol['TIPO_IDENTIDAD'] . ' : ' . | |
trim($datbol['IDENTIDAD_NUMERO']) . | |
chr(13) . | |
'LUGAR DE EMBARQUE : ' . | |
strtoupper(trim($embarque)) . | |
' / FECHA : ' . | |
$datbol['FECHA'] . | |
' / HORA : ' . | |
$datbol['HORA']; | |
if ($menu != '-' && !empty($menu)) { | |
if ($puntos != '-' && !empty($puntos)) { | |
$descripcion .= chr(13) . | |
chr(13) . | |
$puntos . | |
' ******** ' . | |
$menu; | |
} else { | |
$descripcion .= chr(13) . | |
chr(13) . | |
$menu; | |
} | |
} else { | |
if ($puntos != '-' && !empty($puntos)) { | |
$descripcion .= chr(13) . | |
chr(13) . | |
$puntos; | |
} | |
} | |
$item->descripcion = $descripcion; | |
$item->item = 1; | |
$documento->items[] = $item; | |
$opt = array( | |
'uri' => $wsUrl, | |
'location' => $wsUrl | |
); | |
$client = new Client(NULL, $opt); | |
$documentoNuevo[] = $client->getDocumento($documento); | |
} | |
return $documentoNuevo; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment