1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Finance module for HiPanel |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/hipanel-module-finance |
6
|
|
|
* @package hipanel-module-finance |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hipanel\modules\finance\controllers; |
12
|
|
|
|
13
|
|
|
use hipanel\actions\IndexAction; |
14
|
|
|
use hipanel\actions\RedirectAction; |
15
|
|
|
use hipanel\actions\SmartPerformAction; |
16
|
|
|
use hipanel\actions\SmartUpdateAction; |
17
|
|
|
use hipanel\actions\ValidateFormAction; |
18
|
|
|
use hipanel\actions\ViewAction; |
19
|
|
|
use hipanel\modules\finance\models\Purse; |
20
|
|
|
use Yii; |
21
|
|
|
|
22
|
|
|
class PurseController extends \hipanel\base\CrudController |
23
|
|
|
{ |
24
|
1 |
|
public function actions() |
25
|
|
|
{ |
26
|
|
|
return [ |
27
|
|
|
'index' => [ |
28
|
|
|
'class' => IndexAction::class, |
29
|
1 |
|
], |
30
|
|
|
'view' => [ |
31
|
|
|
'class' => ViewAction::class, |
32
|
1 |
|
], |
33
|
|
|
'update' => [ |
34
|
|
|
'class' => SmartUpdateAction::class, |
35
|
1 |
|
], |
36
|
|
|
'update-contact' => [ |
37
|
|
|
'class' => SmartUpdateAction::class, |
38
|
1 |
|
], |
39
|
|
|
'update-requisite' => [ |
40
|
|
|
'class' => SmartUpdateAction::class, |
41
|
1 |
|
], |
42
|
|
|
'validate-form' => [ |
43
|
|
|
'class' => ValidateFormAction::class, |
44
|
1 |
|
], |
45
|
|
|
'invoice-archive' => [ |
46
|
1 |
|
'class' => RedirectAction::class, |
47
|
1 |
|
'error' => Yii::t('hipanel', 'Under construction'), |
48
|
1 |
|
], |
49
|
|
|
'update-monthly-invoice' => [ |
50
|
1 |
|
'class' => SmartPerformAction::class, |
51
|
1 |
|
'success' => Yii::t('hipanel:finance', 'Invoice updated'), |
52
|
1 |
|
], |
53
|
1 |
|
]; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function actionGenerateInvoice($id, $month = null) |
57
|
|
|
{ |
58
|
|
|
$content_type = 'application/pdf'; |
59
|
|
|
$data = Purse::perform('generate-monthly-invoice', compact('id', 'month')); |
60
|
|
|
$response = Yii::$app->getResponse(); |
61
|
|
|
$response->format = $response::FORMAT_RAW; |
62
|
|
|
$response->getHeaders()->add('content-type', $content_type); |
63
|
|
|
|
64
|
|
|
return $data; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|