Proyectos de Subversion LeadersLinked - Services

Rev

Rev 530 | Rev 532 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 530 Rev 531
Línea 354... Línea 354...
354
 
354
 
355
            // 🔹 Crear nueva competencia si nro == 0
355
            // 🔹 Crear nueva competencia si nro == 0
356
            if ((int) ($hasIdData['nro'] ?? 0) === 0) {
356
            if ((int) ($hasIdData['nro'] ?? 0) === 0) {
Línea 357... Línea 357...
357
                $uuid = $this->generateUuid();
357
                $uuid = $this->generateUuid();
358
 
358
 
359
                $insert = $sql->insert(CompetencyMapper::_TABLE)
359
                $insert = $sql->insert('tbl_competencies')
360
                    ->values([
360
                    ->values([
361
                        'uuid' => $uuid,
361
                        'uuid' => $uuid,
362
                        'name' => $name,
362
                        'name' => $name,
363
                        'description' => $description,
363
                        'description' => $description,
364
                        'competency_type_id' => $competencyTypeId,
364
                        'competency_type_id' => $competencyTypeId,
365
                        'status' => CompetencyMapper::STATUS_ACTIVE,
365
                        'status' => 'a',
366
                        'added_on' => date('Y-m-d H:i:s'),
366
                        'added_on' => date('Y-m-d H:i:s'),
367
                        'updated_on' => date('Y-m-d H:i:s')
367
                        'updated_on' => date('Y-m-d H:i:s')
368
                    ]);
368
                    ]);
Línea 372... Línea 372...
372
            }
372
            }
373
            // 🔹 Actualizar competencia existente si nro > 0
373
            // 🔹 Actualizar competencia existente si nro > 0
374
            else {
374
            else {
375
                $competencyId = (int) $hasIdData['nro'];
375
                $competencyId = (int) $hasIdData['nro'];
Línea 376... Línea 376...
376
 
376
 
377
                $select = $sql->select(CompetencyMapper::_TABLE)
377
                $select = $sql->select('tbl_competencies')
378
                    ->where(['id' => $competencyId]);
378
                    ->where(['id' => $competencyId]);
Línea 379... Línea 379...
379
                $existing = $sql->prepareStatementForSqlObject($select)->execute()->current();
379
                $existing = $sql->prepareStatementForSqlObject($select)->execute()->current();
380
 
380
 
Línea 386... Línea 386...
386
                    ];
386
                    ];
387
                }
387
                }
Línea 388... Línea 388...
388
 
388
 
389
                // Solo actualizamos si realmente cambia el nombre o la descripción
389
                // Solo actualizamos si realmente cambia el nombre o la descripción
390
                if ($existing['name'] !== $name || $existing['description'] !== $description) {
390
                if ($existing['name'] !== $name || $existing['description'] !== $description) {
391
                    $update = $sql->update(CompetencyMapper::_TABLE)
391
                    $update = $sql->update('tbl_competencies')
392
                        ->set([
392
                        ->set([
393
                            'name' => $name,
393
                            'name' => $name,
394
                            'description' => $description,
394
                            'description' => $description,
395
                            'updated_on' => date('Y-m-d H:i:s')
395
                            'updated_on' => date('Y-m-d H:i:s')
Línea 399... Línea 399...
399
                }
399
                }
Línea 400... Línea 400...
400
 
400
 
401
                $status = 'updated';
401
                $status = 'updated';
Línea 402... Línea -...
402
            }
-
 
403
 
-
 
404
            // 🔹 Vincular competencia con job description si no está vinculada
-
 
405
            $linkCheck = $sql->select(JobDescriptionCompetencyMapper::_TABLE)
-
 
406
                ->where([
-
 
407
                    'job_description_id' => $jobDescriptionId,
-
 
408
                    'competency_id' => $competencyId
-
 
409
                ]);
-
 
410
            $existsLink = $sql->prepareStatementForSqlObject($linkCheck)->execute()->current();
-
 
411
 
-
 
412
            if (!$existsLink) {
-
 
413
                $linkInsert = $sql->insert(JobDescriptionCompetencyMapper::_TABLE)
-
 
414
                    ->values([
-
 
415
                        'job_description_id' => $jobDescriptionId,
-
 
416
                        'competency_id' => $competencyId
-
 
417
                    ]);
-
 
418
                $sql->prepareStatementForSqlObject($linkInsert)->execute();
-
 
419
            }
402
            }
420
 
403
 
421
            // 🔹 Guardar resultado
404
            // 🔹 Guardar resultado
422
            $results[] = [
405
            $results[] = [
423
                'name' => $name,
406
                'name' => $name,