@@ -246,6 +246,9 @@ public function crearAccion($crearAccionInput)
246
246
247
247
// Comprobamos si existen datos almacenados previamente
248
248
$ table = Database::get_main_table ('plugin_sepe_actions ' );
249
+ $ actionOrigin = Database::escape_string ($ actionOrigin );
250
+ $ actionCode = Database::escape_string ($ actionCode );
251
+
249
252
$ sql = "SELECT action_origin FROM $ table
250
253
WHERE action_origin=' " .$ actionOrigin ."' AND action_code=' " .$ actionCode ."'; " ;
251
254
$ rs = Database::query ($ sql );
@@ -263,11 +266,29 @@ public function crearAccion($crearAccionInput)
263
266
$ startDate = self ::fixDate ($ startDate );
264
267
$ endDate = self ::fixDate ($ endDate );
265
268
266
- $ sql = "INSERT INTO $ table (action_origin, action_code, situation, specialty_origin, professional_area, specialty_code, duration, start_date, end_date, full_itinerary_indicator, financing_type, attendees_count, action_name, global_info, schedule, requirements, contact_action)
267
- VALUES (' " .$ actionOrigin ."',' " .$ actionCode ."',' " .$ situation ."',' " .$ specialtyOrigin ."',' " .$ professionalArea ."',' " .$ specialtyCode ."',' " .$ duration ."',' " .$ startDate ."',' " .$ endDate ."',' " .$ fullItineraryIndicator ."',' " .$ financingType ."',' " .$ attendeesCount ."',' " .$ actionName ."',' " .$ globalInfo ."',' " .$ schedule ."',' " .$ requerements ."',' " .$ contactAction ."') " ;
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
+ ];
268
288
269
- $ rs = Database::query ($ sql );
270
- if (!$ rs ) {
289
+ $ actionId = Database::insert ( $ table , $ params );
290
+
291
+ if (!empty ($ actionId )) {
271
292
return [
272
293
"RESPUESTA_OBT_ACCION " => [
273
294
"CODIGO_RETORNO " => "-1 " ,
@@ -276,7 +297,6 @@ public function crearAccion($crearAccionInput)
276
297
],
277
298
];
278
299
}
279
- $ actionId = Database::insert_id ();
280
300
281
301
// DATOS ESPECIALIDADES DE LA ACCION
282
302
$ table = Database::get_main_table ('plugin_sepe_specialty ' );
@@ -397,7 +417,9 @@ public function crearAccion($crearAccionInput)
397
417
foreach ($ centroList as $ centro ) {
398
418
$ centerOrigin = $ centro ->ORIGEN_CENTRO ;
399
419
$ centerCode = $ centro ->CODIGO_CENTRO ;
400
- $ sql = "SELECT id FROM $ tableCenters
420
+ $ centerOrigin = Database::escape_string ($ centerOrigin );
421
+ $ centerCode = Database::escape_string ($ centerCode );
422
+ $ sql = "SELECT id FROM $ tableCenters
401
423
WHERE center_origin=' " .$ centerOrigin ."' AND center_code=' " .$ centerCode ."'; " ;
402
424
$ res = Database::query ($ sql );
403
425
if (Database::num_rows ($ res ) > 0 ) {
@@ -446,18 +468,23 @@ public function crearAccion($crearAccionInput)
446
468
$ experienceTeleforming = $ tutor ->EXPERIENCIA_MODALIDAD_TELEFORMACION ;
447
469
$ trainingTeleforming = $ tutor ->FORMACION_MODALIDAD_TELEFORMACION ;
448
470
471
+ $ documentType = Database::escape_string ($ documentType );
472
+ $ documentNumber = Database::escape_string ($ documentNumber );
473
+ $ documentLetter = Database::escape_string ($ documentLetter );
474
+
449
475
/* check tutor not exists */
450
- $ sql = "SELECT id FROM $ tableTutors WHERE
451
- document_type=' " .$ documentType ."' AND
452
- document_number=' " .$ documentNumber ."' AND
476
+ $ sql = "SELECT id FROM $ tableTutors
477
+ WHERE
478
+ document_type=' " .$ documentType ."' AND
479
+ document_number=' " .$ documentNumber ."' AND
453
480
document_letter=' " .$ documentLetter ."'; " ;
454
481
$ res = Database::query ($ sql );
455
482
if (Database::num_rows ($ res ) > 0 ) {
456
483
$ aux_row = Database::fetch_assoc ($ res );
457
484
$ tutorId = $ aux_row ['id ' ];
458
485
} else {
459
486
$ sql = "INSERT INTO $ tableTutors (document_type, document_number, document_letter)
460
- VALUES (' " .$ documentType ."',' " .$ documentNumber ."',' " .$ documentLetter ."'); " ;
487
+ VALUES (' " .$ documentType ."',' " .$ documentNumber ."',' " .$ documentLetter ."'); " ;
461
488
Database::query ($ sql );
462
489
$ tutorId = Database::insert_id ();
463
490
}
@@ -470,15 +497,24 @@ public function crearAccion($crearAccionInput)
470
497
],
471
498
];
472
499
}
473
- $ sql = "INSERT INTO $ tableSpecialityTutors (specialty_id, tutor_id, tutor_accreditation, professional_experience, teaching_competence, experience_teleforming, training_teleforming)
474
- VALUES (' " .$ specialtyId ."',' " .$ tutorId ."',' " .$ tutorAccreditation ."',' " .$ professionalExperience ."',' " .$ teachingCompetence ."',' " .$ experienceTeleforming ."',' " .$ trainingTeleforming ."'); " ;
475
- Database::query ($ sql );
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 );
476
511
}
477
512
}
478
513
}
479
514
}
480
515
}
481
516
}
517
+
482
518
// DATOS PARTICIPANTES
483
519
$ tableParticipants = Database::get_main_table ('plugin_sepe_participants ' );
484
520
$ tableTutorsCompany = Database::get_main_table ('plugin_sepe_tutors_company ' );
@@ -532,12 +568,15 @@ public function crearAccion($crearAccionInput)
532
568
$ documentNumberTraining = isset ($ participant ->CONTRATO_FORMACION ->ID_TUTOR_FORMACION ->NUM_DOCUMENTO ) ? $ participant ->CONTRATO_FORMACION ->ID_TUTOR_FORMACION ->NUM_DOCUMENTO : null ;
533
569
$ documentLetterTraining = isset ($ participant ->CONTRATO_FORMACION ->ID_TUTOR_FORMACION ->LETRA_NIF ) ? $ participant ->CONTRATO_FORMACION ->ID_TUTOR_FORMACION ->LETRA_NIF : null ;
534
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 );
535
574
$ tmp_f = Database::query (
536
575
'
537
- SELECT id FROM ' .$ tableTutorsCompany .'
576
+ SELECT id FROM ' .$ tableTutorsCompany .'
538
577
WHERE
539
- document_type=" ' .$ documentTypeTraining .'" AND
540
- document_number=" ' .$ documentNumberTraining .'" AND
578
+ document_type=" ' .$ documentTypeTraining .'" AND
579
+ document_number=" ' .$ documentNumberTraining .'" AND
541
580
document_letter=" ' .$ documentLetterTraining .'"; '
542
581
);
543
582
if (Database::num_rows ($ tmp_f ) > 0 ) {
@@ -631,10 +670,24 @@ public function crearAccion($crearAccionInput)
631
670
$ endDate = self ::fixDate ($ endDate );
632
671
633
672
$ table_aux = Database::get_main_table ('plugin_sepe_participants_specialty ' );
634
- $ sql = "INSERT INTO $ table_aux (participant_id,specialty_origin,professional_area,specialty_code,registration_date,leaving_date,center_origin,center_code,start_date,end_date,final_result,final_qualification,final_score)
635
- VALUES (' " .$ participantId ."',' " .$ specialtyOrigin ."',' " .$ professionalArea ."',' " .$ specialtyCode ."',' " .$ registrationDate ."',' " .$ leavingDate ."',' " .$ centerOrigin ."',' " .$ centerCode ."',' " .$ startDate ."',' " .$ endDate ."',' " .$ finalResult ."',' " .$ finalQualification ."',' " .$ finalScore ."'); " ;
636
- Database::query ($ sql );
637
- $ participantSpecialtyId = Database::insert_id ();
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 );
638
691
if (empty ($ participantSpecialtyId )) {
639
692
return [
640
693
"RESPUESTA_OBT_ACCION " => [
@@ -661,10 +714,16 @@ public function crearAccion($crearAccionInput)
661
714
$ endDate = self ::fixDate ($ endDate );
662
715
663
716
$ table_aux2 = Database::get_main_table ('plugin_sepe_participants_specialty_tutorials ' );
664
- $ sql = "INSERT INTO $ table_aux2 (participant_specialty_id,center_origin,center_code,start_date,end_date)
665
- VALUES (' " .$ participantSpecialtyId ."',' " .$ centerOrigin ."',' " .$ centerCode ."',' " .$ startDate ."',' " .$ endDate ."'); " ;
666
- $ rs = Database::query ($ sql );
667
- if (!$ rs ) {
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 )) {
668
727
return [
669
728
"RESPUESTA_OBT_ACCION " => [
670
729
"CODIGO_RETORNO " => "-1 " ,
@@ -685,9 +744,7 @@ public function crearAccion($crearAccionInput)
685
744
$ obtenerAccionInput ->ID_ACCION ->ORIGEN_ACCION = $ actionOrigin ;
686
745
$ obtenerAccionInput ->ID_ACCION ->CODIGO_ACCION = $ actionCode ;
687
746
688
- $ result = self ::obtenerAccion ($ obtenerAccionInput );
689
-
690
- return $ result ;
747
+ return self ::obtenerAccion ($ obtenerAccionInput );
691
748
}
692
749
693
750
public function obtenerAccion ($ obtenerAccionInput )
@@ -725,6 +782,9 @@ public function obtenerAccion($obtenerAccionInput)
725
782
$ participantsSpecialityTutorialsTable = Database::get_main_table ('plugin_sepe_participants_specialty_tutorials ' );
726
783
$ tableTutorsCompany = Database::get_main_table ('plugin_sepe_tutors_company ' );
727
784
785
+ $ actionOrigin = Database::escape_string ($ actionOrigin );
786
+ $ actionCode = Database::escape_string ($ actionCode );
787
+
728
788
// Comprobamos si existen datos almacenados previamente
729
789
$ sql = "SELECT *
730
790
FROM $ table
0 commit comments