|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Investform module for webcms2. |
|
5
|
|
|
* Copyright (c) @see LICENSE |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace AdminModule\InvestformModule; |
|
9
|
|
|
|
|
10
|
|
|
use Nette\Forms\Form; |
|
11
|
|
|
use WebCMS\InvestformModule\Entity\Businessman; |
|
12
|
|
|
use WebCMS\InvestformModule\Entity\Company; |
|
13
|
|
|
use WebCMS\InvestformModule\Entity\Investment; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Description of |
|
17
|
|
|
* |
|
18
|
|
|
* @author Jakub Sanda <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class CompanyPresenter extends BasePresenter |
|
21
|
|
|
{ |
|
22
|
|
|
|
|
23
|
|
|
private $company; |
|
24
|
|
|
|
|
25
|
|
|
private $companies; |
|
26
|
|
|
|
|
27
|
|
|
private $businessmen; |
|
28
|
|
|
|
|
29
|
|
|
private $newInvestments = 0; |
|
30
|
|
|
|
|
31
|
|
|
private $newInvestmentsAmount = 0; |
|
32
|
|
|
|
|
33
|
|
|
private $openInvestments = 0; |
|
34
|
|
|
|
|
35
|
|
|
private $openInvestmentsAmount = 0; |
|
36
|
|
|
|
|
37
|
|
|
private $closedInvestments = 0; |
|
38
|
|
|
|
|
39
|
|
|
private $closedInvestmentsAmount = 0; |
|
40
|
|
|
|
|
41
|
|
|
private $paidInvestments = 0; |
|
42
|
|
|
|
|
43
|
|
|
private $paidInvestmentsAmount = 0; |
|
44
|
|
|
|
|
45
|
|
|
protected function startup() |
|
46
|
|
|
{ |
|
47
|
|
|
parent::startup(); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
protected function beforeRender() |
|
51
|
|
|
{ |
|
52
|
|
|
parent::beforeRender(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function actionDefault($idPage) |
|
56
|
|
|
{ |
|
57
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function renderDefault($idPage) |
|
61
|
|
|
{ |
|
62
|
|
|
$this->reloadContent(); |
|
63
|
|
|
$this->template->idPage = $idPage; |
|
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function actionActiveCompanies($idPage) |
|
|
|
|
|
|
67
|
|
|
{ |
|
68
|
|
|
$this->reloadContent(); |
|
69
|
|
|
|
|
70
|
|
|
$this->companies = $this->em->getRepository('\WebCMS\InvestformModule\Entity\Company')->findBy(array( |
|
71
|
|
|
'active' => true |
|
72
|
|
|
)); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function renderActiveCompanies($idPage) |
|
76
|
|
|
{ |
|
77
|
|
|
$this->template->idPage = $idPage; |
|
|
|
|
|
|
78
|
|
|
$this->template->numberOfCompanies = count($this->companies); |
|
|
|
|
|
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function actionInactiveCompanies($idPage) |
|
|
|
|
|
|
82
|
|
|
{ |
|
83
|
|
|
$this->reloadContent(); |
|
84
|
|
|
|
|
85
|
|
|
$this->companies = $this->em->getRepository('\WebCMS\InvestformModule\Entity\Company')->findBy(array( |
|
86
|
|
|
'active' => false |
|
87
|
|
|
)); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
public function renderInactiveCompanies($idPage) |
|
91
|
|
|
{ |
|
92
|
|
|
$this->template->idPage = $idPage; |
|
|
|
|
|
|
93
|
|
|
$this->template->numberOfCompanies = count($this->companies); |
|
|
|
|
|
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
View Code Duplication |
protected function createComponentActiveGrid($name) |
|
|
|
|
|
|
97
|
|
|
{ |
|
98
|
|
|
$grid = $this->createGrid($this, $name, "\WebCMS\InvestformModule\Entity\Company", null, array( |
|
99
|
|
|
'active = true', |
|
100
|
|
|
)); |
|
101
|
|
|
|
|
102
|
|
|
$grid->setFilterRenderType(\Grido\Components\Filters\Filter::RENDER_INNER); |
|
103
|
|
|
|
|
104
|
|
|
$grid->addColumnText('name', 'Name')->setSortable(); |
|
105
|
|
|
|
|
106
|
|
|
$grid->addColumnText('street', 'Street and number')->setSortable(); |
|
107
|
|
|
|
|
108
|
|
|
$grid->addColumnText('zipCity', 'Zip and city')->setSortable(); |
|
109
|
|
|
|
|
110
|
|
|
$grid->addActionHref("deactivate", 'Deactivate', 'deactivate', array('idPage' => $this->actualPage->getId()))->getElementPrototype()->addAttributes(array('class' => array('btn', 'btn-primary', 'ajax', 'grey'))); |
|
111
|
|
|
$grid->addActionHref("detail", 'Company detail', 'detail', array('idPage' => $this->actualPage->getId()))->getElementPrototype()->addAttributes(array('class' => array('btn', 'btn-primary', 'green'))); |
|
112
|
|
|
|
|
113
|
|
|
return $grid; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
View Code Duplication |
protected function createComponentInactiveGrid($name) |
|
|
|
|
|
|
117
|
|
|
{ |
|
118
|
|
|
$grid = $this->createGrid($this, $name, "\WebCMS\InvestformModule\Entity\Company", null, array( |
|
119
|
|
|
'active = false', |
|
120
|
|
|
)); |
|
121
|
|
|
|
|
122
|
|
|
$grid->setFilterRenderType(\Grido\Components\Filters\Filter::RENDER_INNER); |
|
123
|
|
|
|
|
124
|
|
|
$grid->addColumnText('name', 'Name')->setSortable(); |
|
125
|
|
|
|
|
126
|
|
|
$grid->addColumnText('street', 'Street and number')->setSortable(); |
|
127
|
|
|
|
|
128
|
|
|
$grid->addColumnText('zipCity', 'Zip and city')->setSortable(); |
|
129
|
|
|
|
|
130
|
|
|
$grid->addActionHref("activate", 'Activate', 'activate', array('idPage' => $this->actualPage->getId()))->getElementPrototype()->addAttributes(array('class' => array('btn', 'btn-primary', 'ajax', 'grey'))); |
|
131
|
|
|
$grid->addActionHref("detail", 'Company detail', 'detail', array('idPage' => $this->actualPage->getId()))->getElementPrototype()->addAttributes(array('class' => array('btn', 'btn-primary', 'green'))); |
|
132
|
|
|
|
|
133
|
|
|
return $grid; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
View Code Duplication |
public function actionDeactivate($id, $idPage, $inDetail = false) |
|
|
|
|
|
|
137
|
|
|
{ |
|
138
|
|
|
|
|
139
|
|
|
$this->company = $this->em->getRepository('\WebCMS\InvestformModule\Entity\Company')->find($id); |
|
140
|
|
|
$this->company->setActive(false); |
|
141
|
|
|
|
|
142
|
|
|
$this->businessmen = $this->em->getRepository('\WebCMS\InvestformModule\Entity\Businessman')->findBy(array( |
|
143
|
|
|
'company' => $this->company |
|
144
|
|
|
)); |
|
145
|
|
|
|
|
146
|
|
|
if ($this->businessmen) { |
|
147
|
|
|
foreach ($this->businessmen as $businessman) { |
|
148
|
|
|
$businessman->setActive(false); |
|
149
|
|
|
} |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
$this->em->flush(); |
|
153
|
|
|
|
|
154
|
|
|
$this->flashMessage('Company has been deactivated', 'success'); |
|
155
|
|
|
|
|
156
|
|
|
if ($inDetail) { |
|
157
|
|
|
$this->forward('detail', array( |
|
158
|
|
|
'id' => $id, |
|
159
|
|
|
'idPage' => $this->actualPage->getId() |
|
160
|
|
|
)); |
|
161
|
|
|
} else { |
|
162
|
|
|
$this->forward('activeCompanies', array( |
|
163
|
|
|
'idPage' => $this->actualPage->getId() |
|
164
|
|
|
)); |
|
165
|
|
|
} |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
View Code Duplication |
public function actionActivate($id, $idPage, $inDetail = false) |
|
|
|
|
|
|
169
|
|
|
{ |
|
170
|
|
|
|
|
171
|
|
|
$this->company = $this->em->getRepository('\WebCMS\InvestformModule\Entity\Company')->find($id); |
|
172
|
|
|
$this->company->setActive(true); |
|
173
|
|
|
|
|
174
|
|
|
$this->businessmen = $this->em->getRepository('\WebCMS\InvestformModule\Entity\Businessman')->findBy(array( |
|
175
|
|
|
'company' => $this->company |
|
176
|
|
|
)); |
|
177
|
|
|
|
|
178
|
|
|
if ($this->businessmen) { |
|
179
|
|
|
foreach ($this->businessmen as $businessman) { |
|
180
|
|
|
$businessman->setActive(true); |
|
181
|
|
|
} |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
$this->em->flush(); |
|
185
|
|
|
|
|
186
|
|
|
$this->flashMessage('Company has been activated', 'success'); |
|
187
|
|
|
|
|
188
|
|
|
if ($inDetail) { |
|
189
|
|
|
$this->forward('detail', array( |
|
190
|
|
|
'id' => $id, |
|
191
|
|
|
'idPage' => $this->actualPage->getId() |
|
192
|
|
|
)); |
|
193
|
|
|
} else { |
|
194
|
|
|
$this->forward('inactiveCompanies', array( |
|
195
|
|
|
'idPage' => $this->actualPage->getId() |
|
196
|
|
|
)); |
|
197
|
|
|
} |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
|
|
201
|
|
|
public function actionUpdate($id, $idPage) |
|
|
|
|
|
|
202
|
|
|
{ |
|
203
|
|
|
if ($id) { |
|
204
|
|
|
$this->company = $this->em->getRepository('\WebCMS\InvestformModule\Entity\Company')->find($id); |
|
205
|
|
|
} |
|
206
|
|
|
} |
|
207
|
|
|
|
|
208
|
|
|
public function renderUpdate($idPage) |
|
209
|
|
|
{ |
|
210
|
|
|
$this->reloadContent(); |
|
211
|
|
|
|
|
212
|
|
|
$this->template->idPage = $idPage; |
|
|
|
|
|
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
public function createComponentForm($name) |
|
|
|
|
|
|
216
|
|
|
{ |
|
217
|
|
|
$form = $this->createForm('form-submit', 'default', null); |
|
|
|
|
|
|
218
|
|
|
|
|
219
|
|
|
$form->addText('name', 'Name')->setRequired('Name is mandatory.'); |
|
220
|
|
|
$form->addText('street', 'Street and number'); |
|
221
|
|
|
$form->addText('zipCity', 'Zip and city'); |
|
222
|
|
|
$form->addText('ico', 'Ico'); |
|
223
|
|
|
$form->addText('dic', 'Dic'); |
|
224
|
|
|
$form->addText('email', 'Email') |
|
225
|
|
|
->addRule(Form::EMAIL, 'This email is not valid.') |
|
226
|
|
|
->setRequired('Email is mandatory.'); |
|
227
|
|
|
$form->addText('phone', 'Phone')->setRequired('Phone is mandatory.'); |
|
228
|
|
|
|
|
229
|
|
|
if ($this->company) { |
|
230
|
|
|
$form->setDefaults($this->company->toArray()); |
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
|
|
$form->addSubmit('save', 'Save new company'); |
|
234
|
|
|
|
|
235
|
|
|
$form->onSuccess[] = callback($this, 'formSubmitted'); |
|
236
|
|
|
|
|
237
|
|
|
return $form; |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
public function formSubmitted($form) |
|
241
|
|
|
{ |
|
242
|
|
|
$values = $form->getValues(); |
|
243
|
|
|
|
|
244
|
|
|
if (!$this->company) { |
|
245
|
|
|
$this->company = new Company; |
|
246
|
|
|
$this->em->persist($this->company); |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
$this->company->setName($values->name); |
|
250
|
|
|
$this->company->setStreet($values->street); |
|
251
|
|
|
$this->company->setZipCity($values->zipCity); |
|
252
|
|
|
$this->company->setIco($values->ico); |
|
253
|
|
|
$this->company->setDic($values->dic); |
|
254
|
|
|
$this->company->setEmail($values->email); |
|
255
|
|
|
$this->company->setPhone($values->phone); |
|
256
|
|
|
$this->company->setActive(true); |
|
257
|
|
|
|
|
258
|
|
|
$this->em->flush(); |
|
259
|
|
|
|
|
260
|
|
|
$this->flashMessage('Company has been updated.', 'success'); |
|
261
|
|
|
|
|
262
|
|
|
$this->forward('detail', array( |
|
263
|
|
|
'id' => $this->company->getId(), |
|
264
|
|
|
'idPage' => $this->actualPage->getId() |
|
265
|
|
|
)); |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
|
|
public function actionDetail($id, $idPage) |
|
|
|
|
|
|
269
|
|
|
{ |
|
270
|
|
|
$this->company = $this->em->getRepository('\WebCMS\InvestformModule\Entity\Company')->find($id); |
|
271
|
|
|
$this->businessmen = $this->em->getRepository('\WebCMS\InvestformModule\Entity\Businessman')->findBy(array( |
|
272
|
|
|
'company' => $this->company |
|
273
|
|
|
)); |
|
274
|
|
|
|
|
275
|
|
|
foreach ($this->businessmen as $businessman) { |
|
276
|
|
|
$investments = $this->em->getRepository('\WebCMS\InvestformModule\Entity\Investment')->findBy(array( |
|
277
|
|
|
'businessman' => $businessman |
|
278
|
|
|
)); |
|
279
|
|
|
|
|
280
|
|
|
if ($investments) { |
|
281
|
|
|
|
|
282
|
|
|
foreach ($investments as $investment) { |
|
283
|
|
|
// new investment |
|
284
|
|
|
if (!$investment->getContractSend() && !$investment->getContractClosed() && !$investment->getContractPaid()) { |
|
285
|
|
|
$this->newInvestments++; |
|
286
|
|
|
$this->newInvestmentsAmount += $investment->getInvestment(); |
|
287
|
|
|
} |
|
288
|
|
|
// open investment |
|
289
|
|
|
if ($investment->getContractSend() && !$investment->getContractClosed() && !$investment->getContractPaid()) { |
|
290
|
|
|
$this->openInvestments++; |
|
291
|
|
|
$this->openInvestmentsAmount += $investment->getInvestment(); |
|
292
|
|
|
} |
|
293
|
|
|
// closed investment |
|
294
|
|
|
if ($investment->getContractSend() && $investment->getContractClosed() && !$investment->getContractPaid()) { |
|
295
|
|
|
$this->closedInvestments++; |
|
296
|
|
|
$this->closedInvestmentsAmount += $investment->getInvestment(); |
|
297
|
|
|
} |
|
298
|
|
|
// paid investment |
|
299
|
|
|
if ($investment->getContractSend() && $investment->getContractClosed() && $investment->getContractPaid()) { |
|
300
|
|
|
$this->paidInvestments++; |
|
301
|
|
|
$this->paidInvestmentsAmount += $investment->getInvestment(); |
|
302
|
|
|
} |
|
303
|
|
|
} |
|
304
|
|
|
|
|
305
|
|
|
} |
|
306
|
|
|
|
|
307
|
|
|
} |
|
308
|
|
|
} |
|
309
|
|
|
|
|
310
|
|
|
public function renderDetail($idPage) |
|
311
|
|
|
{ |
|
312
|
|
|
$this->reloadContent(); |
|
313
|
|
|
$this->template->idPage = $idPage; |
|
|
|
|
|
|
314
|
|
|
$this->template->businessmen = $this->businessmen; |
|
|
|
|
|
|
315
|
|
|
$this->template->company = $this->company; |
|
|
|
|
|
|
316
|
|
|
|
|
317
|
|
|
$this->template->newInvestments = $this->newInvestments; |
|
|
|
|
|
|
318
|
|
|
$this->template->openInvestments = $this->openInvestments; |
|
|
|
|
|
|
319
|
|
|
$this->template->closedInvestments = $this->closedInvestments; |
|
|
|
|
|
|
320
|
|
|
$this->template->paidInvestments = $this->paidInvestments; |
|
|
|
|
|
|
321
|
|
|
$this->template->newInvestmentsAmount = $this->newInvestmentsAmount; |
|
|
|
|
|
|
322
|
|
|
$this->template->openInvestmentsAmount = $this->openInvestmentsAmount; |
|
|
|
|
|
|
323
|
|
|
$this->template->closedInvestmentsAmount = $this->closedInvestmentsAmount; |
|
|
|
|
|
|
324
|
|
|
$this->template->paidInvestmentsAmount = $this->paidInvestmentsAmount; |
|
|
|
|
|
|
325
|
|
|
} |
|
326
|
|
|
|
|
327
|
|
|
protected function createComponentBusinessmenGrid($name) |
|
328
|
|
|
{ |
|
329
|
|
|
|
|
330
|
|
|
$grid = $this->createGrid($this, $name, "\WebCMS\InvestformModule\Entity\Businessman", null, array( |
|
331
|
|
|
'company = '.$this->company->getId() |
|
332
|
|
|
)); |
|
333
|
|
|
|
|
334
|
|
|
$grid->setFilterRenderType(\Grido\Components\Filters\Filter::RENDER_INNER); |
|
335
|
|
|
|
|
336
|
|
|
$grid->addColumnText('name', 'Name')->setCustomRender(function($item) { |
|
337
|
|
|
if ($item->getName()) { |
|
338
|
|
|
return $item->getName() . ' ' . $item->getLastname(); |
|
339
|
|
|
} else { |
|
340
|
|
|
return $item->getBusinessname(); |
|
341
|
|
|
} |
|
342
|
|
|
}); |
|
343
|
|
|
|
|
344
|
|
|
$grid->addColumnText('businessId', 'Business ID'); |
|
345
|
|
|
|
|
346
|
|
|
$grid->addColumnText('company', 'Company')->setCustomRender(function($item) { |
|
347
|
|
|
if ($item->getCompany()) { |
|
348
|
|
|
return $item->getCompany()->getName(); |
|
349
|
|
|
} |
|
350
|
|
|
}); |
|
351
|
|
|
|
|
352
|
|
|
$grid->addColumnText('active', 'Active')->setCustomRender(function($item) { |
|
353
|
|
|
if ($item->getActive()) { |
|
354
|
|
|
return 'Yes'; |
|
355
|
|
|
} else { |
|
356
|
|
|
return 'No'; |
|
357
|
|
|
} |
|
358
|
|
|
}); |
|
359
|
|
|
|
|
360
|
|
|
$grid->addActionHref("changeActive", 'Change active state', 'changeActive', array('idPage' => $this->actualPage->getId()))->getElementPrototype()->addAttributes(array('class' => array('btn', 'btn-primary', 'ajax', 'green'))); |
|
361
|
|
|
$grid->addActionHref("businessmanDetail", 'Businessman detail', 'businessmanDetail', array('idPage' => $this->actualPage->getId()))->getElementPrototype()->addAttributes(array('class' => array('btn', 'btn-primary', 'green'))); |
|
362
|
|
|
|
|
363
|
|
|
return $grid; |
|
364
|
|
|
} |
|
365
|
|
|
|
|
366
|
|
|
public function actionChangeActive($id, $idPage) |
|
|
|
|
|
|
367
|
|
|
{ |
|
368
|
|
|
$businessman = $this->em->getRepository('\WebCMS\InvestformModule\Entity\Businessman')->find($id); |
|
369
|
|
|
|
|
370
|
|
|
if (!$businessman->getActive()) { |
|
371
|
|
|
|
|
372
|
|
|
$this->company = $this->em->getRepository('\WebCMS\InvestformModule\Entity\Company')->find($businessman->getCompany()->getId()); |
|
373
|
|
|
|
|
374
|
|
View Code Duplication |
if ($this->company->getActive()) { |
|
|
|
|
|
|
375
|
|
|
$businessman->setActive(true); |
|
376
|
|
|
|
|
377
|
|
|
$this->em->flush(); |
|
378
|
|
|
|
|
379
|
|
|
$this->flashMessage('Active state has been changed', 'success'); |
|
380
|
|
|
} else { |
|
381
|
|
|
|
|
382
|
|
|
$this->flashMessage('Active state cannot be changed. Company is inactive.', 'error'); |
|
383
|
|
|
} |
|
384
|
|
|
|
|
385
|
|
|
} else { |
|
386
|
|
|
$businessman->setActive(false); |
|
387
|
|
|
|
|
388
|
|
|
$this->em->flush(); |
|
389
|
|
|
|
|
390
|
|
|
$this->flashMessage('Active state has been changed', 'success'); |
|
391
|
|
|
} |
|
392
|
|
|
|
|
393
|
|
|
|
|
394
|
|
|
|
|
395
|
|
|
$this->forward('detail', array( |
|
396
|
|
|
'id' => $businessman->getCompany()->getId(), |
|
397
|
|
|
'idPage' => $this->actualPage->getId() |
|
398
|
|
|
)); |
|
399
|
|
|
} |
|
400
|
|
|
|
|
401
|
|
|
public function actionBusinessmanDetail($id, $idPage) |
|
|
|
|
|
|
402
|
|
|
{ |
|
403
|
|
|
$this->forward('Businessman:detail', array( |
|
404
|
|
|
'id' => $id, |
|
405
|
|
|
'idPage' => $this->actualPage->getId() |
|
406
|
|
|
)); |
|
407
|
|
|
} |
|
408
|
|
|
|
|
409
|
|
|
protected function createComponentInvestmentsGrid($name) |
|
410
|
|
|
{ |
|
411
|
|
|
|
|
412
|
|
|
$businessmenIds = array(); |
|
413
|
|
|
$investments = array(); |
|
414
|
|
|
|
|
415
|
|
|
if ($this->businessmen) { |
|
416
|
|
|
foreach ($this->businessmen as $businessman) { |
|
417
|
|
|
$businessmenIds[] = $businessman->getId(); |
|
418
|
|
|
} |
|
419
|
|
|
} |
|
420
|
|
|
|
|
421
|
|
|
if (count($businessmenIds)) { |
|
422
|
|
|
$investments = $this->em->getRepository('\WebCMS\InvestformModule\Entity\Investment')->findBy(array( |
|
423
|
|
|
'businessman' => $businessmenIds |
|
424
|
|
|
)); |
|
425
|
|
|
} |
|
426
|
|
|
|
|
427
|
|
|
$grid = new \Grido\Grid($this, $name); |
|
428
|
|
|
$grid->setModel($investments); |
|
429
|
|
|
|
|
430
|
|
|
$grid->setFilterRenderType(\Grido\Components\Filters\Filter::RENDER_INNER); |
|
431
|
|
|
|
|
432
|
|
|
$grid->addFilterDateRange('created', 'Created'); |
|
433
|
|
|
|
|
434
|
|
|
$grid->addColumnDate('created', 'Created')->setDateFormat(\Grido\Components\Columns\Date::FORMAT_DATETIME); |
|
435
|
|
|
|
|
436
|
|
|
$grid->addColumnText('client_name', 'Client name')->setCustomRender(function($item) { |
|
437
|
|
|
return $item->getAddress()->getName().' '.$item->getAddress()->getLastname(); |
|
438
|
|
|
}); |
|
439
|
|
|
|
|
440
|
|
|
$grid->addColumnText('businessman_name', 'Businessman name')->setCustomRender(function($item) { |
|
441
|
|
|
if ($item->getBusinessman()->getName()) { |
|
442
|
|
|
return $item->getBusinessman()->getName() . ' ' . $item->getBusinessman()->getLastname(); |
|
443
|
|
|
} else { |
|
444
|
|
|
return $item->getBusinessman()->getBusinessname(); |
|
445
|
|
|
} |
|
446
|
|
|
}); |
|
447
|
|
|
|
|
448
|
|
|
$grid->addColumnText('businessId', 'Business Id')->setCustomRender(function($item) { |
|
449
|
|
|
return $item->getBusinessman()->getBusinessId(); |
|
450
|
|
|
}); |
|
451
|
|
|
|
|
452
|
|
|
$grid->addColumnText('investment', 'Investment'); |
|
453
|
|
|
$grid->addColumnText('contractSend', 'Contract send')->setCustomRender(function($item) { |
|
454
|
|
|
if ($item->getContractSend()) { |
|
455
|
|
|
return 'Yes'; |
|
456
|
|
|
} else { |
|
457
|
|
|
return 'No'; |
|
458
|
|
|
} |
|
459
|
|
|
}); |
|
460
|
|
|
$grid->addColumnText('contractClosed', 'Contract closed')->setCustomRender(function($item) { |
|
461
|
|
|
return $item->getContractClosed() ? 'Yes' : 'No'; |
|
462
|
|
|
}); |
|
463
|
|
|
$grid->addColumnText('contractPaid', 'Contract paid')->setCustomRender(function($item) { |
|
464
|
|
|
if ($item->getContractPaid()) { |
|
465
|
|
|
return 'Yes'; |
|
466
|
|
|
} else { |
|
467
|
|
|
return 'No'; |
|
468
|
|
|
} |
|
469
|
|
|
}); |
|
470
|
|
|
|
|
471
|
|
|
$grid->addActionHref("sendContract", 'Send', 'sendContract', array('idPage' => $this->actualPage->getId()))->getElementPrototype()->addAttributes(array('class' => array('btn', 'btn-primary', 'ajax', 'purple'))); |
|
472
|
|
|
$grid->addActionHref("downloadContract", 'Download', 'downloadContract', array('idPage' => $this->actualPage->getId()))->getElementPrototype()->addAttributes(array('class' => array('btn', 'btn-primary', 'purple'))); |
|
473
|
|
|
$grid->addActionHref("updateContract", 'Edit', 'updateContract', array('idPage' => $this->actualPage->getId()))->getElementPrototype()->addAttributes(array('class' => array('btn', 'btn-primary', 'ajax', 'green'))); |
|
474
|
|
|
|
|
475
|
|
|
return $grid; |
|
476
|
|
|
} |
|
477
|
|
|
|
|
478
|
|
|
public function actionUpdateContract($id, $idPage) |
|
|
|
|
|
|
479
|
|
|
{ |
|
480
|
|
|
$this->forward('Investform:update', array( |
|
481
|
|
|
'id' => $id, |
|
482
|
|
|
'idPage' => $this->actualPage->getId() |
|
483
|
|
|
)); |
|
484
|
|
|
} |
|
485
|
|
|
|
|
486
|
|
|
public function actionDownloadContract($id, $idPage) |
|
|
|
|
|
|
487
|
|
|
{ |
|
488
|
|
|
$this->forward('Investform:download', array( |
|
489
|
|
|
'id' => $id, |
|
490
|
|
|
'idPage' => $this->actualPage->getId() |
|
491
|
|
|
)); |
|
492
|
|
|
} |
|
493
|
|
|
|
|
494
|
|
|
public function actionSendContract($id, $idPage) |
|
|
|
|
|
|
495
|
|
|
{ |
|
496
|
|
|
$this->forward('Investform:send', array( |
|
497
|
|
|
'id' => $id, |
|
498
|
|
|
'idPage' => $this->actualPage->getId() |
|
499
|
|
|
)); |
|
500
|
|
|
} |
|
501
|
|
|
|
|
502
|
|
|
|
|
503
|
|
|
} |
|
504
|
|
|
|
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.