-
Notifications
You must be signed in to change notification settings - Fork 0
/
consumeCaso.php
219 lines (134 loc) · 4.81 KB
/
consumeCaso.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<?php
require_once "/var/www/rest-excel/consultasBD.php";
require_once "/var/www/rest-excel/upload_file.php";
/*
* The routeCaseSGN class save the data on PMT_Tables,
* find appuid of processmaker cases
* and upload files to processmaker through Web services
*/
class routeCaseSGN{
function buscaNomina($rfc_Cliente, $rfc_Pagadora, $path, $params){
$caso = new DBSearch();
$app_uid = $caso->buscarCaso($rfc_Cliente, $rfc_Pagadora);
if($app_uid){
/*
*The subeArchivo method upload the file to processmaker
*/
/********SUBE ARCHIVO SGN******/
$subido = $this->subeArchivo($app_uid, $path);
/*
*The login method is a processmaker web service
*/
/********LOGIN WS PROCESSMAKER******/
$sessionId = $this->login();
/*
*The insertar_SGN method save the info inside data tables
*/
/********ALMACENA INFO DE ARCHIVO SGN******/
$insertado = $caso->insertar_SGN($app_uid, $params);
$continuado = $this->continuarCaso($app_uid, $sessionId);
if(!$continuado)
return "Error al continuar caso";
$caso->actualizarCaso($app_uid);
return $app_uid." ".$sessionId.$insertado.$subido;
}else{
return "No se encontro caso";
}
}
function login(){
ini_set("soap.wsdl_cache_enabled", "1"); // enabling WSDL cache
try {
$user = 'autosystem';
$pass = 'NhiCIfjKFlxVs';
$Endpoint = "http://staging.portal-excel.com:80/sysworkflow/en/classic/services/wsdl2";
$client = new SoapClient($Endpoint);
$params = array('userid'=>$user, 'password'=>$pass );
$result = $client->__SoapCall('login', array($params));
if ( $result->status_code == 0 ) {
return $result->message;
}
}
catch ( Exception $e ){
return false;
}
}
function continuarCaso($app_uid, $sessionId){
try {
$caseId = $app_uid;
$Endpoint = "http://staging.portal-excel.com:80/sysworkflow/en/classic/services/wsdl2";
$client = new SoapClient($Endpoint);
$params = array(array('sessionId'=>$sessionId,'caseId'=>$caseId, 'delIndex'=>'1'));
$result = $client->__SoapCall('routeCase', $params);
if ($result->status_code == 0)
return true;
else
return false;
}
catch ( Exception $e ){
return false;
}
}
function subeArchivo($idCaso,$pathFile)
{
$docUid = '213801913562e773bbeb813098295973';
$idUsuario= '9848340814df501102959b6010421935';
$this->uploader = new uploaderFile();
$this->uploader->upload_file($idCaso, $idUsuario, $pathFile, $docUid);
}
function subeArchivo2($app_uid, $location)
{
$directorio = $location;
$ficheros = scandir($directorio);
$objfile = $this->getValuefile2($ficheros);
$numFile = count($objfile);
for($a=1; $a<=$numFile; $a++){
$arrayfile = $objfile[$a];
}
$fich = $ficheros[$arrayfile];
$directorio2 = $directorio."/".$fich;
$ficheros1 = scandir($directorio2);
$objfile = $this->getValuefile($ficheros1);
$numFile = count($objfile);
for($a=1; $a<=$numFile; $a++){
$objfile_1 = $objfile[$a];
}
$excel = $ficheros1[$objfile_1];
$idCaso = $app_uid;
$idUsuario = '9848340814df501102959b6010421935';
$docUid = '117600019566f0c7a4ca8c7050645875';
$pathFile = $directorio."/".$fich."/".$excel;
$this->uploader = new uploaderFile();
$this->uploader->upload_file($idCaso, $idUsuario, $pathFile, $docUid);
}
function getValuefile2($ficheros)
{
$objfile = array();
$a = 1;
$c = count($ficheros);
for($i=2; $i<3; $i++)
{
if(preg_match('/[a-z]/i', $ficheros[$i]))
{
$objfile[$a] = $i;
$a++;
}
}
return $objfile;
}
function getValuefile($ficheros1)
{
$objfile = array();
$a = 1;
$c = count($ficheros1);
for($i=0; $i< $c; $i++)
{
if(preg_match('/.xls/i', $ficheros1[$i]))
{
$objfile[$a] = $i;
$a++;
}
}
return $objfile;
}
}
?>