-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetFOS.php
executable file
·141 lines (116 loc) · 6.2 KB
/
GetFOS.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
require_once ("lib/nusoap.php");
if (!isset($_SESSION['VAR_SESSIONES'])) {
$cliente = new nusoap_client("http://laws.com.co/ws/GetDetailSuscriptorKeys.wsdl", true);
$error = $cliente->getError();
if ($error) {
echo "<h2>Constructor error</h2><pre>" . $error . "</pre>";
}
$array = array("id" => $_SERVER['HTTP_HOST'], "key" => $_SESSION['user_key']);
$result = $cliente->call("GetDataSesion", $array);
if ($cliente->fault) {
echo "<h2>Fault</h2><pre>";
echo "</pre>";
}else{
$error = $cliente->getError();
if ($error) {
echo "<h2>Error</h2><pre>" . $error . "</pre>";
}else {
if ($result == "") {
echo "No se creo el WS";
}else{
$x = explode(",", $result);
if ($x[0] != 'errno') {
$_SESSION["pzhkCSC0XMwpGMT"] = desencriptar($x[0], $_SESSION['user_key']);
$_SESSION["kYg8omRSc1EDj3u"] = desencriptar($x[1], $_SESSION['user_key']);
$_SESSION["1oKU35BSbQ7CG5Q"] = desencriptar($x[2], $_SESSION['user_key']);
$_SESSION["71c029wus3yJWEN"] = desencriptar($x[3], $_SESSION['user_key']);
$_SESSION['VAR_SESSIONES'] = true;
}else{
$_SESSION['VAR_SESSIONES'] = false;
}
}
}
}
}
include_once('../app/basePaths.inc.php');
include_once(ROOT.DS.'DALC'.DS.'/mySql.php');
include_once('../app/controller/consultas.php');
include_once('../app/controller/funciones.php');
$con = new ConexionBaseDatos;
$con->Connect($con);
$c = new Consultas;
$f = new Funciones;
function GetFOS($var) {
global $con;
global $c;
global $f;
$emptyfields = array();
$validationdata = true;
foreach ($var as $key => $value) {
$response = $f->ValidarXMLField(trim($key), trim($value));
if ($response['respuesta'] == "0") {
array_push($emptyfields, $response['mensaje']);
$validationdata = false;
break;
}
}
if(!$validationdata){
return array('respuesta' => '1', 'mensaje' => $emptyfields);
}else{
$str = $f->GetFOS($var);
$sfile= ROOT."/plugins/facturasXML/ws_cos114322419900000000001.xml";
$fp = fopen($sfile,"w");
fwrite($fp,$str);
fclose($fp);
return array('respuesta' => '1', 'mensaje' => "Archivo XML Generado Correctamente $sfile");
}
}
$var = array(
"UBLVersionID" => "UBL 2.0", "ProfileID" => "DIAN 1.0", "ID" => "45910281428", "UUID" => "ae0869bcc9044db987aecbe976187fd3ba0937c",
"IssueDate" => "2015-07-20", "IssueTime" => "00:00:00", "InvoiceTypeCode" => "1",
"Note" => "Set de pruebas = fos0001_700085371_f7999_R469910-459-27223_0C_700085371 2015-07-20 -- número factura fuera de rango
NumFac: 45910281428
FecFac: 20150720000000
ValFac: 97128.00
CodImp1: 01
ValImp1: 15540.48
CodImp2: 02
ValImp2: 0.00
CodImp3: 03
ValImp3: 4021.09
ValImp: 116689.57
NitOFE: 700085371
TipAdq: 22
NumAdq: 11222333
String: 459102814282015072000000097128.000115540.48020.00034021.09116689.577000853712211222333693ff6f2a553c3646a063436fd4dd9ded0311471 ",
"DocumentCurrencyCode" => "COP", "AdditionalAccountID" => "1", "ID2" => "700085371", "Name" => "PJ - 700085371 - Adquiriente FE",
"Department" => "Bolivar", "CitySubdivisionName" => "Centro", "CityName" => "Pasa Caballos", "Line" => " carrera 8 Nº 6C - 60",
"IdentificationCode" => "CO", "TaxLevelCode" => "0", "RegistrationName" => "PJ - 700085371", "AdditionalAccountID2" => "2",
"ID3" => "11222333", "Department2" => "Huila", "CitySubdivisionName2" => "Centro", "CityName2" => "Aipe",
"Line2" => " carrera 8 Nº 6C - 40", "IdentificationCode2" => "CO", "TaxLevelCode2" => "0", "FirstName" => "Primer-N",
"FamilyName" => "Apellido-11222333", "MiddleName" => "Segundo-N", "TaxAmount" => "15540.48", "TaxEvidenceIndicator" => "FALSE",
"TaxableAmount" => "97128", "TaxAmount2" => "15540.48", "Percent" => "16", "ID4" => "01", "TaxAmount3" => "4021.09",
"TaxEvidenceIndicator2" => "FALSE", "TaxableAmount2" => "97128", "TaxAmount4" => "4021.09", "Percent2" => "4.14",
"ID5" => "03", "LineExtensionAmount" => "97128", "TaxExclusiveAmount" => "19561.57", "PayableAmount" => "116689.57",
"ID6" => "01", "InvoicedQuantity" => "456", "LineExtensionAmount2" => "97128", "Description" => "Línea-1 45910281428 fos0001_700085371_f7999_R469910-459-27223",
"PriceAmount" => "213"
);
print_r(GetFOS($var));
function desencriptar($cadena, $key){
$decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($cadena), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
return $decrypted; //Devuelve el string desencriptado
}
#ESTA FUNCION NOS GENERA EL ARCHIVO WSDL QUE ES EL ARCHIVO DE CONFIGURACION DEL SEBSER
$server = new soap_server();
$server->configureWSDL("CrearExpedienteExterno", "urn:CrearExpedienteExterno");
$server->register("GetCrearExpedienteExterno",
array("cedula" => "xsd:string","nit_suscriptor" => "xsd:string","nombre_suscriptor" => "xsd:string","tipo_suscriptor" => "xsd:string","Direccion_suscriptor" => "xsd:string","Telefonos_suscriptor" => "xsd:string","Email_suscriptor" => "xsd:string","radicado" => "xsd:string","dependencia_destino" => "xsd:string","observacion" => "xsd:string","archivo" => "xsd:string","archivo_nombre" => "xsd:string","como_enviar_expediente" => "xsd:string"),
array("return" => "xsd:string"),
"urn:CrearExpedienteExterno",
"urn:CrearExpedienteExterno#GetCrearExpedienteExterno",
"rpc",
"encoded",
"Registra un expediente");
$server->service($HTTP_RAW_POST_DATA);
?>