Skip to content

Commit

Permalink
Cria db-update para inserir o tipo de conta nos editais de diligência…
Browse files Browse the repository at this point in the history
…s da LPG
  • Loading branch information
erleibiazzio committed Mar 13, 2024
1 parent 088f537 commit 0145005
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions plugins/SettingsPe/db-updates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

use function MapasCulturais\__exec;
use function MapasCulturais\__table_exists;
use function MapasCulturais\__try;
use MapasCulturais\App;

return [
'Insere campo de conta corrente para extração do CNAB' => function () {
$app = App::i();
$em = $app->em;
$conn = $em->getConnection();

$opportunities_ids = [
'1175' => '28773',
'1176' => '28774',
'1177' => '28775',
'1178' => '28776',
'1179' => '28777',
'1180' => '28778',
'1181' => '28779',
'1182' => '28780',
'1183' => '28781',
'1184' => '28782',
'1185' => '28783',
'1186' => '28784',
'1187' => '28785',
'1188' => '28786',
'1189' => '28787',
'1190' => '28788'
];

$app->disableAccessControl();
foreach($opportunities_ids as $opp => $field) {
$field_name = "field_".$field;
if($registration_ids = $conn->fetchAll("SELECT id FROM registration WHERE opportunity_id = {$opp}")) {
foreach($registration_ids as $value) {
$reg_id = $value['id'];
__exec("
INSERT INTO registration_meta (
id,
object_id,
key,
value
) VALUES (
nextval('registration_meta_id_seq'::regclass),
{$reg_id},
'{$field_name}',
'Conta corrente'
)");
$app->log->debug("{$reg_id} definido campo de conta corrente no campo {$field_name}");
}
}
}
$app->enableAccessControl();
},
];

0 comments on commit 0145005

Please sign in to comment.