chamilo /
chamilo-lms
| 1 | <?php |
||||
| 2 | |||||
| 3 | /** |
||||
| 4 | * Class Sepe. |
||||
| 5 | */ |
||||
| 6 | class Sepe |
||||
| 7 | { |
||||
| 8 | /** |
||||
| 9 | * @param crearCentroInput[] $crearCentroInput |
||||
| 10 | * |
||||
| 11 | * @return array |
||||
| 12 | */ |
||||
| 13 | public function crearCentro($crearCentroInput) |
||||
| 14 | { |
||||
| 15 | /* Tracking log */ |
||||
| 16 | $tableLog = Database::get_main_table('plugin_sepe_log'); |
||||
| 17 | $paramsLog = [ |
||||
| 18 | 'ip' => $_SERVER['REMOTE_ADDR'], |
||||
| 19 | 'action' => "crearCentro", |
||||
| 20 | 'fecha' => date("Y-m-d H:i:s"), |
||||
| 21 | ]; |
||||
| 22 | Database::insert($tableLog, $paramsLog); |
||||
| 23 | /* End tracking log */ |
||||
| 24 | |||||
| 25 | // Code |
||||
| 26 | $crearCentroInput = $crearCentroInput->DATOS_IDENTIFICATIVOS; |
||||
| 27 | $centerOrigin = $crearCentroInput->ID_CENTRO->ORIGEN_CENTRO; |
||||
| 28 | $centerCode = $crearCentroInput->ID_CENTRO->CODIGO_CENTRO; |
||||
| 29 | $centerName = $crearCentroInput->NOMBRE_CENTRO; |
||||
| 30 | $urlPlatform = $crearCentroInput->URL_PLATAFORMA; |
||||
| 31 | $urlTracking = $crearCentroInput->URL_SEGUIMIENTO; |
||||
| 32 | $phone = $crearCentroInput->TELEFONO; |
||||
| 33 | $mail = $crearCentroInput->EMAIL; |
||||
| 34 | |||||
| 35 | if (empty($centerOrigin) || |
||||
| 36 | empty($centerCode) || |
||||
| 37 | empty($centerName) || |
||||
| 38 | empty($urlPlatform) || |
||||
| 39 | empty($urlTracking) || |
||||
| 40 | empty($phone) || |
||||
| 41 | empty($mail) |
||||
| 42 | ) { |
||||
| 43 | error_log('no data'); |
||||
| 44 | |||||
| 45 | return [ |
||||
| 46 | "RESPUESTA_DATOS_CENTRO" => [ |
||||
| 47 | "CODIGO_RETORNO" => "2", |
||||
| 48 | "ETIQUETA_ERROR" => "Error en parametro", |
||||
| 49 | "DATOS_IDENTIFICATIVOS" => $crearCentroInput, |
||||
| 50 | ], |
||||
| 51 | ]; |
||||
| 52 | } |
||||
| 53 | |||||
| 54 | $table = Database::get_main_table('plugin_sepe_center'); |
||||
| 55 | |||||
| 56 | // Check if exists data in table |
||||
| 57 | if (Database::count_rows($table) > 0) { |
||||
|
0 ignored issues
–
show
Deprecated Code
introduced
by
Loading history...
|
|||||
| 58 | // Check if exists actions |
||||
| 59 | $table_actions = Database::get_main_table('plugin_sepe_actions'); |
||||
| 60 | if (Database::count_rows($table_actions) > 0) { |
||||
|
0 ignored issues
–
show
The function
Database::count_rows() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 61 | return [ |
||||
| 62 | "RESPUESTA_DATOS_CENTRO" => [ |
||||
| 63 | "CODIGO_RETORNO" => "1", |
||||
| 64 | "ETIQUETA_ERROR" => "Centro con acciones", |
||||
| 65 | "DATOS_IDENTIFICATIVOS" => $crearCentroInput, |
||||
| 66 | ], |
||||
| 67 | ]; |
||||
| 68 | } else { |
||||
| 69 | $sql = "DELETE FROM $table"; |
||||
| 70 | Database::query($sql); |
||||
| 71 | } |
||||
| 72 | } |
||||
| 73 | |||||
| 74 | $params = [ |
||||
| 75 | 'center_origin' => $centerOrigin, |
||||
| 76 | 'center_code' => $centerCode, |
||||
| 77 | 'center_name' => $centerName, |
||||
| 78 | 'url' => $urlPlatform, |
||||
| 79 | 'tracking_url' => $urlTracking, |
||||
| 80 | 'phone' => $phone, |
||||
| 81 | 'mail' => $mail, |
||||
| 82 | ]; |
||||
| 83 | |||||
| 84 | $id = Database::insert($table, $params); |
||||
| 85 | |||||
| 86 | if (empty($id)) { |
||||
| 87 | return [ |
||||
| 88 | "RESPUESTA_DATOS_CENTRO" => [ |
||||
| 89 | "CODIGO_RETORNO" => "-1", |
||||
| 90 | "ETIQUETA_ERROR" => "Problema base de datos", |
||||
| 91 | "DATOS_IDENTIFICATIVOS" => $crearCentroInput, |
||||
| 92 | ], |
||||
| 93 | ]; |
||||
| 94 | } else { |
||||
| 95 | return [ |
||||
| 96 | "RESPUESTA_DATOS_CENTRO" => [ |
||||
| 97 | "CODIGO_RETORNO" => "0", |
||||
| 98 | "ETIQUETA_ERROR" => "Correcto", |
||||
| 99 | "DATOS_IDENTIFICATIVOS" => $crearCentroInput, |
||||
| 100 | ], |
||||
| 101 | ]; |
||||
| 102 | } |
||||
| 103 | } |
||||
| 104 | |||||
| 105 | /** |
||||
| 106 | * @return stdClass |
||||
| 107 | */ |
||||
| 108 | public function obtenerDatosCentro() |
||||
| 109 | { |
||||
| 110 | /* Tracking Log */ |
||||
| 111 | $tableLog = Database::get_main_table('plugin_sepe_log'); |
||||
| 112 | $paramsLog = [ |
||||
| 113 | 'ip' => $_SERVER['REMOTE_ADDR'], |
||||
| 114 | 'action' => "obtenerDatosCentro", |
||||
| 115 | 'fecha' => date("Y-m-d H:i:s"), |
||||
| 116 | ]; |
||||
| 117 | Database::insert($tableLog, $paramsLog); |
||||
| 118 | /* End tracking log */ |
||||
| 119 | |||||
| 120 | // Code |
||||
| 121 | $table = Database::get_main_table('plugin_sepe_center'); |
||||
| 122 | |||||
| 123 | // Comprobamos si existen datos almacenados previamente |
||||
| 124 | if (Database::count_rows($table) > 0) { |
||||
|
0 ignored issues
–
show
The function
Database::count_rows() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 125 | //Hay datos en la tabla; |
||||
| 126 | $sql = "SELECT * FROM $table;"; |
||||
| 127 | $rs = Database::query($sql); |
||||
| 128 | if (!$rs) { |
||||
|
0 ignored issues
–
show
|
|||||
| 129 | return [ |
||||
| 130 | "CODIGO_RETORNO" => "-1", |
||||
| 131 | "ETIQUETA_ERROR" => "Problema acceso base de datos", |
||||
| 132 | "DATOS_IDENTIFICATIVOS" => '', |
||||
| 133 | ]; |
||||
| 134 | } else { |
||||
| 135 | $row = Database::fetch_assoc($rs); |
||||
| 136 | $centerOrigin = $row['center_origin']; |
||||
| 137 | $centerCode = $row['center_code']; |
||||
| 138 | $centerName = $row['center_name']; |
||||
| 139 | $urlPlatform = $row['url']; |
||||
| 140 | $urlTracking = $row['tracking_url']; |
||||
| 141 | $phone = $row['phone']; |
||||
| 142 | $mail = $row['mail']; |
||||
| 143 | |||||
| 144 | $data = new stdClass(); |
||||
| 145 | $data->ID_CENTRO = new stdClass(); |
||||
| 146 | $data->ID_CENTRO->ORIGEN_CENTRO = $centerOrigin; |
||||
| 147 | $data->ID_CENTRO->CODIGO_CENTRO = $centerCode; |
||||
| 148 | $data->NOMBRE_CENTRO = $centerName; |
||||
| 149 | $data->URL_PLATAFORMA = $urlPlatform; |
||||
| 150 | $data->URL_SEGUIMIENTO = $urlTracking; |
||||
| 151 | $data->TELEFONO = $phone; |
||||
| 152 | $data->EMAIL = $mail; |
||||
| 153 | |||||
| 154 | $obj = new stdClass(); |
||||
| 155 | $obj->CODIGO_RETORNO = 0; |
||||
| 156 | $obj->ETIQUETA_ERROR = 'Correcto'; |
||||
| 157 | $obj->DATOS_IDENTIFICATIVOS = new SoapVar($data, SOAP_ENC_OBJECT); |
||||
| 158 | |||||
| 159 | $result = new stdClass(); |
||||
| 160 | $result->RESPUESTA_DATOS_CENTRO = new SoapVar($obj, SOAP_ENC_OBJECT); |
||||
| 161 | |||||
| 162 | return $result; |
||||
| 163 | } |
||||
| 164 | } else { |
||||
| 165 | $data = new stdClass(); |
||||
| 166 | $data->ID_CENTRO = new stdClass(); |
||||
| 167 | $data->ID_CENTRO->ORIGEN_CENTRO = ''; |
||||
| 168 | $data->ID_CENTRO->CODIGO_CENTRO = ''; |
||||
| 169 | $data->NOMBRE_CENTRO = ''; |
||||
| 170 | $data->URL_PLATAFORMA = ''; |
||||
| 171 | $data->URL_SEGUIMIENTO = ''; |
||||
| 172 | $data->TELEFONO = ''; |
||||
| 173 | $data->EMAIL = ''; |
||||
| 174 | |||||
| 175 | $obj = new stdClass(); |
||||
| 176 | $obj->CODIGO_RETORNO = 0; |
||||
| 177 | $obj->ETIQUETA_ERROR = 'Correcto'; |
||||
| 178 | $obj->DATOS_IDENTIFICATIVOS = new SoapVar($data, SOAP_ENC_OBJECT); |
||||
| 179 | |||||
| 180 | $result = new stdClass(); |
||||
| 181 | $result->RESPUESTA_DATOS_CENTRO = new SoapVar($obj, SOAP_ENC_OBJECT); |
||||
| 182 | //error_log('Sin datos en la BD'); |
||||
| 183 | /* |
||||
| 184 | $data = new stdClass(); |
||||
| 185 | $obj = new stdClass(); |
||||
| 186 | $obj->CODIGO_RETORNO = '-1'; |
||||
| 187 | $obj->ETIQUETA_ERROR = 'Sin datos'; |
||||
| 188 | $obj->DATOS_IDENTIFICATIVOS = new SoapVar($data, SOAP_ENC_OBJECT); |
||||
| 189 | |||||
| 190 | $result = new stdClass(); |
||||
| 191 | $result->RESPUESTA_DATOS_CENTRO = new SoapVar($obj, SOAP_ENC_OBJECT); |
||||
| 192 | */ |
||||
| 193 | return $result; |
||||
| 194 | } |
||||
| 195 | } |
||||
| 196 | |||||
| 197 | /** |
||||
| 198 | * @param $crearAccionInput |
||||
| 199 | * |
||||
| 200 | * @return array |
||||
| 201 | */ |
||||
| 202 | public function crearAccion($crearAccionInput) |
||||
| 203 | { |
||||
| 204 | /* Tracking Log */ |
||||
| 205 | $tableLog = Database::get_main_table('plugin_sepe_log'); |
||||
| 206 | $paramsLog = [ |
||||
| 207 | 'ip' => $_SERVER['REMOTE_ADDR'], |
||||
| 208 | 'action' => "crearAccion", |
||||
| 209 | 'fecha' => date("Y-m-d H:i:s"), |
||||
| 210 | ]; |
||||
| 211 | Database::insert($tableLog, $paramsLog); |
||||
| 212 | /* End tracking log */ |
||||
| 213 | |||||
| 214 | $array = json_decode(json_encode($crearAccionInput), true); |
||||
| 215 | $crearAccionInputArray = (array) $array; |
||||
| 216 | // Code |
||||
| 217 | $actionOrigin = $crearAccionInput->ACCION_FORMATIVA->ID_ACCION->ORIGEN_ACCION; |
||||
| 218 | $actionCode = $crearAccionInput->ACCION_FORMATIVA->ID_ACCION->CODIGO_ACCION; |
||||
| 219 | $situation = $crearAccionInput->ACCION_FORMATIVA->SITUACION; |
||||
| 220 | $specialtyOrigin = $crearAccionInput->ACCION_FORMATIVA->ID_ESPECIALIDAD_PRINCIPAL->ORIGEN_ESPECIALIDAD; |
||||
| 221 | $professionalArea = $crearAccionInput->ACCION_FORMATIVA->ID_ESPECIALIDAD_PRINCIPAL->AREA_PROFESIONAL; |
||||
| 222 | $specialtyCode = $crearAccionInput->ACCION_FORMATIVA->ID_ESPECIALIDAD_PRINCIPAL->CODIGO_ESPECIALIDAD; |
||||
| 223 | $duration = $crearAccionInput->ACCION_FORMATIVA->DURACION; |
||||
| 224 | $startDate = $crearAccionInput->ACCION_FORMATIVA->FECHA_INICIO; |
||||
| 225 | $endDate = $crearAccionInput->ACCION_FORMATIVA->FECHA_FIN; |
||||
| 226 | $fullItineraryIndicator = $crearAccionInput->ACCION_FORMATIVA->IND_ITINERARIO_COMPLETO; |
||||
| 227 | $financingType = $crearAccionInput->ACCION_FORMATIVA->TIPO_FINANCIACION; |
||||
| 228 | $attendeesCount = $crearAccionInput->ACCION_FORMATIVA->NUMERO_ASISTENTES; |
||||
| 229 | $actionName = $crearAccionInput->ACCION_FORMATIVA->DESCRIPCION_ACCION->DENOMINACION_ACCION; |
||||
| 230 | $globalInfo = $crearAccionInput->ACCION_FORMATIVA->DESCRIPCION_ACCION->INFORMACION_GENERAL; |
||||
| 231 | $schedule = $crearAccionInput->ACCION_FORMATIVA->DESCRIPCION_ACCION->HORARIOS; |
||||
| 232 | $requerements = $crearAccionInput->ACCION_FORMATIVA->DESCRIPCION_ACCION->REQUISITOS; |
||||
| 233 | $contactAction = $crearAccionInput->ACCION_FORMATIVA->DESCRIPCION_ACCION->CONTACTO_ACCION; |
||||
| 234 | |||||
| 235 | if (empty($actionOrigin) || empty($actionCode)) { |
||||
| 236 | error_log('2 - error en parametros - l244'); |
||||
| 237 | |||||
| 238 | return [ |
||||
| 239 | "RESPUESTA_OBT_ACCION" => [ |
||||
| 240 | "CODIGO_RETORNO" => "2", |
||||
| 241 | "ETIQUETA_ERROR" => "Error en parametro", |
||||
| 242 | "ACCION_FORMATIVA" => $crearAccionInputArray['ACCION_FORMATIVA'], |
||||
| 243 | ], |
||||
| 244 | ]; |
||||
| 245 | } |
||||
| 246 | |||||
| 247 | // Comprobamos si existen datos almacenados previamente |
||||
| 248 | $table = Database::get_main_table('plugin_sepe_actions'); |
||||
| 249 | $actionOrigin = Database::escape_string($actionOrigin); |
||||
| 250 | $actionCode = Database::escape_string($actionCode); |
||||
| 251 | |||||
| 252 | $sql = "SELECT action_origin FROM $table |
||||
| 253 | WHERE action_origin='".$actionOrigin."' AND action_code='".$actionCode."';"; |
||||
| 254 | $rs = Database::query($sql); |
||||
| 255 | |||||
| 256 | if (Database::num_rows($rs) > 0) { |
||||
| 257 | return [ |
||||
| 258 | "RESPUESTA_OBT_ACCION" => [ |
||||
| 259 | "CODIGO_RETORNO" => "1", |
||||
| 260 | "ETIQUETA_ERROR" => "Acción existente", |
||||
| 261 | "ACCION_FORMATIVA" => $crearAccionInputArray['ACCION_FORMATIVA'], |
||||
| 262 | ], |
||||
| 263 | ]; |
||||
| 264 | } |
||||
| 265 | |||||
| 266 | $startDate = self::fixDate($startDate); |
||||
| 267 | $endDate = self::fixDate($endDate); |
||||
| 268 | |||||
| 269 | $params = [ |
||||
| 270 | 'action_origin' => $actionOrigin, |
||||
| 271 | 'action_code' => $actionCode, |
||||
| 272 | 'situation' => $situation, |
||||
| 273 | 'specialty_origin' => $specialtyOrigin, |
||||
| 274 | 'professional_area' => $professionalArea, |
||||
| 275 | 'specialty_code' => $specialtyCode, |
||||
| 276 | 'duration' => $duration, |
||||
| 277 | 'start_date' => $startDate, |
||||
| 278 | 'end_date' => $endDate, |
||||
| 279 | 'full_itinerary_indicator' => $fullItineraryIndicator, |
||||
| 280 | 'financing_type' => $financingType, |
||||
| 281 | 'attendees_count' => $attendeesCount, |
||||
| 282 | 'action_name' => $actionName, |
||||
| 283 | 'global_info' => $globalInfo, |
||||
| 284 | 'schedule' => $schedule, |
||||
| 285 | 'requirements' => $requerements, |
||||
| 286 | 'contact_actio' => $contactAction, |
||||
| 287 | ]; |
||||
| 288 | |||||
| 289 | $actionId = Database::insert($table, $params); |
||||
| 290 | |||||
| 291 | if (!empty($actionId)) { |
||||
| 292 | return [ |
||||
| 293 | "RESPUESTA_OBT_ACCION" => [ |
||||
| 294 | "CODIGO_RETORNO" => "-1", |
||||
| 295 | "ETIQUETA_ERROR" => "Problema base de datos - insertando acciones formativas", |
||||
| 296 | "ACCION_FORMATIVA" => $crearAccionInputArray['ACCION_FORMATIVA'], |
||||
| 297 | ], |
||||
| 298 | ]; |
||||
| 299 | } |
||||
| 300 | |||||
| 301 | // DATOS ESPECIALIDADES DE LA ACCION |
||||
| 302 | $table = Database::get_main_table('plugin_sepe_specialty'); |
||||
| 303 | |||||
| 304 | $specialties = $crearAccionInput->ACCION_FORMATIVA->ESPECIALIDADES_ACCION; |
||||
| 305 | foreach ($specialties as $specialtyList) { |
||||
| 306 | if (!is_array($specialtyList)) { |
||||
| 307 | $auxList = []; |
||||
| 308 | $auxList[] = $specialtyList; |
||||
| 309 | $specialtyList = $auxList; |
||||
| 310 | } |
||||
| 311 | foreach ($specialtyList as $specialty) { |
||||
| 312 | $specialtyOrigin = $specialty->ID_ESPECIALIDAD->ORIGEN_ESPECIALIDAD; |
||||
| 313 | $professionalArea = $specialty->ID_ESPECIALIDAD->AREA_PROFESIONAL; |
||||
| 314 | $specialtyCode = $specialty->ID_ESPECIALIDAD->CODIGO_ESPECIALIDAD; |
||||
| 315 | $centerOrigin = $specialty->CENTRO_IMPARTICION->ORIGEN_CENTRO; |
||||
| 316 | $centerCode = $specialty->CENTRO_IMPARTICION->CODIGO_CENTRO; |
||||
| 317 | $startDate = $specialty->FECHA_INICIO; |
||||
| 318 | $endDate = $specialty->FECHA_FIN; |
||||
| 319 | |||||
| 320 | $modalityImpartition = $specialty->MODALIDAD_IMPARTICION; |
||||
| 321 | $classroomHours = $specialty->DATOS_DURACION->HORAS_PRESENCIAL; |
||||
| 322 | $distanceHours = $specialty->DATOS_DURACION->HORAS_TELEFORMACION; |
||||
| 323 | |||||
| 324 | $morningParticipansNumber = null; |
||||
| 325 | $morningAccessNumber = null; |
||||
| 326 | $morningTotalDuration = null; |
||||
| 327 | |||||
| 328 | if (isset($specialty->USO->HORARIO_MANANA)) { |
||||
| 329 | $morningParticipansNumber = $specialty->USO->HORARIO_MANANA->NUM_PARTICIPANTES; |
||||
| 330 | $morningAccessNumber = $specialty->USO->HORARIO_MANANA->NUMERO_ACCESOS; |
||||
| 331 | $morningTotalDuration = $specialty->USO->HORARIO_MANANA->DURACION_TOTAL; |
||||
| 332 | } |
||||
| 333 | |||||
| 334 | $afternoonParticipantNumber = null; |
||||
| 335 | $afternoonAccessNumber = null; |
||||
| 336 | $afternoonTotalDuration = null; |
||||
| 337 | |||||
| 338 | if (isset($specialty->USO->HORARIO_TARDE)) { |
||||
| 339 | $afternoonParticipantNumber = $specialty->USO->HORARIO_TARDE->NUM_PARTICIPANTES; |
||||
| 340 | $afternoonAccessNumber = $specialty->USO->HORARIO_TARDE->NUMERO_ACCESOS; |
||||
| 341 | $afternoonTotalDuration = $specialty->USO->HORARIO_TARDE->DURACION_TOTAL; |
||||
| 342 | } |
||||
| 343 | |||||
| 344 | $nightParticipantsNumber = null; |
||||
| 345 | $nightAccessNumber = null; |
||||
| 346 | $nightTotalDuration = null; |
||||
| 347 | |||||
| 348 | if (isset($specialty->USO->HORARIO_NOCHE)) { |
||||
| 349 | $nightParticipantsNumber = $specialty->USO->HORARIO_NOCHE->NUM_PARTICIPANTES; |
||||
| 350 | $nightAccessNumber = $specialty->USO->HORARIO_NOCHE->NUMERO_ACCESOS; |
||||
| 351 | $nightTotalDuration = $specialty->USO->HORARIO_NOCHE->DURACION_TOTAL; |
||||
| 352 | } |
||||
| 353 | |||||
| 354 | $attendeesCount = null; |
||||
| 355 | $learningActivityCount = null; |
||||
| 356 | $attemptCount = null; |
||||
| 357 | $evaluationActivityCount = null; |
||||
| 358 | |||||
| 359 | if (isset($specialty->USO->SEGUIMIENTO_EVALUACION)) { |
||||
| 360 | $attendeesCount = $specialty->USO->SEGUIMIENTO_EVALUACION->NUM_PARTICIPANTES; |
||||
| 361 | $learningActivityCount = $specialty->USO->SEGUIMIENTO_EVALUACION->NUMERO_ACTIVIDADES_APRENDIZAJE; |
||||
| 362 | $attemptCount = $specialty->USO->SEGUIMIENTO_EVALUACION->NUMERO_INTENTOS; |
||||
| 363 | $evaluationActivityCount = $specialty->USO->SEGUIMIENTO_EVALUACION->NUMERO_ACTIVIDADES_EVALUACION; |
||||
| 364 | } |
||||
| 365 | |||||
| 366 | $startDate = self::fixDate($startDate); |
||||
| 367 | $endDate = self::fixDate($endDate); |
||||
| 368 | |||||
| 369 | $params = [ |
||||
| 370 | 'action_id' => $actionId, |
||||
| 371 | 'specialty_origin' => $specialtyOrigin, |
||||
| 372 | 'professional_area' => $professionalArea, |
||||
| 373 | 'specialty_code' => $specialtyCode, |
||||
| 374 | 'center_origin' => $centerOrigin, |
||||
| 375 | 'center_code' => $centerCode, |
||||
| 376 | 'start_date' => $startDate, |
||||
| 377 | 'end_date' => $endDate, |
||||
| 378 | 'modality_impartition' => $modalityImpartition, |
||||
| 379 | 'classroom_hours' => $classroomHours, |
||||
| 380 | 'distance_hours' => $distanceHours, |
||||
| 381 | 'mornings_participants_number' => $morningParticipansNumber, |
||||
| 382 | 'mornings_access_number' => $morningAccessNumber, |
||||
| 383 | 'morning_total_duration' => $morningTotalDuration, |
||||
| 384 | 'afternoon_participants_number' => $afternoonParticipantNumber, |
||||
| 385 | 'afternoon_access_number' => $afternoonAccessNumber, |
||||
| 386 | 'afternoon_total_duration' => $afternoonTotalDuration, |
||||
| 387 | 'night_participants_number' => $nightParticipantsNumber, |
||||
| 388 | 'night_access_number' => $nightAccessNumber, |
||||
| 389 | 'night_total_duration' => $nightTotalDuration, |
||||
| 390 | 'attendees_count' => $attendeesCount, |
||||
| 391 | 'learning_activity_count' => $learningActivityCount, |
||||
| 392 | 'attempt_count' => $attemptCount, |
||||
| 393 | 'evaluation_activity_count' => $evaluationActivityCount, |
||||
| 394 | ]; |
||||
| 395 | |||||
| 396 | $specialtyId = Database::insert($table, $params); |
||||
| 397 | |||||
| 398 | if (empty($specialtyId)) { |
||||
| 399 | return [ |
||||
| 400 | "RESPUESTA_OBT_ACCION" => [ |
||||
| 401 | "CODIGO_RETORNO" => "-1", |
||||
| 402 | "ETIQUETA_ERROR" => "Problema base de datos - insertando datos de especialidad de la accion", |
||||
| 403 | "ACCION_FORMATIVA" => $crearAccionInputArray['ACCION_FORMATIVA'], |
||||
| 404 | ], |
||||
| 405 | ]; |
||||
| 406 | } |
||||
| 407 | |||||
| 408 | if ($specialtyId) { |
||||
| 409 | $tableSpecialtyClassroom = Database::get_main_table('plugin_sepe_specialty_classroom'); |
||||
| 410 | $tableCenters = Database::get_main_table('plugin_sepe_centers'); |
||||
| 411 | foreach ($specialty->CENTROS_SESIONES_PRESENCIALES->CENTRO_PRESENCIAL as $centroList) { |
||||
| 412 | if (!is_array($centroList)) { |
||||
| 413 | $auxList = []; |
||||
| 414 | $auxList[] = $centroList; |
||||
| 415 | $centroList = $auxList; |
||||
| 416 | } |
||||
| 417 | foreach ($centroList as $centro) { |
||||
| 418 | $centerOrigin = $centro->ORIGEN_CENTRO; |
||||
| 419 | $centerCode = $centro->CODIGO_CENTRO; |
||||
| 420 | $centerOrigin = Database::escape_string($centerOrigin); |
||||
| 421 | $centerCode = Database::escape_string($centerCode); |
||||
| 422 | $sql = "SELECT id FROM $tableCenters |
||||
| 423 | WHERE center_origin='".$centerOrigin."' AND center_code='".$centerCode."';"; |
||||
| 424 | $res = Database::query($sql); |
||||
| 425 | if (Database::num_rows($res) > 0) { |
||||
| 426 | $aux_row = Database::fetch_assoc($res); |
||||
| 427 | $centerId = $aux_row['id']; |
||||
| 428 | } else { |
||||
| 429 | $sql = "INSERT INTO $tableCenters (center_origin, center_code) |
||||
| 430 | VALUES ('".$centerOrigin."','".$centerCode."');"; |
||||
| 431 | Database::query($sql); |
||||
| 432 | $centerId = Database::insert_id(); |
||||
| 433 | } |
||||
| 434 | $sql = "INSERT INTO $tableSpecialtyClassroom (specialty_id, center_id) |
||||
| 435 | VALUES ('".$specialtyId."','".$centerId."')"; |
||||
| 436 | Database::query($sql); |
||||
| 437 | $id = Database::insert_id(); |
||||
| 438 | |||||
| 439 | if (empty($id)) { |
||||
| 440 | return [ |
||||
| 441 | "RESPUESTA_OBT_ACCION" => [ |
||||
| 442 | "CODIGO_RETORNO" => "-1", |
||||
| 443 | "ETIQUETA_ERROR" => "Problema base de datos - insertando centro presenciales", |
||||
| 444 | "ACCION_FORMATIVA" => $crearAccionInputArray['ACCION_FORMATIVA'], |
||||
| 445 | ], |
||||
| 446 | ]; |
||||
| 447 | } |
||||
| 448 | } |
||||
| 449 | } |
||||
| 450 | |||||
| 451 | $tableTutors = Database::get_main_table('plugin_sepe_tutors'); |
||||
| 452 | $tableSpecialityTutors = Database::get_main_table('plugin_sepe_specialty_tutors'); |
||||
| 453 | |||||
| 454 | if (!empty($specialty->TUTORES_FORMADORES)) { |
||||
| 455 | foreach ($specialty->TUTORES_FORMADORES as $tutorList) { |
||||
| 456 | if (!is_array($tutorList)) { |
||||
| 457 | $auxList = []; |
||||
| 458 | $auxList[] = $tutorList; |
||||
| 459 | $tutorList = $auxList; |
||||
| 460 | } |
||||
| 461 | foreach ($tutorList as $tutor) { |
||||
| 462 | $documentType = $tutor->ID_TUTOR->TIPO_DOCUMENTO; |
||||
| 463 | $documentNumber = $tutor->ID_TUTOR->NUM_DOCUMENTO; |
||||
| 464 | $documentLetter = $tutor->ID_TUTOR->LETRA_NIF; |
||||
| 465 | $tutorAccreditation = $tutor->ACREDITACION_TUTOR; |
||||
| 466 | $professionalExperience = $tutor->EXPERIENCIA_PROFESIONAL; |
||||
| 467 | $teachingCompetence = $tutor->COMPETENCIA_DOCENTE; |
||||
| 468 | $experienceTeleforming = $tutor->EXPERIENCIA_MODALIDAD_TELEFORMACION; |
||||
| 469 | $trainingTeleforming = $tutor->FORMACION_MODALIDAD_TELEFORMACION; |
||||
| 470 | |||||
| 471 | $documentType = Database::escape_string($documentType); |
||||
| 472 | $documentNumber = Database::escape_string($documentNumber); |
||||
| 473 | $documentLetter = Database::escape_string($documentLetter); |
||||
| 474 | |||||
| 475 | /* check tutor not exists */ |
||||
| 476 | $sql = "SELECT id FROM $tableTutors |
||||
| 477 | WHERE |
||||
| 478 | document_type='".$documentType."' AND |
||||
| 479 | document_number='".$documentNumber."' AND |
||||
| 480 | document_letter='".$documentLetter."';"; |
||||
| 481 | $res = Database::query($sql); |
||||
| 482 | if (Database::num_rows($res) > 0) { |
||||
| 483 | $aux_row = Database::fetch_assoc($res); |
||||
| 484 | $tutorId = $aux_row['id']; |
||||
| 485 | } else { |
||||
| 486 | $sql = "INSERT INTO $tableTutors (document_type, document_number, document_letter) |
||||
| 487 | VALUES ('".$documentType."','".$documentNumber."','".$documentLetter."');"; |
||||
| 488 | Database::query($sql); |
||||
| 489 | $tutorId = Database::insert_id(); |
||||
| 490 | } |
||||
| 491 | if (empty($tutorId)) { |
||||
| 492 | return [ |
||||
| 493 | "RESPUESTA_OBT_ACCION" => [ |
||||
| 494 | "CODIGO_RETORNO" => "-1", |
||||
| 495 | "ETIQUETA_ERROR" => "Problema base de datos - insertando tutores", |
||||
| 496 | "ACCION_FORMATIVA" => $crearAccionInputArray['ACCION_FORMATIVA'], |
||||
| 497 | ], |
||||
| 498 | ]; |
||||
| 499 | } |
||||
| 500 | |||||
| 501 | $params = [ |
||||
| 502 | 'specialty_id' => $specialtyId, |
||||
| 503 | 'tutor_id' => $tutorId, |
||||
| 504 | 'tutor_accreditation' => $tutorAccreditation, |
||||
| 505 | 'professional_experience' => $professionalExperience, |
||||
| 506 | 'teaching_competence' => $teachingCompetence, |
||||
| 507 | 'experience_teleforming' => $experienceTeleforming, |
||||
| 508 | 'training_teleforming' => $trainingTeleforming, |
||||
| 509 | ]; |
||||
| 510 | Database::insert($tableSpecialityTutors, $params); |
||||
| 511 | } |
||||
| 512 | } |
||||
| 513 | } |
||||
| 514 | } |
||||
| 515 | } |
||||
| 516 | } |
||||
| 517 | |||||
| 518 | // DATOS PARTICIPANTES |
||||
| 519 | $tableParticipants = Database::get_main_table('plugin_sepe_participants'); |
||||
| 520 | $tableTutorsCompany = Database::get_main_table('plugin_sepe_tutors_company'); |
||||
| 521 | $participants = $crearAccionInput->ACCION_FORMATIVA->PARTICIPANTES; |
||||
| 522 | foreach ($participants as $participantList) { |
||||
| 523 | if (!is_array($participantList)) { |
||||
| 524 | $auxList = []; |
||||
| 525 | $auxList[] = $participantList; |
||||
| 526 | $participantList = $auxList; |
||||
| 527 | } |
||||
| 528 | foreach ($participantList as $participant) { |
||||
| 529 | $documentType = $participant->ID_PARTICIPANTE->TIPO_DOCUMENTO; |
||||
| 530 | $documentNumber = $participant->ID_PARTICIPANTE->NUM_DOCUMENTO; |
||||
| 531 | $documentLetter = $participant->ID_PARTICIPANTE->LETRA_NIF; |
||||
| 532 | $keyCompetence = $participant->INDICADOR_COMPETENCIAS_CLAVE; |
||||
| 533 | $contractId = null; |
||||
| 534 | $companyFiscalNumber = null; |
||||
| 535 | $documentTypeCompany = null; |
||||
| 536 | $documentNumberCompany = null; |
||||
| 537 | $documentLetterCompany = null; |
||||
| 538 | $documentTypeTraining = null; |
||||
| 539 | $documentNumberTraining = null; |
||||
| 540 | $documentLetterTraining = null; |
||||
| 541 | $tutorIdCompany = null; |
||||
| 542 | $tutorIdTraining = null; |
||||
| 543 | |||||
| 544 | if (isset($participant->CONTRATO_FORMACION)) { |
||||
| 545 | $contractId = isset($participant->CONTRATO_FORMACION->ID_CONTRATO_CFA) ? $participant->CONTRATO_FORMACION->ID_CONTRATO_CFA : null; |
||||
| 546 | $companyFiscalNumber = isset($participant->CONTRATO_FORMACION->CIF_EMPRESA) ? $participant->CONTRATO_FORMACION->CIF_EMPRESA : null; |
||||
| 547 | $documentTypeCompany = isset($participant->CONTRATO_FORMACION->ID_TUTOR_EMPRESA->TIPO_DOCUMENTO) ? $participant->CONTRATO_FORMACION->ID_TUTOR_EMPRESA->TIPO_DOCUMENTO : null; |
||||
| 548 | $documentNumberCompany = isset($participant->CONTRATO_FORMACION->ID_TUTOR_EMPRESA->NUM_DOCUMENTO) ? $participant->CONTRATO_FORMACION->ID_TUTOR_EMPRESA->NUM_DOCUMENTO : null; |
||||
| 549 | $documentLetterCompany = isset($participant->CONTRATO_FORMACION->ID_TUTOR_EMPRESA->LETRA_NIF) ? $participant->CONTRATO_FORMACION->ID_TUTOR_EMPRESA->LETRA_NIF : null; |
||||
| 550 | if (!empty($documentTypeCompany) || !empty($documentNumberCompany) || !empty($documentLetterCompany)) { |
||||
| 551 | $tmp_e = Database::query('SELECT id FROM '.$tableTutorsCompany.' WHERE document_type="'.$documentTypeCompany.'" AND document_number="'.$documentNumberCompany.'" AND document_letter="'.$documentLetterCompany.'";'); |
||||
| 552 | if (Database::num_rows($tmp_e) > 0) { |
||||
| 553 | $row_tmp = Database::fetch_assoc($tmp_e); |
||||
| 554 | $tutorIdCompany = $row_tmp['id']; |
||||
| 555 | Database::query("UPDATE $tableTutorsCompany SET company='1' WHERE id='".$tutorIdCompany."'"); |
||||
| 556 | } else { |
||||
| 557 | $params_tmp = [ |
||||
| 558 | 'document_type' => $documentTypeCompany, |
||||
| 559 | 'document_number' => $documentNumberCompany, |
||||
| 560 | 'document_letter' => $documentLetterCompany, |
||||
| 561 | 'company' => '1', |
||||
| 562 | ]; |
||||
| 563 | $tutorIdCompany = Database::insert($tableTutorsCompany, $params_tmp); |
||||
| 564 | } |
||||
| 565 | } |
||||
| 566 | |||||
| 567 | $documentTypeTraining = isset($participant->CONTRATO_FORMACION->ID_TUTOR_FORMACION->TIPO_DOCUMENTO) ? $participant->CONTRATO_FORMACION->ID_TUTOR_FORMACION->TIPO_DOCUMENTO : null; |
||||
| 568 | $documentNumberTraining = isset($participant->CONTRATO_FORMACION->ID_TUTOR_FORMACION->NUM_DOCUMENTO) ? $participant->CONTRATO_FORMACION->ID_TUTOR_FORMACION->NUM_DOCUMENTO : null; |
||||
| 569 | $documentLetterTraining = isset($participant->CONTRATO_FORMACION->ID_TUTOR_FORMACION->LETRA_NIF) ? $participant->CONTRATO_FORMACION->ID_TUTOR_FORMACION->LETRA_NIF : null; |
||||
| 570 | if (!empty($documentTypeTraining) || !empty($documentNumberTraining) || !empty($documentLetterTraining)) { |
||||
| 571 | $documentTypeTraining = Database::escape_string($documentTypeTraining); |
||||
| 572 | $documentNumberTraining = Database::escape_string($documentNumberTraining); |
||||
| 573 | $documentLetterTraining = Database::escape_string($documentLetterTraining); |
||||
| 574 | $tmp_f = Database::query( |
||||
| 575 | ' |
||||
| 576 | SELECT id FROM '.$tableTutorsCompany.' |
||||
| 577 | WHERE |
||||
| 578 | document_type="'.$documentTypeTraining.'" AND |
||||
| 579 | document_number="'.$documentNumberTraining.'" AND |
||||
| 580 | document_letter="'.$documentLetterTraining.'";' |
||||
| 581 | ); |
||||
| 582 | if (Database::num_rows($tmp_f) > 0) { |
||||
| 583 | $row_tmp = Database::fetch_assoc($tmp_f); |
||||
| 584 | $tutorIdTraining = $row_tmp['id']; |
||||
| 585 | Database::query("UPDATE $tableTutorsCompany SET training='1' WHERE id='".$tutorIdTraining."'"); |
||||
| 586 | } else { |
||||
| 587 | $params_tmp = [ |
||||
| 588 | 'document_type' => $documentTypeTraining, |
||||
| 589 | 'document_number' => $documentNumberTraining, |
||||
| 590 | 'document_letter' => $documentLetterTraining, |
||||
| 591 | 'training' => '1', |
||||
| 592 | ]; |
||||
| 593 | $tutorIdTraining = Database::insert($tableTutorsCompany, $params_tmp); |
||||
| 594 | } |
||||
| 595 | } |
||||
| 596 | } |
||||
| 597 | |||||
| 598 | $params = [ |
||||
| 599 | 'action_id' => $actionId, |
||||
| 600 | 'document_type' => $documentType, |
||||
| 601 | 'document_number' => $documentNumber, |
||||
| 602 | 'document_letter' => $documentLetter, |
||||
| 603 | 'key_competence' => $keyCompetence, |
||||
| 604 | 'contract_id' => $contractId, |
||||
| 605 | 'company_fiscal_number' => $companyFiscalNumber, |
||||
| 606 | 'company_tutor_id' => $tutorIdCompany, |
||||
| 607 | 'training_tutor_id' => $tutorIdTraining, |
||||
| 608 | ]; |
||||
| 609 | $participantId = Database::insert($tableParticipants, $params); |
||||
| 610 | if (empty($participantId)) { |
||||
| 611 | return [ |
||||
| 612 | "RESPUESTA_OBT_ACCION" => [ |
||||
| 613 | "CODIGO_RETORNO" => "-1", |
||||
| 614 | "ETIQUETA_ERROR" => "Problema base de datos - insertando participantes", |
||||
| 615 | "ACCION_FORMATIVA" => $crearAccionInputArray['ACCION_FORMATIVA'], |
||||
| 616 | ], |
||||
| 617 | ]; |
||||
| 618 | } |
||||
| 619 | |||||
| 620 | $participantId = Database::insert_id(); |
||||
| 621 | |||||
| 622 | foreach ($participant->ESPECIALIDADES_PARTICIPANTE as $valueList) { |
||||
| 623 | if (!is_array($participantList)) { |
||||
| 624 | $auxList = []; |
||||
| 625 | $auxList[] = $valueList; |
||||
| 626 | $valueList = $auxList; |
||||
| 627 | } |
||||
| 628 | foreach ($valueList as $value) { |
||||
| 629 | $specialtyOrigin = null; |
||||
| 630 | $professionalArea = null; |
||||
| 631 | $specialtyCode = null; |
||||
| 632 | |||||
| 633 | if (isset($value->ID_ESPECIALIDAD)) { |
||||
| 634 | $specialtyOrigin = $value->ID_ESPECIALIDAD->ORIGEN_ESPECIALIDAD; |
||||
| 635 | $professionalArea = $value->ID_ESPECIALIDAD->AREA_PROFESIONAL; |
||||
| 636 | $specialtyCode = $value->ID_ESPECIALIDAD->CODIGO_ESPECIALIDAD; |
||||
| 637 | } |
||||
| 638 | |||||
| 639 | $registrationDate = $value->FECHA_ALTA; |
||||
| 640 | $leavingDate = $value->FECHA_BAJA; |
||||
| 641 | |||||
| 642 | $centerOrigin = null; |
||||
| 643 | $centerCode = null; |
||||
| 644 | $startDate = null; |
||||
| 645 | $endDate = null; |
||||
| 646 | |||||
| 647 | if (!empty($value->EVALUACION_FINAL)) { |
||||
| 648 | $startDate = isset($value->EVALUACION_FINAL->FECHA_INICIO) ? $value->EVALUACION_FINAL->FECHA_INICIO : null; |
||||
| 649 | $endDate = isset($value->EVALUACION_FINAL->FECHA_FIN) ? $value->EVALUACION_FINAL->FECHA_FIN : null; |
||||
| 650 | if (!empty($value->EVALUACION_FINAL->CENTRO_PRESENCIAL_EVALUACION)) { |
||||
| 651 | $centerOrigin = $value->EVALUACION_FINAL->CENTRO_PRESENCIAL_EVALUACION->ORIGEN_CENTRO; |
||||
| 652 | $centerCode = $value->EVALUACION_FINAL->CENTRO_PRESENCIAL_EVALUACION->CODIGO_CENTRO; |
||||
| 653 | } |
||||
| 654 | } |
||||
| 655 | |||||
| 656 | $finalResult = null; |
||||
| 657 | $finalQualification = null; |
||||
| 658 | $finalScore = null; |
||||
| 659 | |||||
| 660 | if (isset($value->RESULTADOS)) { |
||||
| 661 | $finalResult = isset($value->RESULTADOS->RESULTADO_FINAL) ? $value->RESULTADOS->RESULTADO_FINAL : null; |
||||
| 662 | $finalQualification = isset($value->RESULTADOS->CALIFICACION_FINAL) ? $value->RESULTADOS->CALIFICACION_FINAL : null; |
||||
| 663 | $finalScore = isset($value->RESULTADOS->PUNTUACION_FINAL) ? $value->RESULTADOS->PUNTUACION_FINAL : null; |
||||
| 664 | } |
||||
| 665 | |||||
| 666 | $registrationDate = self::fixDate($registrationDate); |
||||
| 667 | $leavingDate = self::fixDate($leavingDate); |
||||
| 668 | |||||
| 669 | $startDate = self::fixDate($startDate); |
||||
| 670 | $endDate = self::fixDate($endDate); |
||||
| 671 | |||||
| 672 | $table_aux = Database::get_main_table('plugin_sepe_participants_specialty'); |
||||
| 673 | |||||
| 674 | $params = [ |
||||
| 675 | 'participant_id' => $participantId, |
||||
| 676 | 'specialty_origin' => $specialtyOrigin, |
||||
| 677 | 'professional_area' => $professionalArea, |
||||
| 678 | 'specialty_code' => $specialtyCode, |
||||
| 679 | 'registration_date' => $registrationDate, |
||||
| 680 | 'leaving_date' => $leavingDate, |
||||
| 681 | 'center_origin' => $centerOrigin, |
||||
| 682 | 'center_code' => $centerCode, |
||||
| 683 | 'start_date' => $startDate, |
||||
| 684 | 'end_date' => $endDate, |
||||
| 685 | 'final_result' => $finalResult, |
||||
| 686 | 'final_qualification' => $finalQualification, |
||||
| 687 | 'final_score' => $finalScore, |
||||
| 688 | ]; |
||||
| 689 | |||||
| 690 | $participantSpecialtyId = Database::insert($table_aux, $params); |
||||
| 691 | if (empty($participantSpecialtyId)) { |
||||
| 692 | return [ |
||||
| 693 | "RESPUESTA_OBT_ACCION" => [ |
||||
| 694 | "CODIGO_RETORNO" => "-1", |
||||
| 695 | "ETIQUETA_ERROR" => "Problema base de datos - insertando especialidad participante", |
||||
| 696 | "ACCION_FORMATIVA" => $crearAccionInputArray['ACCION_FORMATIVA'], |
||||
| 697 | ], |
||||
| 698 | ]; |
||||
| 699 | } |
||||
| 700 | |||||
| 701 | foreach ($value->TUTORIAS_PRESENCIALES as $tutorialList) { |
||||
| 702 | if (!is_array($tutorialList)) { |
||||
| 703 | $auxList = []; |
||||
| 704 | $auxList[] = $tutorialList; |
||||
| 705 | $tutorialList = $auxList; |
||||
| 706 | } |
||||
| 707 | foreach ($tutorialList as $tutorial) { |
||||
| 708 | $centerOrigin = $tutorial->CENTRO_PRESENCIAL_TUTORIA->ORIGEN_CENTRO; |
||||
| 709 | $centerCode = $tutorial->CENTRO_PRESENCIAL_TUTORIA->CODIGO_CENTRO; |
||||
| 710 | $startDate = $tutorial->FECHA_INICIO; |
||||
| 711 | $endDate = $tutorial->FECHA_FIN; |
||||
| 712 | |||||
| 713 | $startDate = self::fixDate($startDate); |
||||
| 714 | $endDate = self::fixDate($endDate); |
||||
| 715 | |||||
| 716 | $table_aux2 = Database::get_main_table('plugin_sepe_participants_specialty_tutorials'); |
||||
| 717 | $params = [ |
||||
| 718 | 'participant_specialty_id' => $participantSpecialtyId, |
||||
| 719 | 'center_origin' => $centerOrigin, |
||||
| 720 | 'center_code' => $centerCode, |
||||
| 721 | 'start_date' => $startDate, |
||||
| 722 | 'end_date' => $endDate, |
||||
| 723 | ]; |
||||
| 724 | $id = Database::insert($table_aux2, $params); |
||||
| 725 | |||||
| 726 | if (!empty($id)) { |
||||
| 727 | return [ |
||||
| 728 | "RESPUESTA_OBT_ACCION" => [ |
||||
| 729 | "CODIGO_RETORNO" => "-1", |
||||
| 730 | "ETIQUETA_ERROR" => "Problema base de datos - insertando tutorias presenciales participante", |
||||
| 731 | "ACCION_FORMATIVA" => $crearAccionInputArray['ACCION_FORMATIVA'], |
||||
| 732 | ], |
||||
| 733 | ]; |
||||
| 734 | } |
||||
| 735 | } |
||||
| 736 | } |
||||
| 737 | } |
||||
| 738 | } |
||||
| 739 | } |
||||
| 740 | } |
||||
| 741 | |||||
| 742 | $obtenerAccionInput = new stdClass(); |
||||
| 743 | $obtenerAccionInput->ID_ACCION = new stdClass(); |
||||
| 744 | $obtenerAccionInput->ID_ACCION->ORIGEN_ACCION = $actionOrigin; |
||||
| 745 | $obtenerAccionInput->ID_ACCION->CODIGO_ACCION = $actionCode; |
||||
| 746 | |||||
| 747 | return self::obtenerAccion($obtenerAccionInput); |
||||
|
0 ignored issues
–
show
The method
Sepe::obtenerAccion() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 748 | } |
||||
| 749 | |||||
| 750 | public function obtenerAccion($obtenerAccionInput) |
||||
| 751 | { |
||||
| 752 | /* Tracking Log */ |
||||
| 753 | $tableLog = Database::get_main_table('plugin_sepe_log'); |
||||
| 754 | $paramsLog = [ |
||||
| 755 | 'ip' => $_SERVER['REMOTE_ADDR'], |
||||
| 756 | 'action' => "obtenerAccion", |
||||
| 757 | 'fecha' => date("Y-m-d H:i:s"), |
||||
| 758 | ]; |
||||
| 759 | Database::insert($tableLog, $paramsLog); |
||||
| 760 | |||||
| 761 | /* End tracking log */ |
||||
| 762 | |||||
| 763 | $actionOrigin = $obtenerAccionInput->ID_ACCION->ORIGEN_ACCION; |
||||
| 764 | $actionCode = $obtenerAccionInput->ID_ACCION->CODIGO_ACCION; |
||||
| 765 | |||||
| 766 | if (empty($actionOrigin) || empty($actionCode)) { |
||||
| 767 | return [ |
||||
| 768 | "RESPUESTA_OBT_ACCION" => [ |
||||
| 769 | "CODIGO_RETORNO" => "2", |
||||
| 770 | "ETIQUETA_ERROR" => "Error en parametro", |
||||
| 771 | "ACCION_FORMATIVA" => "", |
||||
| 772 | ], |
||||
| 773 | ]; |
||||
| 774 | } |
||||
| 775 | |||||
| 776 | $table = Database::get_main_table('plugin_sepe_actions'); |
||||
| 777 | $tableCenters = Database::get_main_table('plugin_sepe_centers'); |
||||
| 778 | $classRoomTable = Database::get_main_table('plugin_sepe_specialty_classroom'); |
||||
| 779 | $tutorTable = Database::get_main_table('plugin_sepe_tutors'); |
||||
| 780 | $specialityTutorTable = Database::get_main_table('plugin_sepe_specialty_tutors'); |
||||
| 781 | $participantsSpecialityTable = Database::get_main_table('plugin_sepe_participants_specialty'); |
||||
| 782 | $participantsSpecialityTutorialsTable = Database::get_main_table('plugin_sepe_participants_specialty_tutorials'); |
||||
| 783 | $tableTutorsCompany = Database::get_main_table('plugin_sepe_tutors_company'); |
||||
| 784 | |||||
| 785 | $actionOrigin = Database::escape_string($actionOrigin); |
||||
| 786 | $actionCode = Database::escape_string($actionCode); |
||||
| 787 | |||||
| 788 | // Comprobamos si existen datos almacenados previamente |
||||
| 789 | $sql = "SELECT * |
||||
| 790 | FROM $table |
||||
| 791 | WHERE |
||||
| 792 | action_origin='".$actionOrigin."' AND |
||||
| 793 | action_code='".$actionCode."';"; |
||||
| 794 | $rs = Database::query($sql); |
||||
| 795 | if (Database::num_rows($rs) > 0) { |
||||
| 796 | $row = Database::fetch_assoc($rs); |
||||
| 797 | $mainSpecialty = [ |
||||
| 798 | 'ORIGEN_ESPECIALIDAD' => $row['specialty_origin'], |
||||
| 799 | 'AREA_PROFESIONAL' => $row['professional_area'], |
||||
| 800 | 'CODIGO_ESPECIALIDAD' => $row['specialty_code'], |
||||
| 801 | ]; |
||||
| 802 | $actionDescription = [ |
||||
| 803 | 'DENOMINACION_ACCION' => $row['action_name'], |
||||
| 804 | 'INFORMACION_GENERAL' => $row['global_info'], |
||||
| 805 | 'HORARIOS' => $row['schedule'], |
||||
| 806 | 'REQUISITOS' => $row['requirements'], |
||||
| 807 | 'CONTACTO_ACCION' => $row['contact_action'], |
||||
| 808 | ]; |
||||
| 809 | |||||
| 810 | $tableSpeciality = Database::get_main_table('plugin_sepe_specialty'); |
||||
| 811 | $tableParticipants = Database::get_main_table('plugin_sepe_participants'); |
||||
| 812 | $sql = "SELECT * FROM $tableSpeciality |
||||
| 813 | WHERE action_id ='".$row['id']."'"; |
||||
| 814 | $rs = Database::query($sql); |
||||
| 815 | $specialty = []; |
||||
| 816 | if (Database::num_rows($rs) > 0) { |
||||
| 817 | while ($aux = Database::fetch_assoc($rs)) { |
||||
| 818 | $specialtyId = $aux['id']; |
||||
| 819 | $sql = "SELECT * FROM $classRoomTable |
||||
| 820 | WHERE specialty_id='".$specialtyId."'"; |
||||
| 821 | $resultClassroom = Database::query($sql); |
||||
| 822 | if (Database::num_rows($resultClassroom) === 0) { |
||||
| 823 | return [ |
||||
| 824 | "RESPUESTA_OBT_ACCION" => [ |
||||
| 825 | "CODIGO_RETORNO" => "-1", |
||||
| 826 | "ETIQUETA_ERROR" => "Problema base de datos - consulta de centros presenciales", |
||||
| 827 | "ACCION_FORMATIVA" => '', |
||||
| 828 | ], |
||||
| 829 | ]; |
||||
| 830 | } |
||||
| 831 | |||||
| 832 | $classroomCenterList = new ArrayObject(); |
||||
| 833 | while ($tmp = Database::fetch_assoc($resultClassroom)) { |
||||
| 834 | $sql = "SELECT * FROM $tableCenters WHERE id='".$tmp['center_id']."';"; |
||||
| 835 | $resultCenter = Database::query($sql); |
||||
| 836 | $auxCenter = Database::fetch_assoc($resultCenter); |
||||
| 837 | |||||
| 838 | $classroomCenter = new stdClass(); |
||||
| 839 | $classroomCenter->ORIGEN_CENTRO = $auxCenter['center_origin']; |
||||
| 840 | $classroomCenter->CODIGO_CENTRO = $auxCenter['center_code']; |
||||
| 841 | $classroomCenter = new SoapVar( |
||||
| 842 | $classroomCenter, |
||||
| 843 | SOAP_ENC_OBJECT, |
||||
| 844 | null, |
||||
| 845 | null, |
||||
| 846 | 'CENTRO_PRESENCIAL' |
||||
| 847 | ); |
||||
| 848 | $classroomCenterList->append($classroomCenter); |
||||
| 849 | } |
||||
| 850 | $sql = "SELECT * FROM $specialityTutorTable |
||||
| 851 | WHERE specialty_id='".$specialtyId."'"; |
||||
| 852 | $resultSpecialtyTutor = Database::query($sql); |
||||
| 853 | |||||
| 854 | $trainingTutors = new ArrayObject(); |
||||
| 855 | if (Database::num_rows($resultSpecialtyTutor)) { |
||||
| 856 | while ($tmp_aux = Database::fetch_assoc($resultSpecialtyTutor)) { |
||||
| 857 | $sql = "SELECT * FROM $tutorTable |
||||
| 858 | WHERE id='".$tmp_aux['tutor_id']."' |
||||
| 859 | LIMIT 1"; |
||||
| 860 | $rs_tutor = Database::query($sql); |
||||
| 861 | if (Database::num_rows($rs_tutor)) { |
||||
| 862 | $tmp = Database::fetch_assoc($rs_tutor); |
||||
| 863 | |||||
| 864 | $obj = new stdClass(); |
||||
| 865 | $obj->ID_TUTOR = new stdClass(); |
||||
| 866 | $obj->ID_TUTOR->TIPO_DOCUMENTO = $tmp['document_type']; |
||||
| 867 | $obj->ID_TUTOR->NUM_DOCUMENTO = $tmp['document_number']; |
||||
| 868 | $obj->ID_TUTOR->LETRA_NIF = $tmp['document_letter']; |
||||
| 869 | |||||
| 870 | $obj->ACREDITACION_TUTOR = $tmp_aux['tutor_accreditation']; |
||||
| 871 | $obj->EXPERIENCIA_PROFESIONAL = $tmp_aux['professional_experience']; |
||||
| 872 | $obj->COMPETENCIA_DOCENTE = $tmp_aux['teaching_competence']; |
||||
| 873 | $obj->EXPERIENCIA_MODALIDAD_TELEFORMACION = $tmp_aux['experience_teleforming']; |
||||
| 874 | $obj->FORMACION_MODALIDAD_TELEFORMACION = $tmp_aux['training_teleforming']; |
||||
| 875 | |||||
| 876 | $obj = new SoapVar($obj, SOAP_ENC_OBJECT, null, null, 'TUTOR_FORMADOR'); |
||||
| 877 | $trainingTutors->append($obj); |
||||
| 878 | } |
||||
| 879 | } |
||||
| 880 | } |
||||
| 881 | |||||
| 882 | $params = new ArrayObject(); |
||||
| 883 | $idEspecialidad = new stdClass(); |
||||
| 884 | $idEspecialidad->ORIGEN_ESPECIALIDAD = $aux['specialty_origin']; |
||||
| 885 | $idEspecialidad->AREA_PROFESIONAL = $aux['professional_area']; |
||||
| 886 | $idEspecialidad->CODIGO_ESPECIALIDAD = $aux['specialty_code']; |
||||
| 887 | |||||
| 888 | $params[0] = new SoapVar( |
||||
| 889 | $idEspecialidad, |
||||
| 890 | SOAP_ENC_OBJECT, |
||||
| 891 | null, |
||||
| 892 | null, |
||||
| 893 | 'ID_ESPECIALIDAD', |
||||
| 894 | null |
||||
| 895 | ); |
||||
| 896 | |||||
| 897 | $centroImparticion = new stdClass(); |
||||
| 898 | $centroImparticion->ORIGEN_CENTRO = $aux['center_origin']; |
||||
| 899 | $centroImparticion->CODIGO_CENTRO = $aux['center_code']; |
||||
| 900 | |||||
| 901 | $params[1] = new SoapVar( |
||||
| 902 | $centroImparticion, |
||||
| 903 | SOAP_ENC_OBJECT, |
||||
| 904 | null, |
||||
| 905 | null, |
||||
| 906 | 'CENTRO_IMPARTICION', |
||||
| 907 | null |
||||
| 908 | ); |
||||
| 909 | $params[2] = new SoapVar( |
||||
| 910 | self::undoFixDate($aux['start_date']), |
||||
| 911 | XSD_STRING, |
||||
| 912 | null, |
||||
| 913 | null, |
||||
| 914 | 'FECHA_INICIO', |
||||
| 915 | null |
||||
| 916 | ); |
||||
| 917 | $params[3] = new SoapVar( |
||||
| 918 | self::undoFixDate($aux['end_date']), |
||||
| 919 | XSD_STRING, |
||||
| 920 | null, |
||||
| 921 | null, |
||||
| 922 | 'FECHA_FIN', |
||||
| 923 | null |
||||
| 924 | ); |
||||
| 925 | $params[4] = new SoapVar( |
||||
| 926 | $aux['modality_impartition'], |
||||
| 927 | XSD_STRING, |
||||
| 928 | null, |
||||
| 929 | null, |
||||
| 930 | 'MODALIDAD_IMPARTICION', |
||||
| 931 | null |
||||
| 932 | ); |
||||
| 933 | |||||
| 934 | $obj = new stdClass(); |
||||
| 935 | $obj->HORAS_PRESENCIAL = $aux['classroom_hours']; |
||||
| 936 | $obj->HORAS_TELEFORMACION = $aux['distance_hours']; |
||||
| 937 | |||||
| 938 | $params[5] = new SoapVar( |
||||
| 939 | $obj, |
||||
| 940 | SOAP_ENC_OBJECT, |
||||
| 941 | null, |
||||
| 942 | null, |
||||
| 943 | 'DATOS_DURACION', |
||||
| 944 | null |
||||
| 945 | ); |
||||
| 946 | $params[6] = new SoapVar( |
||||
| 947 | $classroomCenterList, |
||||
| 948 | SOAP_ENC_OBJECT, |
||||
| 949 | null, |
||||
| 950 | null, |
||||
| 951 | 'CENTROS_SESIONES_PRESENCIALES', |
||||
| 952 | null |
||||
| 953 | ); |
||||
| 954 | $params[7] = new SoapVar( |
||||
| 955 | $trainingTutors, |
||||
| 956 | SOAP_ENC_OBJECT, |
||||
| 957 | null, |
||||
| 958 | null, |
||||
| 959 | 'TUTORES_FORMADORES', |
||||
| 960 | null |
||||
| 961 | ); |
||||
| 962 | |||||
| 963 | $obj = new stdClass(); |
||||
| 964 | |||||
| 965 | if (!empty($aux['mornings_participants_number']) || |
||||
| 966 | !empty($aux['mornings_access_number']) || |
||||
| 967 | !empty($aux['morning_total_duration']) |
||||
| 968 | ) { |
||||
| 969 | $obj->HORARIO_MANANA = new stdClass(); |
||||
| 970 | $obj->HORARIO_MANANA->NUM_PARTICIPANTES = $aux['mornings_participants_number']; |
||||
| 971 | $obj->HORARIO_MANANA->NUMERO_ACCESOS = $aux['mornings_access_number']; |
||||
| 972 | $obj->HORARIO_MANANA->DURACION_TOTAL = $aux['morning_total_duration']; |
||||
| 973 | } |
||||
| 974 | |||||
| 975 | if (!empty($aux['afternoon_participants_number']) || |
||||
| 976 | !empty($aux['afternoon_access_number']) || |
||||
| 977 | !empty($aux['afternoon_total_duration']) |
||||
| 978 | ) { |
||||
| 979 | $obj->HORARIO_TARDE = new stdClass(); |
||||
| 980 | $obj->HORARIO_TARDE->NUM_PARTICIPANTES = $aux['afternoon_participants_number']; |
||||
| 981 | $obj->HORARIO_TARDE->NUMERO_ACCESOS = $aux['afternoon_access_number']; |
||||
| 982 | $obj->HORARIO_TARDE->DURACION_TOTAL = $aux['afternoon_total_duration']; |
||||
| 983 | } |
||||
| 984 | |||||
| 985 | if (!empty($aux['night_participants_number']) || |
||||
| 986 | !empty($aux['night_access_number']) || |
||||
| 987 | !empty($aux['night_total_duration']) |
||||
| 988 | ) { |
||||
| 989 | $obj->HORARIO_NOCHE = new stdClass(); |
||||
| 990 | $obj->HORARIO_NOCHE->NUM_PARTICIPANTES = $aux['night_participants_number']; |
||||
| 991 | $obj->HORARIO_NOCHE->NUMERO_ACCESOS = $aux['night_access_number']; |
||||
| 992 | $obj->HORARIO_NOCHE->DURACION_TOTAL = $aux['night_total_duration']; |
||||
| 993 | } |
||||
| 994 | |||||
| 995 | if (!empty($aux['attendees_count']) || |
||||
| 996 | !empty($aux['learning_activity_count']) || |
||||
| 997 | !empty($aux['attempt_count']) || |
||||
| 998 | !empty($aux['evaluation_activity_count']) |
||||
| 999 | ) { |
||||
| 1000 | $obj->SEGUIMIENTO_EVALUACION = new stdClass(); |
||||
| 1001 | $obj->SEGUIMIENTO_EVALUACION->NUM_PARTICIPANTES = $aux['attendees_count']; |
||||
| 1002 | $obj->SEGUIMIENTO_EVALUACION->NUMERO_ACTIVIDADES_APRENDIZAJE = $aux['learning_activity_count']; |
||||
| 1003 | $obj->SEGUIMIENTO_EVALUACION->NUMERO_INTENTOS = $aux['attempt_count']; |
||||
| 1004 | $obj->SEGUIMIENTO_EVALUACION->NUMERO_ACTIVIDADES_EVALUACION = $aux['evaluation_activity_count']; |
||||
| 1005 | } |
||||
| 1006 | |||||
| 1007 | $params[8] = new SoapVar( |
||||
| 1008 | $obj, |
||||
| 1009 | SOAP_ENC_OBJECT, |
||||
| 1010 | null, |
||||
| 1011 | null, |
||||
| 1012 | 'USO', |
||||
| 1013 | null |
||||
| 1014 | ); |
||||
| 1015 | $specialty[] = new SoapVar( |
||||
| 1016 | $params, |
||||
| 1017 | SOAP_ENC_OBJECT, |
||||
| 1018 | null, |
||||
| 1019 | null, |
||||
| 1020 | 'ESPECIALIDAD' |
||||
| 1021 | ); |
||||
| 1022 | } |
||||
| 1023 | } else { |
||||
| 1024 | return [ |
||||
| 1025 | "RESPUESTA_OBT_ACCION" => [ |
||||
| 1026 | "CODIGO_RETORNO" => "-1", |
||||
| 1027 | "ETIQUETA_ERROR" => "Problema base de datos - consulta especialidad de accion", |
||||
| 1028 | "ACCION_FORMATIVA" => '', |
||||
| 1029 | ], |
||||
| 1030 | ]; |
||||
| 1031 | } |
||||
| 1032 | |||||
| 1033 | $sql = "SELECT * FROM $tableParticipants |
||||
| 1034 | WHERE action_id ='".$row['id']."'"; |
||||
| 1035 | $resultParticipants = Database::query($sql); |
||||
| 1036 | $specialtyMainParticipant = []; |
||||
| 1037 | if (Database::num_rows($resultParticipants)) { |
||||
| 1038 | while ($aux = Database::fetch_assoc($resultParticipants)) { |
||||
| 1039 | $participantId = $aux['id']; |
||||
| 1040 | |||||
| 1041 | $sql = "SELECT * FROM $participantsSpecialityTable |
||||
| 1042 | WHERE participant_id='".$participantId."'"; |
||||
| 1043 | $resultParticipantSpecialty = Database::query($sql); |
||||
| 1044 | |||||
| 1045 | $namespace = null; |
||||
| 1046 | $specialtyParticipant = []; |
||||
| 1047 | while ($tmp = Database::fetch_assoc($resultParticipantSpecialty)) { |
||||
| 1048 | $participantSpecialtyId = $tmp['id']; |
||||
| 1049 | $sql = "SELECT * FROM $participantsSpecialityTutorialsTable |
||||
| 1050 | WHERE participant_specialty_id='".$participantSpecialtyId."'"; |
||||
| 1051 | $resultTutorials = Database::query($sql); |
||||
| 1052 | $classroomTutorials = new ArrayObject(); |
||||
| 1053 | |||||
| 1054 | while ($tmp2 = Database::fetch_assoc($resultTutorials)) { |
||||
| 1055 | $obj = new stdClass(); |
||||
| 1056 | $obj->CENTRO_PRESENCIAL_TUTORIA = new stdClass(); |
||||
| 1057 | $obj->CENTRO_PRESENCIAL_TUTORIA->ORIGEN_CENTRO = $tmp2['center_origin']; |
||||
| 1058 | $obj->CENTRO_PRESENCIAL_TUTORIA->CODIGO_CENTRO = $tmp2['center_code']; |
||||
| 1059 | $startDate = self::undoFixDate($tmp2['start_date']); |
||||
| 1060 | if (!empty($startDate)) { |
||||
| 1061 | $obj->FECHA_INICIO = $startDate; |
||||
| 1062 | } |
||||
| 1063 | $endDate = self::undoFixDate($tmp2['end_date']); |
||||
| 1064 | if (!empty($endDate)) { |
||||
| 1065 | $obj->FECHA_FIN = $endDate; |
||||
| 1066 | } |
||||
| 1067 | |||||
| 1068 | $obj = new SoapVar( |
||||
| 1069 | $obj, |
||||
| 1070 | SOAP_ENC_OBJECT, |
||||
| 1071 | null, |
||||
| 1072 | null, |
||||
| 1073 | 'TUTORIA_PRESENCIAL' |
||||
| 1074 | ); |
||||
| 1075 | $classroomTutorials->append($obj); |
||||
| 1076 | } |
||||
| 1077 | |||||
| 1078 | $obj = new stdClass(); |
||||
| 1079 | $obj->ID_ESPECIALIDAD = new stdClass(); |
||||
| 1080 | $obj->ID_ESPECIALIDAD->ORIGEN_ESPECIALIDAD = $tmp['specialty_origin']; |
||||
| 1081 | $obj->ID_ESPECIALIDAD->AREA_PROFESIONAL = $tmp['professional_area']; |
||||
| 1082 | $obj->ID_ESPECIALIDAD->CODIGO_ESPECIALIDAD = $tmp['specialty_code']; |
||||
| 1083 | |||||
| 1084 | $registrationDate = self::undoFixDate($tmp['registration_date']); |
||||
| 1085 | |||||
| 1086 | // @todo check which is correct send 0000/00/00 or empty |
||||
| 1087 | if (!empty($registrationDate)) { |
||||
| 1088 | $obj->FECHA_ALTA = $registrationDate; |
||||
| 1089 | } |
||||
| 1090 | |||||
| 1091 | $leavingDate = self::undoFixDate($tmp['leaving_date']); |
||||
| 1092 | if (!empty($leavingDate)) { |
||||
| 1093 | $obj->FECHA_BAJA = $leavingDate; |
||||
| 1094 | } |
||||
| 1095 | |||||
| 1096 | $obj->TUTORIAS_PRESENCIALES = new SoapVar( |
||||
| 1097 | $classroomTutorials, |
||||
| 1098 | SOAP_ENC_OBJECT, |
||||
| 1099 | null, |
||||
| 1100 | null, |
||||
| 1101 | 'TUTORIAS_PRESENCIALES', |
||||
| 1102 | null |
||||
| 1103 | ); |
||||
| 1104 | $obj->EVALUACION_FINAL = new stdClass(); |
||||
| 1105 | |||||
| 1106 | if (!empty($tmp['center_origin']) && !empty($tmp['center_code'])) { |
||||
| 1107 | $obj->EVALUACION_FINAL->CENTRO_PRESENCIAL_EVALUACION = new stdClass(); |
||||
| 1108 | $obj->EVALUACION_FINAL->CENTRO_PRESENCIAL_EVALUACION->ORIGEN_CENTRO = $tmp['center_origin']; |
||||
| 1109 | $obj->EVALUACION_FINAL->CENTRO_PRESENCIAL_EVALUACION->CODIGO_CENTRO = $tmp['center_code']; |
||||
| 1110 | } |
||||
| 1111 | |||||
| 1112 | $startDate = self::undoFixDate($tmp['start_date']); |
||||
| 1113 | if (!empty($startDate)) { |
||||
| 1114 | $obj->EVALUACION_FINAL->FECHA_INICIO = $startDate; |
||||
| 1115 | } |
||||
| 1116 | |||||
| 1117 | $endDate = self::undoFixDate($tmp['end_date']); |
||||
| 1118 | |||||
| 1119 | if (!empty($endDate)) { |
||||
| 1120 | $obj->EVALUACION_FINAL->FECHA_FIN = $endDate; |
||||
| 1121 | } |
||||
| 1122 | |||||
| 1123 | $obj->RESULTADOS = new stdClass(); |
||||
| 1124 | |||||
| 1125 | if (isset($tmp['final_result']) && $tmp['final_result'] != '') { |
||||
| 1126 | $obj->RESULTADOS->RESULTADO_FINAL = $tmp['final_result']; |
||||
| 1127 | } |
||||
| 1128 | if (isset($tmp['final_qualification']) && $tmp['final_qualification'] != '') { |
||||
| 1129 | $obj->RESULTADOS->CALIFICACION_FINAL = $tmp['final_qualification']; |
||||
| 1130 | } |
||||
| 1131 | |||||
| 1132 | if (isset($tmp['final_score']) && $tmp['final_score'] != '') { |
||||
| 1133 | $obj->RESULTADOS->PUNTUACION_FINAL = $tmp['final_score']; |
||||
| 1134 | } |
||||
| 1135 | $specialtyParticipant[] = new SoapVar( |
||||
| 1136 | $obj, |
||||
| 1137 | SOAP_ENC_OBJECT, |
||||
| 1138 | null, |
||||
| 1139 | null, |
||||
| 1140 | 'ESPECIALIDAD' |
||||
| 1141 | ); |
||||
| 1142 | } |
||||
| 1143 | |||||
| 1144 | $params = new stdClass(); |
||||
| 1145 | $params->ID_PARTICIPANTE = new stdClass(); |
||||
| 1146 | $params->ID_PARTICIPANTE->TIPO_DOCUMENTO = $aux['document_type']; |
||||
| 1147 | $params->ID_PARTICIPANTE->NUM_DOCUMENTO = $aux['document_number']; |
||||
| 1148 | $params->ID_PARTICIPANTE->LETRA_NIF = $aux['document_letter']; |
||||
| 1149 | $params->INDICADOR_COMPETENCIAS_CLAVE = $aux['key_competence']; |
||||
| 1150 | |||||
| 1151 | $params->CONTRATO_FORMACION = new stdClass(); |
||||
| 1152 | |||||
| 1153 | if (!empty($aux['contract_id'])) { |
||||
| 1154 | $params->CONTRATO_FORMACION->ID_CONTRATO_CFA = $aux['contract_id']; |
||||
| 1155 | } |
||||
| 1156 | |||||
| 1157 | if (!empty($aux['company_fiscal_number'])) { |
||||
| 1158 | $params->CONTRATO_FORMACION->CIF_EMPRESA = $aux['company_fiscal_number']; |
||||
| 1159 | } |
||||
| 1160 | |||||
| 1161 | if (!empty($aux['company_tutor_id'])) { |
||||
| 1162 | $resultCompany = Database::query("SELECT * FROM $tableTutorsCompany WHERE id='".$aux['company_tutor_id']."';"); |
||||
| 1163 | $auxCompany = Database::fetch_assoc($resultCompany); |
||||
| 1164 | if (!empty($auxCompany['document_type']) || |
||||
| 1165 | !empty($auxCompany['document_number']) || |
||||
| 1166 | !empty($auxCompany['document_letter']) |
||||
| 1167 | ) { |
||||
| 1168 | $params->CONTRATO_FORMACION->ID_TUTOR_EMPRESA = new stdClass(); |
||||
| 1169 | $params->CONTRATO_FORMACION->ID_TUTOR_EMPRESA->TIPO_DOCUMENTO = $auxCompany['document_type']; |
||||
| 1170 | $params->CONTRATO_FORMACION->ID_TUTOR_EMPRESA->NUM_DOCUMENTO = $auxCompany['document_number']; |
||||
| 1171 | $params->CONTRATO_FORMACION->ID_TUTOR_EMPRESA->LETRA_NIF = $auxCompany['document_letter']; |
||||
| 1172 | } |
||||
| 1173 | } |
||||
| 1174 | if (!empty($aux['training_tutor_id'])) { |
||||
| 1175 | $resultTraining = Database::query("SELECT * FROM $tableTutorsCompany WHERE id='".$aux['training_tutor_id']."';"); |
||||
| 1176 | $auxTraining = Database::fetch_assoc($resultTraining); |
||||
| 1177 | if (!empty($auxTraining['document_type']) || |
||||
| 1178 | !empty($auxTraining['document_number']) || |
||||
| 1179 | !empty($auxTraining['document_letter']) |
||||
| 1180 | ) { |
||||
| 1181 | $params->CONTRATO_FORMACION->ID_TUTOR_FORMACION = new stdClass(); |
||||
| 1182 | $params->CONTRATO_FORMACION->ID_TUTOR_FORMACION->TIPO_DOCUMENTO = $auxTraining['document_type']; |
||||
| 1183 | $params->CONTRATO_FORMACION->ID_TUTOR_FORMACION->NUM_DOCUMENTO = $auxTraining['document_number']; |
||||
| 1184 | $params->CONTRATO_FORMACION->ID_TUTOR_FORMACION->LETRA_NIF = $auxTraining['document_letter']; |
||||
| 1185 | } |
||||
| 1186 | } |
||||
| 1187 | |||||
| 1188 | $params->ESPECIALIDADES_PARTICIPANTE = new SoapVar( |
||||
| 1189 | $specialtyParticipant, |
||||
| 1190 | SOAP_ENC_OBJECT, |
||||
| 1191 | null, |
||||
| 1192 | null, |
||||
| 1193 | 'ESPECIALIDADES_PARTICIPANTE' |
||||
| 1194 | ); |
||||
| 1195 | $specialtyMainParticipant[] = new SoapVar( |
||||
| 1196 | $params, |
||||
| 1197 | SOAP_ENC_OBJECT, |
||||
| 1198 | null, |
||||
| 1199 | null, |
||||
| 1200 | 'PARTICIPANTE' |
||||
| 1201 | ); |
||||
| 1202 | } |
||||
| 1203 | } |
||||
| 1204 | |||||
| 1205 | $result = new stdClass(); |
||||
| 1206 | |||||
| 1207 | $result->RESPUESTA_OBT_ACCION = new stdClass(); |
||||
| 1208 | $result->RESPUESTA_OBT_ACCION->CODIGO_RETORNO = 0; |
||||
| 1209 | $result->RESPUESTA_OBT_ACCION->ETIQUETA_ERROR = 'Correcto'; |
||||
| 1210 | |||||
| 1211 | $result->RESPUESTA_OBT_ACCION->ACCION_FORMATIVA = new stdClass(); |
||||
| 1212 | $result->RESPUESTA_OBT_ACCION->ACCION_FORMATIVA->ID_ACCION = new stdClass(); |
||||
| 1213 | $result->RESPUESTA_OBT_ACCION->ACCION_FORMATIVA->ID_ACCION->ORIGEN_ACCION = $actionOrigin; |
||||
| 1214 | $result->RESPUESTA_OBT_ACCION->ACCION_FORMATIVA->ID_ACCION->CODIGO_ACCION = $actionCode; |
||||
| 1215 | |||||
| 1216 | $result->RESPUESTA_OBT_ACCION->ACCION_FORMATIVA->SITUACION = $row['situation']; |
||||
| 1217 | $result->RESPUESTA_OBT_ACCION->ACCION_FORMATIVA->ID_ESPECIALIDAD_PRINCIPAL = $mainSpecialty; |
||||
| 1218 | |||||
| 1219 | $result->RESPUESTA_OBT_ACCION->ACCION_FORMATIVA->DURACION = $row['duration']; |
||||
| 1220 | $result->RESPUESTA_OBT_ACCION->ACCION_FORMATIVA->FECHA_INICIO = self::undoFixDate($row['start_date']); |
||||
| 1221 | $result->RESPUESTA_OBT_ACCION->ACCION_FORMATIVA->FECHA_FIN = self::undoFixDate($row['end_date']); |
||||
| 1222 | $result->RESPUESTA_OBT_ACCION->ACCION_FORMATIVA->IND_ITINERARIO_COMPLETO = $row['full_itinerary_indicator']; |
||||
| 1223 | $result->RESPUESTA_OBT_ACCION->ACCION_FORMATIVA->TIPO_FINANCIACION = $row['financing_type']; |
||||
| 1224 | $result->RESPUESTA_OBT_ACCION->ACCION_FORMATIVA->NUMERO_ASISTENTES = $row['attendees_count']; |
||||
| 1225 | $result->RESPUESTA_OBT_ACCION->ACCION_FORMATIVA->DESCRIPCION_ACCION = $actionDescription; |
||||
| 1226 | $result->RESPUESTA_OBT_ACCION->ACCION_FORMATIVA->ESPECIALIDADES_ACCION = $specialty; |
||||
| 1227 | $result->RESPUESTA_OBT_ACCION->ACCION_FORMATIVA->PARTICIPANTES = $specialtyMainParticipant; |
||||
| 1228 | |||||
| 1229 | return $result; |
||||
| 1230 | } else { |
||||
| 1231 | // Existe la accion |
||||
| 1232 | return [ |
||||
| 1233 | "RESPUESTA_OBT_ACCION" => [ |
||||
| 1234 | "CODIGO_RETORNO" => "1", |
||||
| 1235 | "ETIQUETA_ERROR" => "Acción inexistente", |
||||
| 1236 | "ACCION_FORMATIVA" => "", |
||||
| 1237 | ], |
||||
| 1238 | ]; |
||||
| 1239 | } |
||||
| 1240 | } |
||||
| 1241 | |||||
| 1242 | public function obtenerListaAcciones() |
||||
| 1243 | { |
||||
| 1244 | /* Tracking Log */ |
||||
| 1245 | $tableLog = Database::get_main_table('plugin_sepe_log'); |
||||
| 1246 | $paramsLog = [ |
||||
| 1247 | 'ip' => $_SERVER['REMOTE_ADDR'], |
||||
| 1248 | 'action' => "obtenerListaAcciones", |
||||
| 1249 | 'fecha' => date("Y-m-d H:i:s"), |
||||
| 1250 | ]; |
||||
| 1251 | Database::insert($tableLog, $paramsLog); |
||||
| 1252 | /* End tracking log */ |
||||
| 1253 | |||||
| 1254 | $table = Database::get_main_table('plugin_sepe_actions'); |
||||
| 1255 | |||||
| 1256 | $sql = "SELECT action_origin, action_code FROM $table"; |
||||
| 1257 | $rs = Database::query($sql); |
||||
| 1258 | |||||
| 1259 | if (!$rs) { |
||||
|
0 ignored issues
–
show
|
|||||
| 1260 | error_log('Problema base de datos '); |
||||
| 1261 | |||||
| 1262 | return [ |
||||
| 1263 | "RESPUESTA_OBT_LISTA_ACCIONES" => [ |
||||
| 1264 | "CODIGO_RETORNO" => "-1", |
||||
| 1265 | "ETIQUETA_ERROR" => "Problema base de datos - consulta acciones disponible", |
||||
| 1266 | "LISTA_ACCIONES" => '', |
||||
| 1267 | ], |
||||
| 1268 | ]; |
||||
| 1269 | } |
||||
| 1270 | |||||
| 1271 | $list = []; |
||||
| 1272 | if (Database::num_rows($rs)) { |
||||
| 1273 | while ($row = Database::fetch_assoc($rs)) { |
||||
| 1274 | $params = new stdClass(); |
||||
| 1275 | $params->ORIGEN_ACCION = $row['action_origin']; |
||||
| 1276 | $params->CODIGO_ACCION = $row['action_code']; |
||||
| 1277 | |||||
| 1278 | $list[] = new SoapVar($params, SOAP_ENC_OBJECT); |
||||
| 1279 | } |
||||
| 1280 | } |
||||
| 1281 | |||||
| 1282 | $result = new stdClass(); |
||||
| 1283 | $result->RESPUESTA_OBT_LISTA_ACCIONES = new stdClass(); |
||||
| 1284 | $result->RESPUESTA_OBT_LISTA_ACCIONES->CODIGO_RETORNO = 0; |
||||
| 1285 | $result->RESPUESTA_OBT_LISTA_ACCIONES->ETIQUETA_ERROR = 'Correcto'; |
||||
| 1286 | |||||
| 1287 | if (!empty($list)) { |
||||
| 1288 | $result->RESPUESTA_OBT_LISTA_ACCIONES->ID_ACCION = $list; |
||||
| 1289 | } |
||||
| 1290 | |||||
| 1291 | return $result; |
||||
| 1292 | } |
||||
| 1293 | |||||
| 1294 | public function eliminarAccion($eliminarAccionInput) |
||||
| 1295 | { |
||||
| 1296 | /* Tracking Log */ |
||||
| 1297 | $tableLog = Database::get_main_table('plugin_sepe_log'); |
||||
| 1298 | $paramsLog = [ |
||||
| 1299 | 'ip' => $_SERVER['REMOTE_ADDR'], |
||||
| 1300 | 'action' => "eliminarAccion", |
||||
| 1301 | 'fecha' => date("Y-m-d H:i:s"), |
||||
| 1302 | ]; |
||||
| 1303 | Database::insert($tableLog, $paramsLog); |
||||
| 1304 | /* End tracking log */ |
||||
| 1305 | |||||
| 1306 | $actionOrigin = $eliminarAccionInput->ID_ACCION->ORIGEN_ACCION; |
||||
| 1307 | $actionCode = $eliminarAccionInput->ID_ACCION->CODIGO_ACCION; |
||||
| 1308 | |||||
| 1309 | if (empty($actionOrigin) || empty($actionCode)) { |
||||
| 1310 | return [ |
||||
| 1311 | "RESPUESTA_ELIMINAR_ACCION" => [ |
||||
| 1312 | "CODIGO_RETORNO" => "2", |
||||
| 1313 | "ETIQUETA_ERROR" => "Error en parametro", |
||||
| 1314 | ], |
||||
| 1315 | ]; |
||||
| 1316 | } |
||||
| 1317 | |||||
| 1318 | $table = Database::get_main_table('plugin_sepe_actions'); |
||||
| 1319 | $sql = "DELETE FROM $table |
||||
| 1320 | WHERE action_origin='".$actionOrigin."' AND action_code='".$actionCode."';"; |
||||
| 1321 | |||||
| 1322 | $rs = Database::query($sql); |
||||
| 1323 | if (!$rs) { |
||||
|
0 ignored issues
–
show
|
|||||
| 1324 | return [ |
||||
| 1325 | "RESPUESTA_ELIMINAR_ACCION" => [ |
||||
| 1326 | "CODIGO_RETORNO" => "-1", |
||||
| 1327 | "ETIQUETA_ERROR" => "Problema base de datos - consulta acciones disponible", |
||||
| 1328 | ], |
||||
| 1329 | ]; |
||||
| 1330 | } |
||||
| 1331 | |||||
| 1332 | return [ |
||||
| 1333 | "RESPUESTA_ELIMINAR_ACCION" => [ |
||||
| 1334 | "CODIGO_RETORNO" => "0", |
||||
| 1335 | "ETIQUETA_ERROR" => "Correcto", |
||||
| 1336 | ], |
||||
| 1337 | ]; |
||||
| 1338 | } |
||||
| 1339 | |||||
| 1340 | // yyyy-mm-dd to dd/mm/yyyy |
||||
| 1341 | public static function undoFixDate($date) |
||||
| 1342 | { |
||||
| 1343 | if ($date == '0000-00-00' || empty($date)) { |
||||
| 1344 | return null; |
||||
| 1345 | } |
||||
| 1346 | |||||
| 1347 | $date = explode('-', $date); |
||||
| 1348 | |||||
| 1349 | $date = $date[2].'/'.$date[1].'/'.$date[0]; |
||||
| 1350 | |||||
| 1351 | return $date; |
||||
| 1352 | } |
||||
| 1353 | |||||
| 1354 | // dd/mm/yyyy to yyyy-mm-dd |
||||
| 1355 | public static function fixDate($date) |
||||
| 1356 | { |
||||
| 1357 | if ($date == '00/00/0000' || empty($date)) { |
||||
| 1358 | return null; |
||||
| 1359 | } |
||||
| 1360 | |||||
| 1361 | $date = explode('/', $date); |
||||
| 1362 | // Year-month-day |
||||
| 1363 | $date = $date[2].'-'.$date[1].'-'.$date[0]; |
||||
| 1364 | |||||
| 1365 | return $date; |
||||
| 1366 | } |
||||
| 1367 | |||||
| 1368 | protected function checkAuth() |
||||
| 1369 | { |
||||
| 1370 | if (!$this->authenticated) { |
||||
|
0 ignored issues
–
show
|
|||||
| 1371 | error_log('403'); |
||||
| 1372 | } |
||||
| 1373 | } |
||||
| 1374 | } |
||||
| 1375 |