Skip to content

Commit 0bd3984

Browse files
committed
Merge branch 'feature/plano-de-trabalho-doctrine' into feature/docker-osi-compatible
* feature/plano-de-trabalho-doctrine: feat: deixa permanente diretório assets do module feat: cria metadados das novas entidades feat: adiciona fluxo nos controladores feat: muda estrutura das entidades e metadados feat: cria db updates do plano de trabalho feat: add crud básico para plano, metas e entregas feat: add estrutura minima com doctrine feat: adiciona collapse para plano de trabalho feat: limpa campos quando entregas vinculadas a meta são desativadas feat: reimplementa formulário de configuração do plano de trabalho na oportunidade feat: configura css das metas e entregas feat: configura fields quando moeda nas metas e entregas feat: adiciona gerenciamento de entregas para as metas feat: adiciona fluxo inicial de entregas nas metas feat: adiciona novo campo de segmento cultural no plano de trabalho e aplica css de acordo com figma feat: define estrutura mínima das metas na inscrição feat: inicia criação do componente de cadastro do plano de trabalho na inscrição feat: atualiza configurações do plano de trabalho no gerenciamento da oportunidade feat: refatora e atualiza escopo nome dos metadados feat: cria estrutura mínima do módulo de plano de trabalho
2 parents bb2ae0d + 1d2363a commit 0bd3984

File tree

19 files changed

+1900
-0
lines changed

19 files changed

+1900
-0
lines changed
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<?php
2+
3+
namespace OpportunityWorkplan\Controllers;
4+
5+
use MapasCulturais\App;
6+
use MapasCulturais\Entities\Registration;
7+
use OpportunityWorkplan\Entities\GoalDelivery;
8+
use OpportunityWorkplan\Entities\Workplan as EntitiesWorkplan;
9+
use OpportunityWorkplan\Entities\WorkplanGoal;
10+
use MapasCulturais\i;
11+
12+
class Workplan extends \MapasCulturais\Controller
13+
{
14+
public function GET_index()
15+
{
16+
$app = App::i();
17+
18+
$registration = $app->repo(Registration::class)->find($this->data['id']);
19+
$workplan = $app->repo(EntitiesWorkplan::class)->findOneBy(['registration' => $registration->id]);
20+
21+
$data = [
22+
'workplan' => []
23+
];
24+
25+
if ($workplan) {
26+
$data = [
27+
'workplan' => $workplan->jsonSerialize(),
28+
];
29+
}
30+
31+
32+
$this->json($data);
33+
}
34+
35+
public function POST_save()
36+
{
37+
$app = App::i();
38+
39+
$app->disableAccessControl();
40+
41+
$registration = $app->repo(Registration::class)->find($this->data['registrationId']);
42+
$workplan = $app->repo(EntitiesWorkplan::class)->findOneBy(['registration' => $registration->id]);
43+
44+
if (!$workplan) {
45+
$workplan = new EntitiesWorkplan();
46+
}
47+
$dataWorkplan = $this->data['workplan'];
48+
49+
if (array_key_exists('projectDuration', $dataWorkplan)) {
50+
$workplan->projectDuration = $dataWorkplan['projectDuration'];
51+
}
52+
53+
if (array_key_exists('culturalArtisticSegment', $dataWorkplan)) {
54+
$workplan->culturalArtisticSegment = $dataWorkplan['culturalArtisticSegment'];
55+
}
56+
57+
$workplan->registration = $registration;
58+
$workplan->save(true);
59+
60+
if (array_key_exists('goals', $dataWorkplan)) {
61+
foreach ($dataWorkplan['goals'] as $g) {
62+
if ($g['id'] > 0) {
63+
$goal = $app->repo(WorkplanGoal::class)->find($g['id']);
64+
} else {
65+
$goal = new WorkplanGoal();
66+
}
67+
68+
$goal->monthInitial = $g['monthInitial'] ?? null;
69+
$goal->monthEnd = $g['monthEnd'] ?? null;
70+
$goal->title = $g['title'] ?? null;
71+
$goal->description = $g['description'] ?? null;
72+
$goal->culturalMakingStage = $g['culturalMakingStage'] ?? null;
73+
$goal->amount = $g['amount'] ?? null;
74+
$goal->workplan = $workplan;
75+
$goal->save(true);
76+
77+
78+
foreach ($g['deliveries'] as $d) {
79+
if ($d['id'] > 0) {
80+
$delivery = $app->repo(GoalDelivery::class)->find($d['id']);
81+
} else {
82+
$delivery = new GoalDelivery();
83+
}
84+
85+
$delivery->name = $d['name'] ?? null;
86+
$delivery->description = $d['description'] ?? null;
87+
$delivery->type = $d['type'] ?? null;
88+
$delivery->segmentDelivery = $d['segmentDelivery'] ?? null;
89+
$delivery->budgetAction = $d['budgetAction'] ?? null;
90+
$delivery->expectedNumberPeople = $d['expectedNumberPeople'] ?? null;
91+
$delivery->generaterRevenue = $d['generaterRevenue'] ?? null;
92+
$delivery->renevueQtd = $d['renevueQtd'] ?? null;
93+
$delivery->unitValueForecast = $d['unitValueForecast'] ?? null;
94+
$delivery->totalValueForecast = $d['totalValueForecast'] ?? null;
95+
$delivery->goal = $goal;
96+
$delivery->save(true);
97+
}
98+
}
99+
}
100+
101+
$app->enableAccessControl();
102+
103+
$this->json([
104+
'workplan' => $workplan->jsonSerialize(),
105+
]);
106+
}
107+
108+
109+
public function DELETE_goal()
110+
{
111+
$app = App::i();
112+
113+
$goal = $app->repo(WorkplanGoal::class)->find($this->data['id']);
114+
115+
if ($goal) {
116+
$app->em->remove($goal);
117+
$app->em->flush();
118+
}
119+
$this->json(true);
120+
}
121+
122+
public function DELETE_delivery()
123+
{
124+
$app = App::i();
125+
126+
$delivery = $app->repo(GoalDelivery::class)->find($this->data['id']);
127+
128+
if ($delivery) {
129+
$app->em->remove($delivery);
130+
$app->em->flush();
131+
}
132+
133+
$this->json(true);
134+
}
135+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
namespace OpportunityWorkplan\Entities;
3+
4+
use Doctrine\ORM\Mapping as ORM;
5+
6+
use MapasCulturais\Traits\EntityMetadata;
7+
use MapasCulturais\Traits\EntityOwnerAgent;
8+
9+
/**
10+
*
11+
* @ORM\Table(name="registration_workplan_goal_delivery")
12+
* @ORM\Entity
13+
* @ORM\entity(repositoryClass="MapasCulturais\Repository")
14+
*/
15+
class GoalDelivery extends \MapasCulturais\Entity {
16+
17+
use EntityMetadata,
18+
EntityOwnerAgent;
19+
20+
/**
21+
*
22+
* @ORM\Id
23+
* @ORM\Column(type="integer")
24+
* @ORM\GeneratedValue(strategy="IDENTITY")
25+
*/
26+
protected $id;
27+
28+
/**
29+
* @var \MapasCulturais\Entities\Agent
30+
*
31+
* @ORM\ManyToOne(targetEntity="MapasCulturais\Entities\Agent", fetch="LAZY")
32+
* @ORM\JoinColumns({
33+
* @ORM\JoinColumn(name="agent_id", referencedColumnName="id", onDelete="CASCADE")
34+
* })
35+
*/
36+
protected $owner;
37+
38+
/**
39+
*
40+
* @ORM\ManyToOne(targetEntity=\OpportunityWorkplan\Entities\WorkplanGoal::class, inversedBy="deliveries"))
41+
* @ORM\JoinColumns({
42+
* @ORM\JoinColumn(name="goal_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
43+
* })
44+
*/
45+
protected $goal;
46+
47+
/**
48+
* @ORM\OneToMany(targetEntity=\OpportunityWorkplan\Entities\GoalDeliveryMeta::class, mappedBy="owner", cascade={"remove","persist"}, orphanRemoval=true)
49+
*/
50+
protected $__metadata;
51+
52+
/**
53+
* @var \DateTime
54+
*
55+
* @ORM\Column(name="create_timestamp", type="datetime", nullable=false)
56+
*/
57+
protected $createTimestamp;
58+
59+
/**
60+
* @var \DateTime
61+
*
62+
* @ORM\Column(name="update_timestamp", type="datetime", nullable=true)
63+
*/
64+
protected $updateTimestamp;
65+
66+
public function jsonSerialize(): array
67+
{
68+
$metadatas = $this->getMetadata();
69+
70+
return [
71+
'id' => $this->id,
72+
...$metadatas
73+
];
74+
}
75+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
3+
namespace OpportunityWorkplan\Entities;
4+
5+
use Doctrine\ORM\Mapping as ORM;
6+
7+
use MapasCulturais\App;
8+
9+
/**
10+
* GoalDelivery
11+
*
12+
* @ORM\Table(name="registration_workplan_goal_delivery_meta")
13+
* @ORM\Entity
14+
* @ORM\entity(repositoryClass="MapasCulturais\Repository")
15+
*/
16+
class GoalDeliveryMeta extends \MapasCulturais\Entity {
17+
/**
18+
* @ORM\Id
19+
* @ORM\Column(type="integer")
20+
* @ORM\GeneratedValue(strategy="IDENTITY")
21+
*/
22+
public $id;
23+
24+
/**
25+
* @var string
26+
*
27+
* @ORM\Column(name="key", type="string", nullable=false)
28+
*/
29+
public $key;
30+
31+
/**
32+
* @var string
33+
*
34+
* @ORM\Column(name="value", type="text", nullable=true)
35+
*/
36+
protected $value;
37+
38+
/**
39+
* @var \OpportunityWorkplan\Entities\GoalDelivery
40+
*
41+
* @ORM\ManyToOne(targetEntity=\OpportunityWorkplan\Entities\GoalDelivery::class)
42+
* @ORM\JoinColumns({
43+
* @ORM\JoinColumn(name="object_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
44+
* })
45+
*/
46+
protected $owner;
47+
48+
49+
/** @ORM\PrePersist */
50+
public function _prePersist($args = null){
51+
App::i()->applyHookBoundTo($this, 'entity(GoalDelivery).meta(' . $this->key . ').insert:before');
52+
}
53+
/** @ORM\PostPersist */
54+
public function _postPersist($args = null){
55+
App::i()->applyHookBoundTo($this, 'entity(GoalDelivery).meta(' . $this->key . ').insert:after');
56+
}
57+
58+
/** @ORM\PreRemove */
59+
public function _preRemove($args = null){
60+
App::i()->applyHookBoundTo($this, 'entity(GoalDelivery).meta(' . $this->key . ').remove:before');
61+
}
62+
/** @ORM\PostRemove */
63+
public function _postRemove($args = null){
64+
App::i()->applyHookBoundTo($this, 'entity(GoalDelivery).meta(' . $this->key . ').remove:after');
65+
}
66+
67+
/** @ORM\PreUpdate */
68+
public function _preUpdate($args = null){
69+
App::i()->applyHookBoundTo($this, 'entity(GoalDelivery).meta(' . $this->key . ').update:before');
70+
}
71+
/** @ORM\PostUpdate */
72+
public function _postUpdate($args = null){
73+
App::i()->applyHookBoundTo($this, 'entity(GoalDelivery).meta(' . $this->key . ').update:after');
74+
}
75+
76+
//============================================================= //
77+
// The following lines ara used by MapasCulturais hook system.
78+
// Please do not change them.
79+
// ============================================================ //
80+
81+
/** @ORM\PrePersist */
82+
public function prePersist($args = null){ parent::prePersist($args); }
83+
/** @ORM\PostPersist */
84+
public function postPersist($args = null){ parent::postPersist($args); }
85+
86+
/** @ORM\PreRemove */
87+
public function preRemove($args = null){ parent::preRemove($args); }
88+
/** @ORM\PostRemove */
89+
public function postRemove($args = null){ parent::postRemove($args); }
90+
91+
/** @ORM\PreUpdate */
92+
public function preUpdate($args = null){ parent::preUpdate($args); }
93+
/** @ORM\PostUpdate */
94+
public function postUpdate($args = null){ parent::postUpdate($args); }
95+
}

0 commit comments

Comments
 (0)