From 014500508854b5eb226009503701c346359d4262 Mon Sep 17 00:00:00 2001 From: Erlei Biazzio Date: Wed, 13 Mar 2024 15:37:10 -0300 Subject: [PATCH] =?UTF-8?q?Cria=20db-update=20para=20inserir=20o=20tipo=20?= =?UTF-8?q?de=20conta=20nos=20editais=20de=20dilig=C3=AAncias=20da=20LPG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/SettingsPe/db-updates.php | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 plugins/SettingsPe/db-updates.php diff --git a/plugins/SettingsPe/db-updates.php b/plugins/SettingsPe/db-updates.php new file mode 100644 index 0000000..4c26db4 --- /dev/null +++ b/plugins/SettingsPe/db-updates.php @@ -0,0 +1,57 @@ + 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(); + }, +]; \ No newline at end of file